From 6f5f2ee2f5e16d4ff4dc04b907e74b3e0985f1a7 Mon Sep 17 00:00:00 2001 From: Jennyf19 Date: Sat, 8 Oct 2022 13:06:33 -0700 Subject: [PATCH 1/3] fix tests --- .../ServiceCollectionExtensionsTests.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/Microsoft.Identity.Web.Test/ServiceCollectionExtensionsTests.cs b/tests/Microsoft.Identity.Web.Test/ServiceCollectionExtensionsTests.cs index c54dfa524..9ed8e48c9 100644 --- a/tests/Microsoft.Identity.Web.Test/ServiceCollectionExtensionsTests.cs +++ b/tests/Microsoft.Identity.Web.Test/ServiceCollectionExtensionsTests.cs @@ -35,16 +35,15 @@ public void AddTokenAcquisition_AddsWithCorrectLifetime() actual => { Assert.Equal(ServiceLifetime.Singleton, actual.Lifetime); - Assert.Equal(typeof(IPostConfigureOptions), actual.ServiceType); - Assert.Equal(typeof(ConfidentialClientApplicationOptionsMerger), actual.ImplementationType); + Assert.Equal(typeof(IPostConfigureOptions), actual.ServiceType); + Assert.Equal(typeof(MicrosoftAuthenticationOptionsMerger), actual.ImplementationType); Assert.Null(actual.ImplementationInstance); Assert.Null(actual.ImplementationFactory); - }, - actual => + }, actual => { Assert.Equal(ServiceLifetime.Singleton, actual.Lifetime); - Assert.Equal(typeof(IPostConfigureOptions), actual.ServiceType); - Assert.Equal(typeof(MicrosoftAuthenticationOptionsMerger), actual.ImplementationType); + Assert.Equal(typeof(IPostConfigureOptions), actual.ServiceType); + Assert.Equal(typeof(ConfidentialClientApplicationOptionsMerger), actual.ImplementationType); Assert.Null(actual.ImplementationInstance); Assert.Null(actual.ImplementationFactory); }, From 8227fd22fc4d661eafd405785db895d9afec4551 Mon Sep 17 00:00:00 2001 From: Jennyf19 Date: Sat, 8 Oct 2022 17:29:32 -0700 Subject: [PATCH 2/3] fix test and support net 6 --- src/Directory.Build.props | 4 ++-- ...crosoft.Identity.Web.MicrosoftGraph.csproj | 2 +- ...oft.Identity.Web.MicrosoftGraphBeta.csproj | 2 +- .../MergedOptions.cs | 6 ++--- ...osoft.Identity.Web.TokenAcquisition.csproj | 2 +- .../Microsoft.Identity.Web.TokenCache.csproj | 2 +- .../Microsoft.Identity.Web.UI.csproj | 2 +- .../Microsoft.Identity.Web.csproj | 4 ++-- .../Client/TodoListClient.csproj | 2 +- .../TodoListService/TodoListService.csproj | 2 +- tests/BlazorServerCallsGraph/blazor.csproj | 2 +- .../IntegrationTestService.csproj | 2 +- .../WebAppUiTests/WebAppUiTests.csproj | 2 +- .../Microsoft.Identity.Web.Test.Common.csproj | 2 +- ...osoft.Identity.Web.Test.Integration.csproj | 2 +- ...Identity.Web.Test.LabInfrastructure.csproj | 2 +- .../Microsoft.Identity.Web.Test.csproj | 7 ++---- .../WebAppExtensionsTests.cs | 2 +- ...crosoft.Identity.Web.Perf.Benchmark.csproj | 2 +- .../Microsoft.Identity.Web.Perf.Client.csproj | 2 +- .../TestRunner.cs | 24 +++++++++---------- .../PerformanceTestService.csproj | 2 +- .../WebAppCallsMicrosoftGraph.csproj | 2 +- .../Client/TodoListClient.csproj | 2 +- .../TodoListService/TodoListService.csproj | 4 ++-- .../gRPC/grpc.csproj | 4 ++-- .../blazor.csproj | 2 +- tests/blazorwasm-b2c/blazorwasm2-b2c.csproj | 12 +++++----- .../GenerateMergeOptionsMethods.csproj | 4 ++-- 29 files changed, 53 insertions(+), 56 deletions(-) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 0b458156d..d54be43cd 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -20,7 +20,7 @@ - netcoreapp3.1; net462; net472; net5.0; netstandard2.0 + netcoreapp3.1; net462; net472; net6.0; netstandard2.0 true ../../build/MSAL.snk true @@ -72,7 +72,7 @@ 2.0.1-preview - + 5.0.12-* 5.0.12-* 5.0.0 diff --git a/src/Microsoft.Identity.Web.MicrosoftGraph/Microsoft.Identity.Web.MicrosoftGraph.csproj b/src/Microsoft.Identity.Web.MicrosoftGraph/Microsoft.Identity.Web.MicrosoftGraph.csproj index 1f1a81090..411e57559 100644 --- a/src/Microsoft.Identity.Web.MicrosoftGraph/Microsoft.Identity.Web.MicrosoftGraph.csproj +++ b/src/Microsoft.Identity.Web.MicrosoftGraph/Microsoft.Identity.Web.MicrosoftGraph.csproj @@ -20,7 +20,7 @@ - netcoreapp3.1; net5.0; net462; net472 + netcoreapp3.1; net6.0; net462; net472 diff --git a/src/Microsoft.Identity.Web.MicrosoftGraphBeta/Microsoft.Identity.Web.MicrosoftGraphBeta.csproj b/src/Microsoft.Identity.Web.MicrosoftGraphBeta/Microsoft.Identity.Web.MicrosoftGraphBeta.csproj index b191ebc9d..0ebbdee72 100644 --- a/src/Microsoft.Identity.Web.MicrosoftGraphBeta/Microsoft.Identity.Web.MicrosoftGraphBeta.csproj +++ b/src/Microsoft.Identity.Web.MicrosoftGraphBeta/Microsoft.Identity.Web.MicrosoftGraphBeta.csproj @@ -11,7 +11,7 @@ - netcoreapp3.1; net5.0 + netcoreapp3.1; net6.0 diff --git a/src/Microsoft.Identity.Web.TokenAcquisition/MergedOptions.cs b/src/Microsoft.Identity.Web.TokenAcquisition/MergedOptions.cs index ba7e45d2d..6c6230f2d 100644 --- a/src/Microsoft.Identity.Web.TokenAcquisition/MergedOptions.cs +++ b/src/Microsoft.Identity.Web.TokenAcquisition/MergedOptions.cs @@ -52,7 +52,7 @@ public ConfidentialClientApplicationOptions ConfidentialClientApplicationOptions internal static void UpdateMergedOptionsFromMicrosoftIdentityOptions(MicrosoftIdentityOptions microsoftIdentityOptions, MergedOptions mergedOptions) { -#if DOTNET_50_AND_ABOVE +#if NET5_0_OR_GREATER mergedOptions.MapInboundClaims = microsoftIdentityOptions.MapInboundClaims; #endif @@ -136,7 +136,7 @@ internal static void UpdateMergedOptionsFromMicrosoftIdentityOptions(MicrosoftId mergedOptions.ProtocolValidator ??= microsoftIdentityOptions.ProtocolValidator; -#if DOTNET_50_AND_ABOVE +#if NET5_0_OR_GREATER mergedOptions.RefreshInterval = microsoftIdentityOptions.RefreshInterval; #endif mergedOptions.RefreshOnIssuerKeyNotFound = microsoftIdentityOptions.RefreshOnIssuerKeyNotFound; @@ -202,7 +202,7 @@ internal static void UpdateMergedOptionsFromMicrosoftIdentityOptions(MicrosoftId mergedOptions.Scope.Add(scope); } } -#if DOTNET_50_AND_ABOVE +#if NET5_0_OR_GREATER mergedOptions.AutomaticRefreshInterval = microsoftIdentityOptions.AutomaticRefreshInterval; #endif #endif diff --git a/src/Microsoft.Identity.Web.TokenAcquisition/Microsoft.Identity.Web.TokenAcquisition.csproj b/src/Microsoft.Identity.Web.TokenAcquisition/Microsoft.Identity.Web.TokenAcquisition.csproj index 0adaa8b37..ef7e7d3ac 100644 --- a/src/Microsoft.Identity.Web.TokenAcquisition/Microsoft.Identity.Web.TokenAcquisition.csproj +++ b/src/Microsoft.Identity.Web.TokenAcquisition/Microsoft.Identity.Web.TokenAcquisition.csproj @@ -8,7 +8,7 @@ true - + diff --git a/src/Microsoft.Identity.Web.TokenCache/Microsoft.Identity.Web.TokenCache.csproj b/src/Microsoft.Identity.Web.TokenCache/Microsoft.Identity.Web.TokenCache.csproj index 3aa469d51..5e8533af8 100644 --- a/src/Microsoft.Identity.Web.TokenCache/Microsoft.Identity.Web.TokenCache.csproj +++ b/src/Microsoft.Identity.Web.TokenCache/Microsoft.Identity.Web.TokenCache.csproj @@ -11,7 +11,7 @@ - + diff --git a/src/Microsoft.Identity.Web.UI/Microsoft.Identity.Web.UI.csproj b/src/Microsoft.Identity.Web.UI/Microsoft.Identity.Web.UI.csproj index 0b21e63f1..77aec4032 100644 --- a/src/Microsoft.Identity.Web.UI/Microsoft.Identity.Web.UI.csproj +++ b/src/Microsoft.Identity.Web.UI/Microsoft.Identity.Web.UI.csproj @@ -7,7 +7,7 @@ - netcoreapp3.1; net5.0 + netcoreapp3.1; net6.0 true diff --git a/src/Microsoft.Identity.Web/Microsoft.Identity.Web.csproj b/src/Microsoft.Identity.Web/Microsoft.Identity.Web.csproj index cda74355d..c57be0d95 100644 --- a/src/Microsoft.Identity.Web/Microsoft.Identity.Web.csproj +++ b/src/Microsoft.Identity.Web/Microsoft.Identity.Web.csproj @@ -10,11 +10,11 @@ - netcoreapp3.1; net462; net472; net5.0 + netcoreapp3.1; net462; net472; net6.0 true - + diff --git a/tests/B2CWebAppCallsWebApi/Client/TodoListClient.csproj b/tests/B2CWebAppCallsWebApi/Client/TodoListClient.csproj index 9a9b0f368..bdec698d5 100644 --- a/tests/B2CWebAppCallsWebApi/Client/TodoListClient.csproj +++ b/tests/B2CWebAppCallsWebApi/Client/TodoListClient.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1; net5.0 + netcoreapp3.1; net6.0 aspnet-WebApp_OpenIDConnect_DotNet-81EA87AD-E64D-4755-A1CC-5EA47F49B5D9 0 ..\..\..\.sonarlint\azuread_microsoft-identity-webcsharp.ruleset diff --git a/tests/B2CWebAppCallsWebApi/TodoListService/TodoListService.csproj b/tests/B2CWebAppCallsWebApi/TodoListService/TodoListService.csproj index ae469b87b..f70ba6f81 100644 --- a/tests/B2CWebAppCallsWebApi/TodoListService/TodoListService.csproj +++ b/tests/B2CWebAppCallsWebApi/TodoListService/TodoListService.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1; net5.0 + netcoreapp3.1; net6.0 aspnet-TodoListService-03230DB1-5145-408C-A48B-BE3DAFC56C30 0 ..\..\..\.sonarlint\azuread_microsoft-identity-webcsharp.ruleset diff --git a/tests/BlazorServerCallsGraph/blazor.csproj b/tests/BlazorServerCallsGraph/blazor.csproj index d306a7238..3485fe7e0 100644 --- a/tests/BlazorServerCallsGraph/blazor.csproj +++ b/tests/BlazorServerCallsGraph/blazor.csproj @@ -1,6 +1,6 @@  - netcoreapp3.1; net5.0 + netcoreapp3.1; net6.0 66e5c3c7-f757-4032-bfcf-68bd81948618 ..\..\.sonarlint\azuread_microsoft-identity-webcsharp.ruleset True diff --git a/tests/IntegrationTests/IntegrationTestService/IntegrationTestService.csproj b/tests/IntegrationTests/IntegrationTestService/IntegrationTestService.csproj index e66dc9962..89eca279b 100644 --- a/tests/IntegrationTests/IntegrationTestService/IntegrationTestService.csproj +++ b/tests/IntegrationTests/IntegrationTestService/IntegrationTestService.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1; net5.0 + netcoreapp3.1; net6.0 false true ../../../build/MSAL.snk diff --git a/tests/IntegrationTests/WebAppUiTests/WebAppUiTests.csproj b/tests/IntegrationTests/WebAppUiTests/WebAppUiTests.csproj index 80ae194c6..830a0d627 100644 --- a/tests/IntegrationTests/WebAppUiTests/WebAppUiTests.csproj +++ b/tests/IntegrationTests/WebAppUiTests/WebAppUiTests.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1; net5.0 + netcoreapp3.1; net6.0 false diff --git a/tests/Microsoft.Identity.Web.Test.Common/Microsoft.Identity.Web.Test.Common.csproj b/tests/Microsoft.Identity.Web.Test.Common/Microsoft.Identity.Web.Test.Common.csproj index 16df3b411..8f0a9688f 100644 --- a/tests/Microsoft.Identity.Web.Test.Common/Microsoft.Identity.Web.Test.Common.csproj +++ b/tests/Microsoft.Identity.Web.Test.Common/Microsoft.Identity.Web.Test.Common.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1; net462; net472; net5.0 + netcoreapp3.1; net462; net472; net6.0 false true ../../build/MSAL.snk diff --git a/tests/Microsoft.Identity.Web.Test.Integration/Microsoft.Identity.Web.Test.Integration.csproj b/tests/Microsoft.Identity.Web.Test.Integration/Microsoft.Identity.Web.Test.Integration.csproj index e7c438b90..37fb3584e 100644 --- a/tests/Microsoft.Identity.Web.Test.Integration/Microsoft.Identity.Web.Test.Integration.csproj +++ b/tests/Microsoft.Identity.Web.Test.Integration/Microsoft.Identity.Web.Test.Integration.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1; net5.0 + netcoreapp3.1; net6.0 false diff --git a/tests/Microsoft.Identity.Web.Test.LabInfrastructure/Microsoft.Identity.Web.Test.LabInfrastructure.csproj b/tests/Microsoft.Identity.Web.Test.LabInfrastructure/Microsoft.Identity.Web.Test.LabInfrastructure.csproj index cc0c0af91..88cc9b60f 100644 --- a/tests/Microsoft.Identity.Web.Test.LabInfrastructure/Microsoft.Identity.Web.Test.LabInfrastructure.csproj +++ b/tests/Microsoft.Identity.Web.Test.LabInfrastructure/Microsoft.Identity.Web.Test.LabInfrastructure.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1; net5.0 + netcoreapp3.1; net6.0 false true ../../build/MSAL.snk diff --git a/tests/Microsoft.Identity.Web.Test/Microsoft.Identity.Web.Test.csproj b/tests/Microsoft.Identity.Web.Test/Microsoft.Identity.Web.Test.csproj index 4dc2356e5..50868ee3a 100644 --- a/tests/Microsoft.Identity.Web.Test/Microsoft.Identity.Web.Test.csproj +++ b/tests/Microsoft.Identity.Web.Test/Microsoft.Identity.Web.Test.csproj @@ -3,9 +3,6 @@ $(DefineConstants);DOTNET_CORE_31 - - $(DefineConstants);DOTNET_50 - $(DefineConstants);DOTNET_472 8.0 @@ -16,14 +13,14 @@ - netcoreapp3.1; net462; net472; net5.0 + netcoreapp3.1; net462; net472; net6.0 false true ../../build/MSAL.snk - + diff --git a/tests/Microsoft.Identity.Web.Test/WebAppExtensionsTests.cs b/tests/Microsoft.Identity.Web.Test/WebAppExtensionsTests.cs index dbf8297f9..8bdf7f295 100644 --- a/tests/Microsoft.Identity.Web.Test/WebAppExtensionsTests.cs +++ b/tests/Microsoft.Identity.Web.Test/WebAppExtensionsTests.cs @@ -822,7 +822,7 @@ public void PreventChangesInOpenIdConnectOptionsToBeOverlooked() #if DOTNET_CORE_31 expectedNumberOfProperties = 54; // System.IO.File.WriteAllLines(@"c:\temp\core31.txt", typeof(OpenIdConnectOptions).GetProperties().Select(p => p.Name)); -#elif DOTNET_50 +#elif NET5_0_OR_GREATER expectedNumberOfProperties = 57; // System.IO.File.WriteAllLines(@"c:\temp\net5.txt", typeof(OpenIdConnectOptions).GetProperties().Select(p => p.Name)); #endif diff --git a/tests/PerformanceTests/Microsoft.Identity.Web.Perf.Benchmark/Microsoft.Identity.Web.Perf.Benchmark.csproj b/tests/PerformanceTests/Microsoft.Identity.Web.Perf.Benchmark/Microsoft.Identity.Web.Perf.Benchmark.csproj index 002e51f8d..043e7930b 100644 --- a/tests/PerformanceTests/Microsoft.Identity.Web.Perf.Benchmark/Microsoft.Identity.Web.Perf.Benchmark.csproj +++ b/tests/PerformanceTests/Microsoft.Identity.Web.Perf.Benchmark/Microsoft.Identity.Web.Perf.Benchmark.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp3.1; net5.0 + netcoreapp3.1; net6.0 ..\..\..\.sonarlint\azuread_microsoft-identity-webcsharp.ruleset diff --git a/tests/PerformanceTests/Microsoft.Identity.Web.Perf.Client/Microsoft.Identity.Web.Perf.Client.csproj b/tests/PerformanceTests/Microsoft.Identity.Web.Perf.Client/Microsoft.Identity.Web.Perf.Client.csproj index ec6534bf4..5a33755d5 100644 --- a/tests/PerformanceTests/Microsoft.Identity.Web.Perf.Client/Microsoft.Identity.Web.Perf.Client.csproj +++ b/tests/PerformanceTests/Microsoft.Identity.Web.Perf.Client/Microsoft.Identity.Web.Perf.Client.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp3.1; net5.0 + netcoreapp3.1; net6.0 ..\..\..\.sonarlint\azuread_microsoft-identity-webcsharp.ruleset diff --git a/tests/PerformanceTests/Microsoft.Identity.Web.Perf.Client/TestRunner.cs b/tests/PerformanceTests/Microsoft.Identity.Web.Perf.Client/TestRunner.cs index 3470047b6..2ccf57b58 100644 --- a/tests/PerformanceTests/Microsoft.Identity.Web.Perf.Client/TestRunner.cs +++ b/tests/PerformanceTests/Microsoft.Identity.Web.Perf.Client/TestRunner.cs @@ -219,7 +219,7 @@ private async Task SendRequestsAsync(int userStartIndex, int userEndIndex, Cance if (!response.IsSuccessStatusCode) { var sb = new StringBuilder(); - sb.AppendLine($"Response was not successful. Status code: {response.StatusCode}. {response.ReasonPhrase}"); + sb.AppendLine((string)$"Response was not successful. Status code: {response.StatusCode}. {response.ReasonPhrase}"); sb.AppendLine(await response.Content.ReadAsStringAsync()); Console.WriteLine(sb); } @@ -229,10 +229,10 @@ private async Task SendRequestsAsync(int userStartIndex, int userEndIndex, Cance catch (Exception ex) { localMetrics.TotalExceptions++; - Console.WriteLine($"Exception in TestRunner at {userIndex} of {userEndIndex} - {userStartIndex}: {ex.Message}"); + Console.WriteLine((string)$"Exception in TestRunner at {userIndex} of {userEndIndex} - {userStartIndex}: {ex.Message}"); - exceptionsDuringRun.AppendLine($"Exception in TestRunner at {userIndex} of {userEndIndex} - {userStartIndex}: {ex.Message}"); - exceptionsDuringRun.AppendLine($"{ex}"); + exceptionsDuringRun.AppendLine((string)$"Exception in TestRunner at {userIndex} of {userEndIndex} - {userStartIndex}: {ex.Message}"); + exceptionsDuringRun.AppendLine((string)$"{ex}"); } } localMetrics.TotalRequestTimeInMilliseconds += stopwatch.Elapsed.TotalMilliseconds; @@ -263,17 +263,17 @@ private void DisplayProgress() { var stringBuilder = new StringBuilder(); stringBuilder.AppendLine("------------------------------------------------------------------------"); - stringBuilder.AppendLine($"Run time: {_processingStartTime} - {DateTime.Now} = {DateTime.Now - _processingStartTime}."); - stringBuilder.AppendLine($"Total number of users: {_options.NumberOfUsersToTest} users from {_options.StartUserIndex} to {_options.StartUserIndex + _options.NumberOfUsersToTest - 1}."); + stringBuilder.AppendLine((string)$"Run time: {_processingStartTime} - {DateTime.Now} = {DateTime.Now - _processingStartTime}."); + stringBuilder.AppendLine((string)$"Total number of users: {_options.NumberOfUsersToTest} users from {_options.StartUserIndex} to {_options.StartUserIndex + _options.NumberOfUsersToTest - 1}."); lock (s_metricsLock) { - stringBuilder.AppendLine($"Loop: {_globalMetrics.TotalRequests / _options.NumberOfUsersToTest}"); - stringBuilder.AppendLine($"Total requests: {_globalMetrics.TotalRequests}."); - stringBuilder.AppendLine($"Average request time: {_globalMetrics.AverageRequestTimeInMilliseconds:0.0000} ms."); - stringBuilder.AppendLine($"Cache requests: {_globalMetrics.TotalTokensReturnedFromCache}."); - stringBuilder.AppendLine($"Average cache time: {_globalMetrics.AverageMsalLookupTimeInMilliseconds:0.0000} ms."); - stringBuilder.AppendLine($"AuthRequest failures: {_globalMetrics.TotalAcquireTokenFailures}. Generic failures: {_globalMetrics.TotalExceptions}."); + stringBuilder.AppendLine((string)$"Loop: {_globalMetrics.TotalRequests / _options.NumberOfUsersToTest}"); + stringBuilder.AppendLine((string)$"Total requests: {_globalMetrics.TotalRequests}."); + stringBuilder.AppendLine((string)$"Average request time: {_globalMetrics.AverageRequestTimeInMilliseconds:0.0000} ms."); + stringBuilder.AppendLine((string)$"Cache requests: {_globalMetrics.TotalTokensReturnedFromCache}."); + stringBuilder.AppendLine((string)$"Average cache time: {_globalMetrics.AverageMsalLookupTimeInMilliseconds:0.0000} ms."); + stringBuilder.AppendLine((string)$"AuthRequest failures: {_globalMetrics.TotalAcquireTokenFailures}. Generic failures: {_globalMetrics.TotalExceptions}."); } Console.WriteLine(stringBuilder); diff --git a/tests/PerformanceTests/PerformanceTestService/PerformanceTestService.csproj b/tests/PerformanceTests/PerformanceTestService/PerformanceTestService.csproj index c013c40d1..fb93e456e 100644 --- a/tests/PerformanceTests/PerformanceTestService/PerformanceTestService.csproj +++ b/tests/PerformanceTests/PerformanceTestService/PerformanceTestService.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1; net5.0 + netcoreapp3.1; net6.0 false true ../../../build/MSAL.snk diff --git a/tests/WebAppCallsMicrosoftGraph/WebAppCallsMicrosoftGraph.csproj b/tests/WebAppCallsMicrosoftGraph/WebAppCallsMicrosoftGraph.csproj index 25207d78e..2c9eb4531 100644 --- a/tests/WebAppCallsMicrosoftGraph/WebAppCallsMicrosoftGraph.csproj +++ b/tests/WebAppCallsMicrosoftGraph/WebAppCallsMicrosoftGraph.csproj @@ -1,6 +1,6 @@  - netcoreapp3.1; net5.0 + netcoreapp3.1; net6.0 aspnet-WebApp_OpenIDConnect_DotNet-81EA87AD-E64D-4755-A1CC-5EA47F49B5D8 ..\..\.sonarlint\azuread_microsoft-identity-webcsharp.ruleset True diff --git a/tests/WebAppCallsWebApiCallsGraph/Client/TodoListClient.csproj b/tests/WebAppCallsWebApiCallsGraph/Client/TodoListClient.csproj index 8b9e65ddb..e7c372a1e 100644 --- a/tests/WebAppCallsWebApiCallsGraph/Client/TodoListClient.csproj +++ b/tests/WebAppCallsWebApiCallsGraph/Client/TodoListClient.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1; net5.0 + netcoreapp3.1; net6.0 aspnet-WebApp_OpenIDConnect_DotNet-81EA87AD-E64D-4755-A1CC-5EA47F49B5D0 0 ..\..\..\.sonarlint\azuread_microsoft-identity-webcsharp.ruleset diff --git a/tests/WebAppCallsWebApiCallsGraph/TodoListService/TodoListService.csproj b/tests/WebAppCallsWebApiCallsGraph/TodoListService/TodoListService.csproj index d713947fc..95c92ee0f 100644 --- a/tests/WebAppCallsWebApiCallsGraph/TodoListService/TodoListService.csproj +++ b/tests/WebAppCallsWebApiCallsGraph/TodoListService/TodoListService.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1; net5.0 + netcoreapp3.1; net6.0 aspnet-TodoListService-03230DB1-5145-408C-A48B-BE3DAFC56C30 0 ..\..\..\.sonarlint\azuread_microsoft-identity-webcsharp.ruleset @@ -21,7 +21,7 @@ - + diff --git a/tests/WebAppCallsWebApiCallsGraph/gRPC/grpc.csproj b/tests/WebAppCallsWebApiCallsGraph/gRPC/grpc.csproj index 514b25520..ec6c407a2 100644 --- a/tests/WebAppCallsWebApiCallsGraph/gRPC/grpc.csproj +++ b/tests/WebAppCallsWebApiCallsGraph/gRPC/grpc.csproj @@ -1,7 +1,7 @@ - net5.0 + net6.0 @@ -11,7 +11,7 @@ - + diff --git a/tests/blazorserver2-b2c-callswebapi/blazor.csproj b/tests/blazorserver2-b2c-callswebapi/blazor.csproj index 78b89255c..defb0ca13 100644 --- a/tests/blazorserver2-b2c-callswebapi/blazor.csproj +++ b/tests/blazorserver2-b2c-callswebapi/blazor.csproj @@ -1,6 +1,6 @@  - netcoreapp3.1; net5.0 + netcoreapp3.1; net6.0 66e5c3c7-f757-4032-bfcf-68bd81948618 ..\..\.sonarlint\azuread_microsoft-identity-webcsharp.ruleset True diff --git a/tests/blazorwasm-b2c/blazorwasm2-b2c.csproj b/tests/blazorwasm-b2c/blazorwasm2-b2c.csproj index d7552c8f5..9fc1ba36a 100644 --- a/tests/blazorwasm-b2c/blazorwasm2-b2c.csproj +++ b/tests/blazorwasm-b2c/blazorwasm2-b2c.csproj @@ -16,12 +16,12 @@ - - - - - - + + + + + + diff --git a/tools/GenerateMergeOptionsMethods/GenerateMergeOptionsMethods.csproj b/tools/GenerateMergeOptionsMethods/GenerateMergeOptionsMethods.csproj index 31f503f02..b0db04acc 100644 --- a/tools/GenerateMergeOptionsMethods/GenerateMergeOptionsMethods.csproj +++ b/tools/GenerateMergeOptionsMethods/GenerateMergeOptionsMethods.csproj @@ -2,7 +2,7 @@ Exe - net5.0 + net6.0 enable true ../../build/MSAL.snk @@ -13,7 +13,7 @@ - + From 4615bed22ed382a05d73f2c0f8d54e6767010d99 Mon Sep 17 00:00:00 2001 From: Jean-Marc Prieur Date: Sat, 8 Oct 2022 19:02:22 -0700 Subject: [PATCH 3/3] Fix a few warnings: (#1905) - Nullability contract in cache classes - Adding missing MicrosoftExtensionsConfigurationBinderVersion in Directory.Builds.props for netstandard2.0 - Updating Web.Config for OWIN web app - Updating CertificateDescriptionTest (to avoid obsolete constructor) --- src/Directory.Build.props | 2 ++ .../AppBuilderExtension.cs | 2 +- .../Microsoft.Identity.Web.TokenAcquisition.csproj | 4 +--- .../MsalDistributedTokenCacheAdapter.cs | 4 ++-- .../InMemory/MsalMemoryTokenCacheProvider.cs | 4 ++-- .../MsalAbstractTokenCacheProvider.cs | 12 ++++++++---- .../Controllers/AccountController.cs | 11 +++++++++-- .../AuthorizeForScopesAttribute.cs | 2 +- .../Session/MsalSessionTokenCacheProvider.cs | 6 +++--- .../Certificates/CertificateDescriptionTests.cs | 8 +++----- tests/aspnet-mvc/OwinWebApp/Web.config | 14 +++++++------- 11 files changed, 39 insertions(+), 30 deletions(-) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index d54be43cd..f96d27af4 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -99,6 +99,8 @@ 2.1.0 2.1.0 2.1.0 + 2.2.4 + diff --git a/src/Microsoft.Identity.Web.OWIN/AppBuilderExtension.cs b/src/Microsoft.Identity.Web.OWIN/AppBuilderExtension.cs index 0f336b10f..03d24a5ec 100644 --- a/src/Microsoft.Identity.Web.OWIN/AppBuilderExtension.cs +++ b/src/Microsoft.Identity.Web.OWIN/AppBuilderExtension.cs @@ -220,7 +220,7 @@ public static IAppBuilder AddMicrosoftIdentityWebApp( string? clientInfo = httpContext.Session[ClaimConstants.ClientInfo] as string; - if (!string.IsNullOrEmpty(clientInfo)) + if (clientInfo!=null && !string.IsNullOrEmpty(clientInfo)) { ClientInfo? clientInfoFromServer = ClientInfo.CreateFromJson(clientInfo); diff --git a/src/Microsoft.Identity.Web.TokenAcquisition/Microsoft.Identity.Web.TokenAcquisition.csproj b/src/Microsoft.Identity.Web.TokenAcquisition/Microsoft.Identity.Web.TokenAcquisition.csproj index ef7e7d3ac..cdce085cf 100644 --- a/src/Microsoft.Identity.Web.TokenAcquisition/Microsoft.Identity.Web.TokenAcquisition.csproj +++ b/src/Microsoft.Identity.Web.TokenAcquisition/Microsoft.Identity.Web.TokenAcquisition.csproj @@ -14,7 +14,7 @@ - + @@ -35,8 +35,6 @@ - - diff --git a/src/Microsoft.Identity.Web.TokenCache/Distributed/MsalDistributedTokenCacheAdapter.cs b/src/Microsoft.Identity.Web.TokenCache/Distributed/MsalDistributedTokenCacheAdapter.cs index a030bab4f..fa56335b4 100644 --- a/src/Microsoft.Identity.Web.TokenCache/Distributed/MsalDistributedTokenCacheAdapter.cs +++ b/src/Microsoft.Identity.Web.TokenCache/Distributed/MsalDistributedTokenCacheAdapter.cs @@ -136,7 +136,7 @@ await L2OperationWithRetryOnFailureAsync( /// Key of the cache item to retrieve. /// Read blob representing a token cache for the cache key /// (account or app). - protected override async Task ReadCacheBytesAsync(string cacheKey) + protected override async Task ReadCacheBytesAsync(string cacheKey) { return await ReadCacheBytesAsync(cacheKey, new CacheSerializerHints()).ConfigureAwait(false); } @@ -149,7 +149,7 @@ protected override async Task ReadCacheBytesAsync(string cacheKey) /// Hints for the cache serialization implementation optimization. /// Read blob representing a token cache for the cache key /// (account or app). - protected override async Task ReadCacheBytesAsync(string cacheKey, CacheSerializerHints cacheSerializerHints) + protected override async Task ReadCacheBytesAsync(string cacheKey, CacheSerializerHints cacheSerializerHints) { const string read = "Read"; byte[]? result = null; diff --git a/src/Microsoft.Identity.Web.TokenCache/InMemory/MsalMemoryTokenCacheProvider.cs b/src/Microsoft.Identity.Web.TokenCache/InMemory/MsalMemoryTokenCacheProvider.cs index 073b0dcee..f3d92dcd0 100644 --- a/src/Microsoft.Identity.Web.TokenCache/InMemory/MsalMemoryTokenCacheProvider.cs +++ b/src/Microsoft.Identity.Web.TokenCache/InMemory/MsalMemoryTokenCacheProvider.cs @@ -59,9 +59,9 @@ protected override Task RemoveKeyAsync(string cacheKey) /// /// Token cache key. /// Read Bytes. - protected override Task ReadCacheBytesAsync(string cacheKey) + protected override Task ReadCacheBytesAsync(string cacheKey) { - byte[] tokenCacheBytes = (byte[])_memoryCache.Get(cacheKey); + byte[]? tokenCacheBytes = (byte[]?)_memoryCache.Get(cacheKey); return Task.FromResult(tokenCacheBytes); } diff --git a/src/Microsoft.Identity.Web.TokenCache/MsalAbstractTokenCacheProvider.cs b/src/Microsoft.Identity.Web.TokenCache/MsalAbstractTokenCacheProvider.cs index c7bb4bf6e..04f66e6ca 100644 --- a/src/Microsoft.Identity.Web.TokenCache/MsalAbstractTokenCacheProvider.cs +++ b/src/Microsoft.Identity.Web.TokenCache/MsalAbstractTokenCacheProvider.cs @@ -110,7 +110,11 @@ private async Task OnBeforeAccessAsync(TokenCacheNotificationArgs args) { if (!string.IsNullOrEmpty(args.SuggestedCacheKey)) { - byte[] tokenCacheBytes = await ReadCacheBytesAsync(args.SuggestedCacheKey, CreateHintsFromArgs(args)).ConfigureAwait(false); + byte[]? tokenCacheBytes = await ReadCacheBytesAsync(args.SuggestedCacheKey, CreateHintsFromArgs(args)).ConfigureAwait(false); + if (tokenCacheBytes == null) + { + return; + } try { @@ -137,7 +141,7 @@ private async Task OnBeforeAccessAsync(TokenCacheNotificationArgs args) } } - private byte[] UnprotectBytes(byte[] msalBytes) + private byte[] UnprotectBytes(byte[]? msalBytes) { if (msalBytes != null && _protector != null) { @@ -204,7 +208,7 @@ protected virtual Task WriteCacheBytesAsync(string cacheKey, byte[] bytes, Cache /// /// Cache key. /// Read bytes. - protected abstract Task ReadCacheBytesAsync(string cacheKey); + protected abstract Task ReadCacheBytesAsync(string cacheKey); /// /// Method to be overridden by concrete cache serializers to Read the cache bytes. @@ -212,7 +216,7 @@ protected virtual Task WriteCacheBytesAsync(string cacheKey, byte[] bytes, Cache /// Cache key. /// Hints for the cache serialization implementation optimization. /// Read bytes. - protected virtual Task ReadCacheBytesAsync(string cacheKey, CacheSerializerHints cacheSerializerHints) + protected virtual Task ReadCacheBytesAsync(string cacheKey, CacheSerializerHints cacheSerializerHints) { return ReadCacheBytesAsync(cacheKey); // default implementation avoids a breaking change. } diff --git a/src/Microsoft.Identity.Web.UI/Areas/MicrosoftIdentity/Controllers/AccountController.cs b/src/Microsoft.Identity.Web.UI/Areas/MicrosoftIdentity/Controllers/AccountController.cs index fb2075676..256a5777d 100644 --- a/src/Microsoft.Identity.Web.UI/Areas/MicrosoftIdentity/Controllers/AccountController.cs +++ b/src/Microsoft.Identity.Web.UI/Areas/MicrosoftIdentity/Controllers/AccountController.cs @@ -95,7 +95,10 @@ public IActionResult Challenge( }; OAuthChallengeProperties oAuthChallengeProperties = new OAuthChallengeProperties(items, parameters); - oAuthChallengeProperties.Scope = scope?.Split(" "); + if (scope != null) + { + oAuthChallengeProperties.Scope = scope.Split(" "); + } oAuthChallengeProperties.RedirectUri = redirectUri; return Challenge( @@ -114,7 +117,11 @@ public IActionResult SignOut( { if (AppServicesAuthenticationInformation.IsAppServicesAadAuthenticationEnabled) { - return LocalRedirect(AppServicesAuthenticationInformation.LogoutUrl); + if (AppServicesAuthenticationInformation.LogoutUrl != null) + { + return LocalRedirect(AppServicesAuthenticationInformation.LogoutUrl); + } + return Ok(); } else { diff --git a/src/Microsoft.Identity.Web/AuthorizeForScopesAttribute.cs b/src/Microsoft.Identity.Web/AuthorizeForScopesAttribute.cs index 079a5aabf..1b6486dca 100644 --- a/src/Microsoft.Identity.Web/AuthorizeForScopesAttribute.cs +++ b/src/Microsoft.Identity.Web/AuthorizeForScopesAttribute.cs @@ -142,7 +142,7 @@ public override void OnException(ExceptionContext context) } } - base.OnException(context); + base.OnException(context!); } /// diff --git a/src/Microsoft.Identity.Web/TokenCacheProviders/Session/MsalSessionTokenCacheProvider.cs b/src/Microsoft.Identity.Web/TokenCacheProviders/Session/MsalSessionTokenCacheProvider.cs index ab42b0481..d1042a4d9 100644 --- a/src/Microsoft.Identity.Web/TokenCacheProviders/Session/MsalSessionTokenCacheProvider.cs +++ b/src/Microsoft.Identity.Web/TokenCacheProviders/Session/MsalSessionTokenCacheProvider.cs @@ -53,7 +53,7 @@ public MsalSessionTokenCacheProvider( /// Key representing the token cache /// (account or app). /// Read blob. - protected override async Task ReadCacheBytesAsync(string cacheKey) + protected override async Task ReadCacheBytesAsync(string cacheKey) { return await ReadCacheBytesAsync(cacheKey, new CacheSerializerHints()).ConfigureAwait(false); } @@ -65,7 +65,7 @@ protected override async Task ReadCacheBytesAsync(string cacheKey) /// (account or app). /// Hints for the cache serialization implementation optimization. /// Read blob. - protected override async Task ReadCacheBytesAsync(string cacheKey, CacheSerializerHints cacheSerializerHints) + protected override async Task ReadCacheBytesAsync(string cacheKey, CacheSerializerHints cacheSerializerHints) { #pragma warning disable CA1062 // Validate arguments of public methods await _session.LoadAsync(cacheSerializerHints.CancellationToken).ConfigureAwait(false); @@ -74,7 +74,7 @@ protected override async Task ReadCacheBytesAsync(string cacheKey, Cache _sessionLock.EnterReadLock(); try { - if (_session.TryGetValue(cacheKey, out byte[] blob)) + if (_session.TryGetValue(cacheKey, out byte[]? blob)) { Logger.SessionCache(_logger, "Read", _session.Id, cacheKey, null); } diff --git a/tests/Microsoft.Identity.Web.Test/Certificates/CertificateDescriptionTests.cs b/tests/Microsoft.Identity.Web.Test/Certificates/CertificateDescriptionTests.cs index 221eec649..143fac03a 100644 --- a/tests/Microsoft.Identity.Web.Test/Certificates/CertificateDescriptionTests.cs +++ b/tests/Microsoft.Identity.Web.Test/Certificates/CertificateDescriptionTests.cs @@ -78,11 +78,9 @@ public void TestFromStoreWithThumbprint(string certificateThumbprint, StoreLocat [Fact] public void TestFromCertificate() { - using (X509Certificate2 certificate2 = new X509Certificate2()) - { - CertificateDescription certificateDescription = - CertificateDescription.FromCertificate(certificate2); - } + using X509Certificate2 certificate2 = new X509Certificate2(new byte[0]); + CertificateDescription certificateDescription = + CertificateDescription.FromCertificate(certificate2); } } } diff --git a/tests/aspnet-mvc/OwinWebApp/Web.config b/tests/aspnet-mvc/OwinWebApp/Web.config index 5663019fd..31438e081 100644 --- a/tests/aspnet-mvc/OwinWebApp/Web.config +++ b/tests/aspnet-mvc/OwinWebApp/Web.config @@ -51,7 +51,7 @@ - + @@ -67,7 +67,7 @@ - + @@ -75,23 +75,23 @@ - + - + - + - + - +