Skip to content

Commit

Permalink
Replace FluentAssertions with Shouldly
Browse files Browse the repository at this point in the history
  • Loading branch information
damianh committed Jan 20, 2025
1 parent acc5584 commit 1eb0385
Show file tree
Hide file tree
Showing 39 changed files with 1,194 additions and 1,204 deletions.
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
<PackageVersion Include="coverlet.collector" Version="6.0.2" />
<PackageVersion Include="Duende.IdentityModel" Version="7.0.0" />
<PackageVersion Include="Duende.IdentityServer" Version="$(IdentityServerVersion)" />
<PackageVersion Include="FluentAssertions" Version="6.12.0" />
<PackageVersion Include="MartinCostello.Logging.XUnit" Version="0.3.0" />
<PackageVersion Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="$(FrameworkVersion)" />
<PackageVersion Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="$(FrameworkVersion)" />
Expand All @@ -58,6 +57,7 @@
<PackageVersion Include="SimpleExec" Version="12.0.0" />
<PackageVersion Include="System.IdentityModel.Tokens.Jwt" Version="$(WilsonVersion)" />
<PackageVersion Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="$(WilsonVersion)" />
<PackageVersion Include="System.Net.Http" Version="4.3.4" />
<PackageVersion Include="System.Text.Json" Version="8.0.5" />
<PackageVersion Include="Verify.Xunit" Version="27.0.1" />
<PackageVersion Include="xunit.core" Version="2.9.2" />
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
global using Shouldly;
global using Xunit;
Original file line number Diff line number Diff line change
@@ -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
{
Expand All @@ -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]
Expand All @@ -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]
Expand Down Expand Up @@ -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...");
}
}
}
Loading

0 comments on commit 1eb0385

Please sign in to comment.