Repository navigation
test(auth): cover non-401 token errors and expiry boundaries (backport #432 to stable/9) - #536
Conversation
* test(auth): cover non-401 token errors and expiry boundaries The 401 path was well covered; nothing drove a 5xx, a transport error, or a 200 whose body cannot yield a token, and nothing ever moved the clock. So the raise_for_status branch, the "missing access_token or expires_in" branch, the skew calculation and the 401 cooldown were all unasserted in both providers. These add, for the sync and async providers: a 5xx and a transport error, each asserted to be retried rather than memoized and to leave no tarpit file behind, which is the distinction that matters for a non-401; five malformed 200 bodies, asserted to cache nothing in memory or on disk; and, driven through the injected clock so they are deterministic, reuse just before the skew-adjusted expiry and a refetch just after, the clamp that keeps a lifetime shorter than the skew from landing in the past, an expired file-cached entry replaced and unlinked even when the refetch fails, a still-valid entry served without a request, and the 401 cooldown on both sides of its boundary. Checked that they bite: memoizing every status, not only 401, fails the non-401 tests; removing the skew fails the expiry tests. Closes #427 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RcVhnekJQeXnMfPhs9pYda * chore(auth): pin the clamped expiry, and mirror the cases on the async provider From Copilot's review. The short-lifetime test asserted only that every call refetched, which removing max(0.0, ...) also satisfies -- an expiry ten seconds in the past looks identical from the outside. It now asserts the stored expiry equals the clock's current time, so the clamp the test is named after is what it checks; both sync and async fail against that mutant. The clamp and the three on-disk cache cases were sync-only, although the async provider has its own expiry calculation and its own cache loading. All four now have async counterparts. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RcVhnekJQeXnMfPhs9pYda --------- Co-authored-by: Claude <noreply@anthropic.com> (cherry picked from commit a2da089)
There was a problem hiding this comment.
🟡 Changes recommended
The tests import a clock module missing from stable/9, blocking pytest collection, and pass an unsupported clock argument to both OAuth provider constructors, causing all new cases to fail once the import is fixed.
2 open issues
What changed in this PR
Backports #432’s OAuth regression tests to stable/9, addressing the negative-case coverage gaps in #427 without changing production code.
Changes:
- Adds sync and async tests for non-401 endpoint failures, transport errors, and malformed token responses.
- Exercises token expiry, skew clamping, disk-cache handling, and 401 cooldowns using controlled time.
- Adds shared provider and response helpers for the new cases.
| File | Description |
|---|---|
tests/acceptance/test_pluggable_auth.py |
Adds 26 OAuth error and timing test cases with shared setup helpers. |
Review effort: Balanced
…ntime clock) Signed-off-by: Josh Wulf <josh.wulf@camunda.com>
|
🤖 The changes in this PR were produced by nano-agent, an autonomous agent. Commits are authored under the operator's own git identity when one is resolvable (the human running the fleet), so they can satisfy CLA/DCO requirements; this note records that the work was generated by the agent. |
|
nano-ack: issuecomment-7284922809 — acknowledged: this is the agent-attribution note, no code change required. |

Backport of #432 to
stable/9.Generated code is restored from
stable/9and regenerated by the Backport workflow in a separatechore(gen)commit.relates to #425 #427