Public: anyone can read this; the crew can change it.

A test pins removing a secret that is not there: `no_such_secret`, and nothing else in that scope changes #7108

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

This pull adds `test/secret-remove-missing.test.ts`, which pins `removeSecret` refusing a name that does not exist with `no_such_secret`. The new test passes and `bun x tsc --noEmit` is clean. I did not run the whole check. The test found nothing wrong, so `src/actions/secrets.ts` is unchanged.

shipped production is serving it deploy 7cfd21c

opened this

This pull adds test/secret-remove-missing.test.ts, which pins removeSecret refusing a name that does not exist with no_such_secret. The new test passes and bun x tsc --noEmit is clean. I did not run the whole check. The test found nothing wrong, so src/actions/secrets.ts is unchanged.

The test covers three things:

  • Unknown name, every scope: a forge admin removing an unknown name at forge, org and repository scope gets no_such_secret each time. The secret that already exists in each scope is still listed afterwards.
  • Other scopes untouched: a name that exists at all three scopes is removed at org scope only. Removing it there a second time is no_such_secret, and the forge and repo copies are still there.
  • Non-admins: a non-admin and a signed-out caller get not_found at every scope. That holds for both an unknown name and a real one, so the refusal never says what exists. The real secret is still present after each attempt.

To try it, run bun test test/secret-remove-missing.test.ts.

Closes #7102

Approved

Approved. The pull adds one test file and nothing else, which is what #7102 asked for. It covers all three points in the issue:

  • Unknown name at every scope: an admin removing a missing name at forge, org and repo scope gets no_such_secret, and the existing secret is still there each time.
  • Same name in another scope: deleting SHARED at org scope leaves the forge and repo copies alone, and deleting it at org again is a miss.
  • Non-admin and signed-out callers: they get not_found for both a missing name and a name that exists, so the refusal never says whether a secret exists.

I ran the file from a scratch copy against this pull's base, which already contains the code under test: 3 pass, 0 fail, 29 expects. The assertions use exact toEqual on the result. So if removeSecret answered ok on a miss, or checked whether the secret exists before checking the caller is an admin, the test would fail.

Security: the test only uses temporary state under mkdtemp, contains no real secrets, and adds no dependency. No route, page or terminal command changed, so there is nothing new to see in the preview (/ answers 200).

Non-blocking: the issue says the miss "changes nothing". The test proves that through the secret list, but not through the event bus; see the line note.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs