mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-09 15:19:10 +02:00
Assert v2 MCPError shape for unauthorized GitHub OAuth access
This commit is contained in:
parent
4985788f57
commit
d267d90e82
1 changed files with 7 additions and 3 deletions
|
|
@ -337,8 +337,12 @@ async def test_github_oauth_server_metadata(github_server: str):
|
|||
|
||||
|
||||
async def test_github_oauth_unauthorized_access(github_server: str):
|
||||
"""Test that unauthenticated requests are rejected."""
|
||||
import httpx
|
||||
"""Test that unauthenticated requests are rejected.
|
||||
|
||||
SDK v2 surfaces the server's 401 as an MCPError ("Server returned an error
|
||||
response") rather than re-raising the raw httpx.HTTPStatusError.
|
||||
"""
|
||||
from mcp.shared.exceptions import MCPError
|
||||
|
||||
from fastmcp.client.transports import StreamableHttpTransport
|
||||
|
||||
|
|
@ -346,7 +350,7 @@ async def test_github_oauth_unauthorized_access(github_server: str):
|
|||
unauthorized_client = Client(transport=StreamableHttpTransport(github_server))
|
||||
|
||||
# Attempt to connect without authentication should fail
|
||||
with pytest.raises(httpx.HTTPStatusError, match="401 Unauthorized"):
|
||||
with pytest.raises(MCPError, match="error response"):
|
||||
async with unauthorized_client:
|
||||
pass
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue