Skip to content

test: pin down CLI login token lifecycle and URL generation#47

Merged
turegjorup merged 4 commits into
developfrom
test/mutation-cli-login
Jun 11, 2026
Merged

test: pin down CLI login token lifecycle and URL generation#47
turegjorup merged 4 commits into
developfrom
test/mutation-cli-login

Conversation

@turegjorup

Copy link
Copy Markdown
Contributor

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.php and src/Command/UserLoginCommand.php (5 escaped mutants, two of them security-adjacent).

Features Added

  • testThrowExceptionIfTokenDoesNotExist now expects TokenNotFoundException specifically — previously it caught the marker interface, so removing the throw still passed because the subsequent CacheException also matched
  • testBothCacheEntriesAreRemovedAfterUse: asserts the reverse username→token entry is deleted on redemption (single-use guarantee), and that a fresh, redeemable token is minted afterwards
  • testEncodeKeyPrependsNamespace: asserts the exact namespaced encoding — the existing encode/decode roundtrip is structurally blind to losing or reordering the cache-key collision guard
  • testExecutePassesTokenAndRouteToUrlGenerator: mocks the URL generator with argument expectations, so dropping the loginToken parameter from the generated login URL now fails

Files Changed

  • tests/Util/CliLoginHelperTest.php - token lifecycle + encoding tests
  • tests/Command/UserLoginCommandTest.php - URL generation argument expectations
  • CHANGELOG.md - Unreleased bullet

Test Plan

  • vendor/bin/phpunit — 82 tests, 177 assertions, green
  • vendor/bin/infection --filter=src/Util,src/Command — 35/35 mutants killed (was 30/35)
  • PHPStan max level + php-cs-fixer — clean

🤖 Generated with Claude Code

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-commenter

codecov-commenter commented Jun 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (a2fd951) to head (cab60df).

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           
Flag Coverage Δ
unittests 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@turegjorup turegjorup self-assigned this Jun 11, 2026
turegjorup and others added 3 commits June 11, 2026 10:22
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@turegjorup turegjorup merged commit 52eee94 into develop Jun 11, 2026
16 checks passed
@turegjorup turegjorup deleted the test/mutation-cli-login branch June 11, 2026 08:31
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