Skip to content

test(portal): cover the onboarding password generator - #945

Open
kingmakeruix wants to merge 1 commit into
OpenDataEnsemble:devfrom
kingmakeruix:test/portal-password-generator
Open

kingmakeruix wants to merge 1 commit into
OpenDataEnsemble:devfrom
kingmakeruix:test/portal-password-generator

Conversation

@kingmakeruix

Copy link
Copy Markdown

What

Adds the missing test plumbing to synkronus-portal and focused, deterministic tests for generateStrongPassword — the handoff password an administrator creates when welcoming a new Formulus user.

  • pnpm run test (vitest) wired up in synkronus-portal/package.json, using the same vitest version (^3.2.7) the monorepo already has in desktop and formulus-formplayer
  • vitest config kept in vite.config.ts (rather than a new file), matching how formulus-formplayer does it
  • pnpm run test added to the pre-flight list in synkronus-portal/AGENTS.md

Why

The generator guarantees a minimum length, one character per class, and the exclusion of look-alike characters (0, O, 1, l, I) — all of it was untested, so a change to the character sets would have been invisible. This is the onboarding path for every new Portal user.

Production randomness is untouched. Only the entropy source is stubbed (seeded xorshift32 over crypto.getRandomValues), so every assertion is reproducible and the suite cannot go flaky.

Testing

From synkronus-portal/:

pnpm run lint          # clean
pnpm run test          # 6 passed
pnpm run format:check  # clean
pnpm run build         # ok

Coverage of generateStrongPassword:

Case Assertion
default 16 characters
minimum 4, 0, -5 all clamp up to 12
above minimum 24 and 64 are honoured
per class always at least one uppercase, lowercase, digit, symbol
look-alikes none of 0, O, 1, l, I in a 256 character password
determinism same seed produces the same password

The look-alike test is a real guard, not a tautology: adding O to the UPPER set makes it fail, and reverting makes it pass again.

Scope is limited to this utility and its test setup, as the issue asks — no wider Portal test-suite migration.

Closes #908

Adds the missing Portal test plumbing and focused tests for
generateStrongPassword, the handoff password an administrator creates when
welcoming a new Formulus user.

- wire up `pnpm run test` (vitest) in package.json, using the same vitest
  version the monorepo already uses in desktop and formulus-formplayer
- keep the vitest config in vite.config.ts, matching formulus-formplayer
- stub only the entropy source with a seeded xorshift32 so every assertion is
  reproducible; production randomness is untouched
- cover the default length, the 12 character minimum, longer requests, one
  character per class, and the documented look-alike exclusions

Refs OpenDataEnsemble#908
@najuna-brian

Copy link
Copy Markdown
Member

Hi @kingmakeruix
Thank you for the PR.

Please always comment on the issues and request them to be assigned to you before opening a PR 😊

Once they are assigned then we can go ahead and open a PR.

Thanks for the contribution again

@najuna-brian

Copy link
Copy Markdown
Member

We also invite you to please join the Community Forum HERE
And introduce yourself and catchup with the rest of the activities

@kingmakeruix

Copy link
Copy Markdown
Author

@najuna-brian Thanks for the correction — understood. I have commented on #908 requesting assignment, and I will ask for the issue to be assigned before opening a PR from now on instead of after.

I also went back to #912 for #947, so both are in the right order now, and I will not push further changes to either branch until the assignment is granted.

Thanks again, and thanks for the forum invitation — I will join and introduce myself.

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.

test(portal): put the onboarding password generator through its paces

2 participants