Skip to content

e2e: generate browser test credentials at runtime with a literal guard - #242

Merged
TusanHomichi merged 1 commit into
mainfrom
issue-143-e2e-generated-credentials
Nov 20, 2026
Merged

TusanHomichi merged 1 commit into
mainfrom
issue-143-e2e-generated-credentials

Conversation

@TusanHomichi

Copy link
Copy Markdown
Member

Primary Issue

Closes #143

Problem And Outcome

#126 moved Rust integration test credentials to runtime-generated OS-random values in crates/consolebook-server/tests/support/mod.rs and added tests/no_credential_literals.rs to prevent hard-coded password literals from returning. However, 11 Playwright browser specs under web/e2e/ still declared 25 hard-coded password literals (const PASSWORD = 'invented-passphrase-1', password: 'invented-passphrase-1', .fill('invented-passphrase-1'), .fill('wrong-password-x'), etc.).

This PR adds one runtime credential generator in web/e2e/fixtures.ts, migrates all 11 browser specs to use it, and adds a Rust guard test (crates/consolebook-server/tests/no_e2e_credential_literals.rs) with a negative-control corpus and tree-walk test covering every .ts file under web/e2e/.

Why not split: web/e2e/draft-recovery.spec.ts only replaces three existing password constant literals with runtime helper calls without adding behavior.

Changes

  • web/e2e/fixtures.ts
    • Added testPassword(), wrongTestPassword(), and freshTestPassword() generating 41-byte OS-random invented-<32 hex> credentials per worker process, mirroring crates/consolebook-server/tests/support/mod.rs.
  • web/e2e/*.spec.ts (11 files: draft-recovery.spec.ts, drafts.spec.ts, installation-export.spec.ts, lifecycle.spec.ts, programs.spec.ts, public-url.spec.ts, retention.spec.ts, sessions.spec.ts, shell.spec.ts, signoff-history.spec.ts, welcome.spec.ts)
    • Replaced all 25 credential literals with calls to testPassword(), wrongTestPassword(), and freshTestPassword() from ./fixtures.
  • crates/consolebook-server/tests/no_e2e_credential_literals.rs & crates/consolebook-server/tests/no_e2e_credential_literals/cases.txt
    • Added a TypeScript credential-literal guard test running in cargo test --workspace (and nix flake check / fmt-clippy-test / cargo xtask proof), covering sensitive bindings, object/JSON fields, embedded JSON, Playwright .getByLabel/.getByPlaceholder(...).fill(...), and sign-in/reset calls, with a 39-case corpus (positive findings, clean shapes, documented missed items drift-checked against the doc header, malformed inputs) and a Unix tree-walk check (nested .ts, skips non-.ts and symlinks, fails naming non-UTF-8 files).

Correction Ladder

Rung 2 (automated static guard test in cargo test --workspace + single runtime credential generator in web/e2e/fixtures.ts).

Verification

Red-first proof (before migrating web/e2e/*.spec.ts)

  • cargo test -p consolebook-server --test no_e2e_credential_literals failed no_e2e_spec_declares_its_own_credential_literal (while the_case_corpus_scans_as_written and the_walk_skips_links_and_data_and_names_bad_files passed), reporting all 25 credential literals across all 11 spec files (draft-recovery.spec.ts, drafts.spec.ts, installation-export.spec.ts, lifecycle.spec.ts, programs.spec.ts, public-url.spec.ts, retention.spec.ts, sessions.spec.ts, shell.spec.ts, signoff-history.spec.ts, welcome.spec.ts).

After migration

  • cargo test -p consolebook-server --test no_e2e_credential_literals: 3/3 passed.
  • cargo test -p consolebook-server --test no_credential_literals: 4/4 passed.

Local proof receipt — passed

  • Candidate: 3996761a41a41ed6398dea22d73065cf69d4a089 tree c588ab2747d1c8547be79e55e5998a63af5cc5a1; unchanged during run: true
  • Scope: local (local run; hosted pr-gate results are separate evidence, linked not copied)
  • Command: cargo xtask proof in /data/dev/src/consolebook
  • Started 2026-11-20T17:57:28Z, finished 2026-11-20T18:11:33Z, 844.1s
  • Sequence source: CONTRIBUTING.md sha256 87f297e8dad4868f1364b29eb9a45b372ca3dc34e8e205c3505d15883036daa5
  • Browser: playwright-managed /home/dev/.cache/ms-playwright/chromium-1254/chrome-linux64/chrome (Google Chrome for Testing 158.0.8127.18)
  • Host: Linux-6.18.64-x86_64; euid 1001; can bypass file permissions: false (from CapEff)
  • Toolchain: rustc 1.99.1 (58cf8f9c3 2026-10-13); node v22.23.5; npm 10.9.9
  • Binary: target/debug/consolebook-server sha256 e86669c18fb4dd6da407be509b38325346aa3d245380b36a5509a422622c6e40
  • Web build manifest: 54 files, sha256 22f6d23e1ba0e5a809c5bef6d755ddaf7260b64eac577bb91bc83ebc7a713561
  • Browser suite: 74 expected, 0 unexpected, 0 flaky, 0 skipped; report sha256 9e9ae832d188b3c187efc2e7864e8fc8d1c86fa28f4e2f9afc69d65439e7f458
# Command Status Exit Seconds Log sha256 (prefix)
1 scripts/check-guidance-names.sh passed 0 0.246 01.log 2b172a8e66c87574
2 (cd web && npm ci && npm run check && npm run build) passed 0 55.7 02.log a32fa5d1785abce9
3 cargo fmt --check passed 0 1.605 03.log e3b0c44298fc1c14
4 cargo clippy --workspace --all-targets -- -D warnings passed 0 23.434 04.log b27fd2d5e31f7322
5 cargo test --workspace passed 0 201.952 05.log 3ef305d9dcd06ffe
6 cargo build -p consolebook-server passed 0 2.586 06.log 3406675665ce13d9
7 (cd web && npx playwright install chromium && npm run e2e) passed 0 558.538 07.log 182efa6bb02e70a8

Moves all browser test passwords out of literals in web/e2e/*.spec.ts into per-run OS-random helpers in web/e2e/fixtures.ts (testPassword, wrongTestPassword, freshTestPassword), mirroring crates/consolebook-server/tests/support/mod.rs. Adds a Rust guard test (tests/no_e2e_credential_literals.rs) with a negative-control corpus and tree-walk check covering every .ts file under web/e2e/.

Closes #143
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T18:14:17.720635Z 3996761 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@fieldmouseworks-steward fieldmouseworks-steward Bot added the waiting: review Its reviewers, or a Claude job judging it, are looking at this head label Nov 20, 2026
@TusanHomichi
TusanHomichi merged commit f805eda into main Nov 20, 2026
23 of 24 checks passed
@TusanHomichi
TusanHomichi deleted the issue-143-e2e-generated-credentials branch November 20, 2026 18:25
@fieldmouseworks-steward fieldmouseworks-steward Bot removed the waiting: review Its reviewers, or a Claude job judging it, are looking at this head label Nov 20, 2026
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.

test(e2e): one generated credential for the browser specs, as #126 did for Rust

1 participant