mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-23 22:14:18 +02:00
Fix auth test to expect None instead of AuthorizationError
This commit is contained in:
parent
6dd1de62e4
commit
3d98862995
1 changed files with 5 additions and 7 deletions
|
|
@ -301,19 +301,17 @@ class TestToolLevelAuth:
|
|||
finally:
|
||||
auth_context_var.reset(tok)
|
||||
|
||||
async def test_get_tool_raises_without_auth(self):
|
||||
"""get_tool() checks auth and raises AuthorizationError for unauthorized tools."""
|
||||
from fastmcp.exceptions import AuthorizationError
|
||||
|
||||
async def test_get_tool_returns_none_without_auth(self):
|
||||
"""get_tool() returns None for unauthorized tools (consistent with list filtering)."""
|
||||
mcp = FastMCP()
|
||||
|
||||
@mcp.tool(auth=require_auth)
|
||||
def protected_tool() -> str:
|
||||
return "protected"
|
||||
|
||||
# get_tool() raises AuthorizationError for unauthorized tools
|
||||
with pytest.raises(AuthorizationError, match="Unauthorized access to tool"):
|
||||
await mcp.get_tool("protected_tool")
|
||||
# get_tool() returns None for unauthorized tools
|
||||
tool = await mcp.get_tool("protected_tool")
|
||||
assert tool is None
|
||||
|
||||
async def test_get_tool_returns_tool_with_auth(self):
|
||||
mcp = FastMCP()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue