mypy fixes

This commit is contained in:
marius-mather
2025-07-04 13:27:31 +10:00
parent 27f701b7c2
commit 3e81fc1663
3 changed files with 13 additions and 7 deletions
+2
View File
@@ -518,6 +518,8 @@ def decode_access_token(social: UserAuthnzToken, backend: OpenIdConnectAuth, **k
which should be handled by social_core.pipeline.social_auth.load_extra_data, so
this step should be placed after load_extra_data in the pipeline.
"""
if social.extra_data is None:
return {"access_token": None}
access_token_encoded = social.extra_data.get("access_token")
if access_token_encoded is None:
return {"access_token": None}
+3
View File
@@ -114,6 +114,7 @@ class AbstractTestCases:
container_name: ClassVar[str]
backend_config_file: ClassVar[str]
provider_name: ClassVar[str]
random_port: ClassVar[int]
saved_oauthlib_insecure_transport: ClassVar[bool]
@classmethod
@@ -421,6 +422,8 @@ class TestGalaxyOIDCLoginPSA(AbstractTestCases.BaseKeycloakIntegrationTestCase):
sa_session = self._app.model.session
user = sa_session.query(model.User).filter_by(email="gxyuser@galaxy.org").one()
social = next((s for s in user.social_auth if s.provider == "oidc"), None)
assert social is not None
extra_data = social.extra_data
assert extra_data is not None
assert "access_token_decoded" in extra_data
assert "realm_access" in extra_data["access_token_decoded"]
+8 -7
View File
@@ -7,6 +7,7 @@ from datetime import (
datetime,
timedelta,
)
from typing import Optional
from unittest.mock import MagicMock
import jwt
@@ -98,15 +99,15 @@ class AuthTokenData:
def create_access_token(
email: str = "user@example.com",
roles: list[str] = None,
roles: Optional[list[str]] = None,
iss: str = "https://issuer.example.com",
sub: str = None,
iat: int = None,
exp: int = None,
sub: Optional[str] = None,
iat: Optional[int] = None,
exp: Optional[int] = None,
aud: str = "https://audience.example.com",
scope: list[str] = None,
azp: str = None,
permissions: list[str] = None,
scope: Optional[list[str]] = None,
azp: Optional[str] = None,
permissions: Optional[list[str]] = None,
algorithm: str = "RS256",
public_key_id: str = "example-key",
) -> AuthTokenData: