test(mcp): assert platform-header probe test observes the 401 for an unknown caller

test_probe_receives_caller_platform_header_and_does_not_challenge had no assertion, which the test-quality gate counts as a new TQ001. Add a negative control showing a caller with a different platform header still gets the 401, so the test fails if the header stops reaching the probe.

Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>
This commit is contained in:
Pujitha Paladugu 2026-10-29 07:36:25 -07:00
parent 906339f2ee
commit c1ac75cbc7
No known key found for this signature in database

View file

@ -7280,6 +7280,18 @@ class TestTruePassthroughProbeForwardsCallerHeaders:
client_ip=None,
raw_headers={"X-Platform-User": "alice"},
)
with pytest.raises(HTTPException) as exc_info:
await server_module._raise_preemptive_401_for_unauthenticated_servers(
scope=self._scope(),
mcp_servers=[self.ALIAS],
oauth2_headers=None,
mcp_server_auth_headers=None,
user_api_key_auth=UserAPIKeyAuth(),
client_ip=None,
raw_headers={"X-Platform-User": "bob"},
)
assert exc_info.value.status_code == 401
@pytest.mark.asyncio
async def test_probe_never_forwards_authorization_via_extra_headers(self):