Skip to content

test(oauth): extend metadata discovery probe timeout - #1833

Open
jstar0 wants to merge 1 commit into
modelcontextprotocol:mainfrom
jstar0:fix/oauth-metadata-probe-timeout
Open

test(oauth): extend metadata discovery probe timeout#1833
jstar0 wants to merge 1 commit into
modelcontextprotocol:mainfrom
jstar0:fix/oauth-metadata-probe-timeout

Conversation

@jstar0

@jstar0 jstar0 commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #1806 by keeping OAuth metadata discovery from being cancelled by the five-second server/discover probe timeout in slow in-memory CI environments.

When the protected MCP endpoint returns 401, metadata discovery runs under the same probe cancellation token. A slow TLS/duplex-pipe handshake can therefore cancel GetAuthServerMetadataAsync before it finishes, producing a misleading metadata-discovery assertion failure.

Changes

  • Add a test-only OAuthTestBase.CreateMcpClientAsync helper that uses the shared 60-second test budget for DiscoverProbeTimeout.
  • Route the ASP.NET Core OAuth tests through that helper.
  • Apply the same probe budget to the standalone conformance client used by OAuth scenarios.
  • Production client defaults and OAuth behavior are unchanged.

Verification

  • dotnet test tests/ModelContextProtocol.AspNetCore.Tests/ModelContextProtocol.AspNetCore.Tests.csproj --framework net10.0 --configuration Release --no-restore --filter 'FullyQualifiedName~CannotAuthenticate_WithInvalidClientMetadataDocument|FullyQualifiedName~DcrRejection_PropagatesToConsumer_WithStatusBodyAndSentParameters' — 3 passed\n- dotnet test tests/ModelContextProtocol.AspNetCore.Tests/ModelContextProtocol.AspNetCore.Tests.csproj --framework net10.0 --configuration Release --no-restore --filter 'FullyQualifiedName~ModelContextProtocol.AspNetCore.Tests.OAuth' — 98 passed\n- git diff --check — passed\n\nThe net8.0/net9.0 variants were not runnable on this workstation because those runtimes are not installed; they remain covered by the repository CI matrix.

@jstar0

jstar0 commented Aug 21, 2026

Copy link
Copy Markdown
Contributor Author

Rechecked current head 4f90f109fb5fb6a23aeabea1533d1e54b3ad982e.

All reported hosted checks are green, including CodeQL, C# analysis, and the Ubuntu/macOS/Windows Debug and Release build jobs. The focused OAuth verification remains green locally (98 tests), and the change is limited to the test/conformance discovery-probe timeout path; production client defaults and OAuth behavior are unchanged.

This is ready for maintainer review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky on windows-latest: OAuth metadata fetch times out in in-memory tests (same class as #1701, not covered by #1702)

1 participant