mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
feat(core): claim wire protocols reactively per Smithy selection guide (#1712)
* feat(core): claim wire protocols reactively per Smithy selection guide AWS services will adopt additional wire protocols without advance notice starting April 2026, so the protocol must be identified per request rather than assumed per service. Adds a ProtocolClaimer that claims each request from its non-payload signals (Smithy-Protocol header, content type, X-Amz-Target, method, path) in Smithy precision order, exposed to downstream filters by a pre-matching claim filter and consumed by the service-enablement filter in place of its duplicated sniffing. Also fixes smithy-rpc-v2 path routing: the service segment AWS SDKs send is the target prefix (Kinesis_20131202, DynamoDB_20120810, ...), not the SDK serviceId, so rpcv2 service names are now derived from the catalog's target prefixes and the path-based CBOR dispatcher gains the missing Kinesis case. Opt-in strict mode (FLOCI_PROTOCOLS_STRICT_CLAIMING) rejects RPC-signaled requests that no supported protocol claims, including the recognized but unimplemented rpc-v2-json. Default wire behavior is unchanged. Refs #156 * fix(core): scope Smithy-Protocol content-type normalization to rpcv2 paths The normalization filter runs before the path-rewriting filters, so rewriting Content-Type on arbitrary paths erased the signal filters like S3VirtualHostFilter use to bypass non-S3 management traffic. Only normalize POST requests whose path matches the rpcv2 shape — the only requests the rpcv2Cbor claim can succeed for.
This commit is contained in:
1 parent
ac96a7d292
commit
38bf55d323
21 files changed
+946
-73
No files matched your search
+167
@@ -0,0 +1,167 @@
|
||||
package io.github.hectorvent.floci.core.common;
|
||||
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import jakarta.inject.Inject;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
@QuarkusTest
|
||||
class ProtocolClaimerIntegrationTest {
|
||||
|
||||
private static final String SQS_AUTH =
|
||||
"AWS4-HMAC-SHA256 Credential=test/20260702/us-east-1/sqs/aws4_request, "
|
||||
+ "SignedHeaders=host;x-amz-date, Signature=abc";
|
||||
|
||||
@Inject
|
||||
ProtocolClaimer claimer;
|
||||
|
||||
private Optional<ProtocolClaim> claim(String method, String path, String contentType,
|
||||
String smithyProtocol, String xAmzTarget, String authorization) {
|
||||
return claimer.claim(new ClaimSignals(method, path, contentType, smithyProtocol, xAmzTarget, authorization));
|
||||
}
|
||||
|
||||
@Test
|
||||
void smithyProtocolHeaderClaimsRpcV2CborAheadOfEverything() {
|
||||
// All signals at once: the Smithy-Protocol header wins by precedence.
|
||||
ProtocolClaim claim = claim("POST", "/service/DynamoDB_20120810/operation/ListTables",
|
||||
"application/x-amz-json-1.1", "rpc-v2-cbor", "DynamoDB_20120810.ListTables", null).orElseThrow();
|
||||
|
||||
assertEquals(WireProtocol.RPCV2_CBOR, claim.protocol());
|
||||
assertEquals("dynamodb", claim.service().externalKey());
|
||||
assertEquals("ListTables", claim.operation());
|
||||
}
|
||||
|
||||
@Test
|
||||
void rpcV2PathToleratesPrefixSegments() {
|
||||
ProtocolClaim claim = claim("POST", "/v1/service/Kinesis_20131202/operation/ListStreams",
|
||||
"application/cbor", "rpc-v2-cbor", null, null).orElseThrow();
|
||||
|
||||
assertEquals(WireProtocol.RPCV2_CBOR, claim.protocol());
|
||||
assertEquals("kinesis", claim.service().externalKey());
|
||||
}
|
||||
|
||||
@Test
|
||||
void headerlessCborOnRpcV2PathStillClaims() {
|
||||
ProtocolClaim claim = claim("POST", "/service/DynamoDB/operation/GetItem",
|
||||
"application/cbor", null, null, null).orElseThrow();
|
||||
|
||||
assertEquals(WireProtocol.RPCV2_CBOR, claim.protocol());
|
||||
assertEquals("dynamodb", claim.service().externalKey());
|
||||
}
|
||||
|
||||
@Test
|
||||
void rpcV2JsonIsRecognized() {
|
||||
ProtocolClaim claim = claim("POST", "/service/AmazonSQS/operation/ListQueues",
|
||||
"application/json", "rpc-v2-json", null, null).orElseThrow();
|
||||
|
||||
assertEquals(WireProtocol.RPCV2_JSON, claim.protocol());
|
||||
assertEquals("sqs", claim.service().externalKey());
|
||||
}
|
||||
|
||||
@Test
|
||||
void malformedRpcV2SignalsAreUnclaimable() {
|
||||
// Valid header value but wrong method.
|
||||
assertTrue(claim("GET", "/service/DynamoDB_20120810/operation/ListTables",
|
||||
null, "rpc-v2-cbor", null, null).isEmpty());
|
||||
// Valid header value but wrong path shape.
|
||||
assertTrue(claim("POST", "/", "application/cbor", "rpc-v2-cbor", null, null).isEmpty());
|
||||
// Unknown header value.
|
||||
assertTrue(claim("POST", "/service/DynamoDB_20120810/operation/ListTables",
|
||||
"application/cbor", "rpc-v2-msgpack", null, null).isEmpty());
|
||||
// Header value comparison is exact per spec (header NAME is case-insensitive, value is not).
|
||||
assertTrue(claim("POST", "/service/DynamoDB_20120810/operation/ListTables",
|
||||
"application/cbor", "RPC-V2-CBOR", null, null).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
void jsonVersionsSplitOnContentType() {
|
||||
ProtocolClaim json10 = claim("POST", "/", "application/x-amz-json-1.0",
|
||||
null, "DynamoDB_20120810.ListTables", null).orElseThrow();
|
||||
assertEquals(WireProtocol.AWS_JSON_1_0, json10.protocol());
|
||||
assertEquals("dynamodb", json10.service().externalKey());
|
||||
assertEquals("ListTables", json10.operation());
|
||||
|
||||
ProtocolClaim json11 = claim("POST", "/", "application/x-amz-json-1.1",
|
||||
null, "AmazonSSM.DescribeParameters", null).orElseThrow();
|
||||
assertEquals(WireProtocol.AWS_JSON_1_1, json11.protocol());
|
||||
assertEquals("ssm", json11.service().externalKey());
|
||||
}
|
||||
|
||||
@Test
|
||||
void mediaTypeParametersAndCasingAreNormalized() {
|
||||
ProtocolClaim claim = claim("POST", "/", "Application/X-Amz-Json-1.1; charset=utf-8",
|
||||
null, "AmazonSSM.DescribeParameters", null).orElseThrow();
|
||||
|
||||
assertEquals(WireProtocol.AWS_JSON_1_1, claim.protocol());
|
||||
}
|
||||
|
||||
@Test
|
||||
void legacyCborWithTargetAtRootClaimsCborTarget() {
|
||||
// Kinesis via aws-sdk-java: x-amz-cbor-1.1 + X-Amz-Target at root, no smithy header.
|
||||
ProtocolClaim claim = claim("POST", "/", "application/x-amz-cbor-1.1",
|
||||
null, "Kinesis_20131202.ListStreams", null).orElseThrow();
|
||||
|
||||
assertEquals(WireProtocol.AWS_CBOR_TARGET, claim.protocol());
|
||||
assertEquals("kinesis", claim.service().externalKey());
|
||||
assertEquals("ListStreams", claim.operation());
|
||||
}
|
||||
|
||||
@Test
|
||||
void targetWithForeignContentTypeIsUnclaimable() {
|
||||
assertTrue(claim("POST", "/", "text/plain",
|
||||
null, "AmazonSSM.DescribeParameters", null).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
void unknownTargetStillClaimsProtocolWithoutService() {
|
||||
ProtocolClaim claim = claim("POST", "/", "application/x-amz-json-1.1",
|
||||
null, "NoSuchService.DoThing", null).orElseThrow();
|
||||
|
||||
assertEquals(WireProtocol.AWS_JSON_1_1, claim.protocol());
|
||||
assertNull(claim.service());
|
||||
assertEquals("NoSuchService.DoThing", claim.target());
|
||||
}
|
||||
|
||||
@Test
|
||||
void formPostAtRootClaimsQueryAndResolvesServiceFromCredentialScope() {
|
||||
ProtocolClaim withAuth = claim("POST", "/",
|
||||
"application/x-www-form-urlencoded; charset=utf-8", null, null, SQS_AUTH).orElseThrow();
|
||||
assertEquals(WireProtocol.AWS_QUERY, withAuth.protocol());
|
||||
assertEquals("sqs", withAuth.service().externalKey());
|
||||
|
||||
ProtocolClaim withoutAuth = claim("POST", "/",
|
||||
"application/x-www-form-urlencoded", null, null, null).orElseThrow();
|
||||
assertEquals(WireProtocol.AWS_QUERY, withoutAuth.protocol());
|
||||
assertNull(withoutAuth.service());
|
||||
}
|
||||
|
||||
@Test
|
||||
void nonRpcTrafficFallsThroughAsRest() {
|
||||
Optional<ProtocolClaim> get = claim("GET", "/", null, null, null, null);
|
||||
assertEquals(WireProtocol.REST, get.orElseThrow().protocol());
|
||||
|
||||
Optional<ProtocolClaim> s3Post = claim("POST", "/my-bucket",
|
||||
"multipart/form-data; boundary=x", null, null, null);
|
||||
assertEquals(WireProtocol.REST, s3Post.orElseThrow().protocol());
|
||||
|
||||
Optional<ProtocolClaim> lambdaPath = claim("POST", "/2015-03-31/functions",
|
||||
"application/json", null, null, null);
|
||||
assertEquals(WireProtocol.REST, lambdaPath.orElseThrow().protocol());
|
||||
}
|
||||
|
||||
@Test
|
||||
void queryFormOnNonRootPathIsRest() {
|
||||
// Form posts on non-root paths (e.g. before SQS queue-URL rewriting) are
|
||||
// not query claims; the router filter rewrites them to "/" before this
|
||||
// claimer runs in the filter chain.
|
||||
ProtocolClaim claim = claim("POST", "/123456789012/my-queue",
|
||||
"application/x-www-form-urlencoded", null, null, null).orElseThrow();
|
||||
|
||||
assertEquals(WireProtocol.REST, claim.protocol());
|
||||
}
|
||||
}
|
||||
+12
@@ -37,6 +37,18 @@ class ServiceCatalogRoutingIntegrationTest {
|
||||
assertEquals("monitoring", catalog.byCborSdkServiceId("GraniteServiceVersion20100801").orElseThrow().externalKey());
|
||||
}
|
||||
|
||||
@Test
|
||||
void rpcV2ServiceNamesDeriveFromTargetPrefixes() {
|
||||
// The smithy-rpc-v2 path segment is the service shape name == target prefix
|
||||
// without the trailing dot (what the AWS SDKs actually send on the wire).
|
||||
assertEquals("dynamodb", catalog.byCborSdkServiceId("DynamoDB_20120810").orElseThrow().externalKey());
|
||||
assertEquals("dynamodb", catalog.byCborSdkServiceId("DynamoDBStreams_20120810").orElseThrow().externalKey());
|
||||
assertEquals("kinesis", catalog.byCborSdkServiceId("Kinesis_20131202").orElseThrow().externalKey());
|
||||
assertEquals("sqs", catalog.byCborSdkServiceId("AmazonSQS").orElseThrow().externalKey());
|
||||
assertEquals("sns", catalog.byCborSdkServiceId("SNS_20100331").orElseThrow().externalKey());
|
||||
assertEquals("states", catalog.byCborSdkServiceId("AWSStepFunctions").orElseThrow().externalKey());
|
||||
}
|
||||
|
||||
@Test
|
||||
void queryProtocolAliasesAreDeclaredOnDescriptors() {
|
||||
assertTrue(catalog.byCredentialScope("sesv2").orElseThrow().supportsProtocol(ServiceProtocol.QUERY));
|
||||
|
||||
+189
@@ -0,0 +1,189 @@
|
||||
package io.github.hectorvent.floci.core.common;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.dataformat.cbor.CBORFactory;
|
||||
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
|
||||
/**
|
||||
* Exercises the smithy-rpc-v2-cbor wire format exactly as the AWS SDKs send it:
|
||||
* POST /service/{serviceShapeName}/operation/{operation} where the service name
|
||||
* segment is the X-Amz-Target prefix without its trailing dot (e.g.
|
||||
* DynamoDB_20120810, Kinesis_20131202, GraniteServiceVersion20100801), with the
|
||||
* smithy-protocol request header and a generic application/cbor content type.
|
||||
* Also covers the sibling legacy format (x-amz-cbor-1.1 + X-Amz-Target at the
|
||||
* root path) and content-type normalization during protocol transitions.
|
||||
* Captured from aws-sdk-java 2.46.7 — see local/plan/smithy/captured/SUMMARY.md.
|
||||
*/
|
||||
@QuarkusTest
|
||||
class SmithyRpcV2RoutingIntegrationTest {
|
||||
|
||||
private static final ObjectMapper CBOR_MAPPER = new ObjectMapper(new CBORFactory());
|
||||
private static final ObjectMapper JSON_MAPPER = new ObjectMapper();
|
||||
|
||||
@BeforeAll
|
||||
static void configureContentTypes() {
|
||||
RestAssuredJsonUtils.configureAwsContentTypes();
|
||||
}
|
||||
|
||||
@Test
|
||||
void dynamoDbRoutesViaTargetPrefixServiceName() throws Exception {
|
||||
JsonNode createRequest = JSON_MAPPER.readTree("""
|
||||
{
|
||||
"TableName": "RpcV2WireTable",
|
||||
"KeySchema": [{"AttributeName": "pk", "KeyType": "HASH"}],
|
||||
"AttributeDefinitions": [{"AttributeName": "pk", "AttributeType": "S"}],
|
||||
"ProvisionedThroughput": {"ReadCapacityUnits": 1, "WriteCapacityUnits": 1}
|
||||
}
|
||||
""");
|
||||
|
||||
byte[] created = given()
|
||||
.contentType("application/cbor")
|
||||
.accept("application/cbor")
|
||||
.header("smithy-protocol", "rpc-v2-cbor")
|
||||
.body(CBOR_MAPPER.writeValueAsBytes(createRequest))
|
||||
.when()
|
||||
.post("/service/DynamoDB_20120810/operation/CreateTable")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.header("smithy-protocol", equalTo("rpc-v2-cbor"))
|
||||
.contentType("application/cbor")
|
||||
.extract().asByteArray();
|
||||
|
||||
assertThat(CBOR_MAPPER.readTree(created)
|
||||
.path("TableDescription").path("TableName").asText(), equalTo("RpcV2WireTable"));
|
||||
|
||||
given()
|
||||
.contentType("application/cbor")
|
||||
.accept("application/cbor")
|
||||
.header("smithy-protocol", "rpc-v2-cbor")
|
||||
.body(CBOR_MAPPER.writeValueAsBytes(JSON_MAPPER.readTree("""
|
||||
{"TableName": "RpcV2WireTable"}
|
||||
""")))
|
||||
.when()
|
||||
.post("/service/DynamoDB_20120810/operation/DeleteTable")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
void kinesisRoutesViaTargetPrefixServiceName() throws Exception {
|
||||
byte[] response = given()
|
||||
.contentType("application/cbor")
|
||||
.accept("application/cbor")
|
||||
.header("smithy-protocol", "rpc-v2-cbor")
|
||||
.body(CBOR_MAPPER.writeValueAsBytes(JSON_MAPPER.createObjectNode()))
|
||||
.when()
|
||||
.post("/service/Kinesis_20131202/operation/ListStreams")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.header("smithy-protocol", equalTo("rpc-v2-cbor"))
|
||||
.contentType("application/cbor")
|
||||
.extract().asByteArray();
|
||||
|
||||
assertThat(CBOR_MAPPER.readTree(response).path("StreamNames"), notNullValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
void cloudWatchRoutesViaGraniteServiceName() throws Exception {
|
||||
byte[] response = given()
|
||||
.contentType("application/cbor")
|
||||
.accept("application/cbor")
|
||||
.header("smithy-protocol", "rpc-v2-cbor")
|
||||
.body(CBOR_MAPPER.writeValueAsBytes(JSON_MAPPER.createObjectNode()))
|
||||
.when()
|
||||
.post("/service/GraniteServiceVersion20100801/operation/ListMetrics")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.header("smithy-protocol", equalTo("rpc-v2-cbor"))
|
||||
.contentType("application/cbor")
|
||||
.extract().asByteArray();
|
||||
|
||||
assertThat(CBOR_MAPPER.readTree(response).path("Metrics"), notNullValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
void unknownServiceNameReturns404() throws Exception {
|
||||
given()
|
||||
.contentType("application/cbor")
|
||||
.accept("application/cbor")
|
||||
.header("smithy-protocol", "rpc-v2-cbor")
|
||||
.body(CBOR_MAPPER.writeValueAsBytes(JSON_MAPPER.createObjectNode()))
|
||||
.when()
|
||||
.post("/service/NoSuchService/operation/DoThing")
|
||||
.then()
|
||||
.statusCode(404);
|
||||
}
|
||||
|
||||
@Test
|
||||
void legacyCborTargetAtRootEchoesAmzCborContentType() throws Exception {
|
||||
// The live Kinesis format from aws-sdk-java: x-amz-cbor-1.1 body with
|
||||
// X-Amz-Target at the root path, no smithy-protocol request header.
|
||||
byte[] response = given()
|
||||
.contentType("application/x-amz-cbor-1.1")
|
||||
.header("X-Amz-Target", "Kinesis_20131202.ListStreams")
|
||||
.body(CBOR_MAPPER.writeValueAsBytes(JSON_MAPPER.createObjectNode()))
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.contentType("application/x-amz-cbor-1.1")
|
||||
.extract().asByteArray();
|
||||
|
||||
assertThat(CBOR_MAPPER.readTree(response).path("StreamNames"), notNullValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
void smithyProtocolHeaderNormalizesDriftedContentType() throws Exception {
|
||||
// A rpcv2Cbor request whose Content-Type drifted away from application/cbor
|
||||
// must still route: the smithy-protocol header is the definitive claim
|
||||
// signal and AwsCborContentTypeFilter normalizes the media type for it.
|
||||
given()
|
||||
.contentType("application/octet-stream")
|
||||
.header("smithy-protocol", "rpc-v2-cbor")
|
||||
.body(CBOR_MAPPER.writeValueAsBytes(JSON_MAPPER.createObjectNode()))
|
||||
.when()
|
||||
.post("/service/Kinesis_20131202/operation/ListStreams")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.header("smithy-protocol", equalTo("rpc-v2-cbor"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void straySmithyHeaderOutsideRpcV2PathDoesNotRewriteContentType() {
|
||||
// A Smithy-Protocol header on a non-rpcv2 path must not trigger content
|
||||
// type normalization: later filters (e.g. S3VirtualHostFilter) rely on
|
||||
// seeing the original management content type, and the request must
|
||||
// still reach its normal JSON controller.
|
||||
given()
|
||||
.contentType("application/x-amz-json-1.1")
|
||||
.header("Smithy-Protocol", "rpc-v2-cbor")
|
||||
.header("X-Amz-Target", "AmazonSSM.DescribeParameters")
|
||||
.body("{}")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
void amzCbor11OnRpcV2PathEchoesOriginalContentType() throws Exception {
|
||||
given()
|
||||
.contentType("application/x-amz-cbor-1.1")
|
||||
.header("smithy-protocol", "rpc-v2-cbor")
|
||||
.body(CBOR_MAPPER.writeValueAsBytes(JSON_MAPPER.createObjectNode()))
|
||||
.when()
|
||||
.post("/service/Kinesis_20131202/operation/ListStreams")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.contentType("application/x-amz-cbor-1.1");
|
||||
}
|
||||
}
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
package io.github.hectorvent.floci.core.common;
|
||||
|
||||
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.quarkus.test.junit.QuarkusTestProfile;
|
||||
import io.quarkus.test.junit.TestProfile;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.nullValue;
|
||||
|
||||
/**
|
||||
* Verifies the floci.protocols.strict-claiming enforcement: RPC-signaled
|
||||
* requests that no supported wire protocol claims are rejected per the Smithy
|
||||
* wire-protocol-selection guide, while REST and well-formed RPC traffic is
|
||||
* untouched.
|
||||
*/
|
||||
@QuarkusTest
|
||||
@TestProfile(StrictProtocolClaimingIntegrationTest.StrictClaimingProfile.class)
|
||||
class StrictProtocolClaimingIntegrationTest {
|
||||
|
||||
public static final class StrictClaimingProfile implements QuarkusTestProfile {
|
||||
@Override
|
||||
public Map<String, String> getConfigOverrides() {
|
||||
return Map.of("floci.protocols.strict-claiming", "true");
|
||||
}
|
||||
}
|
||||
|
||||
@BeforeAll
|
||||
static void configureContentTypes() {
|
||||
RestAssuredJsonUtils.configureAwsContentTypes();
|
||||
}
|
||||
|
||||
@Test
|
||||
void rpcV2JsonIsRecognizedAndRejected() {
|
||||
given()
|
||||
.contentType("application/json")
|
||||
.header("Smithy-Protocol", "rpc-v2-json")
|
||||
.body("{}")
|
||||
.when()
|
||||
.post("/service/AmazonSQS/operation/ListQueues")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.header("x-amzn-query-error", equalTo("UnknownOperationException;Sender"))
|
||||
.body("__type", equalTo("UnknownOperationException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void unknownSmithyProtocolValueIsRejected() {
|
||||
given()
|
||||
.contentType("application/cbor")
|
||||
.header("Smithy-Protocol", "rpc-v2-msgpack")
|
||||
.body(new byte[]{(byte) 0xbf, (byte) 0xff})
|
||||
.when()
|
||||
.post("/service/DynamoDB_20120810/operation/ListTables")
|
||||
.then()
|
||||
.statusCode(404)
|
||||
.body("__type", equalTo("UnknownOperationException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void targetPostWithForeignContentTypeIsRejected() {
|
||||
given()
|
||||
.contentType("text/plain")
|
||||
.header("X-Amz-Target", "AmazonSSM.DescribeParameters")
|
||||
.body("{}")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(404)
|
||||
.body("__type", equalTo("UnknownOperationException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void wellFormedRpcTrafficIsUnaffected() {
|
||||
given()
|
||||
.contentType("application/x-amz-json-1.1")
|
||||
.header("X-Amz-Target", "AmazonSSM.DescribeParameters")
|
||||
.body("{}")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
void restTrafficIsUnaffected() {
|
||||
// S3 list-buckets at root bypasses claiming enforcement.
|
||||
given()
|
||||
.when()
|
||||
.get("/")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
|
||||
// A POST on a REST path reaches its normal handler (here S3's
|
||||
// /{bucket}/{key} catch-all) instead of the claimer's rejection,
|
||||
// which would carry the x-amzn-query-error header.
|
||||
given()
|
||||
.contentType("application/json")
|
||||
.body("{}")
|
||||
.when()
|
||||
.post("/no/such/rest/path")
|
||||
.then()
|
||||
.header("x-amzn-query-error", nullValue());
|
||||
}
|
||||
}
|
||||
+5
-2
@@ -15,8 +15,11 @@ import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
/**
|
||||
* Tests the smithy-rpc-v2-cbor protocol for DynamoDB.
|
||||
* AWS SDK v2 sends DynamoDB requests as CBOR to /service/DynamoDB/operation/{op}.
|
||||
* Tests the smithy-rpc-v2-cbor protocol for DynamoDB using the legacy
|
||||
* /service/DynamoDB/... alias. The AWS SDKs actually send the service shape
|
||||
* name (the target prefix without its trailing dot, i.e. DynamoDB_20120810) —
|
||||
* that wire format is covered by SmithyRpcV2RoutingIntegrationTest; this alias
|
||||
* remains supported via the explicit cborSdkServiceIds declaration.
|
||||
*/
|
||||
@QuarkusTest
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
|
||||
+2
@@ -322,6 +322,8 @@ class EventBridgeSchedulerIntegrationTest {
|
||||
@Override
|
||||
public EmulatorConfig.InitHooksConfig initHooks() { return null; }
|
||||
@Override
|
||||
public ProtocolsConfig protocols() { return () -> false; }
|
||||
@Override
|
||||
public TlsConfig tls() {
|
||||
return new TlsConfig() {
|
||||
@Override public boolean enabled() { return false; }
|
||||
|
||||
Reference in new issue
Block a user