Skip to content

Add tests for dotenv parsing, append/remove keys, and S3 key tokens#7

Draft
cursor[bot] wants to merge 2 commits intomainfrom
cursor/missing-test-coverage-ebd3
Draft

Add tests for dotenv parsing, append/remove keys, and S3 key tokens#7
cursor[bot] wants to merge 2 commits intomainfrom
cursor/missing-test-coverage-ebd3

Conversation

@cursor
Copy link
Copy Markdown

@cursor cursor bot commented Apr 5, 2026

Summary

Adds focused Vitest coverage for recently merged .env handling and URL-safe S3 object key encoding.

Risky behavior now covered

  • parseDotenv / removeDotenvKey / appendDotenvKey (src/lib/dotenv-parse.ts): comments, CRLF, quoted values, duplicate-key rejection, key/value validation messages, trailing-whitespace handling when appending, and quoting rules for values with spaces or #.
  • encodeObjectKeyToken / decodeObjectKeyToken (src/lib/key-token.ts): round-trip for paths with /, +, and non-ASCII characters (regression guard for URL-safe base64 key handling).
  • Parser parity: GitHub Action parseDotenv vs app parseDotenv on shared fixtures so the action and vault stay aligned.

Test files added/updated

  • src/lib/dotenv-parse.test.ts (new)
  • src/lib/key-token.test.ts (new)
  • src/github-action/dotenv-parse-alignment.test.ts (new)

Why this reduces regression risk

Dotenv parsing and append/remove logic directly affect secret plaintext in the UI and server; a subtle parser or formatting bug can drop keys, corrupt values, or allow invalid names. Object key tokens are used across API boundaries; encoding/decoding mistakes break navigation or leak incorrect keys. The parity test catches duplicated parsers drifting apart after a one-sided fix.

Validation

  • npm run test (Vitest) — all tests pass; deterministic, no network or env dependencies beyond Node.
Open in Web View Automation 

- Exercise parseDotenv, removeDotenvKey, and appendDotenvKey including
  validation errors and quoting edge cases used by the vault UI.
- Round-trip encodeObjectKeyToken/decodeObjectKeyToken for S3 key tokens.
Prevents drift between action and server/UI when .env parsing changes.
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