Skip to content

Commit 32a056d

Browse files
committed
test(client/auth): make the expiry-discard test's storage assertions non-vacuous
MockTokenStorage stores tokens by reference and _initialize loads that same object into context.current_tokens, so the discard's in-place refresh-token trim reached the stored object even without the set_tokens persistence call - the storage-side assertions in test_expired_stored_registration_is_discarded_and_the_flow_re_registers passed vacuously. Re-seed storage with a distinct copy after the load so those assertions pass only if the discard actually persists the trimmed tokens (verified by mutation: deleting the set_tokens call now fails the test).
1 parent e53e526 commit 32a056d

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

tests/client/test_auth.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3353,6 +3353,12 @@ async def test_expired_stored_registration_is_discarded_and_the_flow_re_register
33533353
assert oauth_provider.context.current_tokens is not None
33543354
assert request.headers["Authorization"] == f"Bearer {valid_tokens.access_token}"
33553355

3356+
# `MockTokenStorage` stores by reference and `_initialize` loaded that same object into
3357+
# `context.current_tokens`, so the discard's in-place trim would reach the stored object
3358+
# even if it never persisted. Re-seed storage with a distinct copy so the storage-side
3359+
# assertions below pass only if the discard actually calls `set_tokens`.
3360+
await mock_storage.set_tokens(valid_tokens.model_copy())
3361+
33563362
# Server rejects the stale token: the 401 flow re-registers instead of reusing the record.
33573363
response_401 = httpx2.Response(401, request=request)
33583364
prm_req = await auth_flow.asend(response_401)

0 commit comments

Comments
 (0)