test(config): carry the encryption block in the loader fixtures (S04-A required encryption block plan: 6/16)

Summary

Step 12 will make the encryption block required. This step first gives every internal/config loader fixture the block, so the loader suite still passes once the rule turns on. The block is still optional today, so no test result changes.

  • 39 of the 41 fixtures in internal/config/testdata get encryption: local: {} right after version: 1. Some storage tests append indented lines to a fixture's end, and a block there would swallow them. missing_encryption.yaml stays block-free on purpose, and encryption_happy_path.yaml already has its own block.
  • TestLoad_Storage_MissingBackend builds its config inline, so it gets the block too.
  • TestLoad_HappyPath asserts the block: the local topology is selected, and the omitted namespace_key_cache_ttl defaults to 10m. Its doc promises a field-by-field check of happy_path.yaml.
  • The rejection tests now check that a fixture fails only for its own defect. protovalidate reports every violation, so without this, a rejection fixture that lost its block would still pass after Step 12.
    • TestLoad_RequiredMessageRejection and TestLoad_Storage_MissingBackend allow one violation only.
    • The storage-accounting proto-layer helper checks that no violation names encryption. One NegativeCounters row has two violations by design, so a count does not fit there.
    • TestLoad_Storage_CDNBackendPairing checks that its fixtures pass protovalidate, as its doc says. Its cloudfront check alone passed on any error, because the error message carries the fixture's path.
  • The test comments that called happy_path.yaml "server-only" drop the phrase. Each touched block now fits the comment caps and drops its spec and issue citations. Every block in these files that quotes configuration.md quotes it exactly.

No production code changes. This is Step 6 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. The two internal ADRs were not checked at their source.

Testing

  • go test -race ./internal/config/ passes.
  • golangci-lint on ./internal/config/... reports 0 issues, and the comment-caps check passes.
  • Only missing_encryption.yaml lacks the block: git grep -L '^encryption:' -- internal/config/testdata/ prints that file alone.
  • No file outside internal/config reads these fixtures, and no other test in the package appends a second block.

Each new check was falsified. Setting the fixture's block to encryption: {} fails the check, and with the check removed the same broken fixture passes.

Check Fixture broken Fails
one violation in TestLoad_RequiredMessageRejection missing_server.yaml that row
one violation in TestLoad_Storage_MissingBackend its inline config that test
no encryption violation in the storage-accounting helper storage_accounting_chunk_exceeds_batch.yaml that InvalidConfigs row
NotErrorAs in TestLoad_Storage_CDNBackendPairing storage_cloudfront_with_gcs.yaml that row

Removing the block from happy_path.yaml fails both new TestLoad_HappyPath checks in one run.

The diff touches only tests and the plan, so the configuration reference does not change. No behavior changes, so no e2e row or user doc is affected.

Plan and spec amendments

These correct Step 6's own text. No spec changes.

  • Files, the comment bullet: each touched block comes down to the comment caps, drops its spec and issue citations, and quotes configuration.md exactly.
  • Files, a new config_test.go entry: the TestLoad_HappyPath assertions and the TestLoad_RequiredMessageRejection pin.
  • Files, a new storage_test.go entry: the inline block in TestLoad_Storage_MissingBackend, its one-violation pin, and the TestLoad_Storage_CDNBackendPairing pin.
  • Files, a new storageaccounting_test.go entry: the encryption check in the proto-layer helper.
  • Files, a closing bullet: which test fails for each kind of fixture once Step 12 requires the block.
  • Shared seams: config_test.go overlaps !2970 (merged) too, and Step 12 edits it later.

Spec coverage

Spec: S04-A.

Rule Tests
local selects the topology TestLoad_HappyPath, new assertion
An omitted TTL defaults to 10m TestLoad_HappyPath, new assertion; TestLoad_Encryption_AppliesDefault, unchanged
The block is required (AC-28, E-1) Step 12. This step readies every loader fixture for it

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

  • Step 5 (!3320 (merged)) has merged, so the encryption append tests already use the block-free base.
  • Step 12 must merge after this MR. Otherwise the loader suite fails on every fixture without the block.
  • !2970 (merged) (draft) conflicts with this branch in config_test.go, and in authorization_happy_path.yaml, which it deletes and this MR edits. It already conflicts with main, so it needs a rebase either way. The plan says to keep its deletion.
  • !3343 (merged) (Step 8) records row 8 of the plan's Status table, and this MR records row 6. Once !3343 (merged) is rebased onto main, the two merge cleanly in either order. Its current conflict is with main's row 7, not with this MR.

Closes https://gitlab.com/gitlab-org/ops/artifact-registry/-/work_items/1482

Edited by Dzmitry (Dima) Meshcharakou

Merge request reports

Loading
Loading