Skip to content

test(currency): cover whitelist normalization invariants#492

Open
h1065153539-create wants to merge 1 commit into
CredenceOrg:mainfrom
h1065153539-create:test/currency-whitelist-coverage
Open

test(currency): cover whitelist normalization invariants#492
h1065153539-create wants to merge 1 commit into
CredenceOrg:mainfrom
h1065153539-create:test/currency-whitelist-coverage

Conversation

@h1065153539-create

Copy link
Copy Markdown

Closes #458

Summary

  • add src/services/currency/whitelist.test.ts with deterministic Vitest coverage for add/remove, idempotent add, empty vs populated lookups, admin guard behavior, and malformed code rejection
  • add fast-check property tests for normalization idempotence and order-insensitive set replacement
  • centralize currency normalization in normalize_currency_code
  • validate canonical ISO 4217-style codes as exactly three ASCII uppercase letters after trim/case normalization
  • keep set_currencies atomic by validating all inputs before replacing the current whitelist

Verification

  • npm test -- whitelist
  • npm exec -- vitest run src/services/currency/whitelist.test.ts --coverage --coverage.include=src/services/currency/whitelist.ts (100% statements/branches/functions/lines for whitelist.ts)

Also attempted:

  • npm run lint currently fails before linting because eslint.config.js imports missing src/observability/eslint-plugin-logger-schema.js
  • npm run build currently fails on existing unrelated project-wide TypeScript errors outside the currency whitelist service

Security

The whitelist now rejects malformed, non-ASCII, overlong, and look-alike currency codes instead of silently adding them to the allow-list security boundary.

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.

Unit-test the currency whitelist service (src/services/currency/whitelist.ts) for add/remove/normalization invariants

1 participant