Fix auth tests and ruff format (#818)

This commit is contained in:
ihrpr
2025-05-27 17:00:01 +01:00
committed by GitHub
parent 6e418e62f9
commit 9dad26620f
3 changed files with 6 additions and 9 deletions

View File

@@ -154,7 +154,6 @@ class ClientSessionGroup:
for exit_stack in self._session_exit_stacks.values(): for exit_stack in self._session_exit_stacks.values():
tg.start_soon(exit_stack.aclose) tg.start_soon(exit_stack.aclose)
@property @property
def sessions(self) -> list[mcp.ClientSession]: def sessions(self) -> list[mcp.ClientSession]:
"""Returns the list of sessions being managed.""" """Returns the list of sessions being managed."""

View File

@@ -153,12 +153,8 @@ def build_metadata(
client_registration_options: ClientRegistrationOptions, client_registration_options: ClientRegistrationOptions,
revocation_options: RevocationOptions, revocation_options: RevocationOptions,
) -> OAuthMetadata: ) -> OAuthMetadata:
authorization_url = AnyHttpUrl( authorization_url = AnyHttpUrl(str(issuer_url).rstrip("/") + AUTHORIZATION_PATH)
str(issuer_url).rstrip("/") + AUTHORIZATION_PATH token_url = AnyHttpUrl(str(issuer_url).rstrip("/") + TOKEN_PATH)
)
token_url = AnyHttpUrl(
str(issuer_url).rstrip("/") + TOKEN_PATH
)
# Create metadata # Create metadata
metadata = OAuthMetadata( metadata = OAuthMetadata(

View File

@@ -359,7 +359,8 @@ class TestOAuthClientProvider:
assert oauth_provider._has_valid_token() 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.""" """Test token validation with expired token."""
oauth_provider._current_tokens = oauth_token oauth_provider._current_tokens = oauth_token
oauth_provider._token_expiry_time = time.time() - 3600 # Past expiry 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 # No scope should be set since client metadata doesn't have explicit scope
assert "scope" not in auth_params 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.""" """Test that no scope parameter is set when no scopes specified."""
oauth_provider.client_metadata.scope = None oauth_provider.client_metadata.scope = None
oauth_provider._client_info = oauth_client_info oauth_provider._client_info = oauth_client_info