Skip to content

Test that Token.sign forwards key_length - #6881

Open
renanmpimentel wants to merge 1 commit into
phoenixframework:mainfrom
renanmpimentel:test/token-sign-key-length
Open

renanmpimentel wants to merge 1 commit into
phoenixframework:mainfrom
renanmpimentel:test/token-sign-key-length

Conversation

@renanmpimentel

Copy link
Copy Markdown

Summary

Add a test that Phoenix.Token.sign/4 forwards :key_length to the key generator. It compares deterministic tokens made with lengths 16 and 32, verifies the 16-byte token with the matching option, and checks that the mismatched length is rejected.

Why

The documentation lists :key_length as a signing option, but the existing token tests compare only :key_iterations and :key_digest. The key defaults test explicitly uses the default length (32), so discarding :key_length in sign/4 leaves the entire existing suite green.

The regression was applied in an isolated worktree:

State Result
Existing suite + sign/4 discards :key_length 1,111 passed
New test + same regression Assertion fails: tokens for lengths 16 and 32 become identical
New test + correct production Passes

The permanent diff changes only test/phoenix/token_test.exs.

Verification

  • mix format --check-formatted test/phoenix/token_test.exs: passed
  • mix compile --warnings-as-errors: passed
  • mix test --warnings-as-errors: 1,112 passed, 33 excluded
  • git diff --check: passed

One earlier full run had a timing failure in the unrelated crashed channel propagates exit test (200 ms assertion window); that test passed in isolation and the full suite passed on rerun.

Found with Supertest, an audit method for test effectiveness.

This branch has not been deployed

No deployments
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.

1 participant