Improvements to dynamic client registration (#609)
* Add a delegate for handling the dynamic client registration response. * Support passing an initial access token for dynamic client registration.
This commit is contained in:
parent
2fa658e439
commit
f9129f5b28
2 changed files with 102 additions and 28 deletions
|
|
@ -140,6 +140,8 @@ public class AuthEventTests : KestrelInMemoryTest, IAsyncDisposable
|
|||
|
||||
await app.StartAsync(TestContext.Current.CancellationToken);
|
||||
|
||||
DynamicClientRegistrationResponse? dcrResponse = null;
|
||||
|
||||
await using var transport = new SseClientTransport(
|
||||
new()
|
||||
{
|
||||
|
|
@ -148,9 +150,17 @@ public class AuthEventTests : KestrelInMemoryTest, IAsyncDisposable
|
|||
{
|
||||
RedirectUri = new Uri("http://localhost:1179/callback"),
|
||||
AuthorizationRedirectDelegate = HandleAuthorizationUrlAsync,
|
||||
ClientName = "Test MCP Client",
|
||||
ClientUri = new Uri("https://example.com"),
|
||||
Scopes = ["mcp:tools"],
|
||||
DynamicClientRegistration = new()
|
||||
{
|
||||
ClientName = "Test MCP Client",
|
||||
ClientUri = new Uri("https://example.com"),
|
||||
ResponseDelegate = (response, cancellationToken) =>
|
||||
{
|
||||
dcrResponse = response;
|
||||
return Task.CompletedTask;
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
HttpClient,
|
||||
|
|
@ -162,6 +172,10 @@ public class AuthEventTests : KestrelInMemoryTest, IAsyncDisposable
|
|||
loggerFactory: LoggerFactory,
|
||||
cancellationToken: TestContext.Current.CancellationToken
|
||||
);
|
||||
|
||||
Assert.NotNull(dcrResponse);
|
||||
Assert.False(string.IsNullOrEmpty(dcrResponse.ClientId));
|
||||
Assert.False(string.IsNullOrEmpty(dcrResponse.ClientSecret));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -181,9 +181,12 @@ public class AuthTests : KestrelInMemoryTest, IAsyncDisposable
|
|||
{
|
||||
RedirectUri = new Uri("http://localhost:1179/callback"),
|
||||
AuthorizationRedirectDelegate = HandleAuthorizationUrlAsync,
|
||||
ClientName = "Test MCP Client",
|
||||
ClientUri = new Uri("https://example.com"),
|
||||
Scopes = ["mcp:tools"]
|
||||
Scopes = ["mcp:tools"],
|
||||
DynamicClientRegistration = new()
|
||||
{
|
||||
ClientName = "Test MCP Client",
|
||||
ClientUri = new Uri("https://example.com"),
|
||||
},
|
||||
},
|
||||
}, HttpClient, LoggerFactory);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue