Skip to content

Generate test credentials at run time - #75

Merged
imanimanyara merged 2 commits into
mainfrom
chore/generated-test-credentials
Oct 19, 2026
Merged

imanimanyara merged 2 commits into
mainfrom
chore/generated-test-credentials

Conversation

@imanimanyara

@imanimanyara imanimanyara commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

Why

GitGuardian raised 28 incidents across laranail by 2026-10-18; 27 were test literals or false positives, each closed by hand. A value generated when the suite runs never reaches the repository, so there is nothing for a scanner to report. laranail/package-tools 0.1.9 ships TestCredentials (the generator) and AssertsNoLiteralCredentials (the guard).

What changed

  • laranail/package-tools floor raised to ^0.1.9 (the first release with TestCredentials), so prefer-lowest legs resolve it.
  • 41 literals replaced, 0 exempted (scanner count before → after: 41 → 0), across UpdateUserPasswordTest, ResetUserPasswordTest, AttemptEmailPasswordLoginTest, CreateNewUserTest, UpdateUserProfileInformationTest and TurnstileTest. The workbench UserFactory password is generated too.
  • Values that must differ use distinct purposes (old/new, wrong/right, invalid/current, different/new), and each test that depends on the difference asserts it.
  • New tests/Architecture/NoLiteralCredentialsTest.php scans tests/ and workbench/database/factories (24 files, floor 21); tests/Pest.php now binds Architecture.
  • CHANGELOG [Unreleased] → Changed entry.

Verification

  • vendor/bin/pest: 81 passed (173 assertions).
  • laranail-pint --test: passed. (No PHPStan or Rector config in this repo; CI runs pint and the tests.)
  • Red proof: appending $leak = ['password' => '<literal>']; to TurnstileTest.php turned the guard red, naming the file, line and rule named; reverted with git checkout.

Follow-up

One commit adopting laranail/package-tools 0.1.10: the floor is now ^0.1.10, and NoLiteralCredentialsTest gains a second test, assertCredentialPurposesAreWordsIn() over the same directories and file floor, keeping every TestCredentials purpose a single plain lowercase word. Purposes renamed: 0 (all were already single words). Markers removed: 0. CHANGELOG entry updated in place.

Red proof: with a scratch TestCredentials::password('scratch-probe') line appended to the guard file, the purpose test failed naming that line; the file was restored with git checkout HEAD -- and nothing of it is committed.

GitGuardian raised 28 incidents across laranail by 2026-10-18, and 27
were test literals or false positives closed by hand. A value generated
when the suite runs never reaches the repository, so there is nothing
to report.

Passwords, secrets and tokens in tests/ and the workbench factory now
come from package-tools' TestCredentials. Values that must differ (old
and new, wrong and right, unconfirmed) use distinct purposes and assert
the difference. A new architecture test fails on any literal left
behind. The package-tools floor rises to ^0.1.9, the first release that
ships both.
Copilot AI balanced review requested due to automatic review settings October 19, 2026 12:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Raise the laranail/package-tools floor to ^0.1.10 and switch on its
assertCredentialPurposesAreWordsIn() check beside the literal guard.
GitGuardian reads a compound purpose such as password('smtp-new') as the
password itself; a single plain lowercase word has never been reported,
so the second test keeps every purpose that way.
@imanimanyara
imanimanyara merged commit e8987b9 into main Oct 19, 2026
8 checks passed
@imanimanyara
imanimanyara deleted the chore/generated-test-credentials branch October 19, 2026 14:46
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