Add tests for dotenv helpers and URL-safe object key tokens#6
Draft
cursor[bot] wants to merge 2 commits intomainfrom
Draft
Add tests for dotenv helpers and URL-safe object key tokens#6cursor[bot] wants to merge 2 commits intomainfrom
cursor[bot] wants to merge 2 commits intomainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds Vitest coverage for shared
.envparsing/mutation helpers and S3 object key token encoding used in vault flows.Risky behavior now covered
parseDotenv/removeDotenvKey/appendDotenvKey(src/lib/dotenv-parse.ts): quoted values, CRLF, comment/blank handling, duplicate key detection, validation errors (empty key,=in key,#prefix, multiline key/value), and quoting/escaping when appending values that contain spaces or quotes—reduces risk of corrupting secrets files or accepting invalid variable names in the file workspace.encodeObjectKeyToken/decodeObjectKeyToken(src/lib/key-token.ts): round-trip correctness, URL-safe alphabet (no+,/, padding=), and a short key case that exercises base64 padding—guards regressions in query-param safe S3 key handling.Test files added/updated
src/lib/dotenv-parse.test.ts(new)src/lib/key-token.test.ts(new)Why this reduces regression risk
These modules are pure, high blast-radius utilities: mistakes break secret file editing, GitHub Action env extraction (same parse semantics elsewhere), or routing to the wrong S3 object. The tests are deterministic, node-only, and assert explicit outcomes without snapshots.
Validation
npm run test(full Vitest suite) — all tests passed.