mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-09 15:19:10 +02:00
test: acknowledge oauth in-memory storage warnings
add pytest.warns assertions for remaining OAuth tests that trigger the in-memory token storage warning in test_client.py and test_mcp_config.py 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
c73b19eaaf
commit
46da3fa2bd
2 changed files with 40 additions and 9 deletions
|
|
@ -968,26 +968,52 @@ class TestAuth:
|
|||
Client(transport=StdioTransport("echo", ["hello"]), auth="oauth")
|
||||
|
||||
def test_oauth_literal_sets_up_oauth_shttp(self):
|
||||
client = Client(
|
||||
transport=StreamableHttpTransport("http://localhost:8000"), auth="oauth"
|
||||
)
|
||||
# Expect warning about in-memory token storage
|
||||
with pytest.warns(
|
||||
UserWarning,
|
||||
match="Using in-memory token storage is not recommended for production use",
|
||||
):
|
||||
client = Client(
|
||||
transport=StreamableHttpTransport("http://localhost:8000"), auth="oauth"
|
||||
)
|
||||
assert isinstance(client.transport, StreamableHttpTransport)
|
||||
assert isinstance(client.transport.auth, OAuthClientProvider)
|
||||
|
||||
def test_oauth_literal_pass_direct_to_transport(self):
|
||||
client = Client(
|
||||
transport=StreamableHttpTransport("http://localhost:8000", auth="oauth"),
|
||||
)
|
||||
# Expect warning about in-memory token storage
|
||||
with pytest.warns(
|
||||
UserWarning,
|
||||
match="Using in-memory token storage is not recommended for production use",
|
||||
):
|
||||
client = Client(
|
||||
transport=StreamableHttpTransport(
|
||||
"http://localhost:8000", auth="oauth"
|
||||
),
|
||||
)
|
||||
assert isinstance(client.transport, StreamableHttpTransport)
|
||||
assert isinstance(client.transport.auth, OAuthClientProvider)
|
||||
|
||||
def test_oauth_literal_sets_up_oauth_sse(self):
|
||||
client = Client(transport=SSETransport("http://localhost:8000"), auth="oauth")
|
||||
# Expect warning about in-memory token storage
|
||||
with pytest.warns(
|
||||
UserWarning,
|
||||
match="Using in-memory token storage is not recommended for production use",
|
||||
):
|
||||
client = Client(
|
||||
transport=SSETransport("http://localhost:8000"), auth="oauth"
|
||||
)
|
||||
assert isinstance(client.transport, SSETransport)
|
||||
assert isinstance(client.transport.auth, OAuthClientProvider)
|
||||
|
||||
def test_oauth_literal_pass_direct_to_transport_sse(self):
|
||||
client = Client(transport=SSETransport("http://localhost:8000", auth="oauth"))
|
||||
# Expect warning about in-memory token storage
|
||||
with pytest.warns(
|
||||
UserWarning,
|
||||
match="Using in-memory token storage is not recommended for production use",
|
||||
):
|
||||
client = Client(
|
||||
transport=SSETransport("http://localhost:8000", auth="oauth")
|
||||
)
|
||||
assert isinstance(client.transport, SSETransport)
|
||||
assert isinstance(client.transport.auth, OAuthClientProvider)
|
||||
|
||||
|
|
|
|||
|
|
@ -461,7 +461,12 @@ async def test_remote_config_with_oauth_literal():
|
|||
}
|
||||
}
|
||||
}
|
||||
client = Client(config)
|
||||
# Expect warning about in-memory token storage
|
||||
with pytest.warns(
|
||||
UserWarning,
|
||||
match="Using in-memory token storage is not recommended for production use",
|
||||
):
|
||||
client = Client(config)
|
||||
assert isinstance(client.transport.transport, StreamableHttpTransport)
|
||||
assert isinstance(client.transport.transport.auth, OAuthClientProvider)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue