diff --git a/azure-pipelines/templates/stages/build.yml b/azure-pipelines/templates/stages/build.yml index a561b321..b1a55f9a 100644 --- a/azure-pipelines/templates/stages/build.yml +++ b/azure-pipelines/templates/stages/build.yml @@ -34,7 +34,7 @@ stages: target: linux-arm64 osx-x64: - vmImage: macos-latest + vmImage: macos-11 target: osx-x64 pool: diff --git a/azure-pipelines/templates/stages/test.yml b/azure-pipelines/templates/stages/test.yml index f9791a67..704bdecc 100644 --- a/azure-pipelines/templates/stages/test.yml +++ b/azure-pipelines/templates/stages/test.yml @@ -49,7 +49,7 @@ stages: - job: TestMacOS pool: - vmImage: macos-latest + vmImage: macos-11 steps: - template: ../restore.yml diff --git a/src/fiskaltrust.Launcher.Common/Configuration/Configuration.cs b/src/fiskaltrust.Launcher.Common/Configuration/Configuration.cs index 03c90626..84d9127a 100644 --- a/src/fiskaltrust.Launcher.Common/Configuration/Configuration.cs +++ b/src/fiskaltrust.Launcher.Common/Configuration/Configuration.cs @@ -197,12 +197,11 @@ public static LauncherConfiguration Deserialize(string text) var configuration = JsonSerializer.Deserialize( text, typeof(LauncherConfiguration), - new SerializerContext(new JsonSerializerOptions + new JsonSerializerOptions { - Converters = { - new JsonStringEnumConverter() - }, - }) + PropertyNameCaseInsensitive = true, + Converters = { new JsonStringEnumConverter() }, + } ) as LauncherConfiguration ?? throw new Exception($"Could not deserialize {nameof(LauncherConfiguration)}"); configuration.SetAlternateNames(text); return configuration; @@ -339,12 +338,11 @@ public record LauncherConfigurationInCashBoxConfiguration var configuration = (JsonSerializer.Deserialize( text, typeof(LauncherConfigurationInCashBoxConfiguration), - new SerializerContext(new JsonSerializerOptions + new JsonSerializerOptions { - Converters = { - new JsonStringEnumConverter() - } - }) + PropertyNameCaseInsensitive = true, + Converters = { new JsonStringEnumConverter() }, + } ) as LauncherConfigurationInCashBoxConfiguration ?? throw new Exception($"Could not deserialize {nameof(LauncherConfigurationInCashBoxConfiguration)}")).LauncherConfiguration; configuration?.SetAlternateNames(text); return configuration; diff --git a/test/fiskaltrust.Launcher.UnitTest/Configuration/Configuration.cs b/test/fiskaltrust.Launcher.UnitTest/Configuration/Configuration.cs index b6076319..c6875ab6 100644 --- a/test/fiskaltrust.Launcher.UnitTest/Configuration/Configuration.cs +++ b/test/fiskaltrust.Launcher.UnitTest/Configuration/Configuration.cs @@ -47,5 +47,55 @@ public void RandomConfiguration_SerializaAndDeserialize_ShouldPreserveNull() deserialized.Should().BeEquivalentTo(deserialized); } } + + [Fact] + public void DifferentCaseInKeys_Deserialize_ShouldPreserveProperties() + { + var json = @"{ + ""loglevel"": ""Information"", + ""LOGLEVEL"": ""Error"", + ""LogLevel"": ""Warning"" + }"; + + var deserialized = LauncherConfiguration.Deserialize(json); + + deserialized.LogLevel.Should().Be(LogLevel.Warning); + } + + [Fact] + public void LowerCaseKeys_Deserialize_ShouldPreserveProperties() + { + var json = @"{ + ""loglevel"": ""Information"" + }"; + + var deserialized = LauncherConfiguration.Deserialize(json); + + deserialized.LogLevel.Should().Be(LogLevel.Information); + } + + [Fact] + public void UpperCaseKeys_Deserialize_ShouldPreserveProperties() + { + var json = @"{ + ""LOGLEVEL"": ""Error"" + }"; + + var deserialized = LauncherConfiguration.Deserialize(json); + + deserialized.LogLevel.Should().Be(LogLevel.Error); + } + + [Fact] + public void MixedCaseKeys_Deserialize_ShouldPreserveProperties() + { + var json = @"{ + ""logLevel"": ""Warning"" + }"; + + var deserialized = LauncherConfiguration.Deserialize(json); + + deserialized.LogLevel.Should().Be(LogLevel.Warning); + } } } \ No newline at end of file