Skip to content

Fix auth tests and ruff format #818

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/mcp/client/session_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ async def __aexit__(
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."""
Expand Down
8 changes: 2 additions & 6 deletions src/mcp/server/auth/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 4 additions & 2 deletions tests/client/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,8 @@ def test_has_valid_token_valid(self, oauth_provider, oauth_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."""
oauth_provider._current_tokens = oauth_token
oauth_provider._token_expiry_time = time.time() - 3600 # Past expiry
Expand Down Expand Up @@ -810,7 +811,8 @@ def test_scope_priority_no_client_metadata_scope(
# 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
Expand Down
Loading