From ce4f6d1c48ed87f72a7906f7ca5d70b52dc8a31a Mon Sep 17 00:00:00 2001 From: soreavis <263610811+soreavis@users.noreply.github.com> Date: Wed, 26 Aug 2026 05:51:56 +0200 Subject: [PATCH] fix(s3): route the replication subresource instead of falling through (#2519) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PUT /{bucket}?replication fell through to CreateBucket: in the default region the idempotent-create path answered 200 with a Location header and stored no replication configuration, and elsewhere it failed with BucketAlreadyOwnedByYou. GET fell through to ListObjects and returned a ListBucketResult the SDK silently parsed as an empty replication configuration. Only DELETE was routed, as a no-op. Route PUT and GET alongside the existing DELETE case, per the issue's suggested fix: the configuration is stored verbatim on the bucket and echoed back — Floci does not model replication behavior, and neither the SDK nor the Terraform provider needs it to. The PUT body's ReplicationConfiguration root is validated (MalformedXML otherwise); GET on a bucket with no stored configuration answers ReplicationConfigurationNotFoundError (404), which is what the SDK and aws_s3_bucket_replication_configuration treat as "not configured". Now that PUT stores a configuration, DeleteBucketReplication clears it instead of no-opping (still an unconditional 204, matching AWS), and a DELETE on a missing bucket answers NoSuchBucket instead of the no-op's 204. IamActionRegistry maps the three verbs to the documented actions: s3:PutReplicationConfiguration for PUT and DELETE (AWS authorizes DeleteBucketReplication with the put action) and s3:GetReplicationConfiguration for GET. The mapping mirrors the controller's per-method dispatch order: on PUT and GET accelerate is dispatched ahead of replication, while the DELETE chain routes replication and never routes accelerate to an operation. Closes #2296 --- docs/services/s3.md | 1 - .../floci/services/iam/IamActionRegistry.java | 52 ++- .../floci/services/s3/S3Controller.java | 12 +- .../floci/services/s3/S3Service.java | 36 ++ .../floci/services/s3/model/Bucket.java | 6 + .../services/iam/IamActionRegistryTest.java | 96 ++++++ ...plicationConfigurationIntegrationTest.java | 318 ++++++++++++++++++ 7 files changed, 507 insertions(+), 14 deletions(-) create mode 100644 src/test/java/io/github/hectorvent/floci/services/s3/S3ReplicationConfigurationIntegrationTest.java diff --git a/docs/services/s3.md b/docs/services/s3.md index b516802af2..8d9eb2aecb 100644 --- a/docs/services/s3.md +++ b/docs/services/s3.md @@ -148,7 +148,6 @@ When `FLOCI_SERVICES_ATHENA_MOCK=true` is set, Athena queries are stubbed but fl These AWS S3 features have no handler in Floci. Calls will return an error (typically `404` or `NoSuchBucket`-style): -- Replication (`PutBucketReplication`, `GetBucketReplication`, `DeleteBucketReplication`) - Access logging (`PutBucketLogging`, `GetBucketLogging`) - Request payment (`PutBucketRequestPayment`, `GetBucketRequestPayment`) - Intelligent-Tiering configurations diff --git a/src/main/java/io/github/hectorvent/floci/services/iam/IamActionRegistry.java b/src/main/java/io/github/hectorvent/floci/services/iam/IamActionRegistry.java index cf44e4999f..2ec77562ca 100644 --- a/src/main/java/io/github/hectorvent/floci/services/iam/IamActionRegistry.java +++ b/src/main/java/io/github/hectorvent/floci/services/iam/IamActionRegistry.java @@ -170,6 +170,12 @@ public class IamActionRegistry { "uploads", "notification", "versioning", "versions", "location", "object-lock", "website", "logging", "policy", "cors", "lifecycle", "encryption", "publicAccessBlock", "ownershipControls", "requestPayment"); + // S3Controller's DELETE chain dispatches these ahead of replication (tagging is + // resolved above). Accelerate is NOT here: on DELETE it is dispatched after + // replication. Mirrors the controller's dispatch order — extend together. + private static final List DELETE_SUBRESOURCES_BEFORE_REPLICATION = List.of( + "website", "policy", "cors", "lifecycle", "encryption", + "publicAccessBlock", "ownershipControls"); /** * Resolves S3 sub-resource ops (ACL, tagging, retention, etc.) that @@ -182,7 +188,8 @@ public class IamActionRegistry { boolean acl = params.containsKey("acl"); boolean tagging = params.containsKey("tagging"); boolean accelerate = params.containsKey("accelerate"); - if (!acl && !tagging && !accelerate) { + boolean replication = params.containsKey("replication"); + if (!acl && !tagging && !accelerate && !replication) { return null; } // /{bucket}?acl → bucket-level; /{bucket}/{key}?acl → object-level @@ -223,24 +230,49 @@ public class IamActionRegistry { default -> null; }; } - // Accelerate is a bucket-only subresource, and ?accelerate on an object path is - // inert — the object routes ignore it — so only a bucket-level request maps here; - // everything else falls through to the standard rule table. + // Accelerate and replication are bucket-only subresources; on an object path + // both are inert — the object routes ignore them — so only a bucket-level + // request maps here; everything else falls through to the standard rule table. if (!isBucketLevel) { return null; } - List dispatchedFirst = "PUT".equals(method) - ? PUT_SUBRESOURCES_BEFORE_ACCELERATE - : GET_SUBRESOURCES_BEFORE_ACCELERATE; + // S3Controller's PUT and GET chains dispatch accelerate ahead of replication, + // so accelerate resolves when both ride along. Its DELETE chain routes + // replication and never routes accelerate to an operation, so on DELETE + // replication resolves even when accelerate is also present. + if (accelerate && !(replication && "DELETE".equals(method))) { + List dispatchedFirst = "PUT".equals(method) + ? PUT_SUBRESOURCES_BEFORE_ACCELERATE + : GET_SUBRESOURCES_BEFORE_ACCELERATE; + for (String subresource : dispatchedFirst) { + if (params.containsKey(subresource)) { + return null; + } + } + return switch (method) { + case "GET" -> "s3:GetAccelerateConfiguration"; + case "PUT" -> "s3:PutAccelerateConfiguration"; + // AWS defines no DELETE for the subresource. + default -> null; + }; + } + // Replication. On PUT and GET this is only reached without ?accelerate, so the + // accelerate before-lists cover everything dispatched ahead of replication too. + List dispatchedFirst = switch (method) { + case "PUT" -> PUT_SUBRESOURCES_BEFORE_ACCELERATE; + case "GET" -> GET_SUBRESOURCES_BEFORE_ACCELERATE; + default -> DELETE_SUBRESOURCES_BEFORE_REPLICATION; + }; for (String subresource : dispatchedFirst) { if (params.containsKey(subresource)) { return null; } } return switch (method) { - case "GET" -> "s3:GetAccelerateConfiguration"; - case "PUT" -> "s3:PutAccelerateConfiguration"; - // AWS defines no DELETE for the subresource. + case "GET" -> "s3:GetReplicationConfiguration"; + case "PUT" -> "s3:PutReplicationConfiguration"; + // AWS authorizes DeleteBucketReplication with the put action. + case "DELETE" -> "s3:PutReplicationConfiguration"; default -> null; }; } diff --git a/src/main/java/io/github/hectorvent/floci/services/s3/S3Controller.java b/src/main/java/io/github/hectorvent/floci/services/s3/S3Controller.java index 6702bea8be..ce77522f11 100644 --- a/src/main/java/io/github/hectorvent/floci/services/s3/S3Controller.java +++ b/src/main/java/io/github/hectorvent/floci/services/s3/S3Controller.java @@ -324,6 +324,10 @@ public class S3Controller { s3Service.putBucketAccelerateConfiguration(bucket, new String(body, StandardCharsets.UTF_8)); return Response.ok().build(); } + if (hasQueryParam(uriInfo, "replication")) { + s3Service.putBucketReplication(bucket, new String(body, StandardCharsets.UTF_8)); + return Response.ok().build(); + } // Must be handled here: an unmatched subresource falls through to CreateBucket below, // which answers a metrics call with BucketAlreadyOwnedByYou. if (hasQueryParam(uriInfo, "metrics")) { @@ -407,9 +411,7 @@ public class S3Controller { return Response.noContent().build(); } if (hasQueryParam(uriInfo, "replication")) { - // Floci does not model bucket replication; DeleteBucketReplication is a - // no-op that always returns 204, matching real S3. Crucially it must be - // handled here so it does NOT fall through to deleting the whole bucket. + s3Service.deleteBucketReplication(bucket); return Response.noContent().build(); } if (hasQueryParam(uriInfo, "metrics")) { @@ -528,6 +530,10 @@ public class S3Controller { s3Service.authorizeBucketRead(bucket, "s3:GetAccelerateConfiguration", authorization); return Response.ok(s3Service.getBucketAccelerateConfiguration(bucket)).build(); } + if (hasQueryParam(uriInfo, "replication")) { + s3Service.authorizeBucketRead(bucket, "s3:GetReplicationConfiguration", authorization); + return Response.ok(s3Service.getBucketReplication(bucket)).build(); + } // GetBucketMetricsConfiguration and ListBucketMetricsConfigurations share ?metrics and // are told apart by the id, which only the single-configuration read carries. if (hasQueryParam(uriInfo, "metrics")) { diff --git a/src/main/java/io/github/hectorvent/floci/services/s3/S3Service.java b/src/main/java/io/github/hectorvent/floci/services/s3/S3Service.java index dd9397b6a5..f65b4a6e6c 100644 --- a/src/main/java/io/github/hectorvent/floci/services/s3/S3Service.java +++ b/src/main/java/io/github/hectorvent/floci/services/s3/S3Service.java @@ -2497,6 +2497,42 @@ public class S3Service implements Resettable, ResourceProvider { .build(); } + /** + * Stores the bucket replication configuration verbatim. Floci does not model + * replication behavior — the configuration is only stored and echoed back, + * which is what the SDK and the Terraform provider need. The + * ReplicationConfiguration root is required, so a body that does not parse + * to one is rejected with {@code MalformedXML}. + */ + public void putBucketReplication(String bucketName, String replicationXml) { + Bucket bucket = bucketStore.get(bucketName) + .orElseThrow(() -> new AwsException("NoSuchBucket", "The specified bucket does not exist.", 404)); + if (!"ReplicationConfiguration".equals(XmlParser.rootElementName(replicationXml))) { + throw new AwsException("MalformedXML", + "The XML you provided was not well-formed or did not validate against our published schema.", + 400); + } + bucket.setReplicationConfiguration(replicationXml); + bucketStore.put(bucketName, bucket); + } + + public String getBucketReplication(String bucketName) { + Bucket bucket = bucketStore.get(bucketName) + .orElseThrow(() -> new AwsException("NoSuchBucket", "The specified bucket does not exist.", 404)); + if (bucket.getReplicationConfiguration() == null) { + throw new AwsException("ReplicationConfigurationNotFoundError", + "The replication configuration was not found", 404); + } + return bucket.getReplicationConfiguration(); + } + + public void deleteBucketReplication(String bucketName) { + Bucket bucket = bucketStore.get(bucketName) + .orElseThrow(() -> new AwsException("NoSuchBucket", "The specified bucket does not exist.", 404)); + bucket.setReplicationConfiguration(null); + bucketStore.put(bucketName, bucket); + } + public void restoreObject(String bucketName, String key, String versionId, String restoreXml) { // Validation only - stub implementation getObject(bucketName, key, versionId); diff --git a/src/main/java/io/github/hectorvent/floci/services/s3/model/Bucket.java b/src/main/java/io/github/hectorvent/floci/services/s3/model/Bucket.java index 762ed2b0dd..76dce3f07f 100644 --- a/src/main/java/io/github/hectorvent/floci/services/s3/model/Bucket.java +++ b/src/main/java/io/github/hectorvent/floci/services/s3/model/Bucket.java @@ -27,6 +27,7 @@ public class Bucket { private String encryptionConfiguration; // XML string private String publicAccessBlockConfiguration; // XML string private String ownershipControlsConfiguration; // XML string + private String replicationConfiguration; // XML string; null until first PUT private String requestPaymentPayer; // "BucketOwner" (default) or "Requester"; null until first PUT private String accelerateStatus; // "Enabled" or "Suspended"; null until first PUT private String region; @@ -108,6 +109,11 @@ public class Bucket { this.ownershipControlsConfiguration = ownershipControlsConfiguration; } + public String getReplicationConfiguration() { return replicationConfiguration; } + public void setReplicationConfiguration(String replicationConfiguration) { + this.replicationConfiguration = replicationConfiguration; + } + public String getRequestPaymentPayer() { return requestPaymentPayer; } public void setRequestPaymentPayer(String requestPaymentPayer) { this.requestPaymentPayer = requestPaymentPayer; } diff --git a/src/test/java/io/github/hectorvent/floci/services/iam/IamActionRegistryTest.java b/src/test/java/io/github/hectorvent/floci/services/iam/IamActionRegistryTest.java index d40545927d..08b80f2235 100644 --- a/src/test/java/io/github/hectorvent/floci/services/iam/IamActionRegistryTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/iam/IamActionRegistryTest.java @@ -198,6 +198,102 @@ class IamActionRegistryTest { registry.resolve("s3", mockCtx("PUT", "/bucket", withUploads, null, ""))); } + @Test + void s3ReplicationResolvesToItsOwnActions() { + // Without the override, PUT ?replication resolves to s3:CreateBucket — a + // principal allowed only to create buckets could rewrite the replication + // configuration. + MultivaluedMap replication = new MultivaluedHashMap<>(); + replication.add("replication", ""); + assertEquals("s3:PutReplicationConfiguration", + registry.resolve("s3", mockCtx("PUT", "/bucket", replication, null, ""))); + assertEquals("s3:GetReplicationConfiguration", + registry.resolve("s3", mockCtx("GET", "/bucket", replication, null, ""))); + // AWS authorizes DeleteBucketReplication with the put action. + assertEquals("s3:PutReplicationConfiguration", + registry.resolve("s3", mockCtx("DELETE", "/bucket", replication, null, ""))); + } + + @Test + void s3ReplicationOnAnObjectPathKeepsTheObjectActions() { + // The object routes ignore ?replication, so mapping it there would let a + // principal with only replication permissions read or write arbitrary objects. + MultivaluedMap replication = new MultivaluedHashMap<>(); + replication.add("replication", ""); + assertEquals("s3:GetObject", + registry.resolve("s3", mockCtx("GET", "/bucket/secret.txt", replication, null, ""))); + assertEquals("s3:PutObject", + registry.resolve("s3", mockCtx("PUT", "/bucket/key.txt", replication, null, ""))); + assertEquals("s3:DeleteObject", + registry.resolve("s3", mockCtx("DELETE", "/bucket/key.txt", replication, null, ""))); + } + + @Test + void s3ReplicationYieldsToSubresourcesDispatchedFirst() { + // The controller executes the requestPayment operation for this request, so the + // replication mapping must not claim it; resolution falls back to the rule table. + MultivaluedMap withRequestPayment = new MultivaluedHashMap<>(); + withRequestPayment.add("requestPayment", ""); + withRequestPayment.add("replication", ""); + assertEquals("s3:CreateBucket", + registry.resolve("s3", mockCtx("PUT", "/bucket", withRequestPayment, null, ""))); + MultivaluedMap withLocation = new MultivaluedHashMap<>(); + withLocation.add("location", ""); + withLocation.add("replication", ""); + assertEquals("s3:ListBucket", + registry.resolve("s3", mockCtx("GET", "/bucket", withLocation, null, ""))); + // The DELETE chain dispatches website ahead of replication. + MultivaluedMap withWebsite = new MultivaluedHashMap<>(); + withWebsite.add("website", ""); + withWebsite.add("replication", ""); + assertEquals("s3:DeleteBucket", + registry.resolve("s3", mockCtx("DELETE", "/bucket", withWebsite, null, ""))); + // requestPayment has no DELETE dispatch branch; it is inert there and + // replication executes, so the mapping must still claim the request. + MultivaluedMap deleteWithRequestPayment = new MultivaluedHashMap<>(); + deleteWithRequestPayment.add("requestPayment", ""); + deleteWithRequestPayment.add("replication", ""); + assertEquals("s3:PutReplicationConfiguration", + registry.resolve("s3", mockCtx("DELETE", "/bucket", deleteWithRequestPayment, null, ""))); + // uploads is a GET-only dispatch branch; on PUT it is inert and replication + // executes, so the mapping must still claim the request there. + MultivaluedMap putWithUploads = new MultivaluedHashMap<>(); + putWithUploads.add("uploads", ""); + putWithUploads.add("replication", ""); + assertEquals("s3:PutReplicationConfiguration", + registry.resolve("s3", mockCtx("PUT", "/bucket", putWithUploads, null, ""))); + } + + @Test + void s3ReplicationAndAcceleratePrecedenceFollowsEachMethodsDispatchOrder() { + // PUT and GET dispatch accelerate ahead of replication; DELETE routes + // replication and never routes accelerate to an operation. + MultivaluedMap both = new MultivaluedHashMap<>(); + both.add("accelerate", ""); + both.add("replication", ""); + assertEquals("s3:PutAccelerateConfiguration", + registry.resolve("s3", mockCtx("PUT", "/bucket", both, null, ""))); + assertEquals("s3:GetAccelerateConfiguration", + registry.resolve("s3", mockCtx("GET", "/bucket", both, null, ""))); + assertEquals("s3:PutReplicationConfiguration", + registry.resolve("s3", mockCtx("DELETE", "/bucket", both, null, ""))); + } + + @Test + void s3ReplicationDoesNotPreemptAclOrTagging() { + // Appending an inert ?replication must not downgrade a stricter resolution. + MultivaluedMap withAcl = new MultivaluedHashMap<>(); + withAcl.add("replication", ""); + withAcl.add("acl", ""); + assertEquals("s3:PutBucketAcl", + registry.resolve("s3", mockCtx("PUT", "/bucket", withAcl, null, ""))); + MultivaluedMap withTagging = new MultivaluedHashMap<>(); + withTagging.add("replication", ""); + withTagging.add("tagging", ""); + assertEquals("s3:DeleteBucketTagging", + registry.resolve("s3", mockCtx("DELETE", "/bucket", withTagging, null, ""))); + } + @Test void s3AccelerateDoesNotPreemptAclOrTagging() { // Appending an inert ?accelerate must not downgrade a stricter resolution. diff --git a/src/test/java/io/github/hectorvent/floci/services/s3/S3ReplicationConfigurationIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/s3/S3ReplicationConfigurationIntegrationTest.java new file mode 100644 index 0000000000..418f257b11 --- /dev/null +++ b/src/test/java/io/github/hectorvent/floci/services/s3/S3ReplicationConfigurationIntegrationTest.java @@ -0,0 +1,318 @@ +package io.github.hectorvent.floci.services.s3; + +import io.quarkus.test.junit.QuarkusTest; +import org.junit.jupiter.api.MethodOrderer; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestMethodOrder; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.not; +import static org.hamcrest.Matchers.nullValue; + +@QuarkusTest +@TestMethodOrder(MethodOrderer.OrderAnnotation.class) +class S3ReplicationConfigurationIntegrationTest { + + private static final String BUCKET = "replication-config-int-test"; + private static final String REPLICATION_XML = """ + + arn:aws:iam::000000000000:role/replication-role + + rule1 + Enabled + + arn:aws:s3:::replication-config-int-test-target + + + + """; + private static final String REPLACEMENT_XML = """ + + arn:aws:iam::000000000000:role/replication-role-two + + rule2 + Disabled + + arn:aws:s3:::replication-config-int-test-other + + + + """; + + @Test + @Order(1) + void createBucket() { + given() + .when() + .put("/" + BUCKET) + .then() + .statusCode(200); + } + + /** + * A bucket without a replication configuration answers + * {@code ReplicationConfigurationNotFoundError} (404) — what the SDK and the + * Terraform provider treat as "not configured". Before the replication + * subresource was routed this fell through to ListObjects and returned a + * {@code ListBucketResult}, which the SDK parsed as an empty configuration — + * a silent wrong answer instead of the 404. + */ + @Test + @Order(2) + void getReplicationBeforePutReturnsNotFoundError() { + given() + .when() + .get("/" + BUCKET + "?replication") + .then() + .statusCode(404) + .body(containsString("ReplicationConfigurationNotFoundError")) + .body(not(containsString("ListBucketResult"))); + } + + /** + * Regression test for the fall-through to the bucket-creation handler: outside the + * default region it returned {@code BucketAlreadyOwnedByYou}, and inside it the + * idempotent-create path answered a silent 200 with a {@code Location} header + * without storing a replication configuration — the absent header + * distinguishes the routed response. + */ + @Test + @Order(3) + void putReplicationOnExistingBucketReturns200() { + given() + .body(REPLICATION_XML) + .when() + .put("/" + BUCKET + "?replication") + .then() + .statusCode(200) + .header("Location", nullValue()) + .body(not(containsString("BucketAlreadyOwnedByYou"))); + } + + /** The stored configuration is echoed back verbatim. */ + @Test + @Order(4) + void getReplicationEchoesTheStoredConfiguration() { + given() + .when() + .get("/" + BUCKET + "?replication") + .then() + .statusCode(200) + .body(containsString("rule1")); + } + + @Test + @Order(5) + void putReplicationReplacesTheStoredConfiguration() { + given() + .body(REPLACEMENT_XML) + .when() + .put("/" + BUCKET + "?replication") + .then() + .statusCode(200); + given() + .when() + .get("/" + BUCKET + "?replication") + .then() + .statusCode(200) + .body(containsString("rule2")) + .body(not(containsString("rule1"))); + } + + /** The ReplicationConfiguration root is Required: Yes, so a body that does not parse to one is malformed. */ + @Test + @Order(6) + void putReplicationRejectsAnUnparseableBody() { + for (String body : new String[] { + "", + "garbage {} not xml", + """ + + arn:aws:iam::000000000000:role/replication-role""" }) { + given() + .body(body) + .when() + .put("/" + BUCKET + "?replication") + .then() + .statusCode(400) + .body(containsString("MalformedXML")); + } + given() + .when() + .get("/" + BUCKET + "?replication") + .then() + .statusCode(200) + .body(containsString("rule2")); + } + + /** A configuration inside the wrong root must not store anything. */ + @Test + @Order(7) + void putReplicationRejectsAWrongRootElement() { + given() + .body(""" + + Enabled + + """) + .when() + .put("/" + BUCKET + "?replication") + .then() + .statusCode(400) + .body(containsString("MalformedXML")); + given() + .when() + .get("/" + BUCKET + "?replication") + .then() + .statusCode(200) + .body(containsString("rule2")); + } + + @Test + @Order(8) + void putReplicationOnMissingBucketReturns404() { + given() + .body(REPLICATION_XML) + .when() + .put("/this-bucket-does-not-exist-repl?replication") + .then() + .statusCode(404) + .body(containsString("NoSuchBucket")); + } + + @Test + @Order(9) + void getReplicationOnMissingBucketReturns404() { + given() + .when() + .get("/this-bucket-does-not-exist-repl?replication") + .then() + .statusCode(404) + .body(containsString("NoSuchBucket")); + } + + /** + * DeleteBucketReplication removes the stored configuration and answers 204; + * a later GET is back to the not-configured 404. The bucket itself must + * survive — before the subresource was handled a {@code DELETE + * /{bucket}?replication} would have fallen through to {@code DeleteBucket}. + */ + @Test + @Order(10) + void deleteReplicationClearsTheStoredConfiguration() { + given() + .when() + .delete("/" + BUCKET + "?replication") + .then() + .statusCode(204); + given() + .when() + .get("/" + BUCKET + "?replication") + .then() + .statusCode(404) + .body(containsString("ReplicationConfigurationNotFoundError")); + given() + .when() + .get("/" + BUCKET + "?location") + .then() + .statusCode(200); + } + + /** Matching real S3, deleting an already-absent configuration still answers 204. */ + @Test + @Order(11) + void deleteReplicationWithoutConfigurationStillReturns204() { + given() + .when() + .delete("/" + BUCKET + "?replication") + .then() + .statusCode(204); + } + + @Test + @Order(12) + void deleteReplicationOnMissingBucketReturns404() { + given() + .when() + .delete("/this-bucket-does-not-exist-repl?replication") + .then() + .statusCode(404) + .body(containsString("NoSuchBucket")); + } + + /** + * Pins the per-method precedence at the wire: the PUT and GET chains dispatch + * accelerate ahead of replication, while the DELETE chain routes replication — + * accelerate's DELETE arm is a 405 and must not preempt it. The IAM mapping + * mirrors exactly this order, so a silent controller reorder would desynchronize + * the two. + */ + @Test + @Order(13) + void accelerateAndReplicationPrecedenceFollowsEachMethodsDispatchOrder() { + String bucket = "replication-precedence-test"; + given() + .when() + .put("/" + bucket) + .then() + .statusCode(200); + + // PUT ?accelerate&replication executes accelerate: the accelerate body is + // accepted, and nothing lands in the replication store. + given() + .body(""" + + Enabled + + """) + .when() + .put("/" + bucket + "?accelerate&replication") + .then() + .statusCode(200); + given() + .when() + .get("/" + bucket + "?accelerate") + .then() + .statusCode(200) + .body(containsString("Enabled")); + given() + .when() + .get("/" + bucket + "?replication") + .then() + .statusCode(404) + .body(containsString("ReplicationConfigurationNotFoundError")); + + // GET ?accelerate&replication executes accelerate: an AccelerateConfiguration + // comes back, not the replication 404. + given() + .when() + .get("/" + bucket + "?accelerate&replication") + .then() + .statusCode(200) + .body(containsString("