diff --git a/Directory.Packages.props b/Directory.Packages.props index 392c23fe..dfb583ac 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -35,7 +35,6 @@ - @@ -58,9 +57,14 @@ + + + + + \ No newline at end of file diff --git a/access-token-management/src/AccessTokenManagement.OpenIdConnect/AuthenticateResultCache.cs b/access-token-management/src/AccessTokenManagement.OpenIdConnect/AuthenticateResultCache.cs index 248f1405..c6a29c41 100644 --- a/access-token-management/src/AccessTokenManagement.OpenIdConnect/AuthenticateResultCache.cs +++ b/access-token-management/src/AccessTokenManagement.OpenIdConnect/AuthenticateResultCache.cs @@ -1,8 +1,8 @@ // Copyright (c) Duende Software. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -using Microsoft.AspNetCore.Authentication; using System.Collections.Generic; +using Microsoft.AspNetCore.Authentication; /// /// Per-request cache so that if SignInAsync is used, we won't re-read the old/cached AuthenticateResult from the handler. /// This requires this service to be added as scoped to the DI system. diff --git a/access-token-management/src/AccessTokenManagement.OpenIdConnect/AuthenticationSessionUserTokenStore.cs b/access-token-management/src/AccessTokenManagement.OpenIdConnect/AuthenticationSessionUserTokenStore.cs index ac5f5434..dd019e40 100644 --- a/access-token-management/src/AccessTokenManagement.OpenIdConnect/AuthenticationSessionUserTokenStore.cs +++ b/access-token-management/src/AccessTokenManagement.OpenIdConnect/AuthenticationSessionUserTokenStore.cs @@ -1,11 +1,11 @@ // Copyright (c) Duende Software. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +using System.Security.Claims; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Http; -using System.Security.Claims; -using Microsoft.Extensions.Logging; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; namespace Duende.AccessTokenManagement.OpenIdConnect { diff --git a/access-token-management/src/AccessTokenManagement.OpenIdConnect/AuthorizationServerDPoPHandler.cs b/access-token-management/src/AccessTokenManagement.OpenIdConnect/AuthorizationServerDPoPHandler.cs index a2d6e182..5e5769d8 100644 --- a/access-token-management/src/AccessTokenManagement.OpenIdConnect/AuthorizationServerDPoPHandler.cs +++ b/access-token-management/src/AccessTokenManagement.OpenIdConnect/AuthorizationServerDPoPHandler.cs @@ -1,10 +1,10 @@ // Copyright (c) Duende Software. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +using System.Net; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; -using System.Net; namespace Duende.AccessTokenManagement.OpenIdConnect; diff --git a/access-token-management/src/AccessTokenManagement.OpenIdConnect/BlazorServerPrincipalAccessor.cs b/access-token-management/src/AccessTokenManagement.OpenIdConnect/BlazorServerPrincipalAccessor.cs index b2b8f454..e7f08cb4 100644 --- a/access-token-management/src/AccessTokenManagement.OpenIdConnect/BlazorServerPrincipalAccessor.cs +++ b/access-token-management/src/AccessTokenManagement.OpenIdConnect/BlazorServerPrincipalAccessor.cs @@ -1,11 +1,11 @@ // Copyright (c) Duende Software. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +using System.Security.Claims; using Microsoft.AspNetCore.Components.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -using System.Security.Claims; namespace Duende.AccessTokenManagement.OpenIdConnect; diff --git a/access-token-management/src/AccessTokenManagement.OpenIdConnect/HttpContextPrincipalAccessor.cs b/access-token-management/src/AccessTokenManagement.OpenIdConnect/HttpContextPrincipalAccessor.cs index 6d1ad0b1..e8a90055 100644 --- a/access-token-management/src/AccessTokenManagement.OpenIdConnect/HttpContextPrincipalAccessor.cs +++ b/access-token-management/src/AccessTokenManagement.OpenIdConnect/HttpContextPrincipalAccessor.cs @@ -1,8 +1,8 @@ // Copyright (c) Duende Software. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -using Microsoft.AspNetCore.Http; using System.Security.Claims; +using Microsoft.AspNetCore.Http; namespace Duende.AccessTokenManagement.OpenIdConnect; diff --git a/access-token-management/src/AccessTokenManagement.OpenIdConnect/TokenManagementHttpContextExtensions.cs b/access-token-management/src/AccessTokenManagement.OpenIdConnect/TokenManagementHttpContextExtensions.cs index eed7459d..1590f60e 100644 --- a/access-token-management/src/AccessTokenManagement.OpenIdConnect/TokenManagementHttpContextExtensions.cs +++ b/access-token-management/src/AccessTokenManagement.OpenIdConnect/TokenManagementHttpContextExtensions.cs @@ -1,10 +1,10 @@ // Copyright (c) Duende Software. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.DependencyInjection; using Duende.AccessTokenManagement; using Duende.AccessTokenManagement.OpenIdConnect; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; namespace Microsoft.AspNetCore.Authentication; diff --git a/access-token-management/src/AccessTokenManagement.OpenIdConnect/UserTokenEndpointService.cs b/access-token-management/src/AccessTokenManagement.OpenIdConnect/UserTokenEndpointService.cs index 2f239c08..90e84b34 100644 --- a/access-token-management/src/AccessTokenManagement.OpenIdConnect/UserTokenEndpointService.cs +++ b/access-token-management/src/AccessTokenManagement.OpenIdConnect/UserTokenEndpointService.cs @@ -1,8 +1,8 @@ // Copyright (c) Duende Software. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -using Duende.IdentityModel.Client; using Duende.IdentityModel; +using Duende.IdentityModel.Client; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; diff --git a/access-token-management/src/AccessTokenManagement/DefaultDPoPProofService.cs b/access-token-management/src/AccessTokenManagement/DefaultDPoPProofService.cs index 0c58012c..28d0a8df 100644 --- a/access-token-management/src/AccessTokenManagement/DefaultDPoPProofService.cs +++ b/access-token-management/src/AccessTokenManagement/DefaultDPoPProofService.cs @@ -1,13 +1,13 @@ // Copyright (c) Duende Software. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -using Duende.IdentityModel; -using Microsoft.IdentityModel.Tokens; -using System.Text; using System.Security.Cryptography; +using System.Text; using System.Text.Json; -using Microsoft.IdentityModel.JsonWebTokens; +using Duende.IdentityModel; using Microsoft.Extensions.Logging; +using Microsoft.IdentityModel.JsonWebTokens; +using Microsoft.IdentityModel.Tokens; namespace Duende.AccessTokenManagement; diff --git a/access-token-management/test/AccessTokenManagement.Tests/ClientTokenManagementApiTests.cs b/access-token-management/test/AccessTokenManagement.Tests/ClientTokenManagementApiTests.cs index be19894e..d8d6e4e9 100644 --- a/access-token-management/test/AccessTokenManagement.Tests/ClientTokenManagementApiTests.cs +++ b/access-token-management/test/AccessTokenManagement.Tests/ClientTokenManagementApiTests.cs @@ -1,13 +1,13 @@ // Copyright (c) Duende Software. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -using Duende.IdentityServer.Configuration; +using System.Text.Json; using Duende.IdentityModel; +using Duende.IdentityServer.Configuration; using Microsoft.AspNetCore.Authentication; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using Microsoft.IdentityModel.Tokens; -using System.Text.Json; namespace Duende.AccessTokenManagement.Tests; diff --git a/access-token-management/test/AccessTokenManagement.Tests/Framework/AppHost.cs b/access-token-management/test/AccessTokenManagement.Tests/Framework/AppHost.cs index d11870d2..23907576 100644 --- a/access-token-management/test/AccessTokenManagement.Tests/Framework/AppHost.cs +++ b/access-token-management/test/AccessTokenManagement.Tests/Framework/AppHost.cs @@ -1,16 +1,16 @@ // Copyright (c) Duende Software. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +using System.Net; +using System.Net.Http.Json; +using System.Web; +using Duende.AccessTokenManagement.OpenIdConnect; +using Duende.IdentityModel; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; -using System.Net; -using System.Web; -using Duende.IdentityModel; -using Duende.AccessTokenManagement.OpenIdConnect; using RichardSzalay.MockHttp; -using System.Net.Http.Json; namespace Duende.AccessTokenManagement.Tests; diff --git a/access-token-management/test/AccessTokenManagement.Tests/Framework/GenericHost.cs b/access-token-management/test/AccessTokenManagement.Tests/Framework/GenericHost.cs index 47e70f63..031c058b 100644 --- a/access-token-management/test/AccessTokenManagement.Tests/Framework/GenericHost.cs +++ b/access-token-management/test/AccessTokenManagement.Tests/Framework/GenericHost.cs @@ -1,6 +1,9 @@ // Copyright (c) Duende Software. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +using System.Net; +using System.Reflection; +using System.Security.Claims; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; @@ -8,9 +11,6 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; -using System.Net; -using System.Reflection; -using System.Security.Claims; namespace Duende.AccessTokenManagement.Tests; diff --git a/access-token-management/test/AccessTokenManagement.Tests/Framework/IdentityServerHost.cs b/access-token-management/test/AccessTokenManagement.Tests/Framework/IdentityServerHost.cs index 4e44ca68..47a54312 100644 --- a/access-token-management/test/AccessTokenManagement.Tests/Framework/IdentityServerHost.cs +++ b/access-token-management/test/AccessTokenManagement.Tests/Framework/IdentityServerHost.cs @@ -1,13 +1,13 @@ // Copyright (c) Duende Software. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +using System.Security.Claims; using Duende.IdentityServer.Models; using Duende.IdentityServer.Services; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -using System.Security.Claims; using Microsoft.IdentityModel.JsonWebTokens; using Microsoft.IdentityModel.Tokens; diff --git a/access-token-management/test/AccessTokenManagement.Tests/Framework/IntegrationTestBase.cs b/access-token-management/test/AccessTokenManagement.Tests/Framework/IntegrationTestBase.cs index 8edda45f..18b3e1dc 100644 --- a/access-token-management/test/AccessTokenManagement.Tests/Framework/IntegrationTestBase.cs +++ b/access-token-management/test/AccessTokenManagement.Tests/Framework/IntegrationTestBase.cs @@ -1,10 +1,10 @@ // Copyright (c) Duende Software. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +using System.Security.Claims; using Duende.AccessTokenManagement.OpenIdConnect; -using Duende.IdentityServer.Models; using Duende.IdentityModel; -using System.Security.Claims; +using Duende.IdentityServer.Models; namespace Duende.AccessTokenManagement.Tests; diff --git a/access-token-management/test/AccessTokenManagement.Tests/Usings.cs b/access-token-management/test/AccessTokenManagement.Tests/Usings.cs index 522a2dc2..5ce1898d 100644 --- a/access-token-management/test/AccessTokenManagement.Tests/Usings.cs +++ b/access-token-management/test/AccessTokenManagement.Tests/Usings.cs @@ -1,5 +1,5 @@ // Copyright (c) Duende Software. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -global using Xunit; -global using Shouldly; \ No newline at end of file +global using Shouldly; +global using Xunit; \ No newline at end of file diff --git a/identity-model-oidc-client/clients/ConsoleClientWithBrowser/Program.cs b/identity-model-oidc-client/clients/ConsoleClientWithBrowser/Program.cs index 7eac32ee..7b670dd4 100644 --- a/identity-model-oidc-client/clients/ConsoleClientWithBrowser/Program.cs +++ b/identity-model-oidc-client/clients/ConsoleClientWithBrowser/Program.cs @@ -1,20 +1,20 @@ // Copyright (c) Duende Software. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -using Serilog; using System; using System.Collections.Generic; +using System.IdentityModel.Tokens.Jwt; using System.Net.Http; +using System.Security.Claims; using System.Text.Json; using System.Threading.Tasks; -using Microsoft.Extensions.Logging; -using Serilog.Sinks.SystemConsole.Themes; -using System.IdentityModel.Tokens.Jwt; -using System.Security.Claims; -using Duende.IdentityModel.OidcClient; using Duende.IdentityModel; -using Microsoft.IdentityModel.Tokens; using Duende.IdentityModel.Client; +using Duende.IdentityModel.OidcClient; +using Microsoft.Extensions.Logging; +using Microsoft.IdentityModel.Tokens; +using Serilog; +using Serilog.Sinks.SystemConsole.Themes; namespace ConsoleClientWithBrowser { diff --git a/identity-model-oidc-client/clients/ConsoleClientWithBrowser/SystemBrowser.cs b/identity-model-oidc-client/clients/ConsoleClientWithBrowser/SystemBrowser.cs index 7345e32e..9f2e63c4 100644 --- a/identity-model-oidc-client/clients/ConsoleClientWithBrowser/SystemBrowser.cs +++ b/identity-model-oidc-client/clients/ConsoleClientWithBrowser/SystemBrowser.cs @@ -1,9 +1,6 @@ // Copyright (c) Duende Software. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Http; using System; using System.Diagnostics; using System.Net; @@ -12,6 +9,9 @@ using System.Threading; using System.Threading.Tasks; using Duende.IdentityModel.OidcClient.Browser; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; namespace ConsoleClientWithBrowser { diff --git a/identity-model-oidc-client/clients/ConsoleClientWithBrowserAndDPoP/Program.cs b/identity-model-oidc-client/clients/ConsoleClientWithBrowserAndDPoP/Program.cs index 45ff9010..27ce2185 100644 --- a/identity-model-oidc-client/clients/ConsoleClientWithBrowserAndDPoP/Program.cs +++ b/identity-model-oidc-client/clients/ConsoleClientWithBrowserAndDPoP/Program.cs @@ -1,7 +1,6 @@ // Copyright (c) Duende Software. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -using Serilog; using System; using System.Collections.Generic; using System.IO; @@ -10,8 +9,9 @@ using System.Threading.Tasks; using Duende.IdentityModel.OidcClient; using Duende.IdentityModel.OidcClient.DPoP; -using Serilog.Sinks.SystemConsole.Themes; using Microsoft.Extensions.Logging; +using Serilog; +using Serilog.Sinks.SystemConsole.Themes; namespace ConsoleClientWithBrowserAndDPoP { diff --git a/identity-model-oidc-client/clients/ConsoleClientWithBrowserAndDPoP/SystemBrowser.cs b/identity-model-oidc-client/clients/ConsoleClientWithBrowserAndDPoP/SystemBrowser.cs index 15d3fecb..c7dfeb3f 100644 --- a/identity-model-oidc-client/clients/ConsoleClientWithBrowserAndDPoP/SystemBrowser.cs +++ b/identity-model-oidc-client/clients/ConsoleClientWithBrowserAndDPoP/SystemBrowser.cs @@ -1,9 +1,6 @@ // Copyright (c) Duende Software. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Http; using System; using System.Diagnostics; using System.Net; @@ -12,6 +9,9 @@ using System.Threading; using System.Threading.Tasks; using Duende.IdentityModel.OidcClient.Browser; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; namespace ConsoleClientWithBrowserAndDPoP { diff --git a/identity-model-oidc-client/src/IdentityModel.OidcClient/AuthorizeClient.cs b/identity-model-oidc-client/src/IdentityModel.OidcClient/AuthorizeClient.cs index bed9f72d..9d0fecdf 100644 --- a/identity-model-oidc-client/src/IdentityModel.OidcClient/AuthorizeClient.cs +++ b/identity-model-oidc-client/src/IdentityModel.OidcClient/AuthorizeClient.cs @@ -1,11 +1,11 @@ // Copyright (c) Duende Software. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +using Duende.IdentityModel; +using Duende.IdentityModel.Client; using Duende.IdentityModel.OidcClient.Browser; using Duende.IdentityModel.OidcClient.Infrastructure; using Duende.IdentityModel.OidcClient.Results; -using Duende.IdentityModel; -using Duende.IdentityModel.Client; using Microsoft.Extensions.Logging; namespace Duende.IdentityModel.OidcClient diff --git a/identity-model-oidc-client/src/IdentityModel.OidcClient/AuthorizeRequest.cs b/identity-model-oidc-client/src/IdentityModel.OidcClient/AuthorizeRequest.cs index 9d8f2e12..dba7cea7 100644 --- a/identity-model-oidc-client/src/IdentityModel.OidcClient/AuthorizeRequest.cs +++ b/identity-model-oidc-client/src/IdentityModel.OidcClient/AuthorizeRequest.cs @@ -1,8 +1,8 @@ // Copyright (c) Duende Software. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -using Duende.IdentityModel.OidcClient.Browser; using Duende.IdentityModel.Client; +using Duende.IdentityModel.OidcClient.Browser; namespace Duende.IdentityModel.OidcClient { diff --git a/identity-model-oidc-client/src/IdentityModel.OidcClient/LoginRequest.cs b/identity-model-oidc-client/src/IdentityModel.OidcClient/LoginRequest.cs index 587e879f..89cf2706 100644 --- a/identity-model-oidc-client/src/IdentityModel.OidcClient/LoginRequest.cs +++ b/identity-model-oidc-client/src/IdentityModel.OidcClient/LoginRequest.cs @@ -1,8 +1,8 @@ // Copyright (c) Duende Software. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -using Duende.IdentityModel.OidcClient.Browser; using Duende.IdentityModel.Client; +using Duende.IdentityModel.OidcClient.Browser; namespace Duende.IdentityModel.OidcClient { diff --git a/identity-model-oidc-client/src/IdentityModel.OidcClient/NoValidationIdentityTokenValidator.cs b/identity-model-oidc-client/src/IdentityModel.OidcClient/NoValidationIdentityTokenValidator.cs index d7104842..fc5cef9f 100644 --- a/identity-model-oidc-client/src/IdentityModel.OidcClient/NoValidationIdentityTokenValidator.cs +++ b/identity-model-oidc-client/src/IdentityModel.OidcClient/NoValidationIdentityTokenValidator.cs @@ -4,8 +4,8 @@ using System.Security.Claims; using System.Text; using System.Text.Json; -using Duende.IdentityModel.OidcClient.Results; using Duende.IdentityModel; +using Duende.IdentityModel.OidcClient.Results; namespace Duende.IdentityModel.OidcClient { diff --git a/identity-model-oidc-client/src/IdentityModel.OidcClient/OidcClient.cs b/identity-model-oidc-client/src/IdentityModel.OidcClient/OidcClient.cs index 97e4705a..79177a7c 100644 --- a/identity-model-oidc-client/src/IdentityModel.OidcClient/OidcClient.cs +++ b/identity-model-oidc-client/src/IdentityModel.OidcClient/OidcClient.cs @@ -2,11 +2,11 @@ // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. using System.Security.Claims; +using Duende.IdentityModel; +using Duende.IdentityModel.Client; using Duende.IdentityModel.OidcClient.Browser; using Duende.IdentityModel.OidcClient.Infrastructure; using Duende.IdentityModel.OidcClient.Results; -using Duende.IdentityModel; -using Duende.IdentityModel.Client; using Microsoft.Extensions.Logging; namespace Duende.IdentityModel.OidcClient diff --git a/identity-model-oidc-client/src/IdentityModel.OidcClient/OidcClientOptions.cs b/identity-model-oidc-client/src/IdentityModel.OidcClient/OidcClientOptions.cs index 0b99c176..59624d54 100644 --- a/identity-model-oidc-client/src/IdentityModel.OidcClient/OidcClientOptions.cs +++ b/identity-model-oidc-client/src/IdentityModel.OidcClient/OidcClientOptions.cs @@ -2,9 +2,9 @@ // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. using System.Text.Json.Serialization; -using Duende.IdentityModel.OidcClient.Browser; using Duende.IdentityModel; using Duende.IdentityModel.Client; +using Duende.IdentityModel.OidcClient.Browser; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; diff --git a/identity-model-oidc-client/src/IdentityModel.OidcClient/ProviderInformation.cs b/identity-model-oidc-client/src/IdentityModel.OidcClient/ProviderInformation.cs index 96074487..43df544e 100644 --- a/identity-model-oidc-client/src/IdentityModel.OidcClient/ProviderInformation.cs +++ b/identity-model-oidc-client/src/IdentityModel.OidcClient/ProviderInformation.cs @@ -1,8 +1,8 @@ // Copyright (c) Duende Software. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -using Duende.IdentityModel.OidcClient.Infrastructure; using Duende.IdentityModel.Jwk; +using Duende.IdentityModel.OidcClient.Infrastructure; namespace Duende.IdentityModel.OidcClient { diff --git a/identity-model-oidc-client/src/IdentityModel.OidcClient/ResponseProcessor.cs b/identity-model-oidc-client/src/IdentityModel.OidcClient/ResponseProcessor.cs index 8682635f..a3cb548c 100644 --- a/identity-model-oidc-client/src/IdentityModel.OidcClient/ResponseProcessor.cs +++ b/identity-model-oidc-client/src/IdentityModel.OidcClient/ResponseProcessor.cs @@ -2,10 +2,10 @@ // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. using System.Net; -using Duende.IdentityModel.OidcClient.Infrastructure; -using Duende.IdentityModel.OidcClient.Results; using Duende.IdentityModel; using Duende.IdentityModel.Client; +using Duende.IdentityModel.OidcClient.Infrastructure; +using Duende.IdentityModel.OidcClient.Results; using Microsoft.Extensions.Logging; namespace Duende.IdentityModel.OidcClient diff --git a/identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/AuthorizeRequestTests.cs b/identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/AuthorizeRequestTests.cs index 1e62b653..d9865f44 100644 --- a/identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/AuthorizeRequestTests.cs +++ b/identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/AuthorizeRequestTests.cs @@ -1,9 +1,8 @@ // Copyright (c) Duende Software. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -using Duende.IdentityModel.OidcClient.Browser; -using FluentAssertions; using Duende.IdentityModel.Client; +using Duende.IdentityModel.OidcClient.Browser; namespace Duende.IdentityModel.OidcClient { @@ -23,16 +22,16 @@ public void Default_parameters_should_be_used_for_authorize_request() var client = new AuthorizeClient(options); var parameters = client.CreateAuthorizeParameters("state", "code_challenge", null); - parameters.Should().HaveCount(9); - parameters.GetValues("client_id").Single().Should().Be("client_id"); - parameters.GetValues("scope").Single().Should().Be("openid"); - parameters.GetValues("resource").First().Should().Be("urn:resource1"); - parameters.GetValues("resource").Skip(1).First().Should().Be("urn:resource2"); - parameters.GetValues("redirect_uri").Single().Should().Be("http://redirect"); - parameters.GetValues("response_type").Single().Should().Be("code"); - parameters.GetValues("state").Single().Should().Be("state"); - parameters.GetValues("code_challenge").Single().Should().Be("code_challenge"); - parameters.GetValues("code_challenge_method").Single().Should().Be("S256"); + parameters.Count.ShouldBe(9); + parameters.GetValues("client_id").Single().ShouldBe("client_id"); + parameters.GetValues("scope").Single().ShouldBe("openid"); + parameters.GetValues("resource").First().ShouldBe("urn:resource1"); + parameters.GetValues("resource").Skip(1).First().ShouldBe("urn:resource2"); + parameters.GetValues("redirect_uri").Single().ShouldBe("http://redirect"); + parameters.GetValues("response_type").Single().ShouldBe("code"); + parameters.GetValues("state").Single().ShouldBe("state"); + parameters.GetValues("code_challenge").Single().ShouldBe("code_challenge"); + parameters.GetValues("code_challenge_method").Single().ShouldBe("S256"); } [Fact] @@ -53,19 +52,19 @@ public void Missing_default_parameters_can_be_set_by_extra_parameters() var client = new AuthorizeClient(options); var parameters = client.CreateAuthorizeParameters("state", "code_challenge", frontChannel); - parameters.Should().HaveCount(9); - parameters.GetValues("client_id").Single().Should().Be("client_id2"); - parameters.GetValues("scope").Single().Should().Be("openid extra"); - parameters.GetValues("redirect_uri").Single().Should().Be("http://redirect2"); - parameters.GetValues("response_type").Single().Should().Be("code"); - parameters.GetValues("state").Single().Should().Be("state"); - parameters.GetValues("code_challenge").Single().Should().Be("code_challenge"); - parameters.GetValues("code_challenge_method").Single().Should().Be("S256"); + parameters.Count.ShouldBe(9); + parameters.GetValues("client_id").Single().ShouldBe("client_id2"); + parameters.GetValues("scope").Single().ShouldBe("openid extra"); + parameters.GetValues("redirect_uri").Single().ShouldBe("http://redirect2"); + parameters.GetValues("response_type").Single().ShouldBe("code"); + parameters.GetValues("state").Single().ShouldBe("state"); + parameters.GetValues("code_challenge").Single().ShouldBe("code_challenge"); + parameters.GetValues("code_challenge_method").Single().ShouldBe("S256"); var resources = parameters.GetValues("resource").ToList(); - resources.Should().HaveCount(2); - resources[0].Should().Be("urn:resource1"); - resources[1].Should().Be("urn:resource2"); + resources.Count.ShouldBe(2); + resources[0].ShouldBe("urn:resource1"); + resources[1].ShouldBe("urn:resource2"); } [Fact] @@ -93,8 +92,8 @@ public async Task Browser_error_is_surfaced_in_authorize_response() var response = await client.AuthorizeAsync(new AuthorizeRequest()); - response.Error.Should().Be("Something terrible happened"); - response.ErrorDescription.Should().Be("Explaining the terrible error..."); + response.Error.ShouldBe("Something terrible happened"); + response.ErrorDescription.ShouldBe("Explaining the terrible error..."); } } } \ No newline at end of file diff --git a/identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/CodeFlowResponseTests.cs b/identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/CodeFlowResponseTests.cs index fe0a56bc..3b3fa85c 100644 --- a/identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/CodeFlowResponseTests.cs +++ b/identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/CodeFlowResponseTests.cs @@ -5,9 +5,8 @@ using System.Security.Claims; using System.Text.Json; using System.Web; -using Duende.IdentityModel.OidcClient.Infrastructure; -using FluentAssertions; using Duende.IdentityModel.Client; +using Duende.IdentityModel.OidcClient.Infrastructure; namespace Duende.IdentityModel.OidcClient { @@ -44,7 +43,7 @@ public class CodeFlowResponseTestsWithNoValidation [Fact] public async Task Valid_response_with_id_token_should_succeed() { - var client = new Duende.IdentityModel.OidcClient.OidcClient(_options); + var client = new OidcClient(_options); var state = await client.PrepareLoginAsync(); var url = $"?state={state.State}&code=bar"; @@ -66,22 +65,22 @@ public async Task Valid_response_with_id_token_should_succeed() var result = await client.ProcessResponseAsync(url, state); - result.IsError.Should().BeFalse(); - result.AccessToken.Should().Be("token"); - result.IdentityToken.Should().NotBeNull(); - result.User.Should().NotBeNull(); - result.AuthenticationTime.Should().Be(DateTimeOffset.FromUnixTimeSeconds(123)); + result.IsError.ShouldBeFalse(); + result.AccessToken.ShouldBe("token"); + result.IdentityToken.ShouldNotBeNull(); + result.User.ShouldNotBeNull(); + result.AuthenticationTime.ShouldBe(DateTimeOffset.FromUnixTimeSeconds(123)); - result.User.Claims.Count().Should().Be(1); - result.User.Claims.First().Type.Should().Be("sub"); - result.User.Claims.First().Value.Should().Be("123"); + result.User.Claims.Count().ShouldBe(1); + result.User.Claims.First().Type.ShouldBe("sub"); + result.User.Claims.First().Value.ShouldBe("123"); } [Fact] public async Task Valid_response_without_id_token_should_succeed() { _options.Scope = "api"; - var client = new Duende.IdentityModel.OidcClient.OidcClient(_options); + var client = new OidcClient(_options); var state = await client.PrepareLoginAsync(); var url = $"?state={state.State}&code=bar"; @@ -98,10 +97,10 @@ public async Task Valid_response_without_id_token_should_succeed() var result = await client.ProcessResponseAsync(url, state); - result.IsError.Should().BeFalse(); - result.AccessToken.Should().Be("token"); - result.IdentityToken.Should().BeNull(); - result.User.Identity.IsAuthenticated.Should().BeFalse(); + result.IsError.ShouldBeFalse(); + result.AccessToken.ShouldBe("token"); + result.IdentityToken.ShouldBeNull(); + result.User.Identity.IsAuthenticated.ShouldBeFalse(); } [Fact] @@ -109,7 +108,7 @@ public async Task Valid_response_with_profile_should_succeed() { _options.LoadProfile = true; - var client = new Duende.IdentityModel.OidcClient.OidcClient(_options); + var client = new OidcClient(_options); var state = await client.PrepareLoginAsync(); var url = $"?state={state.State}&code=bar"; @@ -151,25 +150,25 @@ public async Task Valid_response_with_profile_should_succeed() var result = await client.ProcessResponseAsync(url, state); - result.IsError.Should().BeFalse(); - result.AccessToken.Should().Be("token"); - result.IdentityToken.Should().NotBeNull(); - result.User.Should().NotBeNull(); + result.IsError.ShouldBeFalse(); + result.AccessToken.ShouldBe("token"); + result.IdentityToken.ShouldNotBeNull(); + result.User.ShouldNotBeNull(); - result.User.Claims.Count().Should().Be(2); - result.User.Claims.First().Type.Should().Be("sub"); - result.User.Claims.First().Value.Should().Be("123"); - result.User.Claims.Skip(1).First().Type.Should().Be("name"); - result.User.Claims.Skip(1).First().Value.Should().Be("Dominick"); + result.User.Claims.Count().ShouldBe(2); + result.User.Claims.First().Type.ShouldBe("sub"); + result.User.Claims.First().Value.ShouldBe("123"); + result.User.Claims.Skip(1).First().Type.ShouldBe("name"); + result.User.Claims.Skip(1).First().Value.ShouldBe("Dominick"); } [Fact] public async Task Sending_authorization_header_should_succeed() { _options.ClientSecret = "secret"; - _options.TokenClientCredentialStyle = global::Duende.IdentityModel.Client.ClientCredentialStyle.AuthorizationHeader; + _options.TokenClientCredentialStyle = ClientCredentialStyle.AuthorizationHeader; - var client = new Duende.IdentityModel.OidcClient.OidcClient(_options); + var client = new OidcClient(_options); var state = await client.PrepareLoginAsync(); var url = $"?state={state.State}&code=bar"; @@ -192,19 +191,19 @@ public async Task Sending_authorization_header_should_succeed() var request = backChannelHandler.Request; - request.Headers.Authorization.Should().NotBeNull(); - request.Headers.Authorization.Scheme.Should().Be("Basic"); - request.Headers.Authorization.Parameter.Should() - .Be(Duende.IdentityModel.Client.BasicAuthenticationOAuthHeaderValue.EncodeCredential("client", "secret")); + request.Headers.Authorization.ShouldNotBeNull(); + request.Headers.Authorization.Scheme.ShouldBe("Basic"); + request.Headers.Authorization.Parameter + .ShouldBe(Client.BasicAuthenticationOAuthHeaderValue.EncodeCredential("client", "secret")); } [Fact] public async Task Sending_client_credentials_in_body_should_succeed() { _options.ClientSecret = "secret"; - _options.TokenClientCredentialStyle = global::Duende.IdentityModel.Client.ClientCredentialStyle.PostBody; + _options.TokenClientCredentialStyle = ClientCredentialStyle.PostBody; - var client = new Duende.IdentityModel.OidcClient.OidcClient(_options); + var client = new OidcClient(_options); var state = await client.PrepareLoginAsync(); var url = $"?state={state.State}&code=bar"; @@ -226,14 +225,14 @@ public async Task Sending_client_credentials_in_body_should_succeed() var result = await client.ProcessResponseAsync(url, state); var fields = QueryHelpers.ParseQuery(backChannelHandler.Body); - fields["client_id"].First().Should().Be("client"); - fields["client_secret"].First().Should().Be("secret"); + fields["client_id"].First().ShouldBe("client"); + fields["client_secret"].First().ShouldBe("secret"); } [Fact] public async Task Multi_tenant_token_issuer_name_should_succeed_by_policy_option() { - var client = new Duende.IdentityModel.OidcClient.OidcClient(_options); + var client = new OidcClient(_options); var state = await client.PrepareLoginAsync(); _options.Policy.Discovery.ValidateEndpoints = false; @@ -257,16 +256,16 @@ public async Task Multi_tenant_token_issuer_name_should_succeed_by_policy_option var result = await client.ProcessResponseAsync(url, state); - result.IsError.Should().BeFalse(); - result.AccessToken.Should().Be("token"); - result.IdentityToken.Should().NotBeNull(); - result.User.Should().NotBeNull(); + result.IsError.ShouldBeFalse(); + result.AccessToken.ShouldBe("token"); + result.IdentityToken.ShouldNotBeNull(); + result.User.ShouldNotBeNull(); } [Fact] public async Task Extra_parameters_on_backchannel_should_be_sent() { - var client = new Duende.IdentityModel.OidcClient.OidcClient(_options); + var client = new OidcClient(_options); var state = await client.PrepareLoginAsync(); var url = $"?state={state.State}&code=bar"; @@ -293,21 +292,21 @@ public async Task Extra_parameters_on_backchannel_should_be_sent() var result = await client.ProcessResponseAsync(url, state, backChannel); - result.IsError.Should().BeFalse(); - result.AccessToken.Should().Be("token"); - result.IdentityToken.Should().NotBeNull(); - result.User.Should().NotBeNull(); + result.IsError.ShouldBeFalse(); + result.AccessToken.ShouldBe("token"); + result.IdentityToken.ShouldNotBeNull(); + result.User.ShouldNotBeNull(); var body = handler.Body; - body.Should().Contain("foo=foo"); - body.Should().Contain("bar=bar"); + body.ShouldContain("foo=foo"); + body.ShouldContain("bar=bar"); } [Fact] public async Task No_identity_token_validator_should_fail() { _options.Policy.RequireIdentityTokenSignature = true; - var client = new Duende.IdentityModel.OidcClient.OidcClient(_options); + var client = new OidcClient(_options); var state = await client.PrepareLoginAsync(); var url = $"?state={state.State}&code=bar"; @@ -327,8 +326,8 @@ public async Task No_identity_token_validator_should_fail() new NetworkHandler(JsonSerializer.Serialize(tokenResponse), HttpStatusCode.OK); var act = async () => { await client.ProcessResponseAsync(url, state); }; - await act.Should().ThrowAsync() - .Where(e => e.Message.StartsWith("No IIdentityTokenValidator is configured")); + var exception = await act.ShouldThrowAsync(); + exception.Message.ShouldStartWith("No IIdentityTokenValidator is configured."); } [Fact] @@ -336,14 +335,14 @@ public async Task Error_redeeming_code_should_fail() { _options.BackchannelHandler = new NetworkHandler(new Exception("error")); - var client = new Duende.IdentityModel.OidcClient.OidcClient(_options); + var client = new OidcClient(_options); var state = await client.PrepareLoginAsync(); var url = $"?state={state.State}&code=bar"; var result = await client.ProcessResponseAsync(url, state); - result.IsError.Should().BeTrue(); - result.Error.Should().StartWith("Error redeeming code: error"); + result.IsError.ShouldBeTrue(); + result.Error.ShouldStartWith("Error redeeming code: error"); } [Fact] @@ -360,14 +359,14 @@ public async Task Missing_access_token_on_token_response_should_fail() _options.BackchannelHandler = new NetworkHandler(JsonSerializer.Serialize(tokenResponse), HttpStatusCode.OK); - var client = new Duende.IdentityModel.OidcClient.OidcClient(_options); + var client = new OidcClient(_options); var state = await client.PrepareLoginAsync(); var url = $"?state={state.State}&code=bar"; var result = await client.ProcessResponseAsync(url, state); - result.IsError.Should().BeTrue(); - result.Error.Should().Be("Error validating token response: Access token is missing on token response."); + result.IsError.ShouldBeTrue(); + result.Error.ShouldBe("Error validating token response: Access token is missing on token response."); } [Fact] @@ -383,18 +382,18 @@ public async Task No_identity_token_on_token_response_and_no_profile_loading_sho _options.BackchannelHandler = new NetworkHandler(JsonSerializer.Serialize(tokenResponse), HttpStatusCode.OK); - var client = new Duende.IdentityModel.OidcClient.OidcClient(_options); + var client = new OidcClient(_options); var state = await client.PrepareLoginAsync(); var url = $"?state={state.State}&code=bar"; var result = await client.ProcessResponseAsync(url, state); - result.IsError.Should().BeFalse(); - result.AccessToken.Should().Be("token"); - result.IdentityToken.Should().BeNull(); + result.IsError.ShouldBeFalse(); + result.AccessToken.ShouldBe("token"); + result.IdentityToken.ShouldBeNull(); - result.User.Should().NotBeNull(); - result.User.Claims.Count().Should().Be(0); + result.User.ShouldNotBeNull(); + result.User.Claims.Count().ShouldBe(0); } [Fact] @@ -402,7 +401,7 @@ public async Task No_identity_token_on_token_response_with_profile_loading_shoul { _options.LoadProfile = true; - var client = new Duende.IdentityModel.OidcClient.OidcClient(_options); + var client = new OidcClient(_options); var state = await client.PrepareLoginAsync(); var url = $"?state={state.State}&code=bar"; @@ -443,16 +442,16 @@ public async Task No_identity_token_on_token_response_with_profile_loading_shoul var result = await client.ProcessResponseAsync(url, state); - result.IsError.Should().BeFalse(); - result.AccessToken.Should().Be("token"); - result.IdentityToken.Should().BeNull(); - result.User.Should().NotBeNull(); + result.IsError.ShouldBeFalse(); + result.AccessToken.ShouldBe("token"); + result.IdentityToken.ShouldBeNull(); + result.User.ShouldNotBeNull(); - result.User.Claims.Count().Should().Be(2); - result.User.Claims.First().Type.Should().Be("sub"); - result.User.Claims.First().Value.Should().Be("123"); - result.User.Claims.Skip(1).First().Type.Should().Be("name"); - result.User.Claims.Skip(1).First().Value.Should().Be("Dominick"); + result.User.Claims.Count().ShouldBe(2); + result.User.Claims.First().Type.ShouldBe("sub"); + result.User.Claims.First().Value.ShouldBe("123"); + result.User.Claims.Skip(1).First().Type.ShouldBe("name"); + result.User.Claims.Skip(1).First().Value.ShouldBe("Dominick"); } [Fact] @@ -469,14 +468,14 @@ public async Task Malformed_identity_token_on_token_response_should_fail() _options.BackchannelHandler = new NetworkHandler(JsonSerializer.Serialize(tokenResponse), HttpStatusCode.OK); - var client = new Duende.IdentityModel.OidcClient.OidcClient(_options); + var client = new OidcClient(_options); var state = await client.PrepareLoginAsync(); var url = $"?state={state.State}&code=bar"; var result = await client.ProcessResponseAsync(url, state); - result.IsError.Should().BeTrue(); - result.Error.Should().Contain("invalid_jwt"); + result.IsError.ShouldBeTrue(); + result.Error.ShouldContain("invalid_jwt"); } [Fact] @@ -485,7 +484,7 @@ public async Task Authorize_should_push_parameters_when_PAR_is_enabled() // Configure the client for PAR, authenticating with a client secret _options.ClientSecret = "secret"; _options.ProviderInformation.PushedAuthorizationRequestEndpoint = "https://this-is-set-so-par-will-be-used"; - var client = new Duende.IdentityModel.OidcClient.OidcClient(_options); + var client = new OidcClient(_options); // Mock the response from the par endpoint var requestUri = "mocked_request_uri"; @@ -502,16 +501,16 @@ public async Task Authorize_should_push_parameters_when_PAR_is_enabled() // Validate that the resulting PAR state is correct var startUrl = new Uri(state.StartUrl); var startUrlQueryParams = HttpUtility.ParseQueryString(startUrl.Query); - startUrlQueryParams.Count.Should().Be(2); - startUrlQueryParams.GetValues("client_id").Single().Should().Be("client"); - startUrlQueryParams.GetValues("request_uri").Single().Should().Be(requestUri); + startUrlQueryParams.Count.ShouldBe(2); + startUrlQueryParams.GetValues("client_id").Single().ShouldBe("client"); + startUrlQueryParams.GetValues("request_uri").Single().ShouldBe(requestUri); // Validate that the client authentication during the PAR request was correct var request = backChannelHandler.Request; - request.Headers.Authorization.Should().NotBeNull(); - request.Headers.Authorization.Scheme.Should().Be("Basic"); - request.Headers.Authorization.Parameter.Should() - .Be(Duende.IdentityModel.Client.BasicAuthenticationOAuthHeaderValue.EncodeCredential("client", "secret")); + request.Headers.Authorization.ShouldNotBeNull(); + request.Headers.Authorization.Scheme.ShouldBe("Basic"); + request.Headers.Authorization.Parameter + .ShouldBe(Client.BasicAuthenticationOAuthHeaderValue.EncodeCredential("client", "secret")); } [Fact] @@ -526,7 +525,7 @@ public async Task Par_request_should_include_client_assertion_in_body() Value = clientAssertion }; _options.ProviderInformation.PushedAuthorizationRequestEndpoint = "https://this-is-set-so-par-will-be-used"; - var client = new Duende.IdentityModel.OidcClient.OidcClient(_options); + var client = new OidcClient(_options); // Mock the response from the par endpoint var requestUri = "mocked_request_uri"; @@ -543,17 +542,17 @@ public async Task Par_request_should_include_client_assertion_in_body() // Validate that the resulting PAR state is correct var startUrl = new Uri(state.StartUrl); var startUrlQueryParams = HttpUtility.ParseQueryString(startUrl.Query); - startUrlQueryParams.Count.Should().Be(2); - startUrlQueryParams.GetValues("client_id").Single().Should().Be("client"); - startUrlQueryParams.GetValues("request_uri").Single().Should().Be(requestUri); + startUrlQueryParams.Count.ShouldBe(2); + startUrlQueryParams.GetValues("client_id").Single().ShouldBe("client"); + startUrlQueryParams.GetValues("request_uri").Single().ShouldBe(requestUri); // Validate that the client authentication during the PAR request was correct var parRequest = backChannelHandler.Request; var parContent = await parRequest.Content.ReadAsStringAsync(); var parParams = HttpUtility.ParseQueryString(parContent); - parParams.GetValues("client_assertion").Single().Should().Be(clientAssertion); - parParams.GetValues("client_assertion_type").Single().Should().Be(clientAssertionType); - parRequest.Headers.Authorization.Should().BeNull(); + parParams.GetValues("client_assertion").Single().ShouldBe(clientAssertion); + parParams.GetValues("client_assertion_type").Single().ShouldBe(clientAssertionType); + parRequest.Headers.Authorization.ShouldBeNull(); } } } \ No newline at end of file diff --git a/identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/CommonResponseTests.cs b/identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/CommonResponseTests.cs index 8dffa085..6ef713ad 100644 --- a/identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/CommonResponseTests.cs +++ b/identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/CommonResponseTests.cs @@ -1,7 +1,7 @@ // Copyright (c) Duende Software. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -using FluentAssertions; + using Duende.IdentityModel.Jwk; namespace Duende.IdentityModel.OidcClient @@ -28,8 +28,8 @@ public async Task Missing_code_should_be_rejected() var url = $"?state={state.State}&id_token=foo"; var result = await client.ProcessResponseAsync(url, state); - result.IsError.Should().BeTrue(); - result.Error.Should().Be("Missing authorization code."); + result.IsError.ShouldBeTrue(); + result.Error.ShouldBe("Missing authorization code."); } [Fact] @@ -41,8 +41,8 @@ public async Task Missing_state_should_be_rejected() var url = $"?code=foo&id_token=foo"; var result = await client.ProcessResponseAsync(url, state); - result.IsError.Should().BeTrue(); - result.Error.Should().Be("Missing state."); + result.IsError.ShouldBeTrue(); + result.Error.ShouldBe("Missing state."); } [Fact] @@ -54,8 +54,8 @@ public async Task Invalid_state_should_be_rejected() var url = $"?state=invalid&id_token=foo&code=bar"; var result = await client.ProcessResponseAsync(url, state); - result.IsError.Should().BeTrue(); - result.Error.Should().Be("Invalid state."); + result.IsError.ShouldBeTrue(); + result.Error.ShouldBe("Invalid state."); } } } diff --git a/identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/ConfigurationTests.cs b/identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/ConfigurationTests.cs index 3cca9bfb..f9928355 100644 --- a/identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/ConfigurationTests.cs +++ b/identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/ConfigurationTests.cs @@ -2,10 +2,9 @@ // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. using System.Net; -using Duende.IdentityModel.OidcClient.Infrastructure; -using FluentAssertions; using Duende.IdentityModel.Client; using Duende.IdentityModel.Jwk; +using Duende.IdentityModel.OidcClient.Infrastructure; namespace Duende.IdentityModel.OidcClient { @@ -16,9 +15,9 @@ public void Null_options_should_throw_exception() { OidcClientOptions options = null; - Action act = () => new Duende.IdentityModel.OidcClient.OidcClient(options); + Action act = () => _ = new OidcClient(options); - act.Should().Throw(); + act.ShouldThrow(); } [Fact] @@ -26,9 +25,10 @@ public void No_authority_and_no_static_config_should_throw_exception() { var options = new OidcClientOptions(); - Action act = () => new Duende.IdentityModel.OidcClient.OidcClient(options); + Action act = () => _ = new OidcClient(options); - act.Should().Throw().Where(e => e.Message.StartsWith("No authority specified")); + var exception = act.ShouldThrow(); + exception.Message.ShouldStartWith("No authority specified"); } [Fact] @@ -45,11 +45,11 @@ public async Task Providing_required_provider_information_should_not_throw() } }; - var client = new Duende.IdentityModel.OidcClient.OidcClient(options); + var client = new OidcClient(options); var act = async () => { await client.EnsureProviderInformationAsync(CancellationToken.None); }; - await act.Should().NotThrowAsync(); + await act.ShouldNotThrowAsync(); } [Fact] @@ -66,11 +66,12 @@ public async Task Missing_issuer_should_throw() } }; - var client = new Duende.IdentityModel.OidcClient.OidcClient(options); + var client = new OidcClient(options); var act = async () => { await client.EnsureProviderInformationAsync(CancellationToken.None); }; - await act.Should().ThrowAsync().Where(e => e.Message.Equals("Issuer name is missing in provider information")); + var exception = await act.ShouldThrowAsync(); + exception.Message.ShouldStartWith("Issuer name is missing in provider information"); } [Fact] @@ -87,11 +88,12 @@ public async Task Missing_authorize_endpoint_should_throw() } }; - var client = new Duende.IdentityModel.OidcClient.OidcClient(options); + var client = new OidcClient(options); var act = async () => { await client.EnsureProviderInformationAsync(CancellationToken.None); }; - await act.Should().ThrowAsync().Where(e => e.Message.Equals("Authorize endpoint is missing in provider information")); + var exception = await act.ShouldThrowAsync(); + exception.Message.ShouldBe("Authorize endpoint is missing in provider information"); } [Fact] @@ -108,11 +110,12 @@ public async Task Missing_token_endpoint_should_throw() } }; - var client = new Duende.IdentityModel.OidcClient.OidcClient(options); + var client = new OidcClient(options); var act = async () => { await client.EnsureProviderInformationAsync(CancellationToken.None); }; - await act.Should().ThrowAsync().Where(e => e.Message.Equals("Token endpoint is missing in provider information")); + var exception = await act.ShouldThrowAsync(); + exception.Message.ShouldBe("Token endpoint is missing in provider information"); } [Fact] @@ -129,11 +132,12 @@ public async Task Missing_keyset_should_throw() } }; - var client = new Duende.IdentityModel.OidcClient.OidcClient(options); + var client = new OidcClient(options); var act = async () => { await client.EnsureProviderInformationAsync(CancellationToken.None); }; - await act.Should().ThrowAsync().Where(e => e.Message.Equals("Key set is missing in provider information")); + var exception = await act.ShouldThrowAsync(); + exception.Message.ShouldBe("Key set is missing in provider information"); } [Fact] @@ -146,11 +150,12 @@ public async Task Exception_while_loading_discovery_document_should_throw() BackchannelHandler = new NetworkHandler(new Exception("error")) }; - var client = new Duende.IdentityModel.OidcClient.OidcClient(options); + var client = new OidcClient(options); var act = async () => { await client.EnsureProviderInformationAsync(CancellationToken.None); }; - await act.Should().ThrowAsync().Where(e => e.Message.Equals("Error loading discovery document: Error connecting to https://authority/.well-known/openid-configuration. error.")); + var exception = await act.ShouldThrowAsync(); + exception.Message.ShouldBe("Error loading discovery document: Error connecting to https://authority/.well-known/openid-configuration. error."); } [Fact] @@ -163,11 +168,12 @@ public async Task Error401_while_loading_discovery_document_should_throw() BackchannelHandler = new NetworkHandler(HttpStatusCode.NotFound, "not found") }; - var client = new Duende.IdentityModel.OidcClient.OidcClient(options); + var client = new OidcClient(options); var act = async () => { await client.EnsureProviderInformationAsync(CancellationToken.None); }; - await act.Should().ThrowAsync().Where(e => e.Message.Equals("Error loading discovery document: Error connecting to https://authority/.well-known/openid-configuration: not found")); + var exception = await act.ShouldThrowAsync(); + exception.Message.ShouldBe("Error loading discovery document: Error connecting to https://authority/.well-known/openid-configuration: not found"); } [Fact] @@ -179,8 +185,8 @@ public async Task GetClientAssertionAsync_should_return_statically_configured_cl }; var result = await options.GetClientAssertionAsync(); - result.Type.Should().Be("test"); - result.Value.Should().Be("expected"); + result.Type.ShouldBe("test"); + result.Value.ShouldBe("expected"); } } } \ No newline at end of file diff --git a/identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/CryptoHelperTests.cs b/identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/CryptoHelperTests.cs index 4bd6aa6f..234924ba 100644 --- a/identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/CryptoHelperTests.cs +++ b/identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/CryptoHelperTests.cs @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. using System.Text; -using FluentAssertions; + using Duende.IdentityModel; namespace Duende.IdentityModel.OidcClient; @@ -27,7 +27,7 @@ public void ComputeHash_should_compute_correct_hashes_for_all_signature_algorith var hashString = Base64Url.Encode(leftHalf); - sut.ValidateHash(data, hashString, algorithmName).Should().BeTrue(); + sut.ValidateHash(data, hashString, algorithmName).ShouldBeTrue(); } } \ No newline at end of file diff --git a/identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/DPoP/DPoPTests.cs b/identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/DPoP/DPoPTests.cs index 33483135..548e129a 100644 --- a/identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/DPoP/DPoPTests.cs +++ b/identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/DPoP/DPoPTests.cs @@ -6,10 +6,9 @@ using System.Net; using System.Net.Http.Headers; using System.Text.Json; +using Duende.IdentityModel.Client; using Duende.IdentityModel.OidcClient.DPoP.Framework; using Duende.IdentityServer.Models; -using FluentAssertions; -using Duende.IdentityModel.Client; using Microsoft.IdentityModel.Tokens; namespace Duende.IdentityModel.OidcClient.DPoP; @@ -55,8 +54,8 @@ public async Task dpop_tokens_should_be_passed_to_token_endpoint() ClientSecret = "secret", }); - tokenResponse.HttpStatusCode.Should().Be(HttpStatusCode.OK); - tokenResponse.TokenType.Should().Be("DPoP"); + tokenResponse.HttpStatusCode.ShouldBe(HttpStatusCode.OK); + tokenResponse.TokenType.ShouldBe("DPoP"); } [Fact] @@ -74,8 +73,8 @@ public async Task when_nonce_required_nonce_should_be_used_for_token_endpoint() ClientSecret = "secret", }); - tokenResponse.HttpStatusCode.Should().Be(HttpStatusCode.OK); - tokenResponse.TokenType.Should().Be("DPoP"); + tokenResponse.HttpStatusCode.ShouldBe(HttpStatusCode.OK); + tokenResponse.TokenType.ShouldBe("DPoP"); } [Fact] @@ -97,11 +96,11 @@ public async Task dpop_tokens_should_be_passed_to_api() ApiHost.ApiInvoked += ctx => { - ctx.User.Identity.IsAuthenticated.Should().BeTrue(); + ctx.User.Identity.IsAuthenticated.ShouldBeTrue(); }; var apiResponse = await apiClient.GetAsync(ApiHost.Url("/api")); - apiResponse.StatusCode.Should().Be(HttpStatusCode.OK); + apiResponse.StatusCode.ShouldBe(HttpStatusCode.OK); } [Fact] @@ -127,11 +126,11 @@ public async Task when_nonce_required_nonce_should_be_used_for_api_endpoint() ApiHost.ApiInvoked += ctx => { - ctx.User.Identity.IsAuthenticated.Should().BeTrue(); + ctx.User.Identity.IsAuthenticated.ShouldBeTrue(); }; var apiResponse = await apiClient.GetAsync(ApiHost.Url("/api")); - apiResponse.StatusCode.Should().Be(HttpStatusCode.OK); + apiResponse.StatusCode.ShouldBe(HttpStatusCode.OK); } } diff --git a/identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/EndSessionUrlTests.cs b/identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/EndSessionUrlTests.cs index dec6922a..b90559fb 100644 --- a/identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/EndSessionUrlTests.cs +++ b/identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/EndSessionUrlTests.cs @@ -1,7 +1,7 @@ // Copyright (c) Duende Software. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -using FluentAssertions; + namespace Duende.IdentityModel.OidcClient { @@ -15,7 +15,7 @@ public void Default_parameters_should_create_expected_end_session_url() var url = client.CreateEndSessionUrl("https://server/end_session", new LogoutRequest()); - url.Should().Be("https://server/end_session"); + url.ShouldBe("https://server/end_session"); } [Fact] @@ -29,7 +29,7 @@ public void Post_logout_redirect_parameter_should_create_expected_end_session_ur var client = new AuthorizeClient(options); var url = client.CreateEndSessionUrl("https://server/end_session", new LogoutRequest()); - url.Should().Be("https://server/end_session?post_logout_redirect_uri=https%3A%2F%2Fclient.com%2Fpage"); + url.ShouldBe("https://server/end_session?post_logout_redirect_uri=https%3A%2F%2Fclient.com%2Fpage"); } [Fact] @@ -43,7 +43,7 @@ public void Post_logout_redirect_parameter_and_id_token_hint_should_create_expec var client = new AuthorizeClient(options); var url = client.CreateEndSessionUrl("https://server/end_session", new LogoutRequest { IdTokenHint = "id_token" }); - url.Should().Be("https://server/end_session?id_token_hint=id_token&post_logout_redirect_uri=https%3A%2F%2Fclient.com%2Fpage"); + url.ShouldBe("https://server/end_session?id_token_hint=id_token&post_logout_redirect_uri=https%3A%2F%2Fclient.com%2Fpage"); } [Fact] @@ -54,7 +54,7 @@ public void Id_token_hint_should_create_expected_end_session_url() var url = client.CreateEndSessionUrl("https://server/end_session", new LogoutRequest { IdTokenHint = "id_token" }); - url.Should().Be("https://server/end_session?id_token_hint=id_token"); + url.ShouldBe("https://server/end_session?id_token_hint=id_token"); } } } \ No newline at end of file diff --git a/identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/IdentityModel.OidcClient.Tests.csproj b/identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/IdentityModel.OidcClient.Tests.csproj index 44476346..6b1666b0 100644 --- a/identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/IdentityModel.OidcClient.Tests.csproj +++ b/identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/IdentityModel.OidcClient.Tests.csproj @@ -13,7 +13,6 @@ - diff --git a/identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/LogSerializerTests.cs b/identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/LogSerializerTests.cs index 768823e8..46ff71aa 100644 --- a/identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/LogSerializerTests.cs +++ b/identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/LogSerializerTests.cs @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. using Duende.IdentityModel.OidcClient.Infrastructure; -using FluentAssertions; + namespace Duende.IdentityModel.OidcClient { @@ -20,7 +20,7 @@ public void LogSerializer_should_serialize_arbitrary_types() // We instantiate the test class as an example of a class that is // not (and won't ever be) in the generation context. var act = () => LogSerializer.Serialize(new LogSerializerTests()); - act.Should().NotThrow(); + act.ShouldNotThrow(); } } } \ No newline at end of file diff --git a/identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/OidcClientTests.cs b/identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/OidcClientTests.cs index 25b7b350..68b96312 100644 --- a/identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/OidcClientTests.cs +++ b/identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/OidcClientTests.cs @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. using Duende.IdentityModel.Client; -using FluentAssertions; + namespace Duende.IdentityModel.OidcClient { @@ -38,7 +38,7 @@ public async Task RefreshTokenAsync_with_scope_should_set_http_request_scope_par Func = async r => { var content = await r.Content.ReadAsStringAsync(); - content.Should().Contain($"scope={scope}", content); + content.ShouldContain($"scope={scope}"); return new HttpResponseMessage { Content = new StringContent($@"{{ @@ -56,7 +56,7 @@ public async Task RefreshTokenAsync_with_scope_should_set_http_request_scope_par var result = await sut.RefreshTokenAsync("test", scope: scope); - result.Should().NotBeNull(); + result.ShouldNotBeNull(); } class FakeHttpMessageHandler : HttpMessageHandler diff --git a/identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/RefreshTokenDelegatingHandlerTests.cs b/identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/RefreshTokenDelegatingHandlerTests.cs index fcee20b2..f1cfb677 100644 --- a/identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/RefreshTokenDelegatingHandlerTests.cs +++ b/identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/RefreshTokenDelegatingHandlerTests.cs @@ -3,10 +3,8 @@ using System.Collections.Concurrent; using System.Net; -using Duende.IdentityModel.OidcClient.Results; -using FluentAssertions; -using FluentAssertions.Extensions; using Duende.IdentityModel.Client; +using Duende.IdentityModel.OidcClient.Results; using Xunit.Abstractions; namespace Duende.IdentityModel.OidcClient @@ -37,13 +35,13 @@ public async Task Can_refresh_access_tokens_with_sliding_refresh_tokens() using (var client = new TestClient(handlerUnderTest)) { - tokens.Count.Should().Be(1); + tokens.Count.ShouldBe(1); await client.SecuredPing(); - tokens.Count.Should().Be(1); + tokens.Count.ShouldBe(1); await client.SecuredPing(); - tokens.Count.Should().Be(1); + tokens.Count.ShouldBe(1); await client.SecuredPing(); - tokens.Count.Should().Be(2); + tokens.Count.ShouldBe(2); } } @@ -57,10 +55,10 @@ public async Task Can_refresh_access_tokens_in_parallel() var tokens = new TestTokens(maxCallsPerAccessToken); var handlerUnderTest = new RefreshTokenDelegatingHandler( - new TestableOidcTokenRefreshClient(tokens, 2.Milliseconds()), + new TestableOidcTokenRefreshClient(tokens, TimeSpan.FromMilliseconds(2)), tokens.InitialAccessToken, tokens.InitialRefreshToken, - innerHandler: new TestServer(tokens, 0.Milliseconds())); + innerHandler: new TestServer(tokens, TimeSpan.FromMilliseconds(0))); using (var client = new TestClient(handlerUnderTest)) { @@ -75,7 +73,7 @@ async Task PerformPingRequests() await Task.WhenAll(tasks); } - tokens.Count.Should().BeGreaterOrEqualTo(logicalThreadCount * callsPerThread / maxCallsPerAccessToken); + tokens.Count.ShouldBeGreaterThanOrEqualTo(logicalThreadCount * callsPerThread / maxCallsPerAccessToken); } private class TestClient : IDisposable diff --git a/identity-model/test/IdentityModel.Tests/AuthorizeResponseTests.cs b/identity-model/test/IdentityModel.Tests/AuthorizeResponseTests.cs index 900d6f81..c716fcd3 100644 --- a/identity-model/test/IdentityModel.Tests/AuthorizeResponseTests.cs +++ b/identity-model/test/IdentityModel.Tests/AuthorizeResponseTests.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. using Duende.IdentityModel.Client; -using FluentAssertions; namespace Duende.IdentityModel { @@ -15,8 +14,8 @@ public void Error_Response_with_QueryString() var response = new AuthorizeResponse(url); - response.IsError.Should().BeTrue(); - response.Error.Should().Be("foo"); + response.IsError.ShouldBeTrue(); + response.Error.ShouldBe("foo"); } [Fact] @@ -26,8 +25,8 @@ public void Error_Response_with_HashFragment() var response = new AuthorizeResponse(url); - response.IsError.Should().BeTrue(); - response.Error.Should().Be("foo"); + response.IsError.ShouldBeTrue(); + response.Error.ShouldBe("foo"); } [Fact] @@ -37,8 +36,8 @@ public void Error_Response_with_QueryString_and_HashFragment() var response = new AuthorizeResponse(url); - response.IsError.Should().BeTrue(); - response.Error.Should().Be("foo"); + response.IsError.ShouldBeTrue(); + response.Error.ShouldBe("foo"); } [Fact] @@ -48,11 +47,11 @@ public void Code_Response_with_QueryString() var response = new AuthorizeResponse(url); - response.IsError.Should().BeFalse(); - response.Code.Should().Be("foo"); + response.IsError.ShouldBeFalse(); + response.Code.ShouldBe("foo"); - response.Values["sid"].Should().Be("123"); - response.TryGet("sid").Should().Be("123"); + response.Values["sid"].ShouldBe("123"); + response.TryGet("sid").ShouldBe("123"); } [Fact] @@ -62,11 +61,11 @@ public void AccessToken_Response_with_QueryString() var response = new AuthorizeResponse(url); - response.IsError.Should().BeFalse(); - response.AccessToken.Should().Be("foo"); + response.IsError.ShouldBeFalse(); + response.AccessToken.ShouldBe("foo"); - response.Values["sid"].Should().Be("123"); - response.TryGet("sid").Should().Be("123"); + response.Values["sid"].ShouldBe("123"); + response.TryGet("sid").ShouldBe("123"); } [Fact] @@ -76,11 +75,11 @@ public void AccessToken_Response_with_QueryString_and_HashFragment() var response = new AuthorizeResponse(url); - response.IsError.Should().BeFalse(); - response.AccessToken.Should().Be("foo"); + response.IsError.ShouldBeFalse(); + response.AccessToken.ShouldBe("foo"); - response.Values["sid"].Should().Be("123"); - response.TryGet("sid").Should().Be("123"); + response.Values["sid"].ShouldBe("123"); + response.TryGet("sid").ShouldBe("123"); } [Fact] @@ -90,11 +89,11 @@ public void AccessToken_Response_with_QueryString_and_Empty_Entry() var response = new AuthorizeResponse(url); - response.IsError.Should().BeFalse(); - response.AccessToken.Should().Be("foo"); + response.IsError.ShouldBeFalse(); + response.AccessToken.ShouldBe("foo"); - response.Values["sid"].Should().Be("123"); - response.TryGet("sid").Should().Be("123"); + response.Values["sid"].ShouldBe("123"); + response.TryGet("sid").ShouldBe("123"); } [Fact] @@ -103,11 +102,11 @@ public void form_post_format_should_parse() const string form = "id_token=foo&code=bar&scope=baz&session_state=quux"; var response = new AuthorizeResponse(form); - response.IsError.Should().BeFalse(); - response.IdentityToken.Should().Be("foo"); - response.Code.Should().Be("bar"); - response.Scope.Should().Be("baz"); - response.Values["session_state"].Should().Be("quux"); + response.IsError.ShouldBeFalse(); + response.IdentityToken.ShouldBe("foo"); + response.Code.ShouldBe("bar"); + response.Scope.ShouldBe("baz"); + response.Values["session_state"].ShouldBe("quux"); } } } \ No newline at end of file diff --git a/identity-model/test/IdentityModel.Tests/BasicAuthenticationEncodingTests.cs b/identity-model/test/IdentityModel.Tests/BasicAuthenticationEncodingTests.cs index f610584f..67e8a9a6 100644 --- a/identity-model/test/IdentityModel.Tests/BasicAuthenticationEncodingTests.cs +++ b/identity-model/test/IdentityModel.Tests/BasicAuthenticationEncodingTests.cs @@ -3,7 +3,6 @@ using System.Text; using Duende.IdentityModel.Client; -using FluentAssertions; namespace Duende.IdentityModel { @@ -22,8 +21,8 @@ public void oauth_values_should_decode_correctly(string id, string secret) var header = new BasicAuthenticationOAuthHeaderValue(id, secret); DecodeOAuthHeader(header.Parameter, out var decodedId, out var decodedSecret); - decodedId.Should().Be(id); - decodedSecret.Should().Be(secret); + decodedId.ShouldBe(id); + decodedSecret.ShouldBe(secret); } private void DecodeOAuthHeader(string value, out string id, out string secret) diff --git a/identity-model/test/IdentityModel.Tests/ClaimsComparisonTests.cs b/identity-model/test/IdentityModel.Tests/ClaimsComparisonTests.cs index b462ab36..d9c8f314 100644 --- a/identity-model/test/IdentityModel.Tests/ClaimsComparisonTests.cs +++ b/identity-model/test/IdentityModel.Tests/ClaimsComparisonTests.cs @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. using System.Security.Claims; -using FluentAssertions; + namespace Duende.IdentityModel { @@ -34,27 +34,27 @@ public void Default_options_should_result_in_four_claims() { var hashSet = new HashSet(_claims, new ClaimComparer()); - hashSet.Count.Should().Be(4); + hashSet.Count.ShouldBe(4); var item = hashSet.First(); - item.Type.Should().Be("claim_type1"); - item.Value.Should().Be("value"); - item.Issuer.Should().Be("issuer1"); + item.Type.ShouldBe("claim_type1"); + item.Value.ShouldBe("value"); + item.Issuer.ShouldBe("issuer1"); item = hashSet.Skip(1).First(); - item.Type.Should().Be("claim_type1"); - item.Value.Should().Be("Value"); - item.Issuer.Should().Be("issuer1"); + item.Type.ShouldBe("claim_type1"); + item.Value.ShouldBe("Value"); + item.Issuer.ShouldBe("issuer1"); item = hashSet.Skip(2).First(); - item.Type.Should().Be("claim_type1"); - item.Value.Should().Be("value"); - item.Issuer.Should().Be("issuer2"); + item.Type.ShouldBe("claim_type1"); + item.Value.ShouldBe("value"); + item.Issuer.ShouldBe("issuer2"); item = hashSet.Skip(3).First(); - item.Type.Should().Be("claim_type1"); - item.Value.Should().Be("Value"); - item.Issuer.Should().Be("issuer2"); + item.Type.ShouldBe("claim_type1"); + item.Value.ShouldBe("Value"); + item.Issuer.ShouldBe("issuer2"); } @@ -63,27 +63,27 @@ public void Ordinal_should_result_in_four_claims() { var hashSet = new HashSet(_claims, new ClaimComparer(new ClaimComparer.Options { IgnoreValueCase = false })); - hashSet.Count.Should().Be(4); + hashSet.Count.ShouldBe(4); var item = hashSet.First(); - item.Type.Should().Be("claim_type1"); - item.Value.Should().Be("value"); - item.Issuer.Should().Be("issuer1"); + item.Type.ShouldBe("claim_type1"); + item.Value.ShouldBe("value"); + item.Issuer.ShouldBe("issuer1"); item = hashSet.Skip(1).First(); - item.Type.Should().Be("claim_type1"); - item.Value.Should().Be("Value"); - item.Issuer.Should().Be("issuer1"); + item.Type.ShouldBe("claim_type1"); + item.Value.ShouldBe("Value"); + item.Issuer.ShouldBe("issuer1"); item = hashSet.Skip(2).First(); - item.Type.Should().Be("claim_type1"); - item.Value.Should().Be("value"); - item.Issuer.Should().Be("issuer2"); + item.Type.ShouldBe("claim_type1"); + item.Value.ShouldBe("value"); + item.Issuer.ShouldBe("issuer2"); item = hashSet.Skip(3).First(); - item.Type.Should().Be("claim_type1"); - item.Value.Should().Be("Value"); - item.Issuer.Should().Be("issuer2"); + item.Type.ShouldBe("claim_type1"); + item.Value.ShouldBe("Value"); + item.Issuer.ShouldBe("issuer2"); } [Fact] @@ -91,17 +91,17 @@ public void Ignoring_issuer_should_result_in_one_claim() { var hashSet = new HashSet(_claims, new ClaimComparer(new ClaimComparer.Options { IgnoreIssuer = true })); - hashSet.Count.Should().Be(2); + hashSet.Count.ShouldBe(2); var item = hashSet.First(); - item.Type.Should().Be("claim_type1"); - item.Value.Should().Be("value"); - item.Issuer.Should().Be("issuer1"); + item.Type.ShouldBe("claim_type1"); + item.Value.ShouldBe("value"); + item.Issuer.ShouldBe("issuer1"); item = hashSet.Skip(1).First(); - item.Type.Should().Be("claim_type1"); - item.Value.Should().Be("Value"); - item.Issuer.Should().Be("issuer1"); + item.Type.ShouldBe("claim_type1"); + item.Value.ShouldBe("Value"); + item.Issuer.ShouldBe("issuer1"); } [Fact] @@ -109,17 +109,17 @@ public void Ordinal_and_ignoring_issuer_should_result_in_two_claims() { var hashSet = new HashSet(_claims, new ClaimComparer(new ClaimComparer.Options { IgnoreValueCase = false, IgnoreIssuer = true })); - hashSet.Count.Should().Be(2); + hashSet.Count.ShouldBe(2); var item = hashSet.First(); - item.Type.Should().Be("claim_type1"); - item.Value.Should().Be("value"); - item.Issuer.Should().Be("issuer1"); + item.Type.ShouldBe("claim_type1"); + item.Value.ShouldBe("value"); + item.Issuer.ShouldBe("issuer1"); item = hashSet.Skip(1).First(); - item.Type.Should().Be("claim_type1"); - item.Value.Should().Be("Value"); - item.Issuer.Should().Be("issuer1"); + item.Type.ShouldBe("claim_type1"); + item.Value.ShouldBe("Value"); + item.Issuer.ShouldBe("issuer1"); } } } \ No newline at end of file diff --git a/identity-model/test/IdentityModel.Tests/DiscoveryCacheTests.cs b/identity-model/test/IdentityModel.Tests/DiscoveryCacheTests.cs index a9a15944..afd01e5e 100644 --- a/identity-model/test/IdentityModel.Tests/DiscoveryCacheTests.cs +++ b/identity-model/test/IdentityModel.Tests/DiscoveryCacheTests.cs @@ -1,11 +1,9 @@ // Copyright (c) Duende Software. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -using System.Net; -using System.Net.Http; using Duende.IdentityModel.Client; using Duende.IdentityModel.Infrastructure; -using FluentAssertions; + namespace Duende.IdentityModel { @@ -41,7 +39,7 @@ public async Task New_initialization_should_work() var disco = await cache.GetAsync(); - disco.IsError.Should().BeFalse(); + disco.IsError.ShouldBeFalse(); } } } diff --git a/identity-model/test/IdentityModel.Tests/DiscoveryPolicyTestsBase.cs b/identity-model/test/IdentityModel.Tests/DiscoveryPolicyTestsBase.cs index efdec7b7..b9636971 100644 --- a/identity-model/test/IdentityModel.Tests/DiscoveryPolicyTestsBase.cs +++ b/identity-model/test/IdentityModel.Tests/DiscoveryPolicyTestsBase.cs @@ -1,7 +1,6 @@ // Copyright (c) Duende Software. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -using System.Net; using Duende.IdentityModel.Client; using Duende.IdentityModel.Infrastructure; diff --git a/identity-model/test/IdentityModel.Tests/DiscoveryPolicyTests_AuthorityStringComparison.cs b/identity-model/test/IdentityModel.Tests/DiscoveryPolicyTests_AuthorityStringComparison.cs index b7db83d2..0a0253f8 100644 --- a/identity-model/test/IdentityModel.Tests/DiscoveryPolicyTests_AuthorityStringComparison.cs +++ b/identity-model/test/IdentityModel.Tests/DiscoveryPolicyTests_AuthorityStringComparison.cs @@ -1,10 +1,9 @@ // Copyright (c) Duende Software. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -using System.Net.Http; using System.Text.Json; using Duende.IdentityModel.Client; -using FluentAssertions; + namespace Duende.IdentityModel { @@ -46,7 +45,7 @@ public async Task Valid_Urls_with_default_policy_should_succeed(string input) Policy = policy }); - disco.IsError.Should().BeFalse(); + disco.IsError.ShouldBeFalse(); } [Fact] @@ -65,11 +64,11 @@ public async Task Connecting_to_http_should_return_error() Policy = policy }); - disco.IsError.Should().BeTrue(); - disco.Json?.ValueKind.Should().Be(JsonValueKind.Undefined); - disco.ErrorType.Should().Be(ResponseErrorType.Exception); - disco.Error.Should().StartWith("Error connecting to"); - disco.Error.Should().EndWith("HTTPS required."); + disco.IsError.ShouldBeTrue(); + disco.Json?.ValueKind.ShouldBe(JsonValueKind.Undefined); + disco.ErrorType.ShouldBe(ResponseErrorType.Exception); + disco.Error.ShouldStartWith("Error connecting to"); + disco.Error.ShouldEndWith("HTTPS required."); } [Fact] @@ -87,7 +86,7 @@ public async Task If_policy_allows_http_non_http_must_not_return_error() Policy = policy }); - disco.IsError.Should().BeFalse(); + disco.IsError.ShouldBeFalse(); } [Theory] @@ -109,7 +108,7 @@ public async Task Http_on_loopback_must_not_return_error(string input) Policy = policy }); - disco.IsError.Should().BeFalse(); + disco.IsError.ShouldBeFalse(); } @@ -128,10 +127,10 @@ public async Task Invalid_issuer_name_must_return_policy_error() Policy = policy }); - disco.IsError.Should().BeTrue(); - disco.Json?.ValueKind.Should().Be(JsonValueKind.Undefined); - disco.ErrorType.Should().Be(ResponseErrorType.PolicyViolation); - disco.Error.Should().StartWith("Issuer name does not match authority"); + disco.IsError.ShouldBeTrue(); + disco.Json?.ValueKind.ShouldBe(JsonValueKind.Undefined); + disco.ErrorType.ShouldBe(ResponseErrorType.PolicyViolation); + disco.Error.ShouldStartWith("Issuer name does not match authority"); } [Fact] @@ -162,7 +161,7 @@ public async Task Excluded_endpoints_should_not_fail_validation() Policy = policy }); - disco.IsError.Should().BeFalse(); + disco.IsError.ShouldBeFalse(); } [Fact] @@ -182,7 +181,7 @@ public async Task Valid_issuer_name_must_return_no_error() Policy = policy }); - disco.IsError.Should().BeFalse(); + disco.IsError.ShouldBeFalse(); } [Fact] @@ -203,7 +202,7 @@ public async Task Authority_comparison_may_be_case_insensitive() Policy = policy }); - disco.IsError.Should().BeFalse(); + disco.IsError.ShouldBeFalse(); } [Fact] @@ -225,10 +224,10 @@ public async Task Endpoints_not_using_https_should_return_policy_error() Policy = policy }); - disco.IsError.Should().BeTrue(); - disco.Json?.ValueKind.Should().Be(JsonValueKind.Undefined); - disco.ErrorType.Should().Be(ResponseErrorType.PolicyViolation); - disco.Error.Should().StartWith("Endpoint does not use HTTPS"); + disco.IsError.ShouldBeTrue(); + disco.Json?.ValueKind.ShouldBe(JsonValueKind.Undefined); + disco.ErrorType.ShouldBe(ResponseErrorType.PolicyViolation); + disco.Error.ShouldStartWith("Endpoint does not use HTTPS"); } [Theory] @@ -252,12 +251,12 @@ public async Task Endpoints_not_beneath_authority_must_return_policy_error(strin Policy = policy }); - disco.IsError.Should().BeTrue(); - disco.Json?.ValueKind.Should().Be(JsonValueKind.Undefined); - disco.ErrorType.Should().Be(ResponseErrorType.PolicyViolation); - disco.Error.Should().StartWith("Invalid base address for endpoint"); - disco.Error.Should().Contain(endpointBase); - disco.Error.Should().Contain(authority); + disco.IsError.ShouldBeTrue(); + disco.Json?.ValueKind.ShouldBe(JsonValueKind.Undefined); + disco.ErrorType.ShouldBe(ResponseErrorType.PolicyViolation); + disco.Error.ShouldStartWith("Invalid base address for endpoint"); + disco.Error.ShouldContain(endpointBase); + disco.Error.ShouldContain(authority); } [Theory] @@ -286,7 +285,7 @@ public async Task Endpoints_not_beneath_authority_must_be_allowed_if_whitelisted Policy = policy }); - disco.IsError.Should().BeFalse(); + disco.IsError.ShouldBeFalse(); } [Theory] @@ -313,10 +312,10 @@ public async Task Endpoints_not_belonging_to_authority_host_must_return_policy_e Policy = policy }); - disco.IsError.Should().BeTrue(); - disco.Json?.ValueKind.Should().Be(JsonValueKind.Undefined); - disco.ErrorType.Should().Be(ResponseErrorType.PolicyViolation); - disco.Error.Should().StartWith("Endpoint is on a different host than authority"); + disco.IsError.ShouldBeTrue(); + disco.Json?.ValueKind.ShouldBe(JsonValueKind.Undefined); + disco.ErrorType.ShouldBe(ResponseErrorType.PolicyViolation); + disco.Error.ShouldStartWith("Endpoint is on a different host than authority"); } [Theory] @@ -348,7 +347,7 @@ public async Task Endpoints_not_belonging_to_authority_host_must_be_allowed_if_w Policy = policy }); - disco.IsError.Should().BeFalse(); + disco.IsError.ShouldBeFalse(); } [Fact] @@ -370,7 +369,7 @@ public async Task Issuer_and_endpoint_can_be_unrelated_if_allowed() Policy = policy }); - disco.IsError.Should().BeFalse(); + disco.IsError.ShouldBeFalse(); } [Fact] @@ -392,10 +391,10 @@ public async Task Issuer_and_endpoint_can_be_unrelated_if_allowed_but_https_is_s Policy = policy }); - disco.IsError.Should().BeTrue(); - disco.Json?.ValueKind.Should().Be(JsonValueKind.Undefined); - disco.ErrorType.Should().Be(ResponseErrorType.PolicyViolation); - disco.Error.Should().StartWith("Endpoint does not use HTTPS"); + disco.IsError.ShouldBeTrue(); + disco.Json?.ValueKind.ShouldBe(JsonValueKind.Undefined); + disco.ErrorType.ShouldBe(ResponseErrorType.PolicyViolation); + disco.Error.ShouldStartWith("Endpoint does not use HTTPS"); } } } \ No newline at end of file diff --git a/identity-model/test/IdentityModel.Tests/DiscoveryPolicyTests_AuthorityUriComparison.cs b/identity-model/test/IdentityModel.Tests/DiscoveryPolicyTests_AuthorityUriComparison.cs index 37bcb1fa..3569de4e 100644 --- a/identity-model/test/IdentityModel.Tests/DiscoveryPolicyTests_AuthorityUriComparison.cs +++ b/identity-model/test/IdentityModel.Tests/DiscoveryPolicyTests_AuthorityUriComparison.cs @@ -1,10 +1,9 @@ // Copyright (c) Duende Software. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -using System.Net.Http; using System.Text.Json; using Duende.IdentityModel.Client; -using FluentAssertions; + namespace Duende.IdentityModel { @@ -46,7 +45,7 @@ public async Task Valid_Urls_with_default_policy_should_succeed(string input) Policy = policy }); - disco.IsError.Should().BeFalse(); + disco.IsError.ShouldBeFalse(); } [Fact] @@ -65,11 +64,11 @@ public async Task Connecting_to_http_should_return_error() Policy = policy }); - disco.IsError.Should().BeTrue(); - disco.Json?.ValueKind.Should().Be(JsonValueKind.Undefined); - disco.ErrorType.Should().Be(ResponseErrorType.Exception); - disco.Error.Should().StartWith("Error connecting to"); - disco.Error.Should().EndWith("HTTPS required."); + disco.IsError.ShouldBeTrue(); + disco.Json?.ValueKind.ShouldBe(JsonValueKind.Undefined); + disco.ErrorType.ShouldBe(ResponseErrorType.Exception); + disco.Error.ShouldStartWith("Error connecting to"); + disco.Error.ShouldEndWith("HTTPS required."); } [Fact] @@ -87,7 +86,7 @@ public async Task If_policy_allows_http_non_http_must_not_return_error() Policy = policy }); - disco.IsError.Should().BeFalse(); + disco.IsError.ShouldBeFalse(); } [Theory] @@ -109,7 +108,7 @@ public async Task Http_on_loopback_must_not_return_error(string input) Policy = policy }); - disco.IsError.Should().BeFalse(); + disco.IsError.ShouldBeFalse(); } @@ -128,10 +127,10 @@ public async Task Invalid_issuer_name_must_return_policy_error() Policy = policy }); - disco.IsError.Should().BeTrue(); - disco.Json?.ValueKind.Should().Be(JsonValueKind.Undefined); - disco.ErrorType.Should().Be(ResponseErrorType.PolicyViolation); - disco.Error.Should().StartWith("Issuer name does not match authority"); + disco.IsError.ShouldBeTrue(); + disco.Json?.ValueKind.ShouldBe(JsonValueKind.Undefined); + disco.ErrorType.ShouldBe(ResponseErrorType.PolicyViolation); + disco.Error.ShouldStartWith("Issuer name does not match authority"); } [Fact] @@ -162,7 +161,7 @@ public async Task Excluded_endpoints_should_not_fail_validation() Policy = policy }); - disco.IsError.Should().BeFalse(); + disco.IsError.ShouldBeFalse(); } [Fact] @@ -182,7 +181,7 @@ public async Task Valid_issuer_name_must_return_no_error() Policy = policy }); - disco.IsError.Should().BeFalse(); + disco.IsError.ShouldBeFalse(); } [Fact] @@ -203,7 +202,7 @@ public async Task Authority_comparison_with_uri_equivalence() Policy = policy }); - disco.IsError.Should().BeFalse(); + disco.IsError.ShouldBeFalse(); } [Fact] @@ -223,7 +222,7 @@ public async Task String_comparison_with_uri_equivalence_is_default_strategy() Policy = policy }); - disco.IsError.Should().BeTrue(); + disco.IsError.ShouldBeTrue(); } [Fact] @@ -245,10 +244,10 @@ public async Task Endpoints_not_using_https_should_return_policy_error() Policy = policy }); - disco.IsError.Should().BeTrue(); - disco.Json?.ValueKind.Should().Be(JsonValueKind.Undefined); - disco.ErrorType.Should().Be(ResponseErrorType.PolicyViolation); - disco.Error.Should().StartWith("Endpoint does not use HTTPS"); + disco.IsError.ShouldBeTrue(); + disco.Json?.ValueKind.ShouldBe(JsonValueKind.Undefined); + disco.ErrorType.ShouldBe(ResponseErrorType.PolicyViolation); + disco.Error.ShouldStartWith("Endpoint does not use HTTPS"); } [Theory] @@ -272,12 +271,12 @@ public async Task Endpoints_not_beneath_authority_must_return_policy_error(strin Policy = policy }); - disco.IsError.Should().BeTrue(); - disco.Json?.ValueKind.Should().Be(JsonValueKind.Undefined); - disco.ErrorType.Should().Be(ResponseErrorType.PolicyViolation); - disco.Error.Should().StartWith("Invalid base address for endpoint"); - disco.Error.Should().Contain(endpointBase); - disco.Error.Should().Contain(authority); + disco.IsError.ShouldBeTrue(); + disco.Json?.ValueKind.ShouldBe(JsonValueKind.Undefined); + disco.ErrorType.ShouldBe(ResponseErrorType.PolicyViolation); + disco.Error.ShouldStartWith("Invalid base address for endpoint"); + disco.Error.ShouldContain(endpointBase); + disco.Error.ShouldContain(authority); } [Theory] @@ -306,7 +305,7 @@ public async Task Endpoints_not_beneath_authority_must_be_allowed_if_whitelisted Policy = policy }); - disco.IsError.Should().BeFalse(); + disco.IsError.ShouldBeFalse(); } [Theory] @@ -333,10 +332,10 @@ public async Task Endpoints_not_belonging_to_authority_host_must_return_policy_e Policy = policy }); - disco.IsError.Should().BeTrue(); - disco.Json?.ValueKind.Should().Be(JsonValueKind.Undefined); - disco.ErrorType.Should().Be(ResponseErrorType.PolicyViolation); - disco.Error.Should().StartWith("Endpoint is on a different host than authority"); + disco.IsError.ShouldBeTrue(); + disco.Json?.ValueKind.ShouldBe(JsonValueKind.Undefined); + disco.ErrorType.ShouldBe(ResponseErrorType.PolicyViolation); + disco.Error.ShouldStartWith("Endpoint is on a different host than authority"); } [Theory] @@ -368,7 +367,7 @@ public async Task Endpoints_not_belonging_to_authority_host_must_be_allowed_if_w Policy = policy }); - disco.IsError.Should().BeFalse(); + disco.IsError.ShouldBeFalse(); } [Fact] @@ -390,7 +389,7 @@ public async Task Issuer_and_endpoint_can_be_unrelated_if_allowed() Policy = policy }); - disco.IsError.Should().BeFalse(); + disco.IsError.ShouldBeFalse(); } [Fact] @@ -412,10 +411,10 @@ public async Task Issuer_and_endpoint_can_be_unrelated_if_allowed_but_https_is_s Policy = policy }); - disco.IsError.Should().BeTrue(); - disco.Json?.ValueKind.Should().Be(JsonValueKind.Undefined); - disco.ErrorType.Should().Be(ResponseErrorType.PolicyViolation); - disco.Error.Should().StartWith("Endpoint does not use HTTPS"); + disco.IsError.ShouldBeTrue(); + disco.Json?.ValueKind.ShouldBe(JsonValueKind.Undefined); + disco.ErrorType.ShouldBe(ResponseErrorType.PolicyViolation); + disco.Error.ShouldStartWith("Endpoint does not use HTTPS"); } } } \ No newline at end of file diff --git a/identity-model/test/IdentityModel.Tests/DiscoveryPolicyTests_WithoutAuthorityValidation.cs b/identity-model/test/IdentityModel.Tests/DiscoveryPolicyTests_WithoutAuthorityValidation.cs index f3c3dc10..f8c9dc6a 100644 --- a/identity-model/test/IdentityModel.Tests/DiscoveryPolicyTests_WithoutAuthorityValidation.cs +++ b/identity-model/test/IdentityModel.Tests/DiscoveryPolicyTests_WithoutAuthorityValidation.cs @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. using Duende.IdentityModel.Client; -using FluentAssertions; + namespace Duende.IdentityModel { @@ -16,7 +16,8 @@ public void Malformed_authority_url_should_throw(string input) { Action act = () => DiscoveryEndpoint.ParseUrl(input); - act.Should().Throw().Where(e => e.Message.Equals("Malformed URL")); + var exception = act.ShouldThrow(); + exception.Message.ShouldBe("Malformed URL"); } [Theory] @@ -29,8 +30,8 @@ public void Various_urls_should_normalize(string input) var result = DiscoveryEndpoint.ParseUrl(input); // test parse URL logic - result.Url.Should().Be("https://server:123/.well-known/openid-configuration"); - result.Authority.Should().Be("https://server:123"); + result.Url.ShouldBe("https://server:123/.well-known/openid-configuration"); + result.Authority.ShouldBe("https://server:123"); } [Theory] @@ -44,8 +45,8 @@ public void Custom_path_is_supported(string input, string documentPath) var result = DiscoveryEndpoint.ParseUrl(input, documentPath); // test parse URL logic - result.Url.Should().Be("https://server:123/strange-location/openid-configuration"); - result.Authority.Should().Be("https://server:123"); + result.Url.ShouldBe("https://server:123/strange-location/openid-configuration"); + result.Authority.ShouldBe("https://server:123"); } } } \ No newline at end of file diff --git a/identity-model/test/IdentityModel.Tests/GlobalUsings.cs b/identity-model/test/IdentityModel.Tests/GlobalUsings.cs new file mode 100644 index 00000000..d073264d --- /dev/null +++ b/identity-model/test/IdentityModel.Tests/GlobalUsings.cs @@ -0,0 +1,4 @@ +// Global using directives + +global using System.Net; +global using System.Net.Http; \ No newline at end of file diff --git a/identity-model/test/IdentityModel.Tests/HttpClientExtensions/CibaExtensionsTests.cs b/identity-model/test/IdentityModel.Tests/HttpClientExtensions/CibaExtensionsTests.cs index 0b56f5f2..fd6f88ba 100644 --- a/identity-model/test/IdentityModel.Tests/HttpClientExtensions/CibaExtensionsTests.cs +++ b/identity-model/test/IdentityModel.Tests/HttpClientExtensions/CibaExtensionsTests.cs @@ -1,11 +1,9 @@ // Copyright (c) Duende Software. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -using System.Net; -using System.Net.Http; using Duende.IdentityModel.Client; using Duende.IdentityModel.Infrastructure; -using FluentAssertions; + using Microsoft.AspNetCore.WebUtilities; namespace Duende.IdentityModel.HttpClientExtensions @@ -51,53 +49,53 @@ public async Task Http_request_should_have_correct_format() var httpRequest = handler.Request; - httpRequest.Method.Should().Be(HttpMethod.Post); - httpRequest.RequestUri.Should().Be(new Uri(Endpoint)); - httpRequest.Content.Should().NotBeNull(); + httpRequest.Method.ShouldBe(HttpMethod.Post); + httpRequest.RequestUri.ShouldBe(new Uri(Endpoint)); + httpRequest.Content.ShouldNotBeNull(); var headers = httpRequest.Headers; - headers.Count().Should().Be(3); - headers.Should().Contain(h => h.Key == "custom" && h.Value.First() == "custom"); + headers.Count().ShouldBe(3); + headers.ShouldContain(h => h.Key == "custom" && h.Value.First() == "custom"); var properties = httpRequest.GetProperties(); - properties.Count.Should().Be(1); + properties.Count.ShouldBe(1); var prop = properties.First(); - prop.Key.Should().Be("custom"); - ((string)prop.Value).Should().Be("custom"); + prop.Key.ShouldBe("custom"); + ((string)prop.Value).ShouldBe("custom"); var fields = QueryHelpers.ParseQuery(handler.Body); - fields.TryGetValue(OidcConstants.BackchannelAuthenticationRequest.Scope, out var scope).Should().BeTrue(); - scope.First().Should().Be("scope"); + fields.TryGetValue(OidcConstants.BackchannelAuthenticationRequest.Scope, out var scope).ShouldBeTrue(); + scope.First().ShouldBe("scope"); - fields.TryGetValue(OidcConstants.BackchannelAuthenticationRequest.AcrValues, out var acr_values).Should().BeTrue(); - acr_values.First().Should().Be("acr_values"); + fields.TryGetValue(OidcConstants.BackchannelAuthenticationRequest.AcrValues, out var acr_values).ShouldBeTrue(); + acr_values.First().ShouldBe("acr_values"); - fields.TryGetValue(OidcConstants.BackchannelAuthenticationRequest.BindingMessage, out var binding_message).Should().BeTrue(); - binding_message.First().Should().Be("binding_message"); + fields.TryGetValue(OidcConstants.BackchannelAuthenticationRequest.BindingMessage, out var binding_message).ShouldBeTrue(); + binding_message.First().ShouldBe("binding_message"); - fields.TryGetValue(OidcConstants.BackchannelAuthenticationRequest.ClientNotificationToken, out var client_notification_token).Should().BeTrue(); - client_notification_token.First().Should().Be("client_notification_token"); + fields.TryGetValue(OidcConstants.BackchannelAuthenticationRequest.ClientNotificationToken, out var client_notification_token).ShouldBeTrue(); + client_notification_token.First().ShouldBe("client_notification_token"); - fields.TryGetValue(OidcConstants.BackchannelAuthenticationRequest.UserCode, out var user_code).Should().BeTrue(); - user_code.First().Should().Be("user_code"); + fields.TryGetValue(OidcConstants.BackchannelAuthenticationRequest.UserCode, out var user_code).ShouldBeTrue(); + user_code.First().ShouldBe("user_code"); - fields.TryGetValue(OidcConstants.BackchannelAuthenticationRequest.RequestedExpiry, out var request_expiry).Should().BeTrue(); - int.Parse(request_expiry.First()).Should().Be(1); + fields.TryGetValue(OidcConstants.BackchannelAuthenticationRequest.RequestedExpiry, out var request_expiry).ShouldBeTrue(); + int.Parse(request_expiry.First()).ShouldBe(1); - fields.TryGetValue(OidcConstants.BackchannelAuthenticationRequest.IdTokenHint, out var id_token_hint).Should().BeTrue(); - id_token_hint.First().Should().Be("id_token_hint"); + fields.TryGetValue(OidcConstants.BackchannelAuthenticationRequest.IdTokenHint, out var id_token_hint).ShouldBeTrue(); + id_token_hint.First().ShouldBe("id_token_hint"); - fields.TryGetValue(OidcConstants.BackchannelAuthenticationRequest.LoginHintToken, out var login_hint_token).Should().BeTrue(); - login_hint_token.First().Should().Be("login_hint_token"); + fields.TryGetValue(OidcConstants.BackchannelAuthenticationRequest.LoginHintToken, out var login_hint_token).ShouldBeTrue(); + login_hint_token.First().ShouldBe("login_hint_token"); - fields.TryGetValue(OidcConstants.BackchannelAuthenticationRequest.LoginHint, out var login_hint).Should().BeTrue(); - login_hint.First().Should().Be("login_hint"); + fields.TryGetValue(OidcConstants.BackchannelAuthenticationRequest.LoginHint, out var login_hint).ShouldBeTrue(); + login_hint.First().ShouldBe("login_hint"); - fields.TryGetValue(OidcConstants.BackchannelAuthenticationRequest.Resource, out var resource).Should().BeTrue(); - resource.Count.Should().Be(2); - resource.First().Should().Be("resource1"); - resource.Skip(1).First().Should().Be("resource2"); + fields.TryGetValue(OidcConstants.BackchannelAuthenticationRequest.Resource, out var resource).ShouldBeTrue(); + resource.Count.ShouldBe(2); + resource.First().ShouldBe("resource1"); + resource.Skip(1).First().ShouldBe("resource2"); } [Fact] @@ -139,35 +137,35 @@ public async Task Http_request_with_request_object_should_have_correct_format() var httpRequest = handler.Request; - httpRequest.Method.Should().Be(HttpMethod.Post); - httpRequest.RequestUri.Should().Be(new Uri(Endpoint)); - httpRequest.Content.Should().NotBeNull(); + httpRequest.Method.ShouldBe(HttpMethod.Post); + httpRequest.RequestUri.ShouldBe(new Uri(Endpoint)); + httpRequest.Content.ShouldNotBeNull(); var headers = httpRequest.Headers; - headers.Count().Should().Be(3); - headers.Should().Contain(h => h.Key == "custom" && h.Value.First() == "custom"); + headers.Count().ShouldBe(3); + headers.ShouldContain(h => h.Key == "custom" && h.Value.First() == "custom"); var properties = httpRequest.GetProperties(); - properties.Count.Should().Be(1); + properties.Count.ShouldBe(1); var prop = properties.First(); - prop.Key.Should().Be("custom"); - ((string)prop.Value).Should().Be("custom"); + prop.Key.ShouldBe("custom"); + ((string)prop.Value).ShouldBe("custom"); var fields = QueryHelpers.ParseQuery(handler.Body); - fields.TryGetValue(OidcConstants.BackchannelAuthenticationRequest.Scope, out var scope).Should().BeFalse(); - fields.TryGetValue(OidcConstants.BackchannelAuthenticationRequest.AcrValues, out var _).Should().BeFalse(); - fields.TryGetValue(OidcConstants.BackchannelAuthenticationRequest.BindingMessage, out _).Should().BeFalse(); - fields.TryGetValue(OidcConstants.BackchannelAuthenticationRequest.ClientNotificationToken, out _).Should().BeFalse(); - fields.TryGetValue(OidcConstants.BackchannelAuthenticationRequest.UserCode, out _).Should().BeFalse(); - fields.TryGetValue(OidcConstants.BackchannelAuthenticationRequest.RequestedExpiry, out _).Should().BeFalse(); - fields.TryGetValue(OidcConstants.BackchannelAuthenticationRequest.IdTokenHint, out _).Should().BeFalse(); - fields.TryGetValue(OidcConstants.BackchannelAuthenticationRequest.LoginHintToken, out _).Should().BeFalse(); - fields.TryGetValue(OidcConstants.BackchannelAuthenticationRequest.LoginHint, out _).Should().BeFalse(); - fields.TryGetValue(OidcConstants.BackchannelAuthenticationRequest.Resource, out _).Should().BeFalse(); + fields.TryGetValue(OidcConstants.BackchannelAuthenticationRequest.Scope, out var scope).ShouldBeFalse(); + fields.TryGetValue(OidcConstants.BackchannelAuthenticationRequest.AcrValues, out var _).ShouldBeFalse(); + fields.TryGetValue(OidcConstants.BackchannelAuthenticationRequest.BindingMessage, out _).ShouldBeFalse(); + fields.TryGetValue(OidcConstants.BackchannelAuthenticationRequest.ClientNotificationToken, out _).ShouldBeFalse(); + fields.TryGetValue(OidcConstants.BackchannelAuthenticationRequest.UserCode, out _).ShouldBeFalse(); + fields.TryGetValue(OidcConstants.BackchannelAuthenticationRequest.RequestedExpiry, out _).ShouldBeFalse(); + fields.TryGetValue(OidcConstants.BackchannelAuthenticationRequest.IdTokenHint, out _).ShouldBeFalse(); + fields.TryGetValue(OidcConstants.BackchannelAuthenticationRequest.LoginHintToken, out _).ShouldBeFalse(); + fields.TryGetValue(OidcConstants.BackchannelAuthenticationRequest.LoginHint, out _).ShouldBeFalse(); + fields.TryGetValue(OidcConstants.BackchannelAuthenticationRequest.Resource, out _).ShouldBeFalse(); - fields.TryGetValue(OidcConstants.BackchannelAuthenticationRequest.Request, out var ro).Should().BeTrue(); - ro.First().Should().Be("request"); + fields.TryGetValue(OidcConstants.BackchannelAuthenticationRequest.Request, out var ro).ShouldBeTrue(); + ro.First().ShouldBe("request"); } [Fact] @@ -184,13 +182,13 @@ public async Task Valid_protocol_response_should_be_handled_correctly() Scope = "scope" }); - response.IsError.Should().BeFalse(); - response.ErrorType.Should().Be(ResponseErrorType.None); - response.HttpStatusCode.Should().Be(HttpStatusCode.OK); + response.IsError.ShouldBeFalse(); + response.ErrorType.ShouldBe(ResponseErrorType.None); + response.HttpStatusCode.ShouldBe(HttpStatusCode.OK); - response.AuthenticationRequestId.Should().Be("1c266114-a1be-4252-8ad1-04986c5b9ac1"); - response.ExpiresIn.Should().Be(120); - response.Interval.Should().Be(2); + response.AuthenticationRequestId.ShouldBe("1c266114-a1be-4252-8ad1-04986c5b9ac1"); + response.ExpiresIn.ShouldBe(120); + response.Interval.ShouldBe(2); } // @@ -207,12 +205,12 @@ public async Task Valid_protocol_response_should_be_handled_correctly() // ClientId = "client" // }); // - // response.IsError.Should().BeTrue(); - // response.ErrorType.Should().Be(ResponseErrorType.Protocol); - // response.HttpStatusCode.Should().Be(HttpStatusCode.BadRequest); - // response.Error.Should().Be("error"); - // response.ErrorDescription.Should().Be("error_description"); - // response.TryGet("custom").Should().Be("custom"); + // response.IsError.ShouldBeTrue(); + // response.ErrorType.ShouldBe(ResponseErrorType.Protocol); + // response.HttpStatusCode.ShouldBe(HttpStatusCode.BadRequest); + // response.Error.ShouldBe("error"); + // response.ErrorDescription.ShouldBe("error_description"); + // response.TryGet("custom").ShouldBe("custom"); // } // // [Fact] @@ -228,10 +226,10 @@ public async Task Valid_protocol_response_should_be_handled_correctly() // ClientId = "client" // }); // - // response.IsError.Should().BeTrue(); - // response.ErrorType.Should().Be(ResponseErrorType.Exception); - // response.Raw.Should().Be("invalid"); - // response.Exception.Should().NotBeNull(); + // response.IsError.ShouldBeTrue(); + // response.ErrorType.ShouldBe(ResponseErrorType.Exception); + // response.Raw.ShouldBe("invalid"); + // response.Exception.ShouldNotBeNull(); // } // // [Fact] @@ -246,10 +244,10 @@ public async Task Valid_protocol_response_should_be_handled_correctly() // ClientId = "client" // }); // - // response.IsError.Should().BeTrue(); - // response.ErrorType.Should().Be(ResponseErrorType.Exception); - // response.Error.Should().Be("exception"); - // response.Exception.Should().NotBeNull(); + // response.IsError.ShouldBeTrue(); + // response.ErrorType.ShouldBe(ResponseErrorType.Exception); + // response.Error.ShouldBe("exception"); + // response.Exception.ShouldNotBeNull(); // } // // [Fact] @@ -264,10 +262,10 @@ public async Task Valid_protocol_response_should_be_handled_correctly() // ClientId = "client" // }); // - // response.IsError.Should().BeTrue(); - // response.ErrorType.Should().Be(ResponseErrorType.Http); - // response.HttpStatusCode.Should().Be(HttpStatusCode.NotFound); - // response.Error.Should().Be("not found"); + // response.IsError.ShouldBeTrue(); + // response.ErrorType.ShouldBe(ResponseErrorType.Http); + // response.HttpStatusCode.ShouldBe(HttpStatusCode.NotFound); + // response.Error.ShouldBe("not found"); // } // // [Fact] @@ -282,11 +280,11 @@ public async Task Valid_protocol_response_should_be_handled_correctly() // ClientId = "client" // }); // - // response.IsError.Should().BeTrue(); - // response.ErrorType.Should().Be(ResponseErrorType.Http); - // response.HttpStatusCode.Should().Be(HttpStatusCode.Unauthorized); - // response.Error.Should().Be("Unauthorized"); - // response.Raw.Should().Be("not_json"); + // response.IsError.ShouldBeTrue(); + // response.ErrorType.ShouldBe(ResponseErrorType.Http); + // response.HttpStatusCode.ShouldBe(HttpStatusCode.Unauthorized); + // response.Error.ShouldBe("Unauthorized"); + // response.Raw.ShouldBe("not_json"); // } // // [Fact] @@ -307,13 +305,13 @@ public async Task Valid_protocol_response_should_be_handled_correctly() // ClientId = "client" // }); // - // response.IsError.Should().BeTrue(); - // response.ErrorType.Should().Be(ResponseErrorType.Http); - // response.HttpStatusCode.Should().Be(HttpStatusCode.Unauthorized); - // response.Error.Should().Be("Unauthorized"); + // response.IsError.ShouldBeTrue(); + // response.ErrorType.ShouldBe(ResponseErrorType.Http); + // response.HttpStatusCode.ShouldBe(HttpStatusCode.Unauthorized); + // response.Error.ShouldBe("Unauthorized"); // - // response.Json?.TryGetString("foo").Should().Be("foo"); - // response.Json?.TryGetString("bar").Should().Be("bar"); + // response.Json?.TryGetString("foo").ShouldBe("foo"); + // response.Json?.TryGetString("bar").ShouldBe("bar"); // } } } \ No newline at end of file diff --git a/identity-model/test/IdentityModel.Tests/HttpClientExtensions/DeviceAuthorizationExtensionsTests.cs b/identity-model/test/IdentityModel.Tests/HttpClientExtensions/DeviceAuthorizationExtensionsTests.cs index 1445f535..b0f6df54 100644 --- a/identity-model/test/IdentityModel.Tests/HttpClientExtensions/DeviceAuthorizationExtensionsTests.cs +++ b/identity-model/test/IdentityModel.Tests/HttpClientExtensions/DeviceAuthorizationExtensionsTests.cs @@ -1,12 +1,10 @@ // Copyright (c) Duende Software. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -using System.Net; -using System.Net.Http; using System.Text.Json; using Duende.IdentityModel.Client; using Duende.IdentityModel.Infrastructure; -using FluentAssertions; + using Microsoft.AspNetCore.WebUtilities; namespace Duende.IdentityModel.HttpClientExtensions @@ -33,12 +31,12 @@ public async Task Request_without_body_should_have_correct_format() var httpRequest = handler.Request; - httpRequest.Method.Should().Be(HttpMethod.Post); - httpRequest.RequestUri.Should().Be(new Uri(Endpoint)); - httpRequest.Content.Should().BeOfType(); + httpRequest.Method.ShouldBe(HttpMethod.Post); + httpRequest.RequestUri.ShouldBe(new Uri(Endpoint)); + httpRequest.Content.ShouldBeOfType(); var headers = httpRequest.Headers; - headers.Count().Should().Be(2); + headers.Count().ShouldBe(2); } [Fact] @@ -60,19 +58,19 @@ public async Task Http_request_should_have_correct_format() var httpRequest = handler.Request; - httpRequest.Method.Should().Be(HttpMethod.Post); - httpRequest.RequestUri.Should().Be(new Uri(Endpoint)); + httpRequest.Method.ShouldBe(HttpMethod.Post); + httpRequest.RequestUri.ShouldBe(new Uri(Endpoint)); var headers = httpRequest.Headers; - headers.Count().Should().Be(3); - headers.Should().Contain(h => h.Key == "custom" && h.Value.First() == "custom"); + headers.Count().ShouldBe(3); + headers.ShouldContain(h => h.Key == "custom" && h.Value.First() == "custom"); var properties = httpRequest.GetProperties(); - properties.Count.Should().Be(1); + properties.Count.ShouldBe(1); var prop = properties.First(); - prop.Key.Should().Be("custom"); - ((string)prop.Value).Should().Be("custom"); + prop.Key.ShouldBe("custom"); + ((string)prop.Value).ShouldBe("custom"); } [Fact] @@ -92,9 +90,9 @@ public async Task Setting_basic_authentication_style_should_send_basic_authentic var request = handler.Request; - request.Headers.Authorization.Should().NotBeNull(); - request.Headers.Authorization.Scheme.Should().Be("Basic"); - request.Headers.Authorization.Parameter.Should().Be(BasicAuthenticationOAuthHeaderValue.EncodeCredential("client", "secret")); + request.Headers.Authorization.ShouldNotBeNull(); + request.Headers.Authorization.Scheme.ShouldBe("Basic"); + request.Headers.Authorization.Parameter.ShouldBe(BasicAuthenticationOAuthHeaderValue.EncodeCredential("client", "secret")); } [Fact] @@ -114,11 +112,11 @@ public async Task Setting_post_values_authentication_style_should_post_values() var request = handler.Request; - request.Headers.Authorization.Should().BeNull(); + request.Headers.Authorization.ShouldBeNull(); var fields = QueryHelpers.ParseQuery(handler.Body); - fields["client_id"].First().Should().Be("client"); - fields["client_secret"].First().Should().Be("secret"); + fields["client_id"].First().ShouldBe("client"); + fields["client_secret"].First().ShouldBe("secret"); } [Fact] @@ -134,17 +132,17 @@ public async Task Valid_protocol_response_should_be_handled_correctly() ClientId = "client" }); - response.IsError.Should().BeFalse(); - response.ErrorType.Should().Be(ResponseErrorType.None); - response.HttpStatusCode.Should().Be(HttpStatusCode.OK); + response.IsError.ShouldBeFalse(); + response.ErrorType.ShouldBe(ResponseErrorType.None); + response.HttpStatusCode.ShouldBe(HttpStatusCode.OK); - response.DeviceCode.Should().Be("GMMhmHCXhWEzkobqIHGG_EnNYYsAkukHspeYUk9E8"); - response.UserCode.Should().Be("WDJB-MJHT"); - response.VerificationUri.Should().Be("https://www.example.com/device"); - response.VerificationUriComplete.Should().Be("https://www.example.com/device?user_code=WDJB-MJHT"); + response.DeviceCode.ShouldBe("GMMhmHCXhWEzkobqIHGG_EnNYYsAkukHspeYUk9E8"); + response.UserCode.ShouldBe("WDJB-MJHT"); + response.VerificationUri.ShouldBe("https://www.example.com/device"); + response.VerificationUriComplete.ShouldBe("https://www.example.com/device?user_code=WDJB-MJHT"); - response.ExpiresIn.Should().Be(1800); - response.Interval.Should().Be(10); + response.ExpiresIn.ShouldBe(1800); + response.Interval.ShouldBe(10); } [Fact] @@ -162,32 +160,32 @@ public async Task Repeating_a_request_should_succeed() var client = new HttpClient(handler); var response = await client.RequestDeviceAuthorizationAsync(request); - response.IsError.Should().BeFalse(); - response.ErrorType.Should().Be(ResponseErrorType.None); - response.HttpStatusCode.Should().Be(HttpStatusCode.OK); + response.IsError.ShouldBeFalse(); + response.ErrorType.ShouldBe(ResponseErrorType.None); + response.HttpStatusCode.ShouldBe(HttpStatusCode.OK); - response.DeviceCode.Should().Be("GMMhmHCXhWEzkobqIHGG_EnNYYsAkukHspeYUk9E8"); - response.UserCode.Should().Be("WDJB-MJHT"); - response.VerificationUri.Should().Be("https://www.example.com/device"); - response.VerificationUriComplete.Should().Be("https://www.example.com/device?user_code=WDJB-MJHT"); + response.DeviceCode.ShouldBe("GMMhmHCXhWEzkobqIHGG_EnNYYsAkukHspeYUk9E8"); + response.UserCode.ShouldBe("WDJB-MJHT"); + response.VerificationUri.ShouldBe("https://www.example.com/device"); + response.VerificationUriComplete.ShouldBe("https://www.example.com/device?user_code=WDJB-MJHT"); - response.ExpiresIn.Should().Be(1800); - response.Interval.Should().Be(10); + response.ExpiresIn.ShouldBe(1800); + response.Interval.ShouldBe(10); // repeat response = await client.RequestDeviceAuthorizationAsync(request); - response.IsError.Should().BeFalse(); - response.ErrorType.Should().Be(ResponseErrorType.None); - response.HttpStatusCode.Should().Be(HttpStatusCode.OK); + response.IsError.ShouldBeFalse(); + response.ErrorType.ShouldBe(ResponseErrorType.None); + response.HttpStatusCode.ShouldBe(HttpStatusCode.OK); - response.DeviceCode.Should().Be("GMMhmHCXhWEzkobqIHGG_EnNYYsAkukHspeYUk9E8"); - response.UserCode.Should().Be("WDJB-MJHT"); - response.VerificationUri.Should().Be("https://www.example.com/device"); - response.VerificationUriComplete.Should().Be("https://www.example.com/device?user_code=WDJB-MJHT"); + response.DeviceCode.ShouldBe("GMMhmHCXhWEzkobqIHGG_EnNYYsAkukHspeYUk9E8"); + response.UserCode.ShouldBe("WDJB-MJHT"); + response.VerificationUri.ShouldBe("https://www.example.com/device"); + response.VerificationUriComplete.ShouldBe("https://www.example.com/device?user_code=WDJB-MJHT"); - response.ExpiresIn.Should().Be(1800); - response.Interval.Should().Be(10); + response.ExpiresIn.ShouldBe(1800); + response.Interval.ShouldBe(10); } [Fact] @@ -203,12 +201,12 @@ public async Task Valid_protocol_error_should_be_handled_correctly() ClientId = "client" }); - response.IsError.Should().BeTrue(); - response.ErrorType.Should().Be(ResponseErrorType.Protocol); - response.HttpStatusCode.Should().Be(HttpStatusCode.BadRequest); - response.Error.Should().Be("error"); - response.ErrorDescription.Should().Be("error_description"); - response.TryGet("custom").Should().Be("custom"); + response.IsError.ShouldBeTrue(); + response.ErrorType.ShouldBe(ResponseErrorType.Protocol); + response.HttpStatusCode.ShouldBe(HttpStatusCode.BadRequest); + response.Error.ShouldBe("error"); + response.ErrorDescription.ShouldBe("error_description"); + response.TryGet("custom").ShouldBe("custom"); } [Fact] @@ -224,10 +222,10 @@ public async Task Malformed_response_document_should_be_handled_correctly() ClientId = "client" }); - response.IsError.Should().BeTrue(); - response.ErrorType.Should().Be(ResponseErrorType.Exception); - response.Raw.Should().Be("invalid"); - response.Exception.Should().NotBeNull(); + response.IsError.ShouldBeTrue(); + response.ErrorType.ShouldBe(ResponseErrorType.Exception); + response.Raw.ShouldBe("invalid"); + response.Exception.ShouldNotBeNull(); } [Fact] @@ -242,10 +240,10 @@ public async Task Exception_should_be_handled_correctly() ClientId = "client" }); - response.IsError.Should().BeTrue(); - response.ErrorType.Should().Be(ResponseErrorType.Exception); - response.Error.Should().Be("exception"); - response.Exception.Should().NotBeNull(); + response.IsError.ShouldBeTrue(); + response.ErrorType.ShouldBe(ResponseErrorType.Exception); + response.Error.ShouldBe("exception"); + response.Exception.ShouldNotBeNull(); } [Fact] @@ -260,10 +258,10 @@ public async Task Http_error_should_be_handled_correctly() ClientId = "client" }); - response.IsError.Should().BeTrue(); - response.ErrorType.Should().Be(ResponseErrorType.Http); - response.HttpStatusCode.Should().Be(HttpStatusCode.NotFound); - response.Error.Should().Be("not found"); + response.IsError.ShouldBeTrue(); + response.ErrorType.ShouldBe(ResponseErrorType.Http); + response.HttpStatusCode.ShouldBe(HttpStatusCode.NotFound); + response.Error.ShouldBe("not found"); } [Fact] @@ -278,11 +276,11 @@ public async Task Http_error_with_non_json_content_should_be_handled_correctly() ClientId = "client" }); - response.IsError.Should().BeTrue(); - response.ErrorType.Should().Be(ResponseErrorType.Http); - response.HttpStatusCode.Should().Be(HttpStatusCode.Unauthorized); - response.Error.Should().Be("Unauthorized"); - response.Raw.Should().Be("not_json"); + response.IsError.ShouldBeTrue(); + response.ErrorType.ShouldBe(ResponseErrorType.Http); + response.HttpStatusCode.ShouldBe(HttpStatusCode.Unauthorized); + response.Error.ShouldBe("Unauthorized"); + response.Raw.ShouldBe("not_json"); } [Fact] @@ -303,13 +301,13 @@ public async Task Http_error_with_json_content_should_be_handled_correctly() ClientId = "client" }); - response.IsError.Should().BeTrue(); - response.ErrorType.Should().Be(ResponseErrorType.Http); - response.HttpStatusCode.Should().Be(HttpStatusCode.Unauthorized); - response.Error.Should().Be("Unauthorized"); + response.IsError.ShouldBeTrue(); + response.ErrorType.ShouldBe(ResponseErrorType.Http); + response.HttpStatusCode.ShouldBe(HttpStatusCode.Unauthorized); + response.Error.ShouldBe("Unauthorized"); - response.Json?.TryGetString("foo").Should().Be("foo"); - response.Json?.TryGetString("bar").Should().Be("bar"); + response.Json?.TryGetString("foo").ShouldBe("foo"); + response.Json?.TryGetString("bar").ShouldBe("bar"); } } } \ No newline at end of file diff --git a/identity-model/test/IdentityModel.Tests/HttpClientExtensions/DiscoveryExtensionsTests.cs b/identity-model/test/IdentityModel.Tests/HttpClientExtensions/DiscoveryExtensionsTests.cs index 71ecb6d5..8e8e9ab1 100644 --- a/identity-model/test/IdentityModel.Tests/HttpClientExtensions/DiscoveryExtensionsTests.cs +++ b/identity-model/test/IdentityModel.Tests/HttpClientExtensions/DiscoveryExtensionsTests.cs @@ -1,12 +1,10 @@ // Copyright (c) Duende Software. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -using System.Net; -using System.Net.Http; using System.Text.Json; using Duende.IdentityModel.Client; using Duende.IdentityModel.Infrastructure; -using FluentAssertions; + namespace Duende.IdentityModel.HttpClientExtensions { @@ -53,20 +51,20 @@ public async Task Http_request_should_have_correct_format() var httpRequest = handler.Request; - httpRequest.Method.Should().Be(HttpMethod.Get); - httpRequest.RequestUri.Should().Be(new Uri(_endpoint)); - httpRequest.Content.Should().BeNull(); + httpRequest.Method.ShouldBe(HttpMethod.Get); + httpRequest.RequestUri.ShouldBe(new Uri(_endpoint)); + httpRequest.Content.ShouldBeNull(); var headers = httpRequest.Headers; - headers.Count().Should().Be(2); - headers.Should().Contain(h => h.Key == "custom" && h.Value.First() == "custom"); + headers.Count().ShouldBe(2); + headers.ShouldContain(h => h.Key == "custom" && h.Value.First() == "custom"); var properties = httpRequest.GetProperties(); - properties.Count.Should().Be(1); + properties.Count.ShouldBe(1); var prop = properties.First(); - prop.Key.Should().Be("custom"); - ((string)prop.Value).Should().Be("custom"); + prop.Key.ShouldBe("custom"); + ((string)prop.Value).ShouldBe("custom"); } @@ -80,7 +78,7 @@ public async Task Base_address_should_work() var disco = await client.GetDiscoveryDocumentAsync(); - disco.IsError.Should().BeFalse(); + disco.IsError.ShouldBeFalse(); } [Fact] @@ -90,7 +88,7 @@ public async Task Null_client_base_address_should_throw() Func act = () => client.GetDiscoveryDocumentAsync(); - await act.Should().ThrowAsync().WithMessage("Either the address parameter or the HttpClient BaseAddress must not be null."); + await act.ShouldThrowAsync("Either the address parameter or the HttpClient BaseAddress must not be null."); } [Fact] @@ -100,7 +98,7 @@ public async Task Null_discovery_document_address_should_throw() Func act = () => client.GetDiscoveryDocumentAsync(new DiscoveryDocumentRequest()); - await act.Should().ThrowAsync().WithMessage("Either the DiscoveryDocumentRequest Address or the HttpClient BaseAddress must not be null."); + await act.ShouldThrowAsync("Either the DiscoveryDocumentRequest Address or the HttpClient BaseAddress must not be null."); } [Fact] @@ -113,7 +111,7 @@ public async Task Explicit_address_should_work() Address = _endpoint }); - disco.IsError.Should().BeFalse(); + disco.IsError.ShouldBeFalse(); } [Fact] @@ -127,8 +125,8 @@ public async Task Authority_should_expand_to_endpoint() Address = _authority }); - disco.IsError.Should().BeTrue(); - handler.Request.RequestUri.Should().Be(_endpoint); + disco.IsError.ShouldBeTrue(); + handler.Request.RequestUri!.AbsoluteUri.ShouldBe(_endpoint); } [Fact] @@ -142,11 +140,11 @@ public async Task Http_error_should_be_handled_correctly() var disco = await client.GetDiscoveryDocumentAsync(); - disco.IsError.Should().BeTrue(); - disco.ErrorType.Should().Be(ResponseErrorType.Http); - disco.Error.Should().StartWith("Error connecting to"); - disco.Error.Should().EndWith("not found"); - disco.HttpStatusCode.Should().Be(HttpStatusCode.NotFound); + disco.IsError.ShouldBeTrue(); + disco.ErrorType.ShouldBe(ResponseErrorType.Http); + disco.Error.ShouldStartWith("Error connecting to"); + disco.Error.ShouldEndWith("not found"); + disco.HttpStatusCode.ShouldBe(HttpStatusCode.NotFound); } [Fact] @@ -164,8 +162,8 @@ public async Task Policy_authority_does_not_get_overwritten() Policy = policy }); - disco.IsError.Should().BeTrue(); - policy.Authority.Should().Be("https://server:123"); + disco.IsError.ShouldBeTrue(); + policy.Authority.ShouldBe("https://server:123"); } [Fact] @@ -179,10 +177,10 @@ public async Task Exception_should_be_handled_correctly() Address = _endpoint }); - disco.IsError.Should().BeTrue(); - disco.ErrorType.Should().Be(ResponseErrorType.Exception); - disco.Error.Should().StartWith("Error connecting to"); - disco.Error.Should().EndWith("error."); + disco.IsError.ShouldBeTrue(); + disco.ErrorType.ShouldBe(ResponseErrorType.Exception); + disco.Error.ShouldStartWith("Error connecting to"); + disco.Error.ShouldEndWith("error."); } [Fact] @@ -195,13 +193,13 @@ public async Task TryGetValue_calls_should_behave_as_excected() var disco = await client.GetDiscoveryDocumentAsync(); - disco.IsError.Should().BeFalse(); + disco.IsError.ShouldBeFalse(); - disco.TryGetValue(OidcConstants.Discovery.AuthorizationEndpoint).Should().NotBeNull(); - disco.TryGetValue("unknown")?.ValueKind.Should().Be(JsonValueKind.Undefined); + disco.TryGetValue(OidcConstants.Discovery.AuthorizationEndpoint).ShouldNotBeNull(); + disco.TryGetValue("unknown")?.ValueKind.ShouldBe(JsonValueKind.Undefined); - disco.TryGetString(OidcConstants.Discovery.AuthorizationEndpoint).Should().Be("https://demo.identityserver.io/connect/authorize"); - disco.TryGetString("unknown").Should().BeNull(); + disco.TryGetString(OidcConstants.Discovery.AuthorizationEndpoint).ShouldBe("https://demo.identityserver.io/connect/authorize"); + disco.TryGetString("unknown").ShouldBeNull(); } [Fact] @@ -214,29 +212,29 @@ public async Task Strongly_typed_accessors_should_behave_as_expected() var disco = await client.GetDiscoveryDocumentAsync(); - disco.IsError.Should().BeFalse(); + disco.IsError.ShouldBeFalse(); - disco.TokenEndpoint.Should().Be("https://demo.identityserver.io/connect/token"); - disco.AuthorizeEndpoint.Should().Be("https://demo.identityserver.io/connect/authorize"); - disco.UserInfoEndpoint.Should().Be("https://demo.identityserver.io/connect/userinfo"); - disco.PushedAuthorizationRequestEndpoint.Should().Be("https://demo.identityserver.io/connect/par"); + disco.TokenEndpoint.ShouldBe("https://demo.identityserver.io/connect/token"); + disco.AuthorizeEndpoint.ShouldBe("https://demo.identityserver.io/connect/authorize"); + disco.UserInfoEndpoint.ShouldBe("https://demo.identityserver.io/connect/userinfo"); + disco.PushedAuthorizationRequestEndpoint.ShouldBe("https://demo.identityserver.io/connect/par"); - disco.FrontChannelLogoutSupported.Should().Be(true); - disco.FrontChannelLogoutSessionSupported.Should().Be(true); + disco.FrontChannelLogoutSupported.ShouldBe(true); + disco.FrontChannelLogoutSessionSupported.ShouldBe(true); var responseModes = disco.ResponseModesSupported.ToList(); - responseModes.Should().Contain("form_post"); - responseModes.Should().Contain("query"); - responseModes.Should().Contain("fragment"); + responseModes.ShouldContain("form_post"); + responseModes.ShouldContain("query"); + responseModes.ShouldContain("fragment"); - disco.KeySet.Keys.Count.Should().Be(1); - disco.KeySet.Keys.First().Kid.Should().Be("a3rMUgMFv9tPclLa6yF3zAkfquE"); + disco.KeySet.Keys.Count.ShouldBe(1); + disco.KeySet.Keys.First().Kid.ShouldBe("a3rMUgMFv9tPclLa6yF3zAkfquE"); - disco.MtlsEndpointAliases.Should().NotBeNull(); - disco.MtlsEndpointAliases.TokenEndpoint.Should().BeNull(); + disco.MtlsEndpointAliases.ShouldNotBeNull(); + disco.MtlsEndpointAliases.TokenEndpoint.ShouldBeNull(); - disco.RequirePushedAuthorizationRequests.Should().BeTrue(); + disco.RequirePushedAuthorizationRequests!.Value.ShouldBeTrue(); } [Fact] @@ -265,15 +263,15 @@ public async Task Mtls_alias_accessors_should_behave_as_expected() var disco = await client.GetDiscoveryDocumentAsync(); - disco.IsError.Should().BeFalse(); - disco.MtlsEndpointAliases.Should().NotBeNull(); + disco.IsError.ShouldBeFalse(); + disco.MtlsEndpointAliases.ShouldNotBeNull(); - disco.MtlsEndpointAliases.TokenEndpoint.Should().Be("https://mtls.identityserver.io/connect/token"); - disco.MtlsEndpointAliases.Json?.TryGetString(OidcConstants.Discovery.TokenEndpoint).Should().Be("https://mtls.identityserver.io/connect/token"); + disco.MtlsEndpointAliases.TokenEndpoint.ShouldBe("https://mtls.identityserver.io/connect/token"); + disco.MtlsEndpointAliases.Json?.TryGetString(OidcConstants.Discovery.TokenEndpoint).ShouldBe("https://mtls.identityserver.io/connect/token"); - disco.MtlsEndpointAliases.RevocationEndpoint.Should().Be("https://mtls.identityserver.io/connect/revocation"); - disco.MtlsEndpointAliases.IntrospectionEndpoint.Should().Be("https://mtls.identityserver.io/connect/introspect"); - disco.MtlsEndpointAliases.DeviceAuthorizationEndpoint.Should().Be("https://mtls.identityserver.io/connect/deviceauthorization"); + disco.MtlsEndpointAliases.RevocationEndpoint.ShouldBe("https://mtls.identityserver.io/connect/revocation"); + disco.MtlsEndpointAliases.IntrospectionEndpoint.ShouldBe("https://mtls.identityserver.io/connect/introspect"); + disco.MtlsEndpointAliases.DeviceAuthorizationEndpoint.ShouldBe("https://mtls.identityserver.io/connect/deviceauthorization"); } [Fact] @@ -287,12 +285,12 @@ public async Task Http_error_with_non_json_content_should_be_handled_correctly() var disco = await client.GetDiscoveryDocumentAsync(); - disco.IsError.Should().BeTrue(); - disco.ErrorType.Should().Be(ResponseErrorType.Http); - disco.HttpStatusCode.Should().Be(HttpStatusCode.InternalServerError); - disco.Error.Should().Contain("Internal Server Error"); - disco.Raw.Should().Be("not_json"); - disco.Json?.ValueKind.Should().Be(JsonValueKind.Undefined); + disco.IsError.ShouldBeTrue(); + disco.ErrorType.ShouldBe(ResponseErrorType.Http); + disco.HttpStatusCode.ShouldBe(HttpStatusCode.InternalServerError); + disco.Error.ShouldContain("Internal Server Error"); + disco.Raw.ShouldBe("not_json"); + disco.Json?.ValueKind.ShouldBe(JsonValueKind.Undefined); } [Fact] @@ -313,13 +311,13 @@ public async Task Http_error_with_json_content_should_be_handled_correctly() var disco = await client.GetDiscoveryDocumentAsync(); - disco.IsError.Should().BeTrue(); - disco.ErrorType.Should().Be(ResponseErrorType.Http); - disco.HttpStatusCode.Should().Be(HttpStatusCode.InternalServerError); - disco.Error.Should().Contain("Internal Server Error"); + disco.IsError.ShouldBeTrue(); + disco.ErrorType.ShouldBe(ResponseErrorType.Http); + disco.HttpStatusCode.ShouldBe(HttpStatusCode.InternalServerError); + disco.Error.ShouldContain("Internal Server Error"); - disco.Json?.TryGetString("foo").Should().Be("foo"); - disco.Json?.TryGetString("bar").Should().Be("bar"); + disco.Json?.TryGetString("foo").ShouldBe("foo"); + disco.Json?.TryGetString("bar").ShouldBe("bar"); } [Fact] @@ -357,12 +355,12 @@ public async Task Http_error_at_jwk_with_non_json_content_should_be_handled_corr var disco = await client.GetDiscoveryDocumentAsync(); - disco.IsError.Should().BeTrue(); - disco.ErrorType.Should().Be(ResponseErrorType.Http); - disco.HttpStatusCode.Should().Be(HttpStatusCode.InternalServerError); - disco.Error.Should().Contain("Internal Server Error"); - disco.Raw.Should().Be("not_json"); - disco.Json?.ValueKind.Should().Be(JsonValueKind.Undefined); + disco.IsError.ShouldBeTrue(); + disco.ErrorType.ShouldBe(ResponseErrorType.Http); + disco.HttpStatusCode.ShouldBe(HttpStatusCode.InternalServerError); + disco.Error.ShouldContain("Internal Server Error"); + disco.Raw.ShouldBe("not_json"); + disco.Json?.ValueKind.ShouldBe(JsonValueKind.Undefined); } [Fact] @@ -406,13 +404,13 @@ public async Task Http_error_at_jwk_with_json_content_should_be_handled_correctl var disco = await client.GetDiscoveryDocumentAsync(); - disco.IsError.Should().BeTrue(); - disco.ErrorType.Should().Be(ResponseErrorType.Http); - disco.HttpStatusCode.Should().Be(HttpStatusCode.InternalServerError); - disco.Error.Should().Contain("Internal Server Error"); + disco.IsError.ShouldBeTrue(); + disco.ErrorType.ShouldBe(ResponseErrorType.Http); + disco.HttpStatusCode.ShouldBe(HttpStatusCode.InternalServerError); + disco.Error.ShouldContain("Internal Server Error"); - disco.Json?.TryGetString("foo").Should().Be("foo"); - disco.Json?.TryGetString("bar").Should().Be("bar"); + disco.Json?.TryGetString("foo").ShouldBe("foo"); + disco.Json?.TryGetString("bar").ShouldBe("bar"); } [Fact] @@ -443,10 +441,10 @@ public async Task Exception_at_jwk_should_be_handled_correctly() var disco = await client.GetDiscoveryDocumentAsync(); - disco.IsError.Should().BeTrue(); - disco.ErrorType.Should().Be(ResponseErrorType.Exception); - disco.Error.Should().Contain("jwk failure"); - disco.Error.Should().NotContain("Object reference not set to an instance of an object"); + disco.IsError.ShouldBeTrue(); + disco.ErrorType.ShouldBe(ResponseErrorType.Exception); + disco.Error.ShouldContain("jwk failure"); + disco.Error.ShouldNotContain("Object reference not set to an instance of an object"); } [Fact] @@ -481,11 +479,11 @@ public async Task Http_error_at_jwk_with_no_content_should_be_handled_correctly( var disco = await client.GetDiscoveryDocumentAsync(); - disco.IsError.Should().BeTrue(); - disco.ErrorType.Should().Be(ResponseErrorType.Http); - disco.HttpStatusCode.Should().Be(HttpStatusCode.InternalServerError); - disco.Error.Should().Contain("Internal Server Error"); - disco.Json?.ValueKind.Should().Be(JsonValueKind.Undefined); + disco.IsError.ShouldBeTrue(); + disco.ErrorType.ShouldBe(ResponseErrorType.Http); + disco.HttpStatusCode.ShouldBe(HttpStatusCode.InternalServerError); + disco.Error.ShouldContain("Internal Server Error"); + disco.Json?.ValueKind.ShouldBe(JsonValueKind.Undefined); } } } \ No newline at end of file diff --git a/identity-model/test/IdentityModel.Tests/HttpClientExtensions/DynamicClientRegistrationTests.cs b/identity-model/test/IdentityModel.Tests/HttpClientExtensions/DynamicClientRegistrationTests.cs index 7d9d78fc..d7bfd918 100644 --- a/identity-model/test/IdentityModel.Tests/HttpClientExtensions/DynamicClientRegistrationTests.cs +++ b/identity-model/test/IdentityModel.Tests/HttpClientExtensions/DynamicClientRegistrationTests.cs @@ -1,12 +1,10 @@ // Copyright (c) Duende Software. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -using System.Net; -using System.Net.Http; using System.Text.Json; using Duende.IdentityModel.Client; using Duende.IdentityModel.Infrastructure; -using FluentAssertions; + namespace Duende.IdentityModel.HttpClientExtensions { @@ -36,20 +34,20 @@ public async Task Http_request_should_have_correct_format() var httpRequest = handler.Request; - httpRequest.Method.Should().Be(HttpMethod.Post); - httpRequest.RequestUri.Should().Be(new Uri(Endpoint)); - httpRequest.Content.Should().NotBeNull(); + httpRequest.Method.ShouldBe(HttpMethod.Post); + httpRequest.RequestUri.ShouldBe(new Uri(Endpoint)); + httpRequest.Content.ShouldNotBeNull(); var headers = httpRequest.Headers; - headers.Count().Should().Be(2); - headers.Should().Contain(h => h.Key == "custom" && h.Value.First() == "custom"); + headers.Count().ShouldBe(2); + headers.ShouldContain(h => h.Key == "custom" && h.Value.First() == "custom"); var properties = httpRequest.GetProperties(); - properties.Count.Should().Be(1); + properties.Count.ShouldBe(1); var prop = properties.First(); - prop.Key.Should().Be("custom"); - ((string)prop.Value).Should().Be("custom"); + prop.Key.ShouldBe("custom"); + ((string)prop.Value).ShouldBe("custom"); } [Fact] @@ -68,23 +66,21 @@ public async Task Valid_protocol_response_should_be_handled_correctly() } }); - response.IsError.Should().BeFalse(); - response.ErrorType.Should().Be(ResponseErrorType.None); - response.HttpStatusCode.Should().Be(HttpStatusCode.Created); - - response.ClientId.Should().Be("s6BhdRkqt3"); - response.ClientSecret.Should().Be("ZJYCqe3GGRvdrudKyZS0XhGv_Z45DuKhCUk0gBR1vZk"); - response.ClientSecretExpiresAt.Should().Be(1577858400); - response.ClientIdIssuedAt.Should().NotHaveValue(); - response.RegistrationAccessToken.Should().Be("this.is.an.access.token.value.ffx83"); - response.RegistrationClientUri.Should() - .Be("https://server.example.com/connect/register?client_id=s6BhdRkqt3"); + response.IsError.ShouldBeFalse(); + response.ErrorType.ShouldBe(ResponseErrorType.None); + response.HttpStatusCode.ShouldBe(HttpStatusCode.Created); + + response.ClientId.ShouldBe("s6BhdRkqt3"); + response.ClientSecret.ShouldBe("ZJYCqe3GGRvdrudKyZS0XhGv_Z45DuKhCUk0gBR1vZk"); + response.ClientSecretExpiresAt.ShouldBe(1577858400); + response.ClientIdIssuedAt.HasValue.ShouldBeFalse(); + response.RegistrationAccessToken.ShouldBe("this.is.an.access.token.value.ffx83"); + response.RegistrationClientUri.ShouldBe("https://server.example.com/connect/register?client_id=s6BhdRkqt3"); // Spec requires that a software statement be echoed back unchanged - response.SoftwareStatement.Should().Be(SoftwareStatement); + response.SoftwareStatement.ShouldBe(SoftwareStatement); response.Json?.TryGetString(OidcConstants.ClientMetadata.TokenEndpointAuthenticationMethod) - .Should() - .Be(OidcConstants.EndpointAuthenticationMethods.BasicAuthentication); + .ShouldBe(OidcConstants.EndpointAuthenticationMethods.BasicAuthentication); } [Fact] @@ -100,10 +96,10 @@ public async Task Malformed_response_document_should_be_handled_correctly() Document = new DynamicClientRegistrationDocument() }); - response.IsError.Should().BeTrue(); - response.ErrorType.Should().Be(ResponseErrorType.Exception); - response.Raw.Should().Be("invalid"); - response.Exception.Should().NotBeNull(); + response.IsError.ShouldBeTrue(); + response.ErrorType.ShouldBe(ResponseErrorType.Exception); + response.Raw.ShouldBe("invalid"); + response.Exception.ShouldNotBeNull(); } [Fact] @@ -118,10 +114,10 @@ public async Task Exception_should_be_handled_correctly() Document = new DynamicClientRegistrationDocument() }); - response.IsError.Should().BeTrue(); - response.ErrorType.Should().Be(ResponseErrorType.Exception); - response.Error.Should().Be("exception"); - response.Exception.Should().NotBeNull(); + response.IsError.ShouldBeTrue(); + response.ErrorType.ShouldBe(ResponseErrorType.Exception); + response.Error.ShouldBe("exception"); + response.Exception.ShouldNotBeNull(); } [Fact] @@ -136,10 +132,10 @@ public async Task Http_error_should_be_handled_correctly() Document = new DynamicClientRegistrationDocument() }); - response.IsError.Should().BeTrue(); - response.ErrorType.Should().Be(ResponseErrorType.Http); - response.HttpStatusCode.Should().Be(HttpStatusCode.NotFound); - response.Error.Should().Be("not found"); + response.IsError.ShouldBeTrue(); + response.ErrorType.ShouldBe(ResponseErrorType.Http); + response.HttpStatusCode.ShouldBe(HttpStatusCode.NotFound); + response.Error.ShouldBe("not found"); } [Fact] @@ -155,12 +151,12 @@ public async Task Valid_protocol_error_should_be_handled_correctly() Document = new DynamicClientRegistrationDocument() }); - response.IsError.Should().BeTrue(); - response.ErrorType.Should().Be(ResponseErrorType.Protocol); - response.HttpStatusCode.Should().Be(HttpStatusCode.BadRequest); - response.Error.Should().Be("invalid_redirect_uri"); - response.ErrorDescription.Should().Be("One or more redirect_uri values are invalid"); - response.TryGet("custom").Should().Be("custom"); + response.IsError.ShouldBeTrue(); + response.ErrorType.ShouldBe(ResponseErrorType.Protocol); + response.HttpStatusCode.ShouldBe(HttpStatusCode.BadRequest); + response.Error.ShouldBe("invalid_redirect_uri"); + response.ErrorDescription.ShouldBe("One or more redirect_uri values are invalid"); + response.TryGet("custom").ShouldBe("custom"); } [Fact] @@ -172,7 +168,7 @@ public async Task Extensions_should_be_serializable() Document = JsonSerializer.Deserialize( "{\"extension\":\"data\"}") }; - request.Document.Extensions.Should().NotBeEmpty(); + request.Document.Extensions.ShouldNotBeEmpty(); var document = File.ReadAllText(FileName.Create("success_registration_response.json")); var handler = new NetworkHandler(document, HttpStatusCode.Created); @@ -181,7 +177,7 @@ public async Task Extensions_should_be_serializable() var response = await client.RegisterClientAsync(request); // Mostly we just want to make sure that serialization didn't throw - response.Should().NotBeNull(); + response.ShouldNotBeNull(); } } } \ No newline at end of file diff --git a/identity-model/test/IdentityModel.Tests/HttpClientExtensions/HttpRequestMethodExtensions.cs b/identity-model/test/IdentityModel.Tests/HttpClientExtensions/HttpRequestMethodExtensions.cs index 35dbcba5..c3c3e832 100644 --- a/identity-model/test/IdentityModel.Tests/HttpClientExtensions/HttpRequestMethodExtensions.cs +++ b/identity-model/test/IdentityModel.Tests/HttpClientExtensions/HttpRequestMethodExtensions.cs @@ -1,5 +1,4 @@ #if NETFRAMEWORK -using System.Net.Http; #endif namespace Duende.IdentityModel.HttpClientExtensions; diff --git a/identity-model/test/IdentityModel.Tests/HttpClientExtensions/JsonWebKeyExtensionsTests.cs b/identity-model/test/IdentityModel.Tests/HttpClientExtensions/JsonWebKeyExtensionsTests.cs index b3ec15fd..82a4c59f 100644 --- a/identity-model/test/IdentityModel.Tests/HttpClientExtensions/JsonWebKeyExtensionsTests.cs +++ b/identity-model/test/IdentityModel.Tests/HttpClientExtensions/JsonWebKeyExtensionsTests.cs @@ -1,12 +1,10 @@ // Copyright (c) Duende Software. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -using System.Net; -using System.Net.Http; using System.Text.Json; using Duende.IdentityModel.Client; using Duende.IdentityModel.Infrastructure; -using FluentAssertions; + namespace Duende.IdentityModel.HttpClientExtensions { @@ -52,20 +50,20 @@ public async Task Http_request_should_have_correct_format() var httpRequest = handler.Request; - httpRequest.Method.Should().Be(HttpMethod.Get); - httpRequest.RequestUri.Should().Be(new Uri(_endpoint)); - httpRequest.Content.Should().BeNull(); + httpRequest.Method.ShouldBe(HttpMethod.Get); + httpRequest.RequestUri.ShouldBe(new Uri(_endpoint)); + httpRequest.Content.ShouldBeNull(); var headers = httpRequest.Headers; - headers.Count().Should().Be(2); - headers.Should().Contain(h => h.Key == "custom" && h.Value.First() == "custom"); + headers.Count().ShouldBe(2); + headers.ShouldContain(h => h.Key == "custom" && h.Value.First() == "custom"); var properties = httpRequest.GetProperties(); - properties.Count.Should().Be(1); + properties.Count.ShouldBe(1); var prop = properties.First(); - prop.Key.Should().Be("custom"); - ((string)prop.Value).Should().Be("custom"); + prop.Key.ShouldBe("custom"); + ((string)prop.Value).ShouldBe("custom"); } [Fact] @@ -78,7 +76,7 @@ public async Task Base_address_should_work() var jwk = await client.GetJsonWebKeySetAsync(); - jwk.IsError.Should().BeFalse(); + jwk.IsError.ShouldBeFalse(); } [Fact] @@ -88,7 +86,7 @@ public async Task Explicit_address_should_work() var jwk = await client.GetJsonWebKeySetAsync(_endpoint); - jwk.IsError.Should().BeFalse(); + jwk.IsError.ShouldBeFalse(); } [Fact] @@ -102,11 +100,11 @@ public async Task Http_error_should_be_handled_correctly() var jwk = await client.GetJsonWebKeySetAsync(); - jwk.IsError.Should().BeTrue(); - jwk.ErrorType.Should().Be(ResponseErrorType.Http); - jwk.Error.Should().StartWith("Error connecting to"); - jwk.Error.Should().EndWith("not found"); - jwk.HttpStatusCode.Should().Be(HttpStatusCode.NotFound); + jwk.IsError.ShouldBeTrue(); + jwk.ErrorType.ShouldBe(ResponseErrorType.Http); + jwk.Error.ShouldStartWith("Error connecting to"); + jwk.Error.ShouldEndWith("not found"); + jwk.HttpStatusCode.ShouldBe(HttpStatusCode.NotFound); } [Fact] @@ -117,10 +115,10 @@ public async Task Exception_should_be_handled_correctly() var client = new HttpClient(handler); var jwk = await client.GetJsonWebKeySetAsync(_endpoint); - jwk.IsError.Should().BeTrue(); - jwk.ErrorType.Should().Be(ResponseErrorType.Exception); - jwk.Error.Should().StartWith("Error connecting to"); - jwk.Error.Should().EndWith("error."); + jwk.IsError.ShouldBeTrue(); + jwk.ErrorType.ShouldBe(ResponseErrorType.Exception); + jwk.Error.ShouldStartWith("Error connecting to"); + jwk.Error.ShouldEndWith("error."); } [Fact] @@ -133,8 +131,8 @@ public async Task Strongly_typed_accessors_should_behave_as_expected() var jwk = await client.GetJsonWebKeySetAsync(); - jwk.IsError.Should().BeFalse(); - jwk.KeySet.Should().NotBeNull(); + jwk.IsError.ShouldBeFalse(); + jwk.KeySet.ShouldNotBeNull(); } [Fact] @@ -148,12 +146,12 @@ public async Task Http_error_with_non_json_content_should_be_handled_correctly() var jwk = await client.GetJsonWebKeySetAsync(); - jwk.IsError.Should().BeTrue(); - jwk.ErrorType.Should().Be(ResponseErrorType.Http); - jwk.HttpStatusCode.Should().Be(HttpStatusCode.InternalServerError); - jwk.Error.Should().Contain("Internal Server Error"); - jwk.Raw.Should().Be("not_json"); - jwk.Json?.ValueKind.Should().Be(JsonValueKind.Undefined); + jwk.IsError.ShouldBeTrue(); + jwk.ErrorType.ShouldBe(ResponseErrorType.Http); + jwk.HttpStatusCode.ShouldBe(HttpStatusCode.InternalServerError); + jwk.Error.ShouldContain("Internal Server Error"); + jwk.Raw.ShouldBe("not_json"); + jwk.Json?.ValueKind.ShouldBe(JsonValueKind.Undefined); } [Fact] @@ -174,13 +172,13 @@ public async Task Http_error_with_json_content_should_be_handled_correctly() var jwk = await client.GetJsonWebKeySetAsync(); - jwk.IsError.Should().BeTrue(); - jwk.ErrorType.Should().Be(ResponseErrorType.Http); - jwk.HttpStatusCode.Should().Be(HttpStatusCode.InternalServerError); - jwk.Error.Should().Contain("Internal Server Error"); + jwk.IsError.ShouldBeTrue(); + jwk.ErrorType.ShouldBe(ResponseErrorType.Http); + jwk.HttpStatusCode.ShouldBe(HttpStatusCode.InternalServerError); + jwk.Error.ShouldContain("Internal Server Error"); - jwk.Json?.TryGetString("foo").Should().Be("foo"); - jwk.Json?.TryGetString("bar").Should().Be("bar"); + jwk.Json?.TryGetString("foo").ShouldBe("foo"); + jwk.Json?.TryGetString("bar").ShouldBe("bar"); } } } \ No newline at end of file diff --git a/identity-model/test/IdentityModel.Tests/HttpClientExtensions/PushedAuthorizationTests.cs b/identity-model/test/IdentityModel.Tests/HttpClientExtensions/PushedAuthorizationTests.cs index 89dfe2d0..9bea800e 100644 --- a/identity-model/test/IdentityModel.Tests/HttpClientExtensions/PushedAuthorizationTests.cs +++ b/identity-model/test/IdentityModel.Tests/HttpClientExtensions/PushedAuthorizationTests.cs @@ -1,11 +1,9 @@ // Copyright (c) Duende Software. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -using System.Net; -using System.Net.Http; using Duende.IdentityModel.Client; using Duende.IdentityModel.Infrastructure; -using FluentAssertions; + using Microsoft.AspNetCore.WebUtilities; namespace Duende.IdentityModel.HttpClientExtensions @@ -44,20 +42,20 @@ public async Task Http_request_should_have_correct_format() var httpRequest = handler.Request; - httpRequest.Method.Should().Be(HttpMethod.Post); - httpRequest.RequestUri.Should().Be(new Uri(Endpoint)); - httpRequest.Content.Should().NotBeNull(); + httpRequest.Method.ShouldBe(HttpMethod.Post); + httpRequest.RequestUri.ShouldBe(new Uri(Endpoint)); + httpRequest.Content.ShouldNotBeNull(); var headers = httpRequest.Headers; - headers.Count().Should().Be(3); - headers.Should().Contain(h => h.Key == "custom" && h.Value.First() == "custom"); + headers.Count().ShouldBe(3); + headers.ShouldContain(h => h.Key == "custom" && h.Value.First() == "custom"); var properties = httpRequest.GetProperties(); - properties.Count.Should().Be(1); + properties.Count.ShouldBe(1); var prop = properties.First(); - prop.Key.Should().Be("custom"); - ((string)prop.Value).Should().Be("custom"); + prop.Key.ShouldBe("custom"); + ((string)prop.Value).ShouldBe("custom"); } [Fact] @@ -78,10 +76,10 @@ public async Task Request_with_request_object_should_succeed() var fields = QueryHelpers.ParseQuery(handler.Body); - fields.Count.Should().Be(2); + fields.Count.ShouldBe(2); - fields["client_id"].First().Should().Be("client"); - fields["request"].First().Should().Be("request object value"); + fields["client_id"].First().ShouldBe("client"); + fields["request"].First().ShouldBe("request object value"); } [Fact] @@ -97,11 +95,11 @@ public async Task Success_protocol_response_should_be_handled_correctly() var response = await client.PushAuthorizationAsync(Request); - response.IsError.Should().BeFalse(); - response.ErrorType.Should().Be(ResponseErrorType.None); - response.HttpStatusCode.Should().Be(HttpStatusCode.OK); - response.RequestUri.Should().Be("urn:ietf:params:oauth:request_uri:123456"); - response.ExpiresIn.Should().Be(600); + response.IsError.ShouldBeFalse(); + response.ErrorType.ShouldBe(ResponseErrorType.None); + response.HttpStatusCode.ShouldBe(HttpStatusCode.OK); + response.RequestUri.ShouldBe("urn:ietf:params:oauth:request_uri:123456"); + response.ExpiresIn.ShouldBe(600); } [Fact] @@ -113,10 +111,10 @@ public async Task Malformed_response_document_should_be_handled_correctly() var client = new HttpClient(handler); var response = await client.PushAuthorizationAsync(Request); - response.IsError.Should().BeTrue(); - response.ErrorType.Should().Be(ResponseErrorType.Exception); - response.Raw.Should().Be("invalid"); - response.Exception.Should().NotBeNull(); + response.IsError.ShouldBeTrue(); + response.ErrorType.ShouldBe(ResponseErrorType.Exception); + response.Raw.ShouldBe("invalid"); + response.Exception.ShouldNotBeNull(); } [Fact] @@ -127,10 +125,10 @@ public async Task Exception_should_be_handled_correctly() var client = new HttpClient(handler); var response = await client.PushAuthorizationAsync(Request); - response.IsError.Should().BeTrue(); - response.ErrorType.Should().Be(ResponseErrorType.Exception); - response.Error.Should().Be("exception"); - response.Exception.Should().NotBeNull(); + response.IsError.ShouldBeTrue(); + response.ErrorType.ShouldBe(ResponseErrorType.Exception); + response.Error.ShouldBe("exception"); + response.Exception.ShouldNotBeNull(); } [Fact] @@ -141,10 +139,10 @@ public async Task Http_error_should_be_handled_correctly() var client = new HttpClient(handler); var response = await client.PushAuthorizationAsync(Request); - response.IsError.Should().BeTrue(); - response.Error.Should().Be("not found"); - response.ErrorType.Should().Be(ResponseErrorType.Http); - response.HttpStatusCode.Should().Be(HttpStatusCode.NotFound); + response.IsError.ShouldBeTrue(); + response.Error.ShouldBe("not found"); + response.ErrorType.ShouldBe(ResponseErrorType.Http); + response.HttpStatusCode.ShouldBe(HttpStatusCode.NotFound); } [Fact] @@ -169,18 +167,18 @@ public async Task Additional_request_parameters_should_be_handled_correctly() // check request var fields = QueryHelpers.ParseQuery(handler.Body); - fields.Count.Should().Be(5); + fields.Count.ShouldBe(5); - fields["client_id"].First().Should().Be("client"); - fields["response_type"].First().Should().Be("code"); - fields["acr_values"].First().Should().Be("idp:example"); - fields["scope"].First().Should().Be("scope1 scope2"); - fields["foo"].First().Should().Be("bar"); + fields["client_id"].First().ShouldBe("client"); + fields["response_type"].First().ShouldBe("code"); + fields["acr_values"].First().ShouldBe("idp:example"); + fields["scope"].First().ShouldBe("scope1 scope2"); + fields["foo"].First().ShouldBe("bar"); // check response - response.IsError.Should().BeFalse(); - response.ErrorType.Should().Be(ResponseErrorType.None); - response.HttpStatusCode.Should().Be(HttpStatusCode.OK); + response.IsError.ShouldBeFalse(); + response.ErrorType.ShouldBe(ResponseErrorType.None); + response.HttpStatusCode.ShouldBe(HttpStatusCode.OK); } [Fact] @@ -194,7 +192,8 @@ public async Task Pushed_authorization_without_response_type_should_fail() Func act = async () => await client.PushAuthorizationAsync(Request); - (await act.Should().ThrowAsync()).WithParameterName("response_type"); + var exception = await act.ShouldThrowAsync(); + exception.ParamName.ShouldBe("response_type"); } [Fact] @@ -209,7 +208,8 @@ public async Task Pushed_authorization_with_request_uri_should_fail() Func act = async () => await client.PushAuthorizationAsync(Request); - (await act.Should().ThrowAsync()).WithParameterName("request_uri"); + var exception = await act.ShouldThrowAsync(); + exception.ParamName.ShouldBe("request_uri"); } } } \ No newline at end of file diff --git a/identity-model/test/IdentityModel.Tests/HttpClientExtensions/TokenIntrospectionTests.cs b/identity-model/test/IdentityModel.Tests/HttpClientExtensions/TokenIntrospectionTests.cs index c99b93db..ebf5fe27 100644 --- a/identity-model/test/IdentityModel.Tests/HttpClientExtensions/TokenIntrospectionTests.cs +++ b/identity-model/test/IdentityModel.Tests/HttpClientExtensions/TokenIntrospectionTests.cs @@ -1,13 +1,10 @@ // Copyright (c) Duende Software. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -using System.Net; -using System.Net.Http; using System.Security.Claims; using System.Text.Json; using Duende.IdentityModel.Client; using Duende.IdentityModel.Infrastructure; -using FluentAssertions; namespace Duende.IdentityModel.HttpClientExtensions { @@ -34,15 +31,15 @@ public async Task Http_request_should_have_correct_format() var httpRequest = handler.Request; - httpRequest.Method.Should().Be(HttpMethod.Post); - httpRequest.RequestUri.Should().Be(new Uri(Endpoint)); - httpRequest.Content.Should().NotBeNull(); - httpRequest.Headers.Should().BeEquivalentTo(new Dictionary + httpRequest.Method.ShouldBe(HttpMethod.Post); + httpRequest.RequestUri.ShouldBe(new Uri(Endpoint)); + httpRequest.Content.ShouldNotBeNull(); + httpRequest.Headers.ShouldBeEquivalentTo(new Dictionary { ["Accept"] = new[] { "application/json" }, ["custom"] = new[] { "custom" }, }); - httpRequest.GetProperties().Should().BeEquivalentTo(new Dictionary + httpRequest.GetProperties().ShouldBeEquivalentTo(new Dictionary { ["custom"] = "custom", }); @@ -64,11 +61,11 @@ public async Task Success_protocol_response_should_be_handled_correctly() Token = "token" }); - response.IsError.Should().BeFalse(); - response.ErrorType.Should().Be(ResponseErrorType.None); - response.HttpStatusCode.Should().Be(HttpStatusCode.OK); - response.IsActive.Should().BeTrue(); - response.Claims.Should().BeEquivalentTo(new[] + response.IsError.ShouldBeFalse(); + response.ErrorType.ShouldBe(ResponseErrorType.None); + response.HttpStatusCode.ShouldBe(HttpStatusCode.OK); + response.IsActive.ShouldBeTrue(); + response.Claims.ShouldBeEquivalentTo(new[] { new Claim("aud", "https://idsvr4/resources", ClaimValueTypes.String, "https://idsvr4"), new Claim("aud", "api1", ClaimValueTypes.String, "https://idsvr4"), @@ -102,11 +99,11 @@ public async Task Success_protocol_response_without_issuer_should_be_handled_cor Token = "token" }); - response.IsError.Should().BeFalse(); - response.ErrorType.Should().Be(ResponseErrorType.None); - response.HttpStatusCode.Should().Be(HttpStatusCode.OK); - response.IsActive.Should().BeTrue(); - response.Claims.Should().BeEquivalentTo(new[] + response.IsError.ShouldBeFalse(); + response.ErrorType.ShouldBe(ResponseErrorType.None); + response.HttpStatusCode.ShouldBe(HttpStatusCode.OK); + response.IsActive.ShouldBeTrue(); + response.Claims.ShouldBeEquivalentTo(new[] { new Claim("aud", "https://idsvr4/resources", ClaimValueTypes.String, "LOCAL AUTHORITY"), new Claim("aud", "api1", ClaimValueTypes.String, "LOCAL AUTHORITY"), @@ -141,11 +138,11 @@ public async Task Repeating_a_request_should_succeed() var response = await client.IntrospectTokenAsync(request); - response.IsError.Should().BeFalse(); - response.ErrorType.Should().Be(ResponseErrorType.None); - response.HttpStatusCode.Should().Be(HttpStatusCode.OK); - response.IsActive.Should().BeTrue(); - response.Claims.Should().BeEquivalentTo(new[] + response.IsError.ShouldBeFalse(); + response.ErrorType.ShouldBe(ResponseErrorType.None); + response.HttpStatusCode.ShouldBe(HttpStatusCode.OK); + response.IsActive.ShouldBeTrue(); + response.Claims.ShouldBeEquivalentTo(new[] { new Claim("aud", "https://idsvr4/resources", ClaimValueTypes.String, "https://idsvr4"), new Claim("aud", "api1", ClaimValueTypes.String, "https://idsvr4"), @@ -165,11 +162,11 @@ public async Task Repeating_a_request_should_succeed() // repeat response = await client.IntrospectTokenAsync(request); - response.IsError.Should().BeFalse(); - response.ErrorType.Should().Be(ResponseErrorType.None); - response.HttpStatusCode.Should().Be(HttpStatusCode.OK); - response.IsActive.Should().BeTrue(); - response.Claims.Should().BeEquivalentTo(new[] + response.IsError.ShouldBeFalse(); + response.ErrorType.ShouldBe(ResponseErrorType.None); + response.HttpStatusCode.ShouldBe(HttpStatusCode.OK); + response.IsActive.ShouldBeTrue(); + response.Claims.ShouldBeEquivalentTo(new[] { new Claim("aud", "https://idsvr4/resources", ClaimValueTypes.String, "https://idsvr4"), new Claim("aud", "api1", ClaimValueTypes.String, "https://idsvr4"), @@ -200,7 +197,8 @@ public async Task Request_without_token_should_fail() Func act = async () => await client.IntrospectTokenAsync(new TokenIntrospectionRequest()); - (await act.Should().ThrowAsync()).WithParameterName("token"); + var exception = await act.ShouldThrowAsync(); + exception.Message.ShouldContain("token"); } [Fact] @@ -216,10 +214,10 @@ public async Task Malformed_response_document_should_be_handled_correctly() Token = "token" }); - response.IsError.Should().BeTrue(); - response.ErrorType.Should().Be(ResponseErrorType.Exception); - response.Raw.Should().Be("invalid"); - response.Exception.Should().BeAssignableTo(); + response.IsError.ShouldBeTrue(); + response.ErrorType.ShouldBe(ResponseErrorType.Exception); + response.Raw.ShouldBe("invalid"); + response.Exception.ShouldBeAssignableTo(); } [Fact] @@ -235,10 +233,10 @@ public async Task Exception_should_be_handled_correctly() Token = "token" }); - response.IsError.Should().BeTrue(); - response.ErrorType.Should().Be(ResponseErrorType.Exception); - response.Error.Should().Be("exception"); - response.Exception.Should().BeSameAs(exception); + response.IsError.ShouldBeTrue(); + response.ErrorType.ShouldBe(ResponseErrorType.Exception); + response.Error.ShouldBe("exception"); + response.Exception.ShouldBeSameAs(exception); } [Fact] @@ -253,10 +251,10 @@ public async Task Http_error_should_be_handled_correctly() Token = "token" }); - response.IsError.Should().BeTrue(); - response.ErrorType.Should().Be(ResponseErrorType.Http); - response.HttpStatusCode.Should().Be(HttpStatusCode.NotFound); - response.Error.Should().Be("not found"); + response.IsError.ShouldBeTrue(); + response.ErrorType.ShouldBe(ResponseErrorType.Http); + response.HttpStatusCode.ShouldBe(HttpStatusCode.NotFound); + response.Error.ShouldBe("not found"); } [Fact] @@ -272,11 +270,11 @@ public async Task Legacy_protocol_response_should_be_handled_correctly() Token = "token" }); - response.IsError.Should().BeFalse(); - response.ErrorType.Should().Be(ResponseErrorType.None); - response.HttpStatusCode.Should().Be(HttpStatusCode.OK); - response.IsActive.Should().BeTrue(); - response.Claims.Should().BeEquivalentTo(new[] + response.IsError.ShouldBeFalse(); + response.ErrorType.ShouldBe(ResponseErrorType.None); + response.HttpStatusCode.ShouldBe(HttpStatusCode.OK); + response.IsActive.ShouldBeTrue(); + response.Claims.ShouldBeEquivalentTo(new[] { new Claim("aud", "https://idsvr4/resources", ClaimValueTypes.String, "https://idsvr4"), new Claim("aud", "api1", ClaimValueTypes.String, "https://idsvr4"), @@ -315,14 +313,14 @@ public async Task Additional_request_parameters_should_be_handled_correctly() }); // check request - handler.Body.Should().Be("scope=scope1&scope=scope2&foo=bar+baz&token=token"); + handler.Body.ShouldBe("scope=scope1&scope=scope2&foo=bar+baz&token=token"); // check response - response.IsError.Should().BeFalse(); - response.ErrorType.Should().Be(ResponseErrorType.None); - response.HttpStatusCode.Should().Be(HttpStatusCode.OK); - response.IsActive.Should().BeTrue(); - response.Claims.Should().NotBeEmpty(); + response.IsError.ShouldBeFalse(); + response.ErrorType.ShouldBe(ResponseErrorType.None); + response.HttpStatusCode.ShouldBe(HttpStatusCode.OK); + response.IsActive.ShouldBeTrue(); + response.Claims.ShouldNotBeEmpty(); } } } \ No newline at end of file diff --git a/identity-model/test/IdentityModel.Tests/HttpClientExtensions/TokenRequestExtensionsRequestTests.cs b/identity-model/test/IdentityModel.Tests/HttpClientExtensions/TokenRequestExtensionsRequestTests.cs index 3f31a07f..13ff0777 100644 --- a/identity-model/test/IdentityModel.Tests/HttpClientExtensions/TokenRequestExtensionsRequestTests.cs +++ b/identity-model/test/IdentityModel.Tests/HttpClientExtensions/TokenRequestExtensionsRequestTests.cs @@ -1,11 +1,9 @@ // Copyright (c) Duende Software. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -using System.Net; -using System.Net.Http; using Duende.IdentityModel.Client; using Duende.IdentityModel.Infrastructure; -using FluentAssertions; + using Microsoft.AspNetCore.WebUtilities; namespace Duende.IdentityModel.HttpClientExtensions @@ -48,20 +46,20 @@ public async Task Http_request_should_have_correct_format() var _ = await client.RequestTokenAsync(request); var httpRequest = handler.Request; - httpRequest.Method.Should().Be(HttpMethod.Post); - httpRequest.RequestUri.Should().Be(new Uri(Endpoint)); - httpRequest.Content.Should().NotBeNull(); + httpRequest.Method.ShouldBe(HttpMethod.Post); + httpRequest.RequestUri.ShouldBe(new Uri(Endpoint)); + httpRequest.Content.ShouldNotBeNull(); var headers = httpRequest.Headers; - headers.Count().Should().Be(3); - headers.Should().Contain(h => h.Key == "custom" && h.Value.First() == "custom"); + headers.Count().ShouldBe(3); + headers.ShouldContain(h => h.Key == "custom" && h.Value.First() == "custom"); var properties = httpRequest.GetProperties(); - properties.Count.Should().Be(1); + properties.Count.ShouldBe(1); var prop = properties.First(); - prop.Key.Should().Be("custom"); - ((string)prop.Value).Should().Be("custom"); + prop.Key.ShouldBe("custom"); + ((string)prop.Value).ShouldBe("custom"); } [Fact] @@ -70,8 +68,8 @@ public async Task No_explicit_endpoint_address_should_use_base_address() var response = await _client.RequestClientCredentialsTokenAsync(new ClientCredentialsTokenRequest { ClientId = "client" }); - response.IsError.Should().BeFalse(); - _handler.Request.RequestUri.AbsoluteUri.Should().Be(Endpoint); + response.IsError.ShouldBeFalse(); + _handler.Request.RequestUri.AbsoluteUri.ShouldBe(Endpoint); } [Fact] @@ -84,24 +82,24 @@ public async Task Repeating_a_request_should_succeed() }; var response = await _client.RequestClientCredentialsTokenAsync(request); - response.IsError.Should().BeFalse(); + response.IsError.ShouldBeFalse(); var fields = QueryHelpers.ParseQuery(_handler.Body); - fields.TryGetValue("grant_type", out var grant_type).Should().BeTrue(); - grant_type.First().Should().Be(OidcConstants.GrantTypes.ClientCredentials); + fields.TryGetValue("grant_type", out var grant_type).ShouldBeTrue(); + grant_type.First().ShouldBe(OidcConstants.GrantTypes.ClientCredentials); - fields.TryGetValue("scope", out var scope).Should().BeTrue(); - scope.First().Should().Be("scope"); + fields.TryGetValue("scope", out var scope).ShouldBeTrue(); + scope.First().ShouldBe("scope"); response = await _client.RequestClientCredentialsTokenAsync(request); - response.IsError.Should().BeFalse(); + response.IsError.ShouldBeFalse(); fields = QueryHelpers.ParseQuery(_handler.Body); - fields.TryGetValue("grant_type", out grant_type).Should().BeTrue(); - grant_type.First().Should().Be(OidcConstants.GrantTypes.ClientCredentials); + fields.TryGetValue("grant_type", out grant_type).ShouldBeTrue(); + grant_type.First().ShouldBe(OidcConstants.GrantTypes.ClientCredentials); - fields.TryGetValue("scope", out scope).Should().BeTrue(); - scope.First().Should().Be("scope"); + fields.TryGetValue("scope", out scope).ShouldBeTrue(); + scope.First().ShouldBe("scope"); } [Fact] @@ -114,19 +112,19 @@ public async Task Client_credentials_request_should_have_correct_format() Resource = { "resource1", "resource2" } }); - response.IsError.Should().BeFalse(); + response.IsError.ShouldBeFalse(); var fields = QueryHelpers.ParseQuery(_handler.Body); - fields.TryGetValue("grant_type", out var grant_type).Should().BeTrue(); - grant_type.First().Should().Be(OidcConstants.GrantTypes.ClientCredentials); + fields.TryGetValue("grant_type", out var grant_type).ShouldBeTrue(); + grant_type.First().ShouldBe(OidcConstants.GrantTypes.ClientCredentials); - fields.TryGetValue("scope", out var scope).Should().BeTrue(); - scope.First().Should().Be("scope"); + fields.TryGetValue("scope", out var scope).ShouldBeTrue(); + scope.First().ShouldBe("scope"); - fields.TryGetValue("resource", out var resource).Should().BeTrue(); - resource.Count.Should().Be(2); - resource[0].Should().Be("resource1"); - resource[1].Should().Be("resource2"); + fields.TryGetValue("resource", out var resource).ShouldBeTrue(); + resource.Count.ShouldBe(2); + resource[0].ShouldBe("resource1"); + resource[1].ShouldBe("resource2"); } [Fact] @@ -142,12 +140,11 @@ public async Task Additional_headers_should_be_propagated() var response = await _client.RequestClientCredentialsTokenAsync(request); - response.IsError.Should().BeFalse(); + response.IsError.ShouldBeFalse(); var headers = _handler.Request.Headers; var foo = headers.FirstOrDefault(h => h.Key == "foo"); - foo.Should().NotBeNull(); - foo.Value.Single().Should().Be("bar"); + foo.Value.Single().ShouldBe("bar"); } [Fact] @@ -163,12 +160,12 @@ public async Task Additional_request_properties_should_be_propagated() var response = await _client.RequestClientCredentialsTokenAsync(request); - response.IsError.Should().BeFalse(); + response.IsError.ShouldBeFalse(); var properties = _handler.Request.GetProperties(); var foo = properties.First().Value as string; - foo.Should().NotBeNull(); - foo.Should().Be("bar"); + foo.ShouldNotBeNull(); + foo.ShouldBe("bar"); } [Fact] @@ -183,8 +180,8 @@ public async Task dpop_proof_token_should_be_propagated() var response = await _client.RequestClientCredentialsTokenAsync(request); - response.IsError.Should().BeFalse(); - _handler.Request.Headers.Single(x => x.Key == "DPoP").Value.First().Should().Be("dpop_token"); + response.IsError.ShouldBeFalse(); + _handler.Request.Headers.Single(x => x.Key == "DPoP").Value.First().ShouldBe("dpop_token"); } [Fact] @@ -210,8 +207,8 @@ public async Task dpop_nonce_should_be_returned() var response = await _client.RequestClientCredentialsTokenAsync(request); - response.IsError.Should().BeTrue(); - response.DPoPNonce.Should().Be("dpop_nonce"); + response.IsError.ShouldBeTrue(); + response.DPoPNonce.ShouldBe("dpop_nonce"); } @@ -222,7 +219,7 @@ public async Task Explicit_null_parameters_should_not_fail_() await _client.RequestClientCredentialsTokenAsync(new ClientCredentialsTokenRequest { ClientId = "client", Parameters = null }); - await act.Should().NotThrowAsync(); + await act.ShouldNotThrowAsync(); } [Fact] @@ -234,14 +231,14 @@ public async Task Device_request_should_have_correct_format() DeviceCode = "device_code" }); - response.IsError.Should().BeFalse(); + response.IsError.ShouldBeFalse(); var fields = QueryHelpers.ParseQuery(_handler.Body); - fields.TryGetValue("grant_type", out var grant_type).Should().BeTrue(); - grant_type.First().Should().Be(OidcConstants.GrantTypes.DeviceCode); + fields.TryGetValue("grant_type", out var grant_type).ShouldBeTrue(); + grant_type.First().ShouldBe(OidcConstants.GrantTypes.DeviceCode); - fields.TryGetValue("device_code", out var device_code).Should().BeTrue(); - device_code.First().Should().Be("device_code"); + fields.TryGetValue("device_code", out var device_code).ShouldBeTrue(); + device_code.First().ShouldBe("device_code"); } [Fact] @@ -250,7 +247,8 @@ public async Task Device_request_without_device_code_should_fail() Func act = async () => await _client.RequestDeviceTokenAsync(new DeviceTokenRequest { ClientId = "device" }); - (await act.Should().ThrowAsync()).WithParameterName("device_code"); + var exception = await act.ShouldThrowAsync(); + exception.ParamName.ShouldBe("device_code"); } [Fact] @@ -265,25 +263,25 @@ public async Task Password_request_should_have_correct_format() Resource = { "resource1", "resource2" } }); - response.IsError.Should().BeFalse(); + response.IsError.ShouldBeFalse(); var fields = QueryHelpers.ParseQuery(_handler.Body); - fields.TryGetValue("grant_type", out var grant_type).Should().BeTrue(); - grant_type.First().Should().Be(OidcConstants.GrantTypes.Password); + fields.TryGetValue("grant_type", out var grant_type).ShouldBeTrue(); + grant_type.First().ShouldBe(OidcConstants.GrantTypes.Password); - fields.TryGetValue("username", out var username).Should().BeTrue(); - username.First().Should().Be("user"); + fields.TryGetValue("username", out var username).ShouldBeTrue(); + username.First().ShouldBe("user"); - fields.TryGetValue("password", out var password).Should().BeTrue(); - grant_type.First().Should().Be("password"); + fields.TryGetValue("password", out var password).ShouldBeTrue(); + grant_type.First().ShouldBe("password"); - fields.TryGetValue("scope", out var scope).Should().BeTrue(); - scope.First().Should().Be("scope"); + fields.TryGetValue("scope", out var scope).ShouldBeTrue(); + scope.First().ShouldBe("scope"); - fields.TryGetValue("resource", out var resource).Should().BeTrue(); - resource.Count.Should().Be(2); - resource[0].Should().Be("resource1"); - resource[1].Should().Be("resource2"); + fields.TryGetValue("resource", out var resource).ShouldBeTrue(); + resource.Count.ShouldBe(2); + resource[0].ShouldBe("resource1"); + resource[1].ShouldBe("resource2"); } [Fact] @@ -295,17 +293,17 @@ public async Task Password_request_without_password_should_have_correct_format() UserName = "user" }); - response.IsError.Should().BeFalse(); + response.IsError.ShouldBeFalse(); var fields = QueryHelpers.ParseQuery(_handler.Body); - fields.TryGetValue("grant_type", out var grant_type).Should().BeTrue(); - grant_type.First().Should().Be(OidcConstants.GrantTypes.Password); + fields.TryGetValue("grant_type", out var grant_type).ShouldBeTrue(); + grant_type.First().ShouldBe(OidcConstants.GrantTypes.Password); - fields.TryGetValue("username", out var username).Should().BeTrue(); - username.First().Should().Be("user"); + fields.TryGetValue("username", out var username).ShouldBeTrue(); + username.First().ShouldBe("user"); - fields.TryGetValue("password", out var password).Should().BeTrue(); - password.First().Should().Be(""); + fields.TryGetValue("password", out var password).ShouldBeTrue(); + password.First().ShouldBe(""); } [Fact] @@ -313,7 +311,8 @@ public async Task Password_request_without_username_should_fail() { Func act = async () => await _client.RequestPasswordTokenAsync(new PasswordTokenRequest()); - (await act.Should().ThrowAsync()).WithParameterName("username"); + var exception = await act.ShouldThrowAsync(); + exception.ParamName.ShouldBe("username"); } [Fact] @@ -328,25 +327,25 @@ public async Task Code_request_should_have_correct_format() Resource = { "resource1", "resource2" }, }); - response.IsError.Should().BeFalse(); + response.IsError.ShouldBeFalse(); var fields = QueryHelpers.ParseQuery(_handler.Body); - fields.TryGetValue("grant_type", out var grant_type).Should().BeTrue(); - grant_type.First().Should().Be(OidcConstants.GrantTypes.AuthorizationCode); + fields.TryGetValue("grant_type", out var grant_type).ShouldBeTrue(); + grant_type.First().ShouldBe(OidcConstants.GrantTypes.AuthorizationCode); - fields.TryGetValue("code", out var code).Should().BeTrue(); - code.First().Should().Be("code"); + fields.TryGetValue("code", out var code).ShouldBeTrue(); + code.First().ShouldBe("code"); - fields.TryGetValue("redirect_uri", out var redirect_uri).Should().BeTrue(); - redirect_uri.First().Should().Be("uri"); + fields.TryGetValue("redirect_uri", out var redirect_uri).ShouldBeTrue(); + redirect_uri.First().ShouldBe("uri"); - fields.TryGetValue("code_verifier", out var code_verifier).Should().BeTrue(); - code_verifier.First().Should().Be("verifier"); + fields.TryGetValue("code_verifier", out var code_verifier).ShouldBeTrue(); + code_verifier.First().ShouldBe("verifier"); - fields.TryGetValue("resource", out var resource).Should().BeTrue(); - resource.Count.Should().Be(2); - resource[0].Should().Be("resource1"); - resource[1].Should().Be("resource2"); + fields.TryGetValue("resource", out var resource).ShouldBeTrue(); + resource.Count.ShouldBe(2); + resource[0].ShouldBe("resource1"); + resource[1].ShouldBe("resource2"); } [Fact] @@ -358,7 +357,8 @@ public async Task Code_request_without_code_should_fail() RedirectUri = "uri" }); - (await act.Should().ThrowAsync()).WithParameterName("code"); + var exception = await act.ShouldThrowAsync(); + exception.ParamName.ShouldBe("code"); } [Fact] @@ -370,7 +370,8 @@ public async Task Code_request_without_redirect_uri_should_fail() Code = "code" }); - (await act.Should().ThrowAsync()).WithParameterName("redirect_uri"); + var exception = await act.ShouldThrowAsync(); + exception.ParamName.ShouldBe("redirect_uri"); } [Fact] @@ -384,22 +385,22 @@ public async Task Refresh_request_should_have_correct_format() Resource = { "resource1", "resource2" } }); - response.IsError.Should().BeFalse(); + response.IsError.ShouldBeFalse(); var fields = QueryHelpers.ParseQuery(_handler.Body); - fields.TryGetValue("grant_type", out var grant_type).Should().BeTrue(); - grant_type.First().Should().Be(OidcConstants.GrantTypes.RefreshToken); + fields.TryGetValue("grant_type", out var grant_type).ShouldBeTrue(); + grant_type.First().ShouldBe(OidcConstants.GrantTypes.RefreshToken); - fields.TryGetValue("refresh_token", out var code).Should().BeTrue(); - code.First().Should().Be("rt"); + fields.TryGetValue("refresh_token", out var code).ShouldBeTrue(); + code.First().ShouldBe("rt"); - fields.TryGetValue("scope", out var redirect_uri).Should().BeTrue(); - redirect_uri.First().Should().Be("scope"); + fields.TryGetValue("scope", out var redirect_uri).ShouldBeTrue(); + redirect_uri.First().ShouldBe("scope"); - fields.TryGetValue("resource", out var resource).Should().BeTrue(); - resource.Count.Should().Be(2); - resource[0].Should().Be("resource1"); - resource[1].Should().Be("resource2"); + fields.TryGetValue("resource", out var resource).ShouldBeTrue(); + resource.Count.ShouldBe(2); + resource[0].ShouldBe("resource1"); + resource[1].ShouldBe("resource2"); } [Fact] @@ -407,7 +408,8 @@ public async Task Refresh_request_without_refresh_token_should_fail() { Func act = async () => await _client.RequestRefreshTokenAsync(new RefreshTokenRequest()); - (await act.Should().ThrowAsync()).WithParameterName("refresh_token"); + var exception = await act.ShouldThrowAsync(); + exception.ParamName.ShouldBe("refresh_token"); } [Fact] @@ -428,32 +430,32 @@ public async Task TokenExchange_request_should_have_correct_format() ActorTokenType = "actor_token_type" }); - response.IsError.Should().BeFalse(); + response.IsError.ShouldBeFalse(); var fields = QueryHelpers.ParseQuery(_handler.Body); - fields.TryGetValue("grant_type", out var grant_type).Should().BeTrue(); - grant_type.First().Should().Be(OidcConstants.GrantTypes.TokenExchange); + fields.TryGetValue("grant_type", out var grant_type).ShouldBeTrue(); + grant_type.First().ShouldBe(OidcConstants.GrantTypes.TokenExchange); - fields.TryGetValue("subject_token", out var subject_token).Should().BeTrue(); - subject_token.First().Should().Be("subject_token"); + fields.TryGetValue("subject_token", out var subject_token).ShouldBeTrue(); + subject_token.First().ShouldBe("subject_token"); - fields.TryGetValue("subject_token_type", out var subject_token_type).Should().BeTrue(); - subject_token_type.First().Should().Be("subject_token_type"); + fields.TryGetValue("subject_token_type", out var subject_token_type).ShouldBeTrue(); + subject_token_type.First().ShouldBe("subject_token_type"); - fields.TryGetValue("scope", out var scope).Should().BeTrue(); - scope.First().Should().Be("scope"); + fields.TryGetValue("scope", out var scope).ShouldBeTrue(); + scope.First().ShouldBe("scope"); - fields.TryGetValue("resource", out var resource).Should().BeTrue(); - resource.First().Should().Be("resource"); + fields.TryGetValue("resource", out var resource).ShouldBeTrue(); + resource.First().ShouldBe("resource"); - fields.TryGetValue("audience", out var audience).Should().BeTrue(); - audience.First().Should().Be("audience"); + fields.TryGetValue("audience", out var audience).ShouldBeTrue(); + audience.First().ShouldBe("audience"); - fields.TryGetValue("actor_token", out var actor_token).Should().BeTrue(); - actor_token.First().Should().Be("actor_token"); + fields.TryGetValue("actor_token", out var actor_token).ShouldBeTrue(); + actor_token.First().ShouldBe("actor_token"); - fields.TryGetValue("actor_token_type", out var actor_token_type).Should().BeTrue(); - actor_token_type.First().Should().Be("actor_token_type"); + fields.TryGetValue("actor_token_type", out var actor_token_type).ShouldBeTrue(); + actor_token_type.First().ShouldBe("actor_token_type"); } [Fact] @@ -471,19 +473,19 @@ public async Task Backchannel_authentication_request_should_have_correct_format( } }); - response.IsError.Should().BeFalse(); + response.IsError.ShouldBeFalse(); var fields = QueryHelpers.ParseQuery(_handler.Body); - fields.TryGetValue("grant_type", out var grant_type).Should().BeTrue(); - grant_type.First().Should().Be(OidcConstants.GrantTypes.Ciba); + fields.TryGetValue("grant_type", out var grant_type).ShouldBeTrue(); + grant_type.First().ShouldBe(OidcConstants.GrantTypes.Ciba); - fields.TryGetValue("auth_req_id", out var id).Should().BeTrue(); - id.First().Should().Be("id"); + fields.TryGetValue("auth_req_id", out var id).ShouldBeTrue(); + id.First().ShouldBe("id"); - fields.TryGetValue(OidcConstants.TokenRequest.Resource, out var resource).Should().BeTrue(); - resource.Count.Should().Be(2); - resource.First().Should().Be("resource1"); - resource.Skip(1).First().Should().Be("resource2"); + fields.TryGetValue(OidcConstants.TokenRequest.Resource, out var resource).ShouldBeTrue(); + resource.Count.ShouldBe(2); + resource.First().ShouldBe("resource1"); + resource.Skip(1).First().ShouldBe("resource2"); } [Fact] @@ -491,7 +493,8 @@ public async Task Setting_no_grant_type_should_fail() { Func act = async () => await _client.RequestTokenAsync(new TokenRequest()); - (await act.Should().ThrowAsync()).WithParameterName("grant_type"); + var exception = await act.ShouldThrowAsync(); + exception.ParamName.ShouldBe("grant_type"); } [Fact] @@ -510,20 +513,20 @@ public async Task Setting_custom_parameters_should_have_correct_format() var request = _handler.Request; - request.Headers.Authorization.Should().BeNull(); + request.Headers.Authorization.ShouldBeNull(); var fields = QueryHelpers.ParseQuery(_handler.Body); - fields.TryGetValue("grant_type", out var grant_type).Should().BeTrue(); - grant_type.First().Should().Be("test"); + fields.TryGetValue("grant_type", out var grant_type).ShouldBeTrue(); + grant_type.First().ShouldBe("test"); - fields.TryGetValue("client_id", out var client_id).Should().BeTrue(); - client_id.First().Should().Be("custom"); + fields.TryGetValue("client_id", out var client_id).ShouldBeTrue(); + client_id.First().ShouldBe("custom"); - fields.TryGetValue("client_secret", out var client_secret).Should().BeTrue(); - client_secret.First().Should().Be("custom"); + fields.TryGetValue("client_secret", out var client_secret).ShouldBeTrue(); + client_secret.First().ShouldBe("custom"); - fields.TryGetValue("custom", out var custom).Should().BeTrue(); - custom.First().Should().Be("custom"); + fields.TryGetValue("custom", out var custom).ShouldBeTrue(); + custom.First().ShouldBe("custom"); } [Fact] @@ -543,11 +546,11 @@ public async Task Setting_grant_type_via_optional_parameters_should_create_corre var request = _handler.Request; var fields = QueryHelpers.ParseQuery(_handler.Body); - fields.TryGetValue("grant_type", out var grant_type).Should().BeTrue(); - grant_type.First().Should().Be("custom"); + fields.TryGetValue("grant_type", out var grant_type).ShouldBeTrue(); + grant_type.First().ShouldBe("custom"); - fields.TryGetValue("custom", out var custom).Should().BeTrue(); - custom.First().Should().Be("custom"); + fields.TryGetValue("custom", out var custom).ShouldBeTrue(); + custom.First().ShouldBe("custom"); } [Fact] @@ -563,22 +566,22 @@ public async Task Sending_raw_parameters_should_create_correct_format() var request = _handler.Request; - request.RequestUri.AbsoluteUri.Should().Be("https://token/"); + request.RequestUri.AbsoluteUri.ShouldBe("https://token/"); var fields = QueryHelpers.ParseQuery(_handler.Body); - fields.TryGetValue("grant_type", out var field).Should().BeTrue(); - field.First().Should().Be("test"); + fields.TryGetValue("grant_type", out var field).ShouldBeTrue(); + field.First().ShouldBe("test"); - fields.TryGetValue("client_id", out field).Should().BeTrue(); - field.First().Should().Be("client"); + fields.TryGetValue("client_id", out field).ShouldBeTrue(); + field.First().ShouldBe("client"); - fields.TryGetValue("client_secret", out field).Should().BeTrue(); - field.First().Should().Be("secret"); + fields.TryGetValue("client_secret", out field).ShouldBeTrue(); + field.First().ShouldBe("secret"); - fields.TryGetValue("scope", out field).Should().BeTrue(); - field.First().Should().Be("scope"); + fields.TryGetValue("scope", out field).ShouldBeTrue(); + field.First().ShouldBe("scope"); } [Fact] @@ -594,10 +597,10 @@ public async Task Setting_basic_authentication_style_should_send_basic_authentic var request = _handler.Request; - request.Headers.Authorization.Should().NotBeNull(); - request.Headers.Authorization.Scheme.Should().Be("Basic"); - request.Headers.Authorization.Parameter.Should() - .Be(BasicAuthenticationOAuthHeaderValue.EncodeCredential("client", "secret")); + request.Headers.Authorization.ShouldNotBeNull(); + request.Headers.Authorization.Scheme.ShouldBe("Basic"); + request.Headers.Authorization.Parameter + .ShouldBe(BasicAuthenticationOAuthHeaderValue.EncodeCredential("client", "secret")); } [Fact] @@ -612,11 +615,11 @@ public async Task Setting_post_values_authentication_style_should_post_values() }); var request = _handler.Request; - request.Headers.Authorization.Should().BeNull(); + request.Headers.Authorization.ShouldBeNull(); var fields = QueryHelpers.ParseQuery(_handler.Body); - fields["client_id"].First().Should().Be("client"); - fields["client_secret"].First().Should().Be("secret"); + fields["client_id"].First().ShouldBe("client"); + fields["client_secret"].First().ShouldBe("secret"); } [Fact] @@ -631,10 +634,10 @@ public async Task Setting_client_id_only_and_post_should_put_client_id_in_post_b var request = _handler.Request; - request.Headers.Authorization.Should().BeNull(); + request.Headers.Authorization.ShouldBeNull(); var fields = QueryHelpers.ParseQuery(_handler.Body); - fields["client_id"].First().Should().Be("client"); + fields["client_id"].First().ShouldBe("client"); } [Fact] @@ -649,14 +652,14 @@ public async Task Setting_client_id_only_and_header_should_put_client_id_in_head var request = _handler.Request; - request.Headers.Authorization.Should().NotBeNull(); - request.Headers.Authorization.Scheme.Should().Be("Basic"); - request.Headers.Authorization.Parameter.Should() - .Be(BasicAuthenticationOAuthHeaderValue.EncodeCredential("client", "")); + request.Headers.Authorization.ShouldNotBeNull(); + request.Headers.Authorization.Scheme.ShouldBe("Basic"); + request.Headers.Authorization.Parameter + .ShouldBe(BasicAuthenticationOAuthHeaderValue.EncodeCredential("client", "")); var fields = QueryHelpers.ParseQuery(_handler.Body); - fields.TryGetValue("client_secret", out _).Should().BeFalse(); - fields.TryGetValue("client_id", out _).Should().BeFalse(); + fields.TryGetValue("client_secret", out _).ShouldBeFalse(); + fields.TryGetValue("client_id", out _).ShouldBeFalse(); } [Fact] @@ -670,8 +673,8 @@ public async Task Setting_client_id_and_assertion_with_authorization_header_shou ClientCredentialStyle = ClientCredentialStyle.AuthorizationHeader }); - await act.Should().ThrowAsync() - .WithMessage("CredentialStyle.AuthorizationHeader and client assertions are not compatible"); + var exception = await act.ShouldThrowAsync(); + exception.Message.ShouldBe("CredentialStyle.AuthorizationHeader and client assertions are not compatible"); } [Fact] @@ -689,10 +692,10 @@ public async Task Setting_client_id_and_assertion_should_have_correct_format() var fields = QueryHelpers.ParseQuery(_handler.Body); - fields["grant_type"].First().Should().Be("test"); - fields["client_id"].First().Should().Be("client"); - fields["client_assertion_type"].First().Should().Be("type"); - fields["client_assertion"].First().Should().Be("value"); + fields["grant_type"].First().ShouldBe("test"); + fields["client_id"].First().ShouldBe("client"); + fields["client_assertion_type"].First().ShouldBe("type"); + fields["client_assertion"].First().ShouldBe("value"); } [Fact] @@ -709,9 +712,9 @@ public async Task Setting_assertion_without_client_id_and_authz_header_should_ha var fields = QueryHelpers.ParseQuery(_handler.Body); - fields["grant_type"].First().Should().Be("test"); - fields["client_assertion_type"].First().Should().Be("type"); - fields["client_assertion"].First().Should().Be("value"); + fields["grant_type"].First().ShouldBe("test"); + fields["client_assertion_type"].First().ShouldBe("type"); + fields["client_assertion"].First().ShouldBe("value"); } } } \ No newline at end of file diff --git a/identity-model/test/IdentityModel.Tests/HttpClientExtensions/TokenRequestExtensionsResponseTests.cs b/identity-model/test/IdentityModel.Tests/HttpClientExtensions/TokenRequestExtensionsResponseTests.cs index 92cd0d3e..ea80d78e 100644 --- a/identity-model/test/IdentityModel.Tests/HttpClientExtensions/TokenRequestExtensionsResponseTests.cs +++ b/identity-model/test/IdentityModel.Tests/HttpClientExtensions/TokenRequestExtensionsResponseTests.cs @@ -1,12 +1,10 @@ // Copyright (c) Duende Software. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -using System.Net; -using System.Net.Http; using System.Text.Json; using Duende.IdentityModel.Client; using Duende.IdentityModel.Infrastructure; -using FluentAssertions; + namespace Duende.IdentityModel.HttpClientExtensions { @@ -28,13 +26,13 @@ public async Task Valid_protocol_response_should_be_handled_correctly() ClientId = "client" }); - response.IsError.Should().BeFalse(); - response.ErrorType.Should().Be(ResponseErrorType.None); - response.HttpStatusCode.Should().Be(HttpStatusCode.OK); - response.ExpiresIn.Should().Be(3600); - response.AccessToken.Should().Be("access_token"); - response.RefreshToken.Should().Be("refresh_token"); - response.TryGet("custom").Should().Be("custom"); + response.IsError.ShouldBeFalse(); + response.ErrorType.ShouldBe(ResponseErrorType.None); + response.HttpStatusCode.ShouldBe(HttpStatusCode.OK); + response.ExpiresIn.ShouldBe(3600); + response.AccessToken.ShouldBe("access_token"); + response.RefreshToken.ShouldBe("refresh_token"); + response.TryGet("custom").ShouldBe("custom"); } [Fact] @@ -51,12 +49,12 @@ public async Task Valid_protocol_error_should_be_handled_correctly() ClientId = "client" }); - response.IsError.Should().BeTrue(); - response.ErrorType.Should().Be(ResponseErrorType.Protocol); - response.HttpStatusCode.Should().Be(HttpStatusCode.BadRequest); - response.Error.Should().Be("error"); - response.ErrorDescription.Should().Be("error_description"); - response.TryGet("custom").Should().Be("custom"); + response.IsError.ShouldBeTrue(); + response.ErrorType.ShouldBe(ResponseErrorType.Protocol); + response.HttpStatusCode.ShouldBe(HttpStatusCode.BadRequest); + response.Error.ShouldBe("error"); + response.ErrorDescription.ShouldBe("error_description"); + response.TryGet("custom").ShouldBe("custom"); } [Fact] @@ -73,10 +71,10 @@ public async Task Malformed_response_document_should_be_handled_correctly() ClientId = "client" }); - response.IsError.Should().BeTrue(); - response.ErrorType.Should().Be(ResponseErrorType.Exception); - response.Raw.Should().Be("invalid"); - response.Exception.Should().NotBeNull(); + response.IsError.ShouldBeTrue(); + response.ErrorType.ShouldBe(ResponseErrorType.Exception); + response.Raw.ShouldBe("invalid"); + response.Exception.ShouldNotBeNull(); } [Fact] @@ -92,10 +90,10 @@ public async Task Exception_should_be_handled_correctly() ClientId = "client" }); - response.IsError.Should().BeTrue(); - response.ErrorType.Should().Be(ResponseErrorType.Exception); - response.Error.Should().Be("exception"); - response.Exception.Should().NotBeNull(); + response.IsError.ShouldBeTrue(); + response.ErrorType.ShouldBe(ResponseErrorType.Exception); + response.Error.ShouldBe("exception"); + response.Exception.ShouldNotBeNull(); } [Fact] @@ -111,10 +109,10 @@ public async Task Http_error_should_be_handled_correctly() ClientId = "client" }); - response.IsError.Should().BeTrue(); - response.ErrorType.Should().Be(ResponseErrorType.Http); - response.HttpStatusCode.Should().Be(HttpStatusCode.NotFound); - response.Error.Should().Be("not found"); + response.IsError.ShouldBeTrue(); + response.ErrorType.ShouldBe(ResponseErrorType.Http); + response.HttpStatusCode.ShouldBe(HttpStatusCode.NotFound); + response.Error.ShouldBe("not found"); } [Fact] @@ -130,11 +128,11 @@ public async Task Http_error_with_non_json_content_should_be_handled_correctly() ClientId = "client" }); - response.IsError.Should().BeTrue(); - response.ErrorType.Should().Be(ResponseErrorType.Http); - response.HttpStatusCode.Should().Be(HttpStatusCode.Unauthorized); - response.Error.Should().Be("Unauthorized"); - response.Raw.Should().Be("not_json"); + response.IsError.ShouldBeTrue(); + response.ErrorType.ShouldBe(ResponseErrorType.Http); + response.HttpStatusCode.ShouldBe(HttpStatusCode.Unauthorized); + response.Error.ShouldBe("Unauthorized"); + response.Raw.ShouldBe("not_json"); } [Fact] @@ -156,13 +154,13 @@ public async Task Http_error_with_json_content_should_be_handled_correctly() ClientId = "client" }); - response.IsError.Should().BeTrue(); - response.ErrorType.Should().Be(ResponseErrorType.Http); - response.HttpStatusCode.Should().Be(HttpStatusCode.Unauthorized); - response.Error.Should().Be("Unauthorized"); + response.IsError.ShouldBeTrue(); + response.ErrorType.ShouldBe(ResponseErrorType.Http); + response.HttpStatusCode.ShouldBe(HttpStatusCode.Unauthorized); + response.Error.ShouldBe("Unauthorized"); - response.Json?.TryGetString("foo").Should().Be("foo"); - response.Json?.TryGetString("bar").Should().Be("bar"); + response.Json?.TryGetString("foo").ShouldBe("foo"); + response.Json?.TryGetString("bar").ShouldBe("bar"); } } } \ No newline at end of file diff --git a/identity-model/test/IdentityModel.Tests/HttpClientExtensions/TokenRevocationExtensions.cs b/identity-model/test/IdentityModel.Tests/HttpClientExtensions/TokenRevocationExtensions.cs index 43e9a964..e4930709 100644 --- a/identity-model/test/IdentityModel.Tests/HttpClientExtensions/TokenRevocationExtensions.cs +++ b/identity-model/test/IdentityModel.Tests/HttpClientExtensions/TokenRevocationExtensions.cs @@ -1,11 +1,9 @@ // Copyright (c) Duende Software. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -using System.Net; -using System.Net.Http; using Duende.IdentityModel.Client; using Duende.IdentityModel.Infrastructure; -using FluentAssertions; + using Microsoft.AspNetCore.WebUtilities; namespace Duende.IdentityModel.HttpClientExtensions @@ -33,20 +31,20 @@ public async Task Http_request_should_have_correct_format() var httpRequest = handler.Request; - httpRequest.Method.Should().Be(HttpMethod.Post); - httpRequest.RequestUri.Should().Be(new Uri(Endpoint)); - httpRequest.Content.Should().NotBeNull(); + httpRequest.Method.ShouldBe(HttpMethod.Post); + httpRequest.RequestUri.ShouldBe(new Uri(Endpoint)); + httpRequest.Content.ShouldNotBeNull(); var headers = httpRequest.Headers; - headers.Count().Should().Be(2); - headers.Should().Contain(h => h.Key == "custom" && h.Value.First() == "custom"); + headers.Count().ShouldBe(2); + headers.ShouldContain(h => h.Key == "custom" && h.Value.First() == "custom"); var properties = httpRequest.GetProperties(); - properties.Count.Should().Be(1); + properties.Count.ShouldBe(1); var prop = properties.First(); - prop.Key.Should().Be("custom"); - ((string)prop.Value).Should().Be("custom"); + prop.Key.ShouldBe("custom"); + ((string)prop.Value).ShouldBe("custom"); } [Fact] @@ -62,9 +60,9 @@ public async Task Valid_protocol_response_should_be_handled_correctly() ClientId = "client" }); - response.IsError.Should().BeFalse(); - response.ErrorType.Should().Be(ResponseErrorType.None); - response.HttpStatusCode.Should().Be(HttpStatusCode.OK); + response.IsError.ShouldBeFalse(); + response.ErrorType.ShouldBe(ResponseErrorType.None); + response.HttpStatusCode.ShouldBe(HttpStatusCode.OK); } [Fact] @@ -82,16 +80,16 @@ public async Task Repeating_a_request_should_succeed() var response = await client.RevokeTokenAsync(request); - response.IsError.Should().BeFalse(); - response.ErrorType.Should().Be(ResponseErrorType.None); - response.HttpStatusCode.Should().Be(HttpStatusCode.OK); + response.IsError.ShouldBeFalse(); + response.ErrorType.ShouldBe(ResponseErrorType.None); + response.HttpStatusCode.ShouldBe(HttpStatusCode.OK); // repeat response = await client.RevokeTokenAsync(request); - response.IsError.Should().BeFalse(); - response.ErrorType.Should().Be(ResponseErrorType.None); - response.HttpStatusCode.Should().Be(HttpStatusCode.OK); + response.IsError.ShouldBeFalse(); + response.ErrorType.ShouldBe(ResponseErrorType.None); + response.HttpStatusCode.ShouldBe(HttpStatusCode.OK); } [Fact] @@ -108,10 +106,10 @@ public async Task Valid_protocol_error_should_be_handled_correctly() ClientId = "client" }); - response.IsError.Should().BeTrue(); - response.ErrorType.Should().Be(ResponseErrorType.Protocol); - response.HttpStatusCode.Should().Be(HttpStatusCode.BadRequest); - response.Error.Should().Be("error"); + response.IsError.ShouldBeTrue(); + response.ErrorType.ShouldBe(ResponseErrorType.Protocol); + response.HttpStatusCode.ShouldBe(HttpStatusCode.BadRequest); + response.Error.ShouldBe("error"); } [Fact] @@ -128,10 +126,10 @@ public async Task Malformed_response_document_should_be_handled_correctly() ClientId = "client" }); - response.IsError.Should().BeTrue(); - response.ErrorType.Should().Be(ResponseErrorType.Exception); - response.Raw.Should().Be("invalid"); - response.Exception.Should().NotBeNull(); + response.IsError.ShouldBeTrue(); + response.ErrorType.ShouldBe(ResponseErrorType.Exception); + response.Raw.ShouldBe("invalid"); + response.Exception.ShouldNotBeNull(); } [Fact] @@ -147,10 +145,10 @@ public async Task Exception_should_be_handled_correctly() ClientId = "client" }); - response.IsError.Should().BeTrue(); - response.ErrorType.Should().Be(ResponseErrorType.Exception); - response.Error.Should().Be("exception"); - response.Exception.Should().NotBeNull(); + response.IsError.ShouldBeTrue(); + response.ErrorType.ShouldBe(ResponseErrorType.Exception); + response.Error.ShouldBe("exception"); + response.Exception.ShouldNotBeNull(); } [Fact] @@ -166,10 +164,10 @@ public async Task Http_error_should_be_handled_correctly() ClientId = "client" }); - response.IsError.Should().BeTrue(); - response.ErrorType.Should().Be(ResponseErrorType.Http); - response.HttpStatusCode.Should().Be(HttpStatusCode.NotFound); - response.Error.Should().Be("not found"); + response.IsError.ShouldBeTrue(); + response.ErrorType.ShouldBe(ResponseErrorType.Http); + response.HttpStatusCode.ShouldBe(HttpStatusCode.NotFound); + response.Error.ShouldBe("not found"); } [Fact] @@ -192,15 +190,15 @@ public async Task Additional_parameters_should_be_sent_correctly() // check request var fields = QueryHelpers.ParseQuery(handler.Body); - fields.Count.Should().Be(2); + fields.Count.ShouldBe(2); - fields["token"].First().Should().Be("token"); - fields["foo"].First().Should().Be("bar"); + fields["token"].First().ShouldBe("token"); + fields["foo"].First().ShouldBe("bar"); // check response - response.IsError.Should().BeFalse(); - response.ErrorType.Should().Be(ResponseErrorType.None); - response.HttpStatusCode.Should().Be(HttpStatusCode.OK); + response.IsError.ShouldBeFalse(); + response.ErrorType.ShouldBe(ResponseErrorType.None); + response.HttpStatusCode.ShouldBe(HttpStatusCode.OK); } } } \ No newline at end of file diff --git a/identity-model/test/IdentityModel.Tests/HttpClientExtensions/UserInfoExtensionsTests.cs b/identity-model/test/IdentityModel.Tests/HttpClientExtensions/UserInfoExtensionsTests.cs index f030823d..155417a0 100644 --- a/identity-model/test/IdentityModel.Tests/HttpClientExtensions/UserInfoExtensionsTests.cs +++ b/identity-model/test/IdentityModel.Tests/HttpClientExtensions/UserInfoExtensionsTests.cs @@ -1,11 +1,9 @@ // Copyright (c) Duende Software. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -using System.Net; -using System.Net.Http; using Duende.IdentityModel.Client; using Duende.IdentityModel.Infrastructure; -using FluentAssertions; + namespace Duende.IdentityModel.HttpClientExtensions { @@ -26,10 +24,10 @@ public async Task Valid_protocol_response_should_be_handled_correctly() Token = "token" }); - response.IsError.Should().BeFalse(); - response.ErrorType.Should().Be(ResponseErrorType.None); - response.HttpStatusCode.Should().Be(HttpStatusCode.OK); - response.Claims.Should().NotBeEmpty(); + response.IsError.ShouldBeFalse(); + response.ErrorType.ShouldBe(ResponseErrorType.None); + response.HttpStatusCode.ShouldBe(HttpStatusCode.OK); + response.Claims.ShouldNotBeEmpty(); } [Fact] @@ -51,21 +49,21 @@ public async Task Http_request_should_have_correct_format() var httpRequest = handler.Request; - httpRequest.Method.Should().Be(HttpMethod.Get); - httpRequest.RequestUri.Should().Be(new Uri(Endpoint)); - httpRequest.Content.Should().BeNull(); + httpRequest.Method.ShouldBe(HttpMethod.Get); + httpRequest.RequestUri.ShouldBe(new Uri(Endpoint)); + httpRequest.Content.ShouldBeNull(); var headers = httpRequest.Headers; - headers.Count().Should().Be(3); - headers.Should().Contain(h => h.Key == "custom" && h.Value.First() == "custom"); - headers.Should().Contain(h => h.Key == "Authorization" && h.Value.First() == "Bearer token"); + headers.Count().ShouldBe(3); + headers.ShouldContain(h => h.Key == "custom" && h.Value.First() == "custom"); + headers.ShouldContain(h => h.Key == "Authorization" && h.Value.First() == "Bearer token"); var properties = httpRequest.GetProperties(); - properties.Count.Should().Be(1); + properties.Count.ShouldBe(1); var prop = properties.First(); - prop.Key.Should().Be("custom"); - ((string)prop.Value).Should().Be("custom"); + prop.Key.ShouldBe("custom"); + ((string)prop.Value).ShouldBe("custom"); } @@ -82,10 +80,10 @@ public async Task Malformed_response_document_should_be_handled_correctly() Token = "token" }); - response.IsError.Should().BeTrue(); - response.ErrorType.Should().Be(ResponseErrorType.Exception); - response.Raw.Should().Be("invalid"); - response.Exception.Should().NotBeNull(); + response.IsError.ShouldBeTrue(); + response.ErrorType.ShouldBe(ResponseErrorType.Exception); + response.Raw.ShouldBe("invalid"); + response.Exception.ShouldNotBeNull(); } [Fact] @@ -100,10 +98,10 @@ public async Task Exception_should_be_handled_correctly() Token = "token" }); - response.IsError.Should().BeTrue(); - response.ErrorType.Should().Be(ResponseErrorType.Exception); - response.Error.Should().Be("exception"); - response.Exception.Should().NotBeNull(); + response.IsError.ShouldBeTrue(); + response.ErrorType.ShouldBe(ResponseErrorType.Exception); + response.Error.ShouldBe("exception"); + response.Exception.ShouldNotBeNull(); } [Fact] @@ -118,10 +116,10 @@ public async Task Http_error_should_be_handled_correctly() Token = "token" }); - response.IsError.Should().BeTrue(); - response.ErrorType.Should().Be(ResponseErrorType.Http); - response.HttpStatusCode.Should().Be(HttpStatusCode.NotFound); - response.Error.Should().Be("not found"); + response.IsError.ShouldBeTrue(); + response.ErrorType.ShouldBe(ResponseErrorType.Http); + response.HttpStatusCode.ShouldBe(HttpStatusCode.NotFound); + response.Error.ShouldBe("not found"); } [Fact] @@ -137,11 +135,11 @@ public async Task BadRequest_with_empty_body_should_be_handled_as_error() Token = "token" }); - response.IsError.Should().BeTrue(); - response.ErrorType.Should().Be(ResponseErrorType.Protocol); - response.Raw.Should().Be(""); - response.Error.Should().BeNull(); - response.Exception.Should().BeNull(); + response.IsError.ShouldBeTrue(); + response.ErrorType.ShouldBe(ResponseErrorType.Protocol); + response.Raw.ShouldBe(""); + response.Error.ShouldBeNull(); + response.Exception.ShouldBeNull(); } [Fact] @@ -160,14 +158,14 @@ public async Task Non_json_response_should_set_raw() Token = "token" }); - response.IsError.Should().BeFalse(); - response.ErrorType.Should().Be(ResponseErrorType.None); - response.HttpStatusCode.Should().Be(HttpStatusCode.OK); - response.Claims.Should().BeNull(); + response.IsError.ShouldBeFalse(); + response.ErrorType.ShouldBe(ResponseErrorType.None); + response.HttpStatusCode.ShouldBe(HttpStatusCode.OK); + response.Claims.ShouldBeNull(); // This is just the literal content of the success_userinfo_response.jwt var expectedContent = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL2lkZW50aXR5LmV4YW1wbGUuY29tIiwiYXVkIjoiaHR0cHM6Ly9hcHAuZXhhbXBsZS5jb20iLCJzdWIiOiIyNDgyODk3NjEwMDEiLCJuYW1lIjoiSmFuZSBEb2UiLCJnaXZlbl9uYW1lIjoiSmFuZSIsImZhbWlseV9uYW1lIjoiRG9lIiwicHJlZmVycmVkX3VzZXJuYW1lIjoiai5kb2UiLCJlbWFpbCI6ImphbmVkb2VAZXhhbXBsZS5jb20iLCJwaWN0dXJlIjoiaHR0cDovL2V4YW1wbGUuY29tL2phbmVkb2UvbWUuanBnIn0.WmamfT6SSfVrJ6iBqPprRvbjKlQpd_8OcjLSbKbfMTQ"; - response.Raw.Should().Be(expectedContent); + response.Raw.ShouldBe(expectedContent); } } } \ No newline at end of file diff --git a/identity-model/test/IdentityModel.Tests/IdentityModel.Tests.csproj b/identity-model/test/IdentityModel.Tests/IdentityModel.Tests.csproj index c6ec7965..770a9c0b 100644 --- a/identity-model/test/IdentityModel.Tests/IdentityModel.Tests.csproj +++ b/identity-model/test/IdentityModel.Tests/IdentityModel.Tests.csproj @@ -11,11 +11,13 @@ - + + + diff --git a/identity-model/test/IdentityModel.Tests/Infrastructure/NetworkHandler.cs b/identity-model/test/IdentityModel.Tests/Infrastructure/NetworkHandler.cs index 3fbe968c..7e26a0da 100644 --- a/identity-model/test/IdentityModel.Tests/Infrastructure/NetworkHandler.cs +++ b/identity-model/test/IdentityModel.Tests/Infrastructure/NetworkHandler.cs @@ -1,8 +1,6 @@ // Copyright (c) Duende Software. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -using System.Net; -using System.Net.Http; using System.Text; namespace Duende.IdentityModel.Infrastructure diff --git a/identity-model/test/IdentityModel.Tests/Internal/ParametersTest.cs b/identity-model/test/IdentityModel.Tests/Internal/ParametersTest.cs index 42bcb23f..812affdf 100644 --- a/identity-model/test/IdentityModel.Tests/Internal/ParametersTest.cs +++ b/identity-model/test/IdentityModel.Tests/Internal/ParametersTest.cs @@ -1,8 +1,9 @@ // Copyright (c) Duende Software. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +using System.CodeDom; using Duende.IdentityModel.Client; -using FluentAssertions; + namespace Duende.IdentityModel.Internal { @@ -18,8 +19,9 @@ public class ParametersTest [InlineData(null)] public void AddOptional_with_missing_key_should_fail(string missingKey) { - Action act = () => Parameters.AddOptional(missingKey, Value); - act.Should().Throw().And.ParamName.Should().Be("key"); + var act = () => Parameters.AddOptional(missingKey, Value); + var exception = act.ShouldThrow(); + exception.ParamName.ShouldBe("key"); } [Theory] @@ -28,14 +30,14 @@ public void AddOptional_with_missing_key_should_fail(string missingKey) public void AddOptional_with_empty_value_should_not_be_added(string emptyValue) { Parameters.AddOptional(Key, emptyValue); - Parameters.Should().BeEmpty(); + Parameters.ShouldBeEmpty(); } [Fact] public void AddOptional_with_key_and_value_should_add() { Parameters.AddOptional(Key, Value); - Parameters.Should().HaveCount(1); + Parameters.Count.ShouldBe(1); } [Theory] @@ -44,8 +46,9 @@ public void AddOptional_with_key_and_value_should_add() public void AddOptional_with_duplicate_key_should_fail(string value) { Parameters.AddOptional(Key, Value); - Action act = () => Parameters.AddOptional(Key, value); - act.Should().Throw().And.Message.Should().Be($"Duplicate parameter: {Key}"); + var act = () => Parameters.AddOptional(Key, value); + var exception = act.ShouldThrow(); + exception.Message.ShouldBe($"Duplicate parameter: {Key}"); } [Theory] @@ -55,7 +58,7 @@ public void AddOptional_with_duplicate_key_without_a_value_should_noop(string em { Parameters.Add(Key, Value); Parameters.AddOptional(Key, emptyValue); - Parameters.Should().HaveCount(1); + Parameters.Count.ShouldBe(1); } [Fact] @@ -63,8 +66,8 @@ public void AddOptional_with_allow_duplicates_should_add_values() { Parameters.Add(Key, Value); Parameters.AddOptional(Key, "new value", allowDuplicates: true); - Parameters.Should().HaveCount(2); - Parameters.GetValues(Key).Should().HaveCount(2); + Parameters.Count.ShouldBe(2); + Parameters.GetValues(Key).Count().ShouldBe(2); } [Theory] @@ -79,8 +82,8 @@ public void AddOptional_with_allow_duplicates_should_not_add_empty_value(string parameters.AddOptional(Key, emptyValue, allowDuplicates: true); - parameters.Should().HaveCount(1); - parameters.GetValues(Key).Should().HaveCount(1); + parameters.Count.ShouldBe(1); + parameters.GetValues(Key).Count().ShouldBe(1); } [Theory] @@ -88,8 +91,9 @@ public void AddOptional_with_allow_duplicates_should_not_add_empty_value(string [InlineData(null)] public void AddRequired_with_missing_key_should_fail(string missingKey) { - Action act = () => Parameters.AddRequired(missingKey, Value); - act.Should().Throw().And.ParamName.Should().Be("key"); + var act = () => Parameters.AddRequired(missingKey, Value); + var exception = act.ShouldThrow(); + exception.ParamName.ShouldBe("key"); } [Theory] @@ -97,15 +101,16 @@ public void AddRequired_with_missing_key_should_fail(string missingKey) [InlineData(null)] public void AddRequired_with_empty_value_should_fail(string emptyValue) { - Action act = () => Parameters.AddRequired(Key, emptyValue); - act.Should().Throw().And.ParamName.Should().Be(Key); + var act = () => Parameters.AddRequired(Key, emptyValue); + var exception = act.ShouldThrow(); + exception.ParamName.ShouldBe(Key); } [Fact] public void AddRequired_with_key_and_value_should_add() { Parameters.AddRequired(Key, Value); - Parameters.Should().HaveCount(1); + Parameters.Count.ShouldBe(1); } [Fact] @@ -116,7 +121,7 @@ public void AddRequired_with_empty_value_and_existing_parameter_should_noop() parameters.AddRequired(Key, null); parameters.AddRequired(Key, ""); - parameters.Should().HaveCount(1); + parameters.Count.ShouldBe(1); } [Theory] @@ -127,7 +132,7 @@ public void AddRequired_with_empty_value_and_allowEmptyValue_should_add(string e var parameters = new Parameters(); parameters.AddRequired(Key, emptyValue, allowEmptyValue: true); - parameters.Should().HaveCount(1); + parameters.Count.ShouldBe(1); } [Theory] @@ -144,8 +149,8 @@ public void AddRequired_with_duplicate_empty_value_and_allowEmptyValue_and_allow }; parameters.AddRequired(Key, emptyValue, allowDuplicates: true, allowEmptyValue: true); - parameters.Should().HaveCount(2); - parameters[Key].Should().HaveCount(2); + parameters.Count.ShouldBe(2); + parameters[Key].Count().ShouldBe(2); } [Fact] @@ -156,8 +161,9 @@ public void AddRequired_with_duplicate_key_and_distinct_values_should_fail() { Key, Value} }; - Action act = () => parameters.AddRequired(Key, "new value"); - act.Should().Throw().And.Message.Should().Be($"Duplicate parameter: {Key}"); + var act = () => parameters.AddRequired(Key, "new value"); + var exception = act.ShouldThrow(); + exception.Message.ShouldBe($"Duplicate parameter: {Key}"); } [Fact] @@ -166,7 +172,7 @@ public void AddRequired_with_duplicate_key_and_value_should_noop() Parameters.AddRequired(Key, Value); Parameters.AddRequired(Key, Value); - Parameters.Should().HaveCount(1); + Parameters.Count.ShouldBe(1); } [Theory] @@ -176,7 +182,7 @@ public void AddRequired_with_duplicate_key_without_a_value_should_noop(string em { Parameters.Add(Key, Value); Parameters.AddRequired(Key, emptyValue); - Parameters.Should().HaveCount(1); + Parameters.Count.ShouldBe(1); } [Fact] @@ -189,7 +195,7 @@ public void Default_add_does_not_replace() parameters.Add(key, value); parameters.Add(key, value); - parameters.Should().HaveCount(2); + parameters.Count.ShouldBe(2); } [Fact] @@ -202,7 +208,7 @@ public void Add_with_single_replace_works_as_expected() parameters.Add(key, value); parameters.Add(key, value, ParameterReplaceBehavior.Single); - parameters.Should().HaveCount(1); + parameters.Count.ShouldBe(1); } [Fact] @@ -215,7 +221,7 @@ public void Add_with_all_replace_works_as_expected() parameters.Add(key, value); parameters.Add(key, value, ParameterReplaceBehavior.All); - parameters.Should().HaveCount(1); + parameters.Count.ShouldBe(1); } [Fact] @@ -227,8 +233,8 @@ public void Add_with_single_replace_but_multiple_exist_should_throw() parameters.Add(key, "value1"); parameters.Add(key, "value2"); - Action act = () => parameters.Add(key,"value3", ParameterReplaceBehavior.Single); - act.Should().Throw(); + var act = () => parameters.Add(key,"value3", ParameterReplaceBehavior.Single); + act.ShouldThrow(); } } } diff --git a/identity-model/test/IdentityModel.Tests/RequestUrlTests.cs b/identity-model/test/IdentityModel.Tests/RequestUrlTests.cs index 034560b1..43c3c697 100644 --- a/identity-model/test/IdentityModel.Tests/RequestUrlTests.cs +++ b/identity-model/test/IdentityModel.Tests/RequestUrlTests.cs @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. using Duende.IdentityModel.Client; -using FluentAssertions; + using Microsoft.AspNetCore.WebUtilities; namespace Duende.IdentityModel @@ -21,7 +21,7 @@ public void null_value_should_return_base() var url = request.Create(null); - url.Should().Be(Authority); + url.ShouldBe(Authority); } [Fact] @@ -32,7 +32,7 @@ public void empty_value_should_return_base() var values = new Parameters(); var url = request.Create(values); - url.Should().Be(Authority); + url.ShouldBe(Authority); } [Fact] @@ -48,7 +48,7 @@ public void Create_absolute_url_should_behave_as_expected() var url = request.Create(parameters); - url.Should().Be("http://server/authorize?foo=foo&bar=bar"); + url.ShouldBe("http://server/authorize?foo=foo&bar=bar"); } [Fact] @@ -64,7 +64,7 @@ public void Multiple_parameter_names_should_behave_as_expected() var url = request.Create(parameters); - url.Should().Be("http://server/authorize?foo=foo&foo=bar"); + url.ShouldBe("http://server/authorize?foo=foo&foo=bar"); } [Fact] @@ -80,7 +80,7 @@ public void Special_characters_in_query_param_should_be_encoded_correctly() var url = request.Create(parameters); - url.Should().Be("http://server/authorize?scope=a%20b%20c&clientId=a%2Bb%2Bc"); + url.ShouldBe("http://server/authorize?scope=a%20b%20c&clientId=a%2Bb%2Bc"); } [Fact] @@ -96,7 +96,7 @@ public void Create_relative_url_should_behave_as_expected() var url = request.Create(parameters); - url.Should().Be("/authorize?foo=foo&bar=bar"); + url.ShouldBe("/authorize?foo=foo&bar=bar"); } [Fact] @@ -112,7 +112,7 @@ public void Null_values_should_be_skipped() var url = request.Create(parameters); - url.Should().Be("/authorize?foo=foo"); + url.ShouldBe("/authorize?foo=foo"); } [Fact] @@ -124,12 +124,12 @@ public void Create_authorize_url_for_par_should_succeed() var urlString = request.CreateAuthorizeUrl(clientId: ClientId, requestUri: requestUri); var url = new Uri(urlString); - url.GetLeftPart(UriPartial.Path).Should().Be(Authority); + url.GetLeftPart(UriPartial.Path).ShouldBe(Authority); var fields = QueryHelpers.ParseQuery(url.Query); - fields.Count.Should().Be(2); - fields["client_id"].Single().Should().Be(ClientId); - fields["request_uri"].Single().Should().Be(requestUri); + fields.Count.ShouldBe(2); + fields["client_id"].Single().ShouldBe(ClientId); + fields["request_uri"].Single().ShouldBe(requestUri); } [Fact] @@ -149,15 +149,15 @@ public void Create_authorize_url_for_non_par_should_succeed() ); var url = new Uri(urlString); - url.GetLeftPart(UriPartial.Path).Should().Be(Authority); + url.GetLeftPart(UriPartial.Path).ShouldBe(Authority); var fields = QueryHelpers.ParseQuery(url.Query); - fields.Count.Should().Be(5); - fields["client_id"].Single().Should().Be(ClientId); - fields["response_type"].Single().Should().Be("code"); - fields["redirect_uri"].Single().Should().Be(redirectUri); - fields["scope"].Single().Should().Be(scope); - fields["state"].Single().Should().Be(state); + fields.Count.ShouldBe(5); + fields["client_id"].Single().ShouldBe(ClientId); + fields["response_type"].Single().ShouldBe("code"); + fields["redirect_uri"].Single().ShouldBe(redirectUri); + fields["scope"].Single().ShouldBe(scope); + fields["state"].Single().ShouldBe(state); } } } \ No newline at end of file diff --git a/identity-model/test/IdentityModel.Tests/TokenClientRequestTests.cs b/identity-model/test/IdentityModel.Tests/TokenClientRequestTests.cs index 3a2bf3f8..6f980c1b 100644 --- a/identity-model/test/IdentityModel.Tests/TokenClientRequestTests.cs +++ b/identity-model/test/IdentityModel.Tests/TokenClientRequestTests.cs @@ -1,11 +1,9 @@ // Copyright (c) Duende Software. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -using System.Net; -using System.Net.Http; using Duende.IdentityModel.Client; using Duende.IdentityModel.Infrastructure; -using FluentAssertions; + using Microsoft.AspNetCore.WebUtilities; namespace Duende.IdentityModel @@ -35,8 +33,8 @@ public async Task No_explicit_endpoint_address_should_use_base_address() var response = await tokenClient.RequestClientCredentialsTokenAsync(); - response.IsError.Should().BeFalse(); - _handler.Request.RequestUri.AbsoluteUri.Should().Be(Endpoint); + response.IsError.ShouldBeFalse(); + _handler.Request.RequestUri.AbsoluteUri.ShouldBe(Endpoint); } [Fact] @@ -46,14 +44,14 @@ public async Task Client_credentials_request_should_have_correct_format() var response = await tokenClient.RequestClientCredentialsTokenAsync(scope: "scope"); - response.IsError.Should().BeFalse(); + response.IsError.ShouldBeFalse(); var fields = QueryHelpers.ParseQuery(_handler.Body); - fields.TryGetValue("grant_type", out var grant_type).Should().BeTrue(); - grant_type.First().Should().Be(OidcConstants.GrantTypes.ClientCredentials); + fields.TryGetValue("grant_type", out var grant_type).ShouldBeTrue(); + grant_type.First().ShouldBe(OidcConstants.GrantTypes.ClientCredentials); - fields.TryGetValue("scope", out var scope).Should().BeTrue(); - scope.First().Should().Be("scope"); + fields.TryGetValue("scope", out var scope).ShouldBeTrue(); + scope.First().ShouldBe("scope"); } [Fact] @@ -63,17 +61,17 @@ public async Task Device_request_should_have_correct_format() var response = await tokenClient.RequestDeviceTokenAsync(deviceCode: "device_code"); - response.IsError.Should().BeFalse(); + response.IsError.ShouldBeFalse(); var fields = QueryHelpers.ParseQuery(_handler.Body); - fields.TryGetValue("grant_type", out var grant_type).Should().BeTrue(); - grant_type.First().Should().Be(OidcConstants.GrantTypes.DeviceCode); + fields.TryGetValue("grant_type", out var grant_type).ShouldBeTrue(); + grant_type.First().ShouldBe(OidcConstants.GrantTypes.DeviceCode); - fields.TryGetValue("client_id", out var client_id).Should().BeTrue(); - client_id.First().Should().Be("device"); + fields.TryGetValue("client_id", out var client_id).ShouldBeTrue(); + client_id.First().ShouldBe("device"); - fields.TryGetValue("device_code", out var device_code).Should().BeTrue(); - device_code.First().Should().Be("device_code"); + fields.TryGetValue("device_code", out var device_code).ShouldBeTrue(); + device_code.First().ShouldBe("device_code"); } [Fact] @@ -83,7 +81,8 @@ public async Task Device_request_without_device_code_should_fail() Func act = async () => await tokenClient.RequestDeviceTokenAsync(null); - (await act.Should().ThrowAsync()).WithParameterName("device_code"); + var exception = await act.ShouldThrowAsync(); + exception.ParamName.ShouldBe("device_code"); } [Fact] @@ -93,20 +92,20 @@ public async Task Password_request_should_have_correct_format() var response = await tokenClient.RequestPasswordTokenAsync(userName: "user", password: "password", scope: "scope"); - response.IsError.Should().BeFalse(); + response.IsError.ShouldBeFalse(); var fields = QueryHelpers.ParseQuery(_handler.Body); - fields.TryGetValue("grant_type", out var grant_type).Should().BeTrue(); - grant_type.First().Should().Be(OidcConstants.GrantTypes.Password); + fields.TryGetValue("grant_type", out var grant_type).ShouldBeTrue(); + grant_type.First().ShouldBe(OidcConstants.GrantTypes.Password); - fields.TryGetValue("username", out var username).Should().BeTrue(); - username.First().Should().Be("user"); + fields.TryGetValue("username", out var username).ShouldBeTrue(); + username.First().ShouldBe("user"); - fields.TryGetValue("password", out var password).Should().BeTrue(); - password.First().Should().Be("password"); + fields.TryGetValue("password", out var password).ShouldBeTrue(); + password.First().ShouldBe("password"); - fields.TryGetValue("scope", out var scope).Should().BeTrue(); - scope.First().Should().Be("scope"); + fields.TryGetValue("scope", out var scope).ShouldBeTrue(); + scope.First().ShouldBe("scope"); } [Fact] @@ -116,17 +115,17 @@ public async Task Password_request_without_password_should_have_correct_format() var response = await tokenClient.RequestPasswordTokenAsync(userName: "user"); - response.IsError.Should().BeFalse(); + response.IsError.ShouldBeFalse(); var fields = QueryHelpers.ParseQuery(_handler.Body); - fields.TryGetValue("grant_type", out var grant_type).Should().BeTrue(); - grant_type.First().Should().Be(OidcConstants.GrantTypes.Password); + fields.TryGetValue("grant_type", out var grant_type).ShouldBeTrue(); + grant_type.First().ShouldBe(OidcConstants.GrantTypes.Password); - fields.TryGetValue("username", out var username).Should().BeTrue(); - username.First().Should().Be("user"); + fields.TryGetValue("username", out var username).ShouldBeTrue(); + username.First().ShouldBe("user"); - fields.TryGetValue("password", out var password).Should().BeTrue(); - password.First().Should().Be(""); + fields.TryGetValue("password", out var password).ShouldBeTrue(); + password.First().ShouldBe(""); } [Fact] @@ -136,7 +135,8 @@ public async Task Password_request_without_username_should_fail() Func act = async () => await tokenClient.RequestPasswordTokenAsync(userName: null); - (await act.Should().ThrowAsync()).WithParameterName("username"); + var exception = await act.ShouldThrowAsync(); + exception.ParamName.ShouldBe("username"); } [Fact] @@ -146,20 +146,20 @@ public async Task Code_request_should_have_correct_format() var response = await tokenClient.RequestAuthorizationCodeTokenAsync(code: "code", redirectUri: "uri", codeVerifier: "verifier"); - response.IsError.Should().BeFalse(); + response.IsError.ShouldBeFalse(); var fields = QueryHelpers.ParseQuery(_handler.Body); - fields.TryGetValue("grant_type", out var grant_type).Should().BeTrue(); - grant_type.First().Should().Be(OidcConstants.GrantTypes.AuthorizationCode); + fields.TryGetValue("grant_type", out var grant_type).ShouldBeTrue(); + grant_type.First().ShouldBe(OidcConstants.GrantTypes.AuthorizationCode); - fields.TryGetValue("code", out var code).Should().BeTrue(); - code.First().Should().Be("code"); + fields.TryGetValue("code", out var code).ShouldBeTrue(); + code.First().ShouldBe("code"); - fields.TryGetValue("redirect_uri", out var redirect_uri).Should().BeTrue(); - redirect_uri.First().Should().Be("uri"); + fields.TryGetValue("redirect_uri", out var redirect_uri).ShouldBeTrue(); + redirect_uri.First().ShouldBe("uri"); - fields.TryGetValue("code_verifier", out var code_verifier).Should().BeTrue(); - code_verifier.First().Should().Be("verifier"); + fields.TryGetValue("code_verifier", out var code_verifier).ShouldBeTrue(); + code_verifier.First().ShouldBe("verifier"); } [Fact] @@ -169,7 +169,8 @@ public async Task Code_request_without_code_should_fail() Func act = async () => await tokenClient.RequestAuthorizationCodeTokenAsync(code: null, redirectUri: "uri", codeVerifier: "verifier"); - (await act.Should().ThrowAsync()).WithParameterName("code"); + var exception = await act.ShouldThrowAsync(); + exception.ParamName.ShouldBe("code"); } [Fact] @@ -179,7 +180,8 @@ public async Task Code_request_without_redirect_uri_should_fail() Func act = async () => await tokenClient.RequestAuthorizationCodeTokenAsync(code: "code", redirectUri: null, codeVerifier: "verifier"); - (await act.Should().ThrowAsync()).WithParameterName("redirect_uri"); + var exception = await act.ShouldThrowAsync(); + exception.ParamName.ShouldBe("redirectUri"); } [Fact] @@ -189,17 +191,17 @@ public async Task Refresh_request_should_have_correct_format() var response = await tokenClient.RequestRefreshTokenAsync(refreshToken: "rt", scope: "scope"); - response.IsError.Should().BeFalse(); + response.IsError.ShouldBeFalse(); var fields = QueryHelpers.ParseQuery(_handler.Body); - fields.TryGetValue("grant_type", out var grant_type).Should().BeTrue(); - grant_type.First().Should().Be(OidcConstants.GrantTypes.RefreshToken); + fields.TryGetValue("grant_type", out var grant_type).ShouldBeTrue(); + grant_type.First().ShouldBe(OidcConstants.GrantTypes.RefreshToken); - fields.TryGetValue("refresh_token", out var code).Should().BeTrue(); - code.First().Should().Be("rt"); + fields.TryGetValue("refresh_token", out var code).ShouldBeTrue(); + code.First().ShouldBe("rt"); - fields.TryGetValue("scope", out var redirect_uri).Should().BeTrue(); - redirect_uri.First().Should().Be("scope"); + fields.TryGetValue("scope", out var redirect_uri).ShouldBeTrue(); + redirect_uri.First().ShouldBe("scope"); } [Fact] @@ -209,7 +211,8 @@ public async Task Refresh_request_without_refresh_token_should_fail() Func act = async () => await tokenClient.RequestRefreshTokenAsync(refreshToken: null, scope: "scope"); - (await act.Should().ThrowAsync()).WithParameterName("refresh_token"); + var exception = await act.ShouldThrowAsync(); + exception.ParamName.ShouldBe("refresh_token"); } [Fact] @@ -219,7 +222,8 @@ public async Task Setting_no_grant_type_should_fail() Func act = async () => await tokenClient.RequestTokenAsync(grantType: null); - (await act.Should().ThrowAsync()).WithParameterName("grant_type"); + var exception = await act.ShouldThrowAsync(); + exception.ParamName.ShouldBe("grant_type"); } [Fact] @@ -238,20 +242,20 @@ public async Task Setting_custom_parameters_should_have_correct_format() var request = _handler.Request; - request.Headers.Authorization.Should().BeNull(); + request.Headers.Authorization.ShouldBeNull(); var fields = QueryHelpers.ParseQuery(_handler.Body); - fields.TryGetValue("grant_type", out var grant_type).Should().BeTrue(); - grant_type.First().Should().Be("test"); + fields.TryGetValue("grant_type", out var grant_type).ShouldBeTrue(); + grant_type.First().ShouldBe("test"); - fields.TryGetValue("client_id", out var client_id).Should().BeTrue(); - client_id.First().Should().Be("custom"); + fields.TryGetValue("client_id", out var client_id).ShouldBeTrue(); + client_id.First().ShouldBe("custom"); - fields.TryGetValue("client_secret", out var client_secret).Should().BeTrue(); - client_secret.First().Should().Be("custom"); + fields.TryGetValue("client_secret", out var client_secret).ShouldBeTrue(); + client_secret.First().ShouldBe("custom"); - fields.TryGetValue("custom", out var custom).Should().BeTrue(); - custom.First().Should().Be("custom"); + fields.TryGetValue("custom", out var custom).ShouldBeTrue(); + custom.First().ShouldBe("custom"); } [Fact] @@ -270,23 +274,23 @@ public async Task Mixing_local_and_global_custom_parameters_should_have_correct_ var request = _handler.Request; - request.Headers.Authorization.Should().BeNull(); + request.Headers.Authorization.ShouldBeNull(); var fields = QueryHelpers.ParseQuery(_handler.Body); - fields.TryGetValue("grant_type", out var grant_type).Should().BeTrue(); - grant_type.First().Should().Be("test"); + fields.TryGetValue("grant_type", out var grant_type).ShouldBeTrue(); + grant_type.First().ShouldBe("test"); - fields.TryGetValue("client_id", out var client_id).Should().BeTrue(); - client_id.First().Should().Be("custom"); + fields.TryGetValue("client_id", out var client_id).ShouldBeTrue(); + client_id.First().ShouldBe("custom"); - fields.TryGetValue("client_secret", out var client_secret).Should().BeTrue(); - client_secret.First().Should().Be("custom"); + fields.TryGetValue("client_secret", out var client_secret).ShouldBeTrue(); + client_secret.First().ShouldBe("custom"); - fields.TryGetValue("custom", out var custom).Should().BeTrue(); - custom.First().Should().Be("custom"); + fields.TryGetValue("custom", out var custom).ShouldBeTrue(); + custom.First().ShouldBe("custom"); - fields.TryGetValue("global", out var global).Should().BeTrue(); - global.First().Should().Be("global"); + fields.TryGetValue("global", out var global).ShouldBeTrue(); + global.First().ShouldBe("global"); } [Fact] @@ -304,9 +308,9 @@ public async Task Local_custom_parameters_should_not_interfere_with_global() _ = await tokenClient.RequestTokenAsync(grantType: "test", parameters: localParameters); - globalOptions.Parameters.Should().HaveCount(1); + globalOptions.Parameters.Count.ShouldBe(1); var globalValue = globalOptions.Parameters.FirstOrDefault(p => p.Key == "global").Value; - globalValue.Should().Be("value"); + globalValue.ShouldBe("value"); } [Fact] @@ -323,9 +327,9 @@ public async Task Setting_basic_authentication_style_should_send_basic_authentic var request = _handler.Request; - request.Headers.Authorization.Should().NotBeNull(); - request.Headers.Authorization.Scheme.Should().Be("Basic"); - request.Headers.Authorization.Parameter.Should().Be(BasicAuthenticationOAuthHeaderValue.EncodeCredential("client", "secret")); + request.Headers.Authorization.ShouldNotBeNull(); + request.Headers.Authorization.Scheme.ShouldBe("Basic"); + request.Headers.Authorization.Parameter.ShouldBe(BasicAuthenticationOAuthHeaderValue.EncodeCredential("client", "secret")); } [Fact] @@ -341,11 +345,11 @@ public async Task Setting_post_values_authentication_style_should_post_values() var response = await tokenClient.RequestTokenAsync(grantType: "test"); var request = _handler.Request; - request.Headers.Authorization.Should().BeNull(); + request.Headers.Authorization.ShouldBeNull(); var fields = QueryHelpers.ParseQuery(_handler.Body); - fields["client_id"].First().Should().Be("client"); - fields["client_secret"].First().Should().Be("secret"); + fields["client_id"].First().ShouldBe("client"); + fields["client_secret"].First().ShouldBe("secret"); } @@ -362,10 +366,10 @@ public async Task Setting_client_id_only_and_post_should_put_client_id_in_post_b var request = _handler.Request; - request.Headers.Authorization.Should().BeNull(); + request.Headers.Authorization.ShouldBeNull(); var fields = QueryHelpers.ParseQuery(_handler.Body); - fields["client_id"].First().Should().Be("client"); + fields["client_id"].First().ShouldBe("client"); } [Fact] @@ -381,13 +385,13 @@ public async Task Setting_client_id_only_and_header_should_put_client_id_in_head var request = _handler.Request; - request.Headers.Authorization.Should().NotBeNull(); - request.Headers.Authorization.Scheme.Should().Be("Basic"); - request.Headers.Authorization.Parameter.Should().Be(BasicAuthenticationOAuthHeaderValue.EncodeCredential("client", "")); + request.Headers.Authorization.ShouldNotBeNull(); + request.Headers.Authorization.Scheme.ShouldBe("Basic"); + request.Headers.Authorization.Parameter.ShouldBe(BasicAuthenticationOAuthHeaderValue.EncodeCredential("client", "")); var fields = QueryHelpers.ParseQuery(_handler.Body); - fields.TryGetValue("client_secret", out _).Should().BeFalse(); - fields.TryGetValue("client_id", out _).Should().BeFalse(); + fields.TryGetValue("client_secret", out _).ShouldBeFalse(); + fields.TryGetValue("client_id", out _).ShouldBeFalse(); } [Fact] @@ -402,10 +406,10 @@ public async Task Setting_client_id_and_assertion_should_have_correct_format() var response = await tokenClient.RequestTokenAsync(grantType: "test"); var fields = QueryHelpers.ParseQuery(_handler.Body); - fields["grant_type"].First().Should().Be("test"); - fields["client_id"].First().Should().Be("client"); - fields["client_assertion_type"].First().Should().Be("type"); - fields["client_assertion"].First().Should().Be("value"); + fields["grant_type"].First().ShouldBe("test"); + fields["client_id"].First().ShouldBe("client"); + fields["client_assertion_type"].First().ShouldBe("type"); + fields["client_assertion"].First().ShouldBe("value"); } } } diff --git a/ignore-this/test/IgnoreThis.Tests/Usings.cs b/ignore-this/test/IgnoreThis.Tests/Usings.cs index 522a2dc2..5ce1898d 100644 --- a/ignore-this/test/IgnoreThis.Tests/Usings.cs +++ b/ignore-this/test/IgnoreThis.Tests/Usings.cs @@ -1,5 +1,5 @@ // Copyright (c) Duende Software. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -global using Xunit; -global using Shouldly; \ No newline at end of file +global using Shouldly; +global using Xunit; \ No newline at end of file