Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

Commit

Permalink
Merge pull request #106 from DuendeSoftware/joe/error-message-simplif…
Browse files Browse the repository at this point in the history
…ication

Remove unknown client error message
  • Loading branch information
brockallen authored May 10, 2024
2 parents f55ae98 + 49a9567 commit 42fd54f
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,10 @@ public virtual async Task<ClientCredentialsToken> RequestToken(
{
var client = _options.Get(clientName);

var clientIdMissing = string.IsNullOrWhiteSpace(client.ClientId);
var tokenEndpointMissing = string.IsNullOrWhiteSpace(client.TokenEndpoint);

// If both are missing, we infer that this client is just not set up at all
if (clientIdMissing && tokenEndpointMissing)
{
throw new InvalidOperationException($"Unknown client {clientName}");
}

// Otherwise, if we don't have a specific value that is required, throw an appropriate exception
if (string.IsNullOrWhiteSpace(client.ClientId))
{
throw new InvalidOperationException($"No ClientId configured for client {clientName}");
}

if (string.IsNullOrWhiteSpace(client.TokenEndpoint))
{
throw new InvalidOperationException($"No TokenEndpoint configured for client {clientName}");
Expand Down
2 changes: 1 addition & 1 deletion test/Tests/ClientTokenManagementTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public async Task Unknown_client_should_throw_exception()
var action = async () => await sut.GetAccessTokenAsync("unknown");

(await Should.ThrowAsync<InvalidOperationException>(action))
.Message.ShouldBe("Unknown client unknown");
.Message.ShouldBe("No ClientId configured for client unknown");
}

[Fact]
Expand Down

0 comments on commit 42fd54f

Please sign in to comment.