Skip to content

test(sse): add strict SSE contract cases to the S3 and KMS suites - #159

Draft
reatang wants to merge 7 commits into
mainfrom
test/sse-contract-cases
Draft

reatang wants to merge 7 commits into
mainfrom
test/sse-contract-cases

Conversation

@reatang

@reatang reatang commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Summary

Adds nineteen server-side-encryption cases that state what a client must observe, exactly:

  • a response carries the SSE headers of its scheme and no other SSE header;
  • a refusal has the expected HTTP status and S3 error code;
  • a HEAD after a refused write answers 404;
  • data read back matches by SHA-256 and Content-Length;
  • a case that evaluated no expectation fails.

The older S3C-90x, ENC-1xx and KMS-3xx cases mostly accept a successful command with matching bytes and match a refusal against a loose pattern such as InvalidArgument|400. They are unchanged; the new cases run next to them.

Suite Cases Server they rely on
rustfs-s3-compat-test.sh ENC-201 to ENC-210 RUSTFS_SSE_S3_MASTER_KEY, no KMS
rustfs-kms-test.sh KMS-601 to KMS-609 KMS running with the suite's default key (Local or Vault KV2)

What each case holds on is listed in docs/sse-contract-cases.md (Chinese: docs/sse-contract-cases.zh-CN.md).

How it is wired

Both suites call scripts/sse_contract_cases.py, one case per invocation, the way the bulk-delete regressions are run. The helper uses the standard library only (Python 3.8 or newer), talks only to the suite's endpoint with a direct connection, and deploys or restarts nothing. The KMS cases create the keys sse-contract-key-1 and sse-contract-key-2 through the admin API and run after KMS-318, before the per-key authorization and fault cases.

Exit status is 0 or 1. It is never 2, which run_test reads as UNSUPPORTED: a wrong command line exits 64 instead of argparse's default 2, and an unreachable endpoint fails the case.

The cases are catalogued as s3.compatibility.enc-2xx and source-procedure.kms.kms-6xx, so --validation-case selects one of them like any older case. validation-migration-review.json has refreshed digests for the two suites and the catalog, and one sentence in evidence_basis saying that these procedures were exercised locally and have no fleet live acceptance. Please check that this is the right way to record it.

The totals the repository pins now count the nineteen entries: 438 catalogued cases and 280 local ones in test_validation_scanner_usage.py, and the same local total in docs/validation-migration-map.md and docs/source-test-migration-inventory.md.

Verification

Run locally, against single-process servers started with the environment each suite writes in rustfs_config_body:

Server Result
master key only ENC-201..ENC-210: 10 pass
Local KMS KMS-601..KMS-609: 9 pass
Vault KV2 KMS (Vault dev server, mount secret, prefix rustfs) 9 pass
Local KMS with RUSTFS_KMS_ENFORCE_SSE_KEY_POLICY=true and RUSTFS_ENCRYPTION_FRAME_V2=true 9 pass

The same runs were repeated through the suites' own run_all_tests (script sourced, endpoint overridden, cases selected), and scripts/functional_case_report.py parses the resulting log. Two server builds were used: rustfs main at 391e23971 and a branch on top of it.

Negative controls on real servers: without a master key ENC-201, ENC-203, ENC-204 and ENC-210 fail and print the refusal they saw; ENC-204 fails on a server with KMS; the KMS cases fail on a server without KMS.

Offline:

  • test_sse_contract_cases.py runs every case against an in-memory S3 that behaves as required, then with one behavior wrong at a time (19 mutation and case pairs), and requires the matching case to fail and name what it saw. It also pins the registration in both suites, the exit statuses, and the SigV4 signature against botocore when that is installed.
  • Every step of the contract-tests job that needs no package installation was run locally and passes, after the first CI run caught the pinned totals. The script tests of the S3 and KMS jobs pass, as do scripts/validation_catalog.py check, scripts/validation_migration_review.py --require-complete, scripts/check_shell_syntax.py, test_validation_s3_basic.sh and test_validation_kms.sh.

Not verified

The cases have not run on the fleet. The packaged binary, the multi-node topologies and the state left by the cases that run before KMS-601 are covered only by a fleet run. This is a draft until the S3 compatibility and KMS workflows have run once from this branch; a case that fails there for a reason of the environment should be fixed here before the nightly chain picks the cases up.

Out of scope

The cases come from a suite that drives a bare server binary. The parts that a deployed cluster cannot provide are not included: starting the server with other key sources (none, an invalid master key, Vault Transit, the Static backend), comparing two binaries, checking the stored form of objects on the drives, and searching a whole run for key material. Per-key authorization with separate identities stays with KMS-401 and KMS-402.

Add ENC-201..ENC-210 to rustfs-s3-compat-test.sh and KMS-601..KMS-609 to
rustfs-kms-test.sh. They state what a client must observe from
server-side encryption, exactly: a response carries the SSE headers of
its scheme and no other SSE header, a refusal has the expected HTTP
status and S3 error code, a HEAD after a refused write answers 404, and
data read back matches by SHA-256 and Content-Length. The older S3C-90x,
ENC-1xx and KMS-3xx cases accept a successful command with matching
bytes and match refusals against loose patterns; they are unchanged.

Both suites run the cases through scripts/sse_contract_cases.py, a
standard-library helper that talks only to the suite's endpoint, the way
the bulk-delete regressions are run. It exits 0 or 1 and never 2, which
run_test reads as UNSUPPORTED; a wrong command line exits 64. The ENC
cases rely on the S3 suite's server having a local master key and no
KMS. The KMS cases take the suite's default key id and create two more
keys through the admin API; they run after KMS-318, before the per-key
authorization and fault cases.

test_sse_contract_cases.py runs every case against an in-memory S3 that
behaves as required, then with one behavior wrong at a time, and
requires the matching case to fail and name what it saw. It also pins
the registration in both suites and checks the SigV4 signature against
botocore when that is installed.

The cases are catalogued as s3.compatibility.enc-2xx and
source-procedure.kms.kms-6xx, and the implementation review digests are
refreshed for the two suites and the catalog.

Verified against local single-process servers started with each
suite's environment (master key only; Local and Vault KV2 KMS, also
with per-key enforcement and frame v2), through the suites' own
run_all_tests. Not yet run on the fleet.
Conflicts: README.md keeps main's Veeam SOSAPI and request-id sections
followed by the strict SSE section; s3-script-tests.yml keeps main's
standalone probe step and adds test_sse_contract_cases.py to the S3 step;
validation-migration-review.json takes main's ledger plus this branch's
evidence sentence.

Also count the nineteen SSE contract procedures where the repository
pins the totals: test_validation_scanner_usage.py (438 catalogued cases,
280 local), docs/validation-migration-map.md and
docs/source-test-migration-inventory.md. The review digests are
recomputed for every reviewed file that changed.
Conflict in validation-migration-review.json only: main's ledger plus this branch's evidence sentence, with the digests of the reviewed files recomputed from the merged tree.
Conflict in validation-migration-review.json only: main's ledger plus this branch's evidence sentence, with the digests of the reviewed files recomputed from the merged tree.
Conflict in validation-migration-review.json only: main's ledger plus this branch's evidence sentence, with the digests of the reviewed files recomputed from the merged tree.
Conflict in validation-migration-review.json only: main's ledger plus this branch's evidence sentence, with the digests of the reviewed files recomputed from the merged tree.
Conflicts: README.md keeps main's MRF long-root refresh section followed by the strict SSE section; validation-migration-review.json takes main's ledger plus this branch's evidence sentence, with the digests of the reviewed files recomputed from the merged tree.
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