Skip to content

Use the factory clock in token expiry checks - #8793

Merged
quexten merged 1 commit into
mainfrom
fix-2fa-remember-test-clock
Nov 2, 2026
Merged

quexten merged 1 commit into
mainfrom
fix-2fa-remember-test-clock

Conversation

@quexten

@quexten quexten commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

🎟️ Tracking

No ticket.

📔 Objective

TwoFactorRememberTokenableFactory stamps ExpirationDate from an injected TimeProvider, but ExpiringTokenable.IsExpired reads DateTime.UtcNow. TwoFactorRememberTokenableFactoryTests fixes the clock at 2026-10-02, so its 30 day token expired on 2026-11-01 and the test has failed on every PR since. Introduced in #8427.

ExpiringTokenable now has an internal TimeProvider (system clock by default, not serialized). The factory sets it to its own clock on the tokens it creates. Deserialized tokens still use the system clock.

@quexten
quexten force-pushed the fix-2fa-remember-test-clock branch 2 times, most recently from 818d885 to f49d2ae Compare November 2, 2026 12:16
@quexten quexten changed the title Fix time-dependent two-factor remember test Use the factory clock in token expiry checks Nov 2, 2026
The remember token factory stamps ExpirationDate from an injected
TimeProvider, but ExpiringTokenable.IsExpired read DateTime.UtcNow.
A token created with a fixed test clock was judged against the real
one, so the factory test started failing on 2026-11-01 when its
30 day token passed its expiry.

Let a factory pass its clock to the token it creates. Tokens that are
deserialized keep using the system clock.
@quexten
quexten force-pushed the fix-2fa-remember-test-clock branch from f49d2ae to cb804d7 Compare November 2, 2026 12:19
@quexten
quexten marked this pull request as ready for review November 2, 2026 12:21
@quexten
quexten requested a review from a team as a code owner November 2, 2026 12:21
@quexten
quexten requested a review from enmande November 2, 2026 12:21
@quexten quexten added the t:bugfix Change Type - Bugfix label Nov 2, 2026
@quexten
quexten enabled auto-merge (squash) November 2, 2026 12:22
@quexten
quexten merged commit 9e94b63 into main Nov 2, 2026
51 of 55 checks passed
@quexten
quexten deleted the fix-2fa-remember-test-clock branch November 2, 2026 13:02
@codecov

codecov Bot commented Nov 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.25%. Comparing base (2028f0a) to head (cb804d7).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8793      +/-   ##
==========================================
- Coverage   68.26%   68.25%   -0.01%     
==========================================
  Files        2742     2742              
  Lines      117709   117711       +2     
  Branches    10692    10692              
==========================================
- Hits        80353    80349       -4     
- Misses      34816    34823       +7     
+ Partials     2540     2539       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t:bugfix Change Type - Bugfix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants