Skip to content

Commit

Permalink
committing suggested changes for issue IdentityModel#415
Browse files Browse the repository at this point in the history
  • Loading branch information
RobK410 committed Mar 8, 2024
1 parent 9b48585 commit d34be27
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/OidcClient/OidcClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ internal async Task EnsureProviderInformationAsync(CancellationToken cancellatio
var discoveryClient = Options.CreateClient();
var disco = await discoveryClient.GetDiscoveryDocumentAsync(new DiscoveryDocumentRequest
{
Address = Options.Authority,
Address = Options.Policy.Discovery.Authority ?? Options.Authority,
Policy = Options.Policy.Discovery
}, cancellationToken).ConfigureAwait(false);

Expand Down
24 changes: 24 additions & 0 deletions test/OidcClient.Tests/ConfigurationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,5 +173,29 @@ public void Error401_while_loading_discovery_document_should_throw()

act.Should().Throw<InvalidOperationException>().Where(e => e.Message.Equals("Error loading discovery document: Error connecting to https://authority/.well-known/openid-configuration: not found"));
}

[Fact]
public void Error404_while_loading_discovery_policy_authority_document_should_throw()
{
var options = new OidcClientOptions
{
Authority = "https://authority",
Policy = new Policy
{
Discovery = new Client.DiscoveryPolicy
{
Authority = "https://diffauthority",
ValidateIssuerName = false
}
},
BackchannelHandler = new NetworkHandler(HttpStatusCode.NotFound, "not found")
};

var client = new OidcClient(options);

Func<Task> act = async () => { await client.EnsureProviderInformationAsync(CancellationToken.None); };

act.Should().Throw<InvalidOperationException>().Where(e => e.Message.Equals("Error loading discovery document: Error connecting to https://diffauthority/.well-known/openid-configuration: not found"));
}
}
}

0 comments on commit d34be27

Please sign in to comment.