Skip to content

test(secrets): pin what happens to a secret's value on each authorship transition - #676

Open
JeroenSoeters wants to merge 1 commit into
mainfrom
test/secret-value-lifecycle
Open

test(secrets): pin what happens to a secret's value on each authorship transition#676
JeroenSoeters wants to merge 1 commit into
mainfrom
test/secret-value-lifecycle

Conversation

@JeroenSoeters

Copy link
Copy Markdown
Collaborator

What

A secret's value has three authorship modes — seeded and enforced, seeded once, and not seeded (the value authored outside formae, which is what an imported secret looks like). The transitions between them had no test coverage at all, and they are exactly where a live credential could be destroyed by accident.

Under reconcile, a field absent from the forma is normally removed. Applied to a write-only secret that would clear a live credential the first time someone applied a forma that merely stopped restating it. The rule is the opposite: an omitted value means don't touch, and there is no "clear the value" operation — getting rid of a value means destroying the secret.

I verified the behaviour is already correct before writing these. They are regression guards, not fixes: nothing stopped a future refactor turning omission into a remove op.

The three transitions

  • omit the value → no operation on that field reaches the provider, nothing is removed, and the omitted value is not resubmitted either.
  • remove the seed → the secret settles as not-seeded. A re-apply of the same forma asks the provider for nothing, since the value is no longer formae's to enforce.
  • destroy the secret while a consumer references it → the apply is admitted, the dangling reference surfaces during execution, the consumer's update fails and the command fails. It does not report success with a consumer pointing at something that no longer exists.

Note on an unrelated pre-existing failure

TestContractAuthFailure in internal/cli/connection fails on a clean checkout of main on this machine, independently of this change. It reads the developer's real local prod profile, so it is environment-dependent, and on failure it prints the actual bearer token to the console. Both worth fixing, neither touched here.

make test-unit is otherwise green, and make lint is clean.

…p transition

A secret's value has three authorship modes: seeded and enforced, seeded
once, and not seeded, where the value is authored outside formae, which is
what an imported secret looks like. The transitions between them were
untested, and they are where a live credential could be destroyed by
accident.

Under reconcile a field absent from the forma is normally removed. For a
write-only secret that would clear a live credential on the first apply of
a forma that merely stopped restating it, so the rule is the opposite: an
omitted value means don't touch. That already holds; nothing enforced it.

Three tests, one per transition. An omitted value produces no operation on
that field and is never removed or resubmitted. A secret whose seed was
removed settles rather than drifting, asking the provider for nothing on a
re-apply, since the value is no longer formae's to enforce. Getting rid of
a value is done by destroying the secret, and a consumer still pointing at
it fails loudly rather than carrying on against something that no longer
exists.
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