test(config): build the encryption append tests on a block-free base (S04-A required encryption block plan: 5/16)
Summary
The encryption loader tests that append an encryption block start from
happy_path.yaml. Step 6 gives that fixture a block, so an append would then
make a second one. A second block with local fails to load, and one without
local merges in silently, so all four append tests would break.
This MR gives them a base that never gets a block:
internal/config/testdata/missing_encryption.yamlis new. It is a byte copy ofhappy_path.yaml.TestLoad_Encryption_AppliesDefault,InvalidTTL,PresentBlockWithoutTopologyandTTLBoundsappend to it.AbsentBlockYieldsZeroValueloads it as is.- The comments no longer call the base
happy_path.yaml.
No production code changes, and no test result changes. This is Step 5 of the S04-A required encryption block plan.
Governing ADRs
None. ./scripts/adr-freshness.sh says the local mirror is current, and no
mirrored ADR decides how the config loader's test fixtures are built.
Testing
go test -race ./internal/config/passes.- Pointing
missingEncryptionFixtureat a missing file fails all 5 moved tests, andTestLoad_Encryption_HappyPathstill passes. So every moved call site reads the new fixture. - Giving the fixture an
encryptionblock also fails all 5. So the tests keep it block-free when Step 6 adds the block totestdata/*.yaml.
The diff touches only tests under internal/config/, so the configuration
reference does not change. No behavior changes, so no e2e row or user doc is
affected.
Spec coverage
Spec: S04-A. This step adds no assertion. It only changes the fixture some loader tests read.
| Rule | Tests |
|---|---|
local selects the topology |
HappyPath, unchanged |
| An omitted TTL defaults to 10m | AppliesDefault, moved |
| TTL is a Go duration, 1m to 1h | TTLBounds, InvalidTTL, moved |
A block needs a root_key arm (the proto oneof rule) |
PresentBlockWithoutTopology, moved |
| The block is required (AC-28, E-1) | Step 12. Until then AbsentBlockYieldsZeroValue (moved) asserts today's behavior: a config without the block loads |
Every other acceptance criterion, error case and security consideration is
outside this step. AC-25 (-race) holds for internal/config.
Full table
Acceptance criteria
| # | Criterion | Tests |
|---|---|---|
| AC-1 | Encrypt/Decrypt round-trip | Not this step |
| AC-2 | Same plaintext, distinct ciphertexts | Not this step |
| AC-3 | Wrong key returns error | Not this step |
| AC-4 | Tampered ciphertext returns error | Not this step |
| AC-5 | Wrong AAD returns error | Not this step |
| AC-6 | Ciphertext moved between rows fails | Not this step |
| AC-7 | Caller AAD is byte-exact | Not this step |
| AC-8 | A zero RowRef is rejected | Not this step |
| AC-9 | Flipped version byte returns error | Not this step |
| AC-10 | WrapKey/UnwrapKey round-trip | Not this step |
| AC-11 | GetKey auto-creates a namespace key | Not this step |
| AC-12 | GetKeyByVersion reads deactivated keys | Not this step |
| AC-13 | EncryptRow/DecryptRow round-trip | Not this step |
| AC-14 | Cross-namespace isolation | Not this step |
| AC-15 | Root key rotation | Not this step |
| AC-16 | Namespace key rotation | Not this step |
| AC-17 | re-encrypt updates rows | Not this step |
| AC-18 | Crypto-shred makes rows unrecoverable | Not this step |
| AC-19 | RedactedString redacts | Not this step |
| AC-20 | Cache TTL; Shred evicts and zeroizes | Not this step |
| AC-21 | Post-shred GetKey is refused | Not this step |
| AC-22 | Re-enable: refusals, then purge | Not this step |
| AC-23 | FK blocks retiring a referenced key | Not this step |
| AC-24 | internal/crypto passes fips140=only | Not this step |
| AC-25 | All tests pass with -race | internal/config passes |
| AC-26 | Migrations apply and revert | Not this step |
| AC-27 | EncryptRow stamps ns_key_id/version | Not this step |
| AC-28 | No block: startup fails, names it | Step 12 |
Error cases
| # | Condition | Tests |
|---|---|---|
| E-1 | encryption block absent |
Step 12 |
| E-2 | Root key file missing | Not this step |
| E-3 | Root key not 32 bytes | Not this step |
| E-4 | Key file has no valid keys | Not this step |
| E-5 | NewLocalProviderFromKeys(empty) | Not this step |
| E-6 | Auto-create race on version 1 | Not this step |
| E-7 | Namespace has no keys | Not this step |
| E-8 | No namespaces parent row | Not this step |
| E-9 | ns_key_id not found | Not this step |
| E-10 | Write from a stale NamespaceKey copy | Not this step |
| E-11 | Ciphertext tampered | Not this step |
| E-12 | Wrong AAD | Not this step |
| E-13 | Version byte flipped | Not this step |
| E-14 | Ciphertext shorter than 29 bytes | Not this step |
| E-15 | Partial credentials | Not this step |
| E-16 | Partial tombstone shape | Not this step |
| E-17 | RootKeyProvider unavailable | Not this step |
| E-18 | Shredded namespace, read path | Not this step |
| E-19 | Shredded namespace, write path | Not this step |
| E-20 | Retire a still-referenced version | Not this step |
| E-21 | Retire on a shredded namespace | Not this step |
| E-22 | Re-enable a non-shredded namespace | Not this step |
| E-23 | Re-enable within 2x cache TTL | Not this step |
| E-24 | Re-encrypt newer than the active key | Not this step |
| E-25 | Key lookup stalled past the cache TTL | Not this step |
Security considerations
| # | Concern | Tests |
|---|---|---|
| SC-1 | DEKs zeroized after use | Not this step |
| SC-2 | KEK cache TTL and sweep | Not this step |
| SC-3 | Key file not world-readable | Not this step |
| SC-4 | No key material in config | Not this step |
| SC-5 | No key material in logs | Not this step |
| SC-6 | Column swap: logical name in AAD | Not this step |
| SC-7 | Row and table swap: bound in AAD | Not this step |
| SC-8 | Cross-namespace: KEKs and wrap AAD | Not this step |
| SC-9 | Timing: constant-time GCM | Go stdlib-owned |
| SC-10 | Backups and the root key | Not this step |
| SC-11 | Cells migration tool memory | Not this step |
| SC-12 | Database role separation | Spec: out of scope |
Merge order
- No open MR touches the two test files.
- !3052 (merged) (Step 1) also edits the plan's Status table, on row 1. This MR edits row 5. They merge cleanly in either order.
- Step 6 must merge after this MR. Otherwise the append tests get a second block.
Closes https://gitlab.com/gitlab-org/ops/artifact-registry/-/work_items/1481