Skip to content

test(auth): cover non-401 token errors and expiry boundaries (backport #432 to stable/10) - #535

Merged
jwulf merged 1 commit into
stable/10from
backport-432-to-stable/10
Nov 30, 2026
Merged

jwulf merged 1 commit into
stable/10from
backport-432-to-stable/10

Conversation

@camunda-sdk-automation

Copy link
Copy Markdown
Contributor

Backport of #432 to stable/10.

Generated code is restored from stable/10 and regenerated by the Backport workflow in a separate chore(gen) commit.

relates to #425 #427

* 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)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The OAuth regression-test backport has no active review issues.

No open issues 🎉

What changed in this PR

Backports #432 to stable/10, extending OAuth authentication regression coverage for the gaps identified in #427 without changing production behavior.

Changes:

  • Covers non-401 endpoint failures, transport errors, and malformed token responses for both sync and async providers.
  • Uses an injected clock to verify token expiry, skew clamping, and 401 cooldown behavior deterministically.
  • Checks valid and expired disk-cache entries, including removal when token refetch fails.
File Description
tests/​acceptance/​test_pluggable_auth.py Adds shared test helpers and 26 cases covering OAuth failures, caching, and timing boundaries.

Review effort: Balanced

@jwulf

jwulf commented Nov 30, 2026

Copy link
Copy Markdown
Member

🤖 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.

@jwulf

jwulf commented Nov 30, 2026

Copy link
Copy Markdown
Member

nano-ack: issuecomment-7284899372 — Acknowledged: informational attribution note only; no code change required.

@jwulf
jwulf merged commit 74ee138 into stable/10 Nov 30, 2026
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants