Skip to content

fix: use JWT-shaped bearer tokens in A2A request context tests - #7331

Merged
brian-hussey merged 3 commits into
mainfrom
fix-a2a-jsonrpc-test-tokens
Oct 23, 2026
Merged

brian-hussey merged 3 commits into
mainfrom
fix-a2a-jsonrpc-test-tokens

Conversation

@jonpspri

Copy link
Copy Markdown
Collaborator

Summary

Three tests in TestRequestContextBearerTokenExtraction failed with assert None == '***REMOVED***'.

A secret scrub replaced the test tokens with the literal ***REMOVED***. _is_jwt_token() rejects tokens that lack three base64url segments, so _extract_a2a_request_context dropped the bearer token and returned None.

Changes

  • Add a module-level JWT_SHAPED_TOKEN constant in tests/unit/mcpgateway/test_a2a_jsonrpc_passthrough.py.
  • Build it at runtime from three meaningless base64url segments. The segments encode the words "header", "payload" and "sig" and carry no claims or secret.
  • Replace the five ***REMOVED*** placeholders with the constant.
  • Remove the # pragma: allowlist secret comments, which no longer apply.

No production code changes.

Replace the scrubbed ***REMOVED*** placeholders with a JWT-shaped constant.
_is_jwt_token() drops opaque tokens, so three tests received None.
Build the token at runtime from three meaningless base64url segments.

Signed-off-by: Jonathan Springer <jps@s390x.com>

@prakhar-singh1928 prakhar-singh1928 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Encode the header, payload and sig placeholder words at runtime.
Shorten the explanatory comment.

Signed-off-by: Jonathan Springer <jps@s390x.com>

@prakhar-singh1928 prakhar-singh1928 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

brian-hussey
brian-hussey previously approved these changes Oct 23, 2026

@brian-hussey brian-hussey left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Lang-Akshay
Lang-Akshay previously approved these changes Oct 23, 2026

@Lang-Akshay Lang-Akshay left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM ✅

@Lang-Akshay
Lang-Akshay added this pull request to the merge queue Oct 23, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 23, 2026
@Lang-Akshay
Lang-Akshay added this pull request to the merge queue Oct 23, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 23, 2026
Signed-off-by: Jonathan Springer <jps@s390x.com>

@Lang-Akshay Lang-Akshay left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM ✅

@brian-hussey brian-hussey left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@brian-hussey
brian-hussey added this pull request to the merge queue Oct 23, 2026
Merged via the queue into main with commit 85dabf0 Oct 23, 2026
35 checks passed
@brian-hussey
brian-hussey deleted the fix-a2a-jsonrpc-test-tokens branch October 23, 2026 16:13
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.

4 participants