mirror of
https://github.com/aljazceru/mcp-python-sdk.git
synced 2025-12-18 22:44:20 +01:00
Fix auth tests and ruff format (#818)
This commit is contained in:
@@ -154,7 +154,6 @@ class ClientSessionGroup:
|
||||
for exit_stack in self._session_exit_stacks.values():
|
||||
tg.start_soon(exit_stack.aclose)
|
||||
|
||||
|
||||
@property
|
||||
def sessions(self) -> list[mcp.ClientSession]:
|
||||
"""Returns the list of sessions being managed."""
|
||||
|
||||
@@ -153,12 +153,8 @@ def build_metadata(
|
||||
client_registration_options: ClientRegistrationOptions,
|
||||
revocation_options: RevocationOptions,
|
||||
) -> OAuthMetadata:
|
||||
authorization_url = AnyHttpUrl(
|
||||
str(issuer_url).rstrip("/") + AUTHORIZATION_PATH
|
||||
)
|
||||
token_url = AnyHttpUrl(
|
||||
str(issuer_url).rstrip("/") + TOKEN_PATH
|
||||
)
|
||||
authorization_url = AnyHttpUrl(str(issuer_url).rstrip("/") + AUTHORIZATION_PATH)
|
||||
token_url = AnyHttpUrl(str(issuer_url).rstrip("/") + TOKEN_PATH)
|
||||
|
||||
# Create metadata
|
||||
metadata = OAuthMetadata(
|
||||
|
||||
@@ -359,7 +359,8 @@ class TestOAuthClientProvider:
|
||||
|
||||
assert oauth_provider._has_valid_token()
|
||||
|
||||
def test_has_valid_token_expired(self, oauth_provider, oauth_token):
|
||||
@pytest.mark.anyio
|
||||
async def test_has_valid_token_expired(self, oauth_provider, oauth_token):
|
||||
"""Test token validation with expired token."""
|
||||
oauth_provider._current_tokens = oauth_token
|
||||
oauth_provider._token_expiry_time = time.time() - 3600 # Past expiry
|
||||
@@ -810,7 +811,8 @@ class TestOAuthClientProvider:
|
||||
# No scope should be set since client metadata doesn't have explicit scope
|
||||
assert "scope" not in auth_params
|
||||
|
||||
def test_scope_priority_no_scope(self, oauth_provider, oauth_client_info):
|
||||
@pytest.mark.anyio
|
||||
async def test_scope_priority_no_scope(self, oauth_provider, oauth_client_info):
|
||||
"""Test that no scope parameter is set when no scopes specified."""
|
||||
oauth_provider.client_metadata.scope = None
|
||||
oauth_provider._client_info = oauth_client_info
|
||||
|
||||
Reference in New Issue
Block a user