Skip to content

UTS: align token-expiry tests with RSA4a2/RSA4b (local detection is optional) - #540

Open
owenpearson wants to merge 1 commit into
mainfrom
fix/uts-token-expiry-detection
Open

owenpearson wants to merge 1 commit into
mainfrom
fix/uts-token-expiry-detection

Conversation

@owenpearson

Copy link
Copy Markdown
Member

Ruling: option (a) — fix the tests, not the spec

Issue #529 documents two REST unit tests that require the client to detect token expiry locally before issuing a request. Per features.md, RSA4b1 licenses this only as an option, and only when a server-time offset has been persisted (RSA10k). A spec-compliant client that declines the option fails both tests.

The normative ruling recorded on the issue is option (a): loosen the tests so they do not require local detection. No features.md change and no SDK change is required.

What changed

uts/rest/unit/auth/auth_scheme.mdrest/unit/RSA4a2/expired-token-no-renewal-0

  • Mock now returns 401 with an Ably token-error body (code: 40142) instead of 200, so the client reaches 40171 via RSA4a2 (server token error + no means of renewal).
  • Removed ASSERT captured_requests.length == 0 — with a real 401 the client legitimately makes a request. Kept ASSERT error.code == 40171.

uts/rest/unit/auth/token_renewal.md — retargeted RSA4b1/preemptive-renewal-0RSA4b/renewal-on-token-error-0

  • Rewrote the mock so the expired token gets a 401 token error and the retry with the renewed token gets 200.
  • Relabelled section heading and Test ID to rest/unit/RSA4b/renewal-on-token-error-0, since it now tests RSA4b (renewal on server 401), not RSA4b1's optional pre-emptive path. callback_count == 2 and a successful Bearer fresh-token history request hold via RSA4b.

uts/rest/unit/auth/token_renewal.md — new RSA4b1/preemptive-renewal-with-offset-0

  • Restores RSA4b1 coverage for the optional pre-emptive path. Sets queryTime: true, stubs /time (returns an array [server_time_ms] per protocol) so the client persists a server-time offset per RSA10k, then asserts the client renews pre-emptively — callback called twice, one history request with Bearer fresh-token, and the expired token never reaching the API.
  • Because RSA4b1 is optional, the test carries a note that SDKs which decline the optional detection should skip it (they are covered by the RSA4b renewal-on-401 test instead).

Notes

Closes #529

🤖 Generated with Claude Code

Local token-expiry detection (RSA4b1) is optional and offset-gated, so tests must
not require it. Rewrites expired-token-no-renewal to reach 40171 via a server token
error (RSA4a2), retargets the pre-emptive-renewal test at RSA4b (renewal on 401),
and adds a queryTime-gated RSA4b1 test for the optional pre-emptive path.

Closes #529

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

This branch was successfully deployed

1 active deployment
staging/pull/540 e01d1ffc Deployed Sep 22, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant