test: pin down CLI login token lifecycle and URL generation#47
Merged
Conversation
Mutation testing exposed four gaps in the CLI login flow tests: removing the TokenNotFoundException throw passed because the test caught the broad marker interface (a later CacheException also matched); the reverse username=>token cache entry could linger after redemption unnoticed; encodeKey was only tested via roundtrip, which is blind to dropping or reordering the collision-guard namespace; and the login URL was built from a stub that ignored its arguments, so the loginToken parameter could be dropped. Kills all 5 escaped mutants in src/Util and src/Command. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #47 +/- ##
===========================================
Coverage 100.00% 100.00%
Complexity 62 62
===========================================
Files 9 9
Lines 282 282
===========================================
Hits 282 282
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…login # Conflicts: # CHANGELOG.md
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Summary
Third of four scoped follow-ups to #44 killing surviving mutants to push the mutation score above 90%. This PR covers the CLI login flow:
src/Util/CliLoginHelper.phpandsrc/Command/UserLoginCommand.php(5 escaped mutants, two of them security-adjacent).Features Added
testThrowExceptionIfTokenDoesNotExistnow expectsTokenNotFoundExceptionspecifically — previously it caught the marker interface, so removing the throw still passed because the subsequentCacheExceptionalso matchedtestBothCacheEntriesAreRemovedAfterUse: asserts the reverse username→token entry is deleted on redemption (single-use guarantee), and that a fresh, redeemable token is minted afterwardstestEncodeKeyPrependsNamespace: asserts the exact namespaced encoding — the existing encode/decode roundtrip is structurally blind to losing or reordering the cache-key collision guardtestExecutePassesTokenAndRouteToUrlGenerator: mocks the URL generator with argument expectations, so dropping theloginTokenparameter from the generated login URL now failsFiles Changed
tests/Util/CliLoginHelperTest.php- token lifecycle + encoding teststests/Command/UserLoginCommandTest.php- URL generation argument expectationsCHANGELOG.md- Unreleased bulletTest Plan
vendor/bin/phpunit— 82 tests, 177 assertions, greenvendor/bin/infection --filter=src/Util,src/Command— 35/35 mutants killed (was 30/35)🤖 Generated with Claude Code