Skip to content

Commit 35e98ac

Browse files
authored
Merge pull request #768 from tisnik/lcore-740-type-hints-for-authentication-tests
LCORE-740: type hints for authentication tests
2 parents 8d49513 + f674438 commit 35e98ac

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

tests/unit/authentication/test_jwk_token.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ def another_single_key_set() -> list[dict[str, Any]]:
6161

6262
@pytest.fixture
6363
def valid_token(
64-
single_key_set: list[dict[str, Any]], token_header: str, token_payload: str
64+
single_key_set: list[dict[str, Any]],
65+
token_header: dict[str, Any],
66+
token_payload: dict[str, Any],
6567
) -> str:
6668
"""A token that is valid and signed with the signing keys."""
6769
jwt_instance = JsonWebToken(algorithms=["RS256"])
@@ -207,7 +209,9 @@ async def test_valid(
207209

208210
@pytest.fixture
209211
def expired_token(
210-
single_key_set: list[dict[str, Any]], token_header: dict, token_payload: dict
212+
single_key_set: list[dict[str, Any]],
213+
token_header: dict[str, Any],
214+
token_payload: dict[str, Any],
211215
) -> str:
212216
"""An well-signed yet expired token."""
213217
jwt_instance = JsonWebToken(algorithms=["RS256"])
@@ -238,8 +242,8 @@ async def test_expired(
238242
@pytest.fixture
239243
def invalid_token(
240244
another_single_key_set: list[dict[str, Any]],
241-
token_header: dict,
242-
token_payload: dict,
245+
token_header: dict[str, Any],
246+
token_payload: dict[str, Any],
243247
) -> str:
244248
"""A token that is signed with different keys than the signing keys."""
245249
jwt_instance = JsonWebToken(algorithms=["RS256"])
@@ -268,7 +272,7 @@ async def test_invalid(
268272
async def test_no_auth_header(
269273
default_jwk_configuration: JwkConfiguration,
270274
mocked_signing_keys_server: Any,
271-
no_token_request: str,
275+
no_token_request: Request,
272276
) -> None:
273277
"""Test with no Authorization header."""
274278
_ = mocked_signing_keys_server
@@ -286,9 +290,9 @@ async def test_no_auth_header(
286290

287291

288292
async def test_no_bearer(
289-
default_jwk_configuration: JwtConfiguration,
293+
default_jwk_configuration: JwkConfiguration,
290294
mocked_signing_keys_server: Any,
291-
not_bearer_token_request: str,
295+
not_bearer_token_request: Request,
292296
) -> None:
293297
"""Test with Authorization header that does not start with Bearer."""
294298
_ = mocked_signing_keys_server
@@ -374,7 +378,9 @@ async def test_no_username(
374378

375379
@pytest.fixture
376380
def custom_claims_token(
377-
single_key_set: list[dict[str, Any]], token_payload: dict, token_header: dict
381+
single_key_set: list[dict[str, Any]],
382+
token_payload: dict[str, Any],
383+
token_header: dict[str, Any],
378384
) -> str:
379385
"""Token with custom claims."""
380386
jwt_instance = JsonWebToken(algorithms=["RS256"])

tests/unit/authentication/test_k8s.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def __init__(
7777
username: Optional[str] = None,
7878
uid: Optional[str] = None,
7979
groups: Optional[list[str]] = None,
80-
):
80+
) -> None:
8181
"""Init function."""
8282
self.status = MockK8sResponseStatus(
8383
authenticated, allowed, username, uid, groups

0 commit comments

Comments
 (0)