diff --git a/src/Raven.Embedded/RavenServerRunner.cs b/src/Raven.Embedded/RavenServerRunner.cs index 5a2dc701834f..942acb7e6437 100644 --- a/src/Raven.Embedded/RavenServerRunner.cs +++ b/src/Raven.Embedded/RavenServerRunner.cs @@ -32,22 +32,22 @@ public static async Task RunAsync(ServerOptions options) commandLineArgs.Add($"--Embedded.ParentProcessId={currentProcess.Id}"); } - if (options.LicenseConfiguration != null) + if (options.Licensing != null) { - if (string.IsNullOrWhiteSpace(options.LicenseConfiguration.License) == false && - string.IsNullOrWhiteSpace(options.LicenseConfiguration.LicensePath) == false) - throw new ArgumentException($"Only one of Licence options '{nameof(options.LicenseConfiguration.License)}' or '{nameof(options.LicenseConfiguration.LicensePath)}' should be specified"); - - if (string.IsNullOrWhiteSpace(options.LicenseConfiguration.License) == false) - commandLineArgs.Add($"--License={CommandLineArgumentEscaper.EscapeSingleArg(options.LicenseConfiguration.License)}"); - else if (string.IsNullOrWhiteSpace(options.LicenseConfiguration.LicensePath) == false) - commandLineArgs.Add($"--License.Path={CommandLineArgumentEscaper.EscapeSingleArg(options.LicenseConfiguration.LicensePath)}"); - - commandLineArgs.Add($"--License.Eula.Accepted={options.LicenseConfiguration.EulaAccepted}"); - commandLineArgs.Add($"--License.DisableAutoUpdate={options.LicenseConfiguration.DisableAutoUpdate}"); - commandLineArgs.Add($"--License.DisableAutoUpdateFromApi={options.LicenseConfiguration.DisableAutoUpdateFromApi}"); - commandLineArgs.Add($"--License.DisableLicenseSupportCheck={options.LicenseConfiguration.DisableLicenseSupportCheck}"); - commandLineArgs.Add($"--License.ThrowOnInvalidOrMissingLicense={options.LicenseConfiguration.ThrowOnInvalidOrMissingLicense}"); + if (string.IsNullOrWhiteSpace(options.Licensing.License) == false && + string.IsNullOrWhiteSpace(options.Licensing.LicensePath) == false) + throw new ArgumentException($"Only one of Licence options '{nameof(options.Licensing.License)}' or '{nameof(options.Licensing.LicensePath)}' should be specified"); + + if (string.IsNullOrWhiteSpace(options.Licensing.License) == false) + commandLineArgs.Add($"--License={CommandLineArgumentEscaper.EscapeSingleArg(options.Licensing.License)}"); + else if (string.IsNullOrWhiteSpace(options.Licensing.LicensePath) == false) + commandLineArgs.Add($"--License.Path={CommandLineArgumentEscaper.EscapeSingleArg(options.Licensing.LicensePath)}"); + + commandLineArgs.Add($"--License.Eula.Accepted={options.Licensing.EulaAccepted}"); + commandLineArgs.Add($"--License.DisableAutoUpdate={options.Licensing.DisableAutoUpdate}"); + commandLineArgs.Add($"--License.DisableAutoUpdateFromApi={options.Licensing.DisableAutoUpdateFromApi}"); + commandLineArgs.Add($"--License.DisableLicenseSupportCheck={options.Licensing.DisableLicenseSupportCheck}"); + commandLineArgs.Add($"--License.ThrowOnInvalidOrMissingLicense={options.Licensing.ThrowOnInvalidOrMissingLicense}"); } commandLineArgs.Add("--Setup.Mode=None"); diff --git a/src/Raven.Embedded/ServerOptions.cs b/src/Raven.Embedded/ServerOptions.cs index c4a04e893854..ab89ff406f56 100644 --- a/src/Raven.Embedded/ServerOptions.cs +++ b/src/Raven.Embedded/ServerOptions.cs @@ -22,11 +22,11 @@ public class ServerOptions public string DotNetPath { get; set; } = "dotnet"; [Obsolete( - $"This property is no longer used and will be removed in the next version, please use '{nameof(LicenseConfiguration)}.{nameof(LicenseOptions.EulaAccepted)}' instead.")] + $"This property is no longer used and will be removed in the next version, please use '{nameof(Licensing)}.{nameof(LicensingOptions.EulaAccepted)}' instead.")] public bool AcceptEula { - get => LicenseConfiguration.EulaAccepted; - set => LicenseConfiguration.EulaAccepted = value; + get => Licensing.EulaAccepted; + set => Licensing.EulaAccepted = value; } public string ServerUrl { get; set; } @@ -41,6 +41,8 @@ public bool AcceptEula public SecurityOptions Security { get; private set; } + public LicensingOptions Licensing { get; set; } = new(); + public ServerOptions Secured(string certificate, string certPassword = null) { if (certificate == null) @@ -95,9 +97,7 @@ internal SecurityOptions() { } public string ServerCertificateThumbprint { get; internal set; } } - public LicenseOptions LicenseConfiguration { get; set; } = new(); - - public class LicenseOptions + public class LicensingOptions { public string License { get; set; } public string LicensePath { get; set; } diff --git a/test/LicenseTests/LicenseOptionsTests.cs b/test/LicenseTests/LicenseOptionsTests.cs index ddabcaefc512..9b49f5771104 100644 --- a/test/LicenseTests/LicenseOptionsTests.cs +++ b/test/LicenseTests/LicenseOptionsTests.cs @@ -251,7 +251,7 @@ private void StartEmbeddedServerLicenseOptionTest(bool throwOnInvalidOrMissingLi var originalLicensePath = Environment.GetEnvironmentVariable("RAVEN_License.Path"); options = CopyServerAndCreateOptions(); - options.LicenseConfiguration.ThrowOnInvalidOrMissingLicense = throwOnInvalidOrMissingLicense; + options.Licensing.ThrowOnInvalidOrMissingLicense = throwOnInvalidOrMissingLicense; try { @@ -282,8 +282,8 @@ private static void HandleLicenseOption(string license, LicenseSource licenseSou switch (licenseSource) { case LicenseSource.EnvironmentVariable: - Assert.Null(options.LicenseConfiguration.License); - Assert.Null(options.LicenseConfiguration.LicensePath); + Assert.Null(options.Licensing.License); + Assert.Null(options.Licensing.LicensePath); Environment.SetEnvironmentVariable("RAVEN_License", license); Environment.SetEnvironmentVariable("RAVEN_License.Path", null); @@ -293,8 +293,8 @@ private static void HandleLicenseOption(string license, LicenseSource licenseSou break; case LicenseSource.ServerOption: - options.LicenseConfiguration.License = license; - Assert.Null(options.LicenseConfiguration.LicensePath); + options.Licensing.License = license; + Assert.Null(options.Licensing.LicensePath); Environment.SetEnvironmentVariable("RAVEN_License", null); Environment.SetEnvironmentVariable("RAVEN_License.Path", null); @@ -315,8 +315,8 @@ private static void HandleLicensePathOption(string license, LicenseSource licens switch (licenseSource) { case LicenseSource.EnvironmentVariable: - Assert.Null(options.LicenseConfiguration.License); - Assert.Null(options.LicenseConfiguration.LicensePath); + Assert.Null(options.Licensing.License); + Assert.Null(options.Licensing.LicensePath); Environment.SetEnvironmentVariable("RAVEN_License", null); Environment.SetEnvironmentVariable("RAVEN_License.Path", licensePath); @@ -326,8 +326,8 @@ private static void HandleLicensePathOption(string license, LicenseSource licens break; case LicenseSource.ServerOption: - options.LicenseConfiguration.LicensePath = licensePath; - Assert.Null(options.LicenseConfiguration.License); + options.Licensing.LicensePath = licensePath; + Assert.Null(options.Licensing.License); Environment.SetEnvironmentVariable("RAVEN_License", null); Environment.SetEnvironmentVariable("RAVEN_License.Path", null);