Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/kms-script-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@ on:
paths:
- rustfs-kms-test.sh
- test_rustfs_kms_presign.py
- scripts/sse_contract_cases.py
- test_sse_contract_cases.py
- test_validation_kms.sh
- .github/workflows/kms-script-tests.yml
push:
branches: [main]
paths:
- rustfs-kms-test.sh
- test_rustfs_kms_presign.py
- scripts/sse_contract_cases.py
- test_sse_contract_cases.py
- test_validation_kms.sh
- .github/workflows/kms-script-tests.yml

Expand All @@ -30,5 +34,7 @@ jobs:
run: bash -n rustfs-kms-test.sh
- name: Test presigned KMS case without a server
run: python3 -m unittest test_rustfs_kms_presign.py
- name: Test strict SSE contract cases without a server
run: python3 -B -m unittest test_sse_contract_cases.py
- name: Test canonical KMS round trip without a server
run: bash test_validation_kms.sh
6 changes: 5 additions & 1 deletion .github/workflows/s3-script-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ on:
- test_s3_bulk_delete_regressions.py
- test_s3_bulk_delete_keys.py
- test_s3_bulk_delete_observations.py
- scripts/sse_contract_cases.py
- test_sse_contract_cases.py
- test_rustfs_worm_object_lock.py
- test_validation_s3_basic.sh
- .github/workflows/s3-script-tests.yml
Expand All @@ -49,6 +51,8 @@ on:
- test_s3_bulk_delete_regressions.py
- test_s3_bulk_delete_keys.py
- test_s3_bulk_delete_observations.py
- scripts/sse_contract_cases.py
- test_sse_contract_cases.py
- test_rustfs_worm_object_lock.py
- test_validation_s3_basic.sh
- .github/workflows/s3-script-tests.yml
Expand All @@ -69,7 +73,7 @@ jobs:
- name: Install independent SigV4 verifier
run: python3 -m pip install botocore==1.43.19 'boto3>=1.43.19,<1.43.20'
- name: Test S3 cases and signatures without a cluster
run: python3 -B -m unittest test_rustfs_s3_usage.py test_rustfs_s3_signing.py test_rustfs_s3_regressions.py test_rustfs_worm_object_lock.py test_s3_bulk_delete_regressions.py test_s3_bulk_delete_keys.py test_s3_bulk_delete_observations.py
run: python3 -B -m unittest test_rustfs_s3_usage.py test_rustfs_s3_signing.py test_rustfs_s3_regressions.py test_rustfs_worm_object_lock.py test_s3_bulk_delete_regressions.py test_s3_bulk_delete_keys.py test_s3_bulk_delete_observations.py test_sse_contract_cases.py
- name: Test standalone S3 probe oracles
run: python3 -B -m unittest test_mrf_long_root_refresh.py test_s3_request_id_parity.py test_s3_upload_part_timeout.py test_s3_veeam_sosapi_capacity.py
- name: Test validation S3 round trip without a cluster
Expand Down
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,21 @@ The S3 script tests run the same live case when `RUSTFS_BIN` points to a candida

Run `python3 scripts/mrf_long_root_refresh.py --rustfs-bin /absolute/path/to/rustfs` with Python 3.10+ and boto3. The `admin.mrf-long-root-refresh` case starts a four-disk instance with a 257-byte root access key, seeds a committed unbound MRF snapshot, verifies that `POST /rustfs/admin/v4/heal/mrf/responsibilities/actions` `refresh` returns 200 `refreshed`, and checks that `acceptUnverifiedRisk` still caps persisted operator identities at 256 bytes.

## Strict SSE contract cases

`ENC-201` to `ENC-210` in `rustfs-s3-compat-test.sh` and `KMS-601` to `KMS-609` in `rustfs-kms-test.sh` 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, and a HEAD after a refused write answers 404. 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; they stay as they are.

Both suites run the cases through `scripts/sse_contract_cases.py`, which needs Python 3.8 or newer and no third-party package, talks only to the suite's endpoint, and deploys nothing. The `ENC-2xx` cases rely on the S3 compatibility suite's server having `RUSTFS_SSE_S3_MASTER_KEY` and no KMS; the `KMS-6xx` cases rely on the KMS suite's default key and create the keys `sse-contract-key-1` and `sse-contract-key-2` through the admin API. The helper can also be pointed at any existing endpoint:

```bash
RUSTFS_ACCESS_KEY=... RUSTFS_SECRET_KEY=... \
python3 scripts/sse_contract_cases.py --endpoint http://node:9000 --case ENC-204
```

It exits 0 when the case holds and 1 when it does not, an unreachable endpoint included; a wrong command line exits 64, never 2, which the suites read as UNSUPPORTED. See [the case contracts](docs/sse-contract-cases.md) ([中文](docs/sse-contract-cases.zh-CN.md)).

`python3 -B -m unittest -v test_sse_contract_cases.py` runs every case against an in-memory S3 that behaves as required, then again with one behavior wrong at a time and requires the matching case to fail. This validates the oracles and the suite wiring, not RustFS.

## Bulk-delete regressions

The complete S3 topology suite includes bulk-delete regressions `S3C-213`, `S3C-214`, `S3C-1306` and `S3C-1307`. They cover batch boundaries, duplicate keys, immutable GET load and finite same-key PUT contention in off/on/suspended versioning modes. Python boto3 is required. Each subcase retains JSON, phase/request timing, HTTP 503 and per-object error counts, version/marker cleanup receipts and a Chinese Markdown summary under `--bulk-delete-results-dir`. The standalone runner accepts existing endpoints and does not deploy nodes; its caller must hold the environment lock. S3C-213 and S3C-1306 distinguish per-key S3 results from the historical ten-second client timeout and can compare short and long keys at controlled depths. See [the case contracts and usage](docs/s3-bulk-delete-regressions.zh-CN.md).
Expand Down
2 changes: 1 addition & 1 deletion docs/source-test-migration-inventory.md
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ The source audit lists the following function entries. Names are preserved as au
- Tests: `TestKeyString`, `TestParseKey`

## Scope interpretation
The target collection absorbs source test content and testing ideas. Observable behavior, negative branches, boundary values, state transitions, cleanup rules, and assertion oracles are represented in the 158 canonical scenarios and 261 local procedures. Source-native implementation mechanics and generated serialization helpers remain in this inventory for traceability and are not copied one-to-one.
The target collection absorbs source test content and testing ideas. Observable behavior, negative branches, boundary values, state transitions, cleanup rules, and assertion oracles are represented in the 158 canonical scenarios and 282 local procedures. Source-native implementation mechanics and generated serialization helpers remain in this inventory for traceability and are not copied one-to-one.

Benchmarks remain performance references. Build, lint, security-scan, and repository workflows remain automation references. They do not create duplicate behavior cases in the target collection.

Expand Down
78 changes: 78 additions & 0 deletions docs/sse-contract-cases.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Strict SSE contract cases

[中文](sse-contract-cases.zh-CN.md)

`scripts/sse_contract_cases.py` holds nineteen cases that state what a client must observe from server-side encryption. The cluster suites register them next to their older encryption cases and report them through the same `[PASS]`, `[FAIL]` and case-table lines.

## What "strict" means

- **Exact SSE headers.** A response is reduced to its headers starting with `x-amz-server-side-encryption`, and that set must equal the expected one: nothing missing and nothing extra. SSE-S3 is `{AES256}`, SSE-KMS is `aws:kms` plus the key id the request resolved to, SSE-C is the customer algorithm plus the key MD5, and a plaintext object has none.
- **Exact refusals.** A refusal must carry the expected HTTP status and S3 error code. A pattern such as `400|InvalidArgument` is not used.
- **No residue.** A refused write is followed by a HEAD of the same key, which must answer 404.
- **Bytes.** Data read back is compared by SHA-256 and by `Content-Length`.
- **No vacuous pass.** A case that evaluated no expectation fails.

A table-driven case names each input row in its failure lines, and a row that breaks does not stop the next row.

## Cases in `rustfs-s3-compat-test.sh`

The server of this suite has `RUSTFS_SSE_S3_MASTER_KEY` and no KMS. `ENC-204` depends on that: with KMS running, SSE-KMS is accepted and the case fails.

| Case | Name | Holds when |
| --- | --- | --- |
| `ENC-201` | SseS3ExactHeaders | SSE-S3 objects of 0, 1 and 71680 bytes answer PUT, GET and HEAD with exactly x-amz-server-side-encryption: AES256, read back byte-identical, and are listed with their plaintext size. |
| `ENC-202` | SseCExactHeaders | SSE-C objects of 0, 1 and 71680 bytes answer PUT, GET and HEAD with exactly the customer algorithm and key-MD5 headers, and a GET without the customer key is refused with 400 InvalidRequest. |
| `ENC-203` | BucketDefaultExact | A bucket default of AES256 encrypts a PUT that names no scheme, leaves an SSE-C PUT as SSE-C, and after its removal new objects carry no SSE header while earlier ones still read back as SSE-S3. |
| `ENC-204` | SseKmsNotDowngraded | Without KMS an SSE-KMS PUT is refused with 400 InvalidRequest and stores nothing, while SSE-S3 under the master key still round-trips. |
| `ENC-205` | SseCTripleNegatives | Seven incomplete or inconsistent SSE-C header triples are each refused with 400 InvalidRequest, and a HEAD of each key answers 404. |
| `ENC-206` | SseCCopySourceKey | CopyObject from an SSE-C source without or with a wrong source key is refused with an explicit 400 and stores nothing; with the right key the destination opens only with its own key. |
| `ENC-207` | SseCMultipartExact | An SSE-C multipart upload answers CreateMultipartUpload and CompleteMultipartUpload with exactly the customer headers, reads back byte-identical with the key, and is refused without it. |
| `ENC-208` | SseCPartKeyMismatch | UploadPart without the key, with another key, or with a key on a plaintext upload is refused with 400 InvalidRequest, and the SSE-C upload still completes afterwards. |
| `ENC-209` | SseReadHeaderMismatch | Six GET requests whose SSE headers do not match how the object was stored are refused with the exact error code and return no object bytes. |
| `ENC-210` | ListingEtagNotPlaintextMd5 | ListObjectsV2, ListObjects and ListObjectVersions never report the MD5 of the plaintext as the ETag of an SSE-S3 or SSE-C object, with a plaintext object as the control. |

## Cases in `rustfs-kms-test.sh`

The server of this suite runs KMS with the default key `kms-default` on the Local or Vault KV2 backend. The helper receives the default key id through `--kms-default-key` and creates `sse-contract-key-1` and `sse-contract-key-2` through the admin API before a case starts; a key that already exists is reused. The cases run after `KMS-318` and before the per-key authorization and fault cases.

| Case | Name | Holds when |
| --- | --- | --- |
| `KMS-601` | SseS3KeyNotNamed | SSE-S3 under KMS round-trips with exactly AES256, and no response of eight operations carries a KMS key id header or names the default key. |
| `KMS-602` | SseKmsKeyResolutionExact | SSE-KMS without a key id answers with the default key id, and with an explicit non-default key answers with that key id on PUT, GET and HEAD for 0, 1 and 71680 bytes. |
| `KMS-603` | SseKmsRangeExact | Four range reads of an SSE-KMS object answer 206 with the exact Content-Range, the plaintext slice and the exact SSE-KMS headers. |
| `KMS-604` | BucketDefaultKmsExact | A bucket default of aws:kms without a key id pins the default key, leaves SSE-C as SSE-C, and an explicit AES256 PUT does not inherit the bucket's KMS key. |
| `KMS-605` | CopySchemeMatrix | Six CopyObject combinations across plaintext, SSE-S3, SSE-KMS and SSE-C produce exactly the destination scheme's headers on GET and HEAD and byte-identical data. |
| `KMS-606` | MultipartSseKmsExact | A three-part SSE-KMS upload answers create, complete, GET and HEAD with exactly the SSE-KMS headers of its key, the full length and a three-part ETag. |
| `KMS-607` | SsePutHeaderNegatives | Ten malformed SSE header combinations are refused with 400 InvalidArgument and a missing KMS key with 400 KMS.NotFoundException; a HEAD of each key answers 404. |
| `KMS-608` | SseReadHeaderMismatch | Seven GET requests whose SSE headers do not match how the object was stored, an SSE-KMS object included, are refused with the exact error code and return no object bytes. |
| `KMS-609` | ContextAndEtagNotEchoed | PUT, GET and HEAD of an object written with an encryption context do not repeat the context, and no listing reports the plaintext MD5 as the ETag of an encrypted object. |

## Running one case

```bash
./rustfs-s3-compat-test.sh --topology single-single -y --cases ENC-204 --package-url <deb url>
./rustfs-kms-test.sh --topology single-single --backends local -y --cases KMS-605 --package-url <deb url>

RUSTFS_ACCESS_KEY=... RUSTFS_SECRET_KEY=... \
python3 scripts/sse_contract_cases.py --endpoint http://node:9000 --case KMS-605 --kms-default-key kms-default
```

The helper needs Python 3.8 or newer and the standard library only. It connects to the endpoint directly and ignores proxy variables. Each case works in buckets named `sse-<case id>-<random>` and removes them afterwards on a best-effort basis. Exit status: 0 the case holds, 1 it does not (an unreachable endpoint included), 64 the command line is wrong. Status 2 is never used, because `run_test` reads it as UNSUPPORTED.

The catalog ids are `s3.compatibility.enc-2xx` and `source-procedure.kms.kms-6xx`, so `--validation-case` selects a single case in the same way as for the older ones.

## What has been verified

- Every case holds against a local single-process server started with the environment the respective suite writes: master key only for `ENC-2xx`; Local and Vault KV2 KMS for `KMS-6xx`, also with `RUSTFS_KMS_ENFORCE_SSE_KEY_POLICY=true` and `RUSTFS_ENCRYPTION_FRAME_V2=true`.
- The suites' own `run_all_tests` ran the cases against those servers and printed the expected `[PASS]` lines; against a server without a master key `ENC-201` and `ENC-204` printed `[FAIL]` with the refusal they saw.
- `test_sse_contract_cases.py` runs every case against an in-memory S3 that behaves as required, and again with one behavior wrong at a time; the matching case must fail and name what it saw.

The cases have not run on the fleet yet. Multi-node topologies and the packaged binary are covered only once the scheduled suites pick the cases up.

## Server versions

The cases describe the behavior of current `main`. `ENC-207` fails against a server built before rustfs/rustfs#9575: such a server answers CreateMultipartUpload and CompleteMultipartUpload of an SSE-C upload with an extra `x-amz-server-side-encryption: AES256`, and the case reports exactly that header set. A run against an older release tag should read this failure as the known defect of that release.

## What is deliberately not here

The cases were taken from a suite that drives a bare server binary. Parts of it need things a deployed cluster cannot give and were left out: starting the server with other key sources (none at all, an invalid master key, Vault Transit, the Static backend), comparing two binaries, checking the stored form of objects on the drives, and searching whole runs for key material. Per-key authorization with separate identities is covered loosely by `KMS-401` and `KMS-402` and is not tightened here.
Loading