Repository navigation
Bot token lifetime test uses a fixed clock - #788
Merged
Merged
Conversation
The response reports the time left after the bot lookup. Hold the happy-path clock still so crossing a second cannot change its exact lifetime assertion. Signed-off-by: zlareb1 <[email protected]>
7 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changelog category (leave one):
Changelog entry
The bot token lifetime test holds its clock still while asserting an exact response lifetime.
Why
The token endpoint records the start time before reading the bot, then reports the time left when building the response. Crossing a whole second during the lookup returns 3,599 seconds while the token claims still span 3,600 seconds. The happy-path test expects exactly 3,600 response seconds without controlling that clock.
Scope and risk
One unit test uses the existing
ManualClockseam. Its response, scope and token-claim assertions stay unchanged. The adjacent slow-lookup test still advances time and checks the remaining lifetime. Authentication runtime and token lifetimes are unchanged.Compatibility, rollout and rollback
Wire changes and operator steps: none. Reverting restores the wall-clock-dependent test and changes no stored data.
Tests
git diff --checkpass..venv/bin/python -m pytest tests/unit/test_machines.py -q -n 0 -k 'a_bots_key_gets_an_hour_long_scoped_token or a_slow_bot_lookup_does_not_lengthen_its_token'.AI assistance in the code
AI-generated: Codex. Checked both clock reads, unchanged assertions and the controlled boundary result.
I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist