From ec73eb697de04425cbebf3b83082ea2e27e7dc65 Mon Sep 17 00:00:00 2001 From: hdavidh Date: Fri, 27 Jun 2025 16:27:17 -0700 Subject: [PATCH 1/9] Add model files and test classes --- .../cases/json-querycompatible-input.json | 50 +++ .../cases/json-querycompatible-output.json | 142 +++++++ ...smithy-rpcv2-nonquerycompatible-input.json | 50 +++ ...mithy-rpcv2-nonquerycompatible-output.json | 1 + .../smithy-rpcv2-querycompatible-input.json | 53 +++ .../smithy-rpcv2-querycompatible-output.json | 142 +++++++ .../suites/json-querycompatible-suite.json | 6 + ...smithy-rpcv2-nonquerycompatible-suite.json | 6 + .../smithy-rpcv2-querycompatible-suite.json | 6 + .../json-querycompatible/customization.config | 3 + .../endpoint-rule-set.json | 355 ++++++++++++++++++ .../json-querycompatible/endpoint-tests.json | 5 + .../json-querycompatible/service-2.json | 68 ++++ .../customization.config | 3 + .../endpoint-rule-set.json | 30 ++ .../endpoint-tests.json | 5 + .../rpcv2-nonquerycompatible/service-2.json | 31 ++ .../customization.config | 3 + .../endpoint-rule-set.json | 30 ++ .../rpcv2-querycompatible/endpoint-tests.json | 5 + .../rpcv2-querycompatible/service-2.json | 67 ++++ .../JsonQueryCompatibleProtocolTest.java | 51 +++ ...cV2CborNonQueryCompatibleProtocolTest.java | 51 +++ ...yRpcV2CborQueryCompatibleProtocolTest.java | 51 +++ 24 files changed, 1214 insertions(+) create mode 100644 test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/json-querycompatible-input.json create mode 100644 test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/json-querycompatible-output.json create mode 100644 test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-nonquerycompatible-input.json create mode 100644 test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-nonquerycompatible-output.json create mode 100644 test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-querycompatible-input.json create mode 100644 test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-querycompatible-output.json create mode 100644 test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/json-querycompatible-suite.json create mode 100644 test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/smithy-rpcv2-nonquerycompatible-suite.json create mode 100644 test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/smithy-rpcv2-querycompatible-suite.json create mode 100644 test/protocol-tests/src/main/resources/codegen-resources/json-querycompatible/customization.config create mode 100644 test/protocol-tests/src/main/resources/codegen-resources/json-querycompatible/endpoint-rule-set.json create mode 100644 test/protocol-tests/src/main/resources/codegen-resources/json-querycompatible/endpoint-tests.json create mode 100644 test/protocol-tests/src/main/resources/codegen-resources/json-querycompatible/service-2.json create mode 100644 test/protocol-tests/src/main/resources/codegen-resources/rpcv2-nonquerycompatible/customization.config create mode 100644 test/protocol-tests/src/main/resources/codegen-resources/rpcv2-nonquerycompatible/endpoint-rule-set.json create mode 100644 test/protocol-tests/src/main/resources/codegen-resources/rpcv2-nonquerycompatible/endpoint-tests.json create mode 100644 test/protocol-tests/src/main/resources/codegen-resources/rpcv2-nonquerycompatible/service-2.json create mode 100644 test/protocol-tests/src/main/resources/codegen-resources/rpcv2-querycompatible/customization.config create mode 100644 test/protocol-tests/src/main/resources/codegen-resources/rpcv2-querycompatible/endpoint-rule-set.json create mode 100644 test/protocol-tests/src/main/resources/codegen-resources/rpcv2-querycompatible/endpoint-tests.json create mode 100644 test/protocol-tests/src/main/resources/codegen-resources/rpcv2-querycompatible/service-2.json create mode 100644 test/protocol-tests/src/test/java/software/amazon/awssdk/protocol/tests/JsonQueryCompatibleProtocolTest.java create mode 100644 test/protocol-tests/src/test/java/software/amazon/awssdk/protocol/tests/SmithyRpcV2CborNonQueryCompatibleProtocolTest.java create mode 100644 test/protocol-tests/src/test/java/software/amazon/awssdk/protocol/tests/SmithyRpcV2CborQueryCompatibleProtocolTest.java diff --git a/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/json-querycompatible-input.json b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/json-querycompatible-input.json new file mode 100644 index 000000000000..a67e9a772d1e --- /dev/null +++ b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/json-querycompatible-input.json @@ -0,0 +1,50 @@ +[ + { + "description": "Test cases for QueryCompatibleOperation operation", + "metadata": { + "apiVersion": "2020-07-14", + "auth": [ + "aws.auth#sigv4" + ], + "awsQueryCompatible": {}, + "endpointPrefix": "querycompatiblejsonrpc10", + "jsonVersion": "1.0", + "protocol": "json", + "protocols": [ + "json" + ], + "serviceFullName": "QueryCompatibleJsonRpc10", + "serviceId": "Query Compatible JSON RPC 10", + "signatureVersion": "v4", + "signingName": "QueryCompatibleJsonRpc10", + "targetPrefix": "QueryCompatibleJsonRpc10", + "uid": "query-compatible-json-rpc-10-2020-07-14" + }, + "shapes": {}, + "cases": [ + { + "id": "QueryCompatibleAwsJson10CborSendsQueryModeHeader", + "given": { + "name": "QueryCompatibleOperation", + "http": { + "method": "POST", + "requestUri": "/" + }, + "idempotent": true + }, + "description": "Clients for query-compatible services MUST send the x-amzn-query-mode header.", + "params": {}, + "serialized": { + "method": "POST", + "uri": "/", + "body": "{}", + "headers": { + "Content-Type": "application/x-amz-json-1.0", + "X-Amz-Target": "QueryCompatibleJsonRpc10.QueryCompatibleOperation", + "x-amzn-query-mode": "true" + } + } + } + ] + } +] \ No newline at end of file diff --git a/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/json-querycompatible-output.json b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/json-querycompatible-output.json new file mode 100644 index 000000000000..746aa0da0248 --- /dev/null +++ b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/json-querycompatible-output.json @@ -0,0 +1,142 @@ +[ + { + "description": "Test cases for QueryCompatibleOperation operation", + "metadata": { + "apiVersion": "2020-07-14", + "auth": [ + "aws.auth#sigv4" + ], + "awsQueryCompatible": {}, + "endpointPrefix": "querycompatiblejsonrpc10", + "jsonVersion": "1.0", + "protocol": "json", + "protocols": [ + "json" + ], + "serviceFullName": "QueryCompatibleJsonRpc10", + "serviceId": "Query Compatible JSON RPC 10", + "signatureVersion": "v4", + "signingName": "QueryCompatibleJsonRpc10", + "targetPrefix": "QueryCompatibleJsonRpc10", + "uid": "query-compatible-json-rpc-10-2020-07-14" + }, + "shapes": { + "NoCustomCodeError": { + "type": "structure", + "members": { + "message": { + "shape": "String" + } + }, + "exception": true + }, + "String": { + "type": "string" + } + }, + "cases": [ + { + "id": "QueryCompatibleAwsJson10CborNoCustomCodeError", + "given": { + "name": "QueryCompatibleOperation", + "http": { + "method": "POST", + "requestUri": "/" + }, + "idempotent": true, + "errors": [ + { + "shape": "NoCustomCodeError" + } + ] + }, + "description": "Parses simple errors with no query error code", + "errorCode": "NoCustomCodeError", + "errorMessage": "Hi", + "error": { + "message": "Hi" + }, + "response": { + "status_code": 400, + "headers": { + "Content-Type": "application/x-amz-json-1.0" + }, + "body": "{\n \"__type\": \"aws.protocoltests.json10#NoCustomCodeError\",\n \"Message\": \"Hi\"\n}" + } + } + ] + }, + { + "description": "Test cases for QueryCompatibleOperation operation", + "metadata": { + "apiVersion": "2020-07-14", + "auth": [ + "aws.auth#sigv4" + ], + "awsQueryCompatible": {}, + "endpointPrefix": "querycompatiblejsonrpc10", + "jsonVersion": "1.0", + "protocol": "json", + "protocols": [ + "json" + ], + "serviceFullName": "QueryCompatibleJsonRpc10", + "serviceId": "Query Compatible JSON RPC 10", + "signatureVersion": "v4", + "signingName": "QueryCompatibleJsonRpc10", + "targetPrefix": "QueryCompatibleJsonRpc10", + "uid": "query-compatible-json-rpc-10-2020-07-14" + }, + "shapes": { + "CustomCodeError": { + "type": "structure", + "members": { + "message": { + "shape": "String" + } + }, + "error": { + "code": "Customized", + "httpStatusCode": 402, + "senderFault": true + }, + "exception": true + }, + "String": { + "type": "string" + } + }, + "cases": [ + { + "id": "QueryCompatibleAwsJson10CustomCodeError", + "given": { + "name": "QueryCompatibleOperation", + "http": { + "method": "POST", + "requestUri": "/" + }, + "idempotent": true, + "errors": [ + { + "shape": "CustomCodeError" + } + ] + }, + "description": "Parses simple errors with query error code", + "errorCode": "Customized", + "errorMessage": "Hi", + "error": { + "message": "Hi" + }, + "response": { + "status_code": 400, + "headers": { + "Content-Type": "application/x-amz-json-1.0", + "x-amzn-query-error": "Customized;Sender" + }, + "body": "{\n \"__type\": \"aws.protocoltests.json10#CustomCodeError\",\n \"Message\": \"Hi\"\n}" + } + } + ] + } +] diff --git a/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-nonquerycompatible-input.json b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-nonquerycompatible-input.json new file mode 100644 index 000000000000..a096fc93f80b --- /dev/null +++ b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-nonquerycompatible-input.json @@ -0,0 +1,50 @@ +[ + { + "description": "Test cases for QueryIncompatibleOperation operation", + "metadata": { + "apiVersion": "2025-06-20", + "auth": [ + "aws.auth#sigv4" + ], + "endpointPrefix": "nonquerycompatiblerpcv2protocol", + "protocol": "smithy-rpc-v2-cbor", + "protocols": [ + "smithy-rpc-v2-cbor" + ], + "serviceFullName": "NonQueryCompatibleRpcV2Protocol", + "serviceId": "Non Query Compatible RpcV2 Protocol", + "signatureVersion": "v4", + "signingName": "NonQueryCompatibleRpcV2Protocol", + "targetPrefix": "NonQueryCompatibleRpcV2Protocol", + "uid": "non-query-compatible-rpcv2-protocol-2025-06-20" + }, + "shapes": {}, + "cases": [ + { + "id": "NonQueryCompatibleRpcV2CborForbidsQueryModeHeader", + "given": { + "name": "QueryIncompatibleOperation", + "http": { + "method": "POST", + "requestUri": "/" + }, + "idempotent": true + }, + "description": "The query mode header MUST NOT be set on non-query-compatible services.", + "params": {}, + "serialized": { + "method": "POST", + "uri": "/service/NonQueryCompatibleRpcV2Protocol/operation/QueryIncompatibleOperation", + "body": "{}", + "headers": { + "Accept": "application/cbor", + "smithy-protocol": "rpc-v2-cbor" + }, + "forbidHeaders": [ + "x-amzn-query-mode" + ] + } + } + ] + } +] diff --git a/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-nonquerycompatible-output.json b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-nonquerycompatible-output.json new file mode 100644 index 000000000000..fe51488c7066 --- /dev/null +++ b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-nonquerycompatible-output.json @@ -0,0 +1 @@ +[] diff --git a/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-querycompatible-input.json b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-querycompatible-input.json new file mode 100644 index 000000000000..e679ee727aec --- /dev/null +++ b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-querycompatible-input.json @@ -0,0 +1,53 @@ +[ + { + "description": "Test cases for QueryCompatibleOperation operation", + "metadata": { + "apiVersion": "2025-06-20", + "auth": [ + "aws.auth#sigv4" + ], + "awsQueryCompatible": {}, + "endpointPrefix": "querycompatiblerpcv2protocol", + "protocol": "smithy-rpc-v2-cbor", + "protocols": [ + "smithy-rpc-v2-cbor" + ], + "serviceFullName": "QueryCompatibleRpcV2Protocol", + "serviceId": "Query Compatible RpcV2 Protocol", + "signatureVersion": "v4", + "signingName": "QueryCompatibleRpcV2Protocol", + "targetPrefix": "QueryCompatibleRpcV2Protocol", + "uid": "query-compatible-rpcv2-protocol-2025-06-20" + }, + "shapes": {}, + "cases": [ + { + "id": "QueryCompatibleRpcV2CborSendsQueryModeHeader", + "given": { + "name": "QueryCompatibleOperation", + "http": { + "method": "POST", + "requestUri": "/" + }, + "idempotent": true + }, + "description": "Clients for query-compatible services MUST send the x-amzn-query-mode header.", + "params": {}, + "serialized": { + "method": "POST", + "uri": "/service/QueryCompatibleRpcV2Protocol/operation/QueryCompatibleOperation", + "body": "", + "headers": { + "Accept": "application/cbor", + "smithy-protocol": "rpc-v2-cbor", + "x-amzn-query-mode": "true" + }, + "forbidHeaders": [ + "Content-Type", + "X-Amz-Target" + ] + } + } + ] + } +] diff --git a/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-querycompatible-output.json b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-querycompatible-output.json new file mode 100644 index 000000000000..91625926bfab --- /dev/null +++ b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-querycompatible-output.json @@ -0,0 +1,142 @@ +[ + { + "description": "Test cases for QueryCompatibleOperation operation", + "metadata": { + "apiVersion": "2025-06-20", + "auth": [ + "aws.auth#sigv4" + ], + "awsQueryCompatible": {}, + "endpointPrefix": "querycompatiblerpcv2protocol", + "protocol": "smithy-rpc-v2-cbor", + "protocols": [ + "smithy-rpc-v2-cbor" + ], + "serviceFullName": "QueryCompatibleRpcV2Protocol", + "serviceId": "Query Compatible RpcV2 Protocol", + "signatureVersion": "v4", + "signingName": "QueryCompatibleRpcV2Protocol", + "targetPrefix": "QueryCompatibleRpcV2Protocol", + "uid": "query-compatible-rpcv2-protocol-2025-06-20" + }, + "shapes": { + "NoCustomCodeError": { + "type": "structure", + "members": { + "message": { + "shape": "String" + } + }, + "exception": true + }, + "String": { + "type": "string" + } + }, + "cases": [ + { + "id": "QueryCompatibleRpcV2CborNoCustomCodeError", + "given": { + "name": "QueryCompatibleOperation", + "http": { + "method": "POST", + "requestUri": "/" + }, + "idempotent": true, + "errors": [ + { + "shape": "NoCustomCodeError" + } + ] + }, + "description": "Parses simple RpcV2 CBOR errors with no query error code", + "errorCode": "NoCustomCodeError", + "errorMessage": "Hi", + "error": { + "message": "Hi" + }, + "response": { + "status_code": 400, + "headers": { + "Content-Type": "application/cbor", + "smithy-protocol": "rpc-v2-cbor" + }, + "body": "uQACZl9fdHlwZXgtYXdzLnByb3RvY29sdGVzdHMucnBjdjJjYm9yI05vQ3VzdG9tQ29kZUVycm9yZ01lc3NhZ2ViSGk=" + } + } + ] + }, + { + "description": "Test cases for QueryCompatibleOperation operation", + "metadata": { + "apiVersion": "2025-06-20", + "auth": [ + "aws.auth#sigv4" + ], + "awsQueryCompatible": {}, + "endpointPrefix": "querycompatiblerpcv2protocol", + "protocol": "smithy-rpc-v2-cbor", + "protocols": [ + "smithy-rpc-v2-cbor" + ], + "serviceFullName": "QueryCompatibleRpcV2Protocol", + "serviceId": "Query Compatible RpcV2 Protocol", + "signatureVersion": "v4", + "signingName": "QueryCompatibleRpcV2Protocol", + "targetPrefix": "QueryCompatibleRpcV2Protocol", + "uid": "query-compatible-rpcv2-protocol-2025-06-20" + }, + "shapes": { + "CustomCodeError": { + "type": "structure", + "members": { + "message": { + "shape": "String" + } + }, + "error": { + "code": "Customized", + "httpStatusCode": 402, + "senderFault": true + }, + "exception": true + }, + "String": { + "type": "string" + } + }, + "cases": [ + { + "id": "QueryCompatibleRpcV2CborCustomCodeError", + "given": { + "name": "QueryCompatibleOperation", + "http": { + "method": "POST", + "requestUri": "/" + }, + "idempotent": true, + "errors": [ + { + "shape": "CustomCodeError" + } + ] + }, + "description": "Parses simple RpcV2 CBOR errors with query error code", + "errorCode": "Customized", + "errorMessage": "Hi", + "error": { + "message": "Hi" + }, + "response": { + "status_code": 400, + "headers": { + "Content-Type": "application/cbor", + "smithy-protocol": "rpc-v2-cbor", + "x-amzn-query-error": "Customized;Sender" + }, + "body": "uQACZl9fdHlwZXgrYXdzLnByb3RvY29sdGVzdHMucnBjdjJjYm9yI0N1c3RvbUNvZGVFcnJvcmdNZXNzYWdlYkhp" + } + } + ] + } +] diff --git a/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/json-querycompatible-suite.json b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/json-querycompatible-suite.json new file mode 100644 index 000000000000..90de2bea00f2 --- /dev/null +++ b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/json-querycompatible-suite.json @@ -0,0 +1,6 @@ +{ + "testCases": [ + "cases/json-querycompatible-input.json", + "cases/json-querycompatible-output.json" + ] +} diff --git a/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/smithy-rpcv2-nonquerycompatible-suite.json b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/smithy-rpcv2-nonquerycompatible-suite.json new file mode 100644 index 000000000000..a7a45711a90b --- /dev/null +++ b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/smithy-rpcv2-nonquerycompatible-suite.json @@ -0,0 +1,6 @@ +{ + "testCases": [ + "cases/smithy-rpcv2-nonquerycompatible-input.json", + "cases/smithy-rpcv2-nonquerycompatible-output.json" + ] +} diff --git a/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/smithy-rpcv2-querycompatible-suite.json b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/smithy-rpcv2-querycompatible-suite.json new file mode 100644 index 000000000000..7950dd2ea631 --- /dev/null +++ b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/smithy-rpcv2-querycompatible-suite.json @@ -0,0 +1,6 @@ +{ + "testCases": [ + "cases/smithy-rpcv2-querycompatible-input.json", + "cases/smithy-rpcv2-querycompatible-output.json" + ] +} diff --git a/test/protocol-tests/src/main/resources/codegen-resources/json-querycompatible/customization.config b/test/protocol-tests/src/main/resources/codegen-resources/json-querycompatible/customization.config new file mode 100644 index 000000000000..ec7c8d355d50 --- /dev/null +++ b/test/protocol-tests/src/main/resources/codegen-resources/json-querycompatible/customization.config @@ -0,0 +1,3 @@ +{ + "skipEndpointTestGeneration": true +} diff --git a/test/protocol-tests/src/main/resources/codegen-resources/json-querycompatible/endpoint-rule-set.json b/test/protocol-tests/src/main/resources/codegen-resources/json-querycompatible/endpoint-rule-set.json new file mode 100644 index 000000000000..f05fbec2e671 --- /dev/null +++ b/test/protocol-tests/src/main/resources/codegen-resources/json-querycompatible/endpoint-rule-set.json @@ -0,0 +1,355 @@ +{ + "version": "1.3", + "parameters": { + "Region": { + "builtIn": "AWS::Region", + "required": true, + "documentation": "The AWS region used to dispatch the request.", + "type": "String" + }, + "UseDualStack": { + "builtIn": "AWS::UseDualStack", + "required": true, + "default": false, + "documentation": "When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.", + "type": "Boolean" + }, + "UseFIPS": { + "builtIn": "AWS::UseFIPS", + "required": true, + "default": false, + "documentation": "When true, send this request to the FIPS-compliant regional endpoint. If the configured endpoint does not have a FIPS compliant endpoint, dispatching the request will return an error.", + "type": "Boolean" + }, + "Endpoint": { + "builtIn": "SDK::Endpoint", + "required": false, + "documentation": "Override the endpoint used to send this request", + "type": "String" + } + }, + "rules": [ + { + "conditions": [ + { + "fn": "aws.partition", + "argv": [ + { + "ref": "Region" + } + ], + "assign": "PartitionResult" + } + ], + "type": "tree", + "rules": [ + { + "conditions": [ + { + "fn": "isSet", + "argv": [ + { + "ref": "Endpoint" + } + ] + }, + { + "fn": "parseURL", + "argv": [ + { + "ref": "Endpoint" + } + ], + "assign": "url" + } + ], + "type": "tree", + "rules": [ + { + "conditions": [ + { + "fn": "booleanEquals", + "argv": [ + { + "ref": "UseFIPS" + }, + true + ] + } + ], + "error": "Invalid Configuration: FIPS and custom endpoint are not supported", + "type": "error" + }, + { + "conditions": [], + "type": "tree", + "rules": [ + { + "conditions": [ + { + "fn": "booleanEquals", + "argv": [ + { + "ref": "UseDualStack" + }, + true + ] + } + ], + "error": "Invalid Configuration: Dualstack and custom endpoint are not supported", + "type": "error" + }, + { + "conditions": [], + "endpoint": { + "url": { + "ref": "Endpoint" + }, + "properties": { + "authSchemes": [ + { + "name": "sigv4", + "signingRegion": "{Region}", + "signingName": "jsonrpc" + } + ] + }, + "headers": {} + }, + "type": "endpoint" + } + ] + } + ] + }, + { + "conditions": [ + { + "fn": "booleanEquals", + "argv": [ + { + "ref": "UseFIPS" + }, + true + ] + }, + { + "fn": "booleanEquals", + "argv": [ + { + "ref": "UseDualStack" + }, + true + ] + } + ], + "type": "tree", + "rules": [ + { + "conditions": [ + { + "fn": "booleanEquals", + "argv": [ + true, + { + "fn": "getAttr", + "argv": [ + { + "ref": "PartitionResult" + }, + "supportsFIPS" + ] + } + ] + }, + { + "fn": "booleanEquals", + "argv": [ + true, + { + "fn": "getAttr", + "argv": [ + { + "ref": "PartitionResult" + }, + "supportsDualStack" + ] + } + ] + } + ], + "type": "tree", + "rules": [ + { + "conditions": [], + "endpoint": { + "url": "https://jsonrpc-fips.{Region}.{PartitionResult#dualStackDnsSuffix}", + "properties": { + "authSchemes": [ + { + "name": "sigv4", + "signingRegion": "{Region}", + "signingName": "jsonrpc" + } + ] + }, + "headers": {} + }, + "type": "endpoint" + } + ] + }, + { + "conditions": [], + "error": "FIPS and DualStack are enabled, but this partition does not support one or both", + "type": "error" + } + ] + }, + { + "conditions": [ + { + "fn": "booleanEquals", + "argv": [ + { + "ref": "UseFIPS" + }, + true + ] + } + ], + "type": "tree", + "rules": [ + { + "conditions": [ + { + "fn": "booleanEquals", + "argv": [ + true, + { + "fn": "getAttr", + "argv": [ + { + "ref": "PartitionResult" + }, + "supportsFIPS" + ] + } + ] + } + ], + "type": "tree", + "rules": [ + { + "conditions": [], + "type": "tree", + "rules": [ + { + "conditions": [], + "endpoint": { + "url": "https://jsonrpc-fips.{Region}.{PartitionResult#dnsSuffix}", + "properties": { + "authSchemes": [ + { + "name": "sigv4", + "signingRegion": "{Region}", + "signingName": "jsonrpc" + } + ] + }, + "headers": {} + }, + "type": "endpoint" + } + ] + } + ] + }, + { + "conditions": [], + "error": "FIPS is enabled but this partition does not support FIPS", + "type": "error" + } + ] + }, + { + "conditions": [ + { + "fn": "booleanEquals", + "argv": [ + { + "ref": "UseDualStack" + }, + true + ] + } + ], + "type": "tree", + "rules": [ + { + "conditions": [ + { + "fn": "booleanEquals", + "argv": [ + true, + { + "fn": "getAttr", + "argv": [ + { + "ref": "PartitionResult" + }, + "supportsDualStack" + ] + } + ] + } + ], + "type": "tree", + "rules": [ + { + "conditions": [], + "endpoint": { + "url": "https://jsonrpc.{Region}.{PartitionResult#dualStackDnsSuffix}", + "properties": { + "authSchemes": [ + { + "name": "sigv4", + "signingRegion": "{Region}", + "signingName": "jsonrpc" + } + ] + }, + "headers": {} + }, + "type": "endpoint" + } + ] + }, + { + "conditions": [], + "error": "DualStack is enabled but this partition does not support DualStack", + "type": "error" + } + ] + }, + { + "conditions": [], + "endpoint": { + "url": "https://jsonrpc.{Region}.{PartitionResult#dnsSuffix}", + "properties": { + "authSchemes": [ + { + "name": "sigv4", + "signingRegion": "{Region}", + "signingName": "jsonrpc" + } + ] + }, + "headers": {} + }, + "type": "endpoint" + } + ] + } + ] +} \ No newline at end of file diff --git a/test/protocol-tests/src/main/resources/codegen-resources/json-querycompatible/endpoint-tests.json b/test/protocol-tests/src/main/resources/codegen-resources/json-querycompatible/endpoint-tests.json new file mode 100644 index 000000000000..f94902ff9d99 --- /dev/null +++ b/test/protocol-tests/src/main/resources/codegen-resources/json-querycompatible/endpoint-tests.json @@ -0,0 +1,5 @@ +{ + "testCases": [ + ], + "version": "1.0" +} \ No newline at end of file diff --git a/test/protocol-tests/src/main/resources/codegen-resources/json-querycompatible/service-2.json b/test/protocol-tests/src/main/resources/codegen-resources/json-querycompatible/service-2.json new file mode 100644 index 000000000000..9e2ac282e569 --- /dev/null +++ b/test/protocol-tests/src/main/resources/codegen-resources/json-querycompatible/service-2.json @@ -0,0 +1,68 @@ +{ + "version": "2.0", + "metadata": { + "apiVersion": "2020-07-14", + "auth": [ + "aws.auth#sigv4" + ], + "awsQueryCompatible": {}, + "endpointPrefix": "query-compatible-jsonrpc10", + "jsonVersion": "1.0", + "protocol": "json", + "protocols": [ + "json" + ], + "serviceFullName": "Query Compatible Json 1.0 Protocol Service", + "serviceId": "Query Compatible JSON RPC 10", + "signatureVersion": "v4", + "signingName": "query-compatible-jsonrpc10", + "targetPrefix": "QueryCompatibleJsonRpc10", + "uid": "query-compatible-json-rpc-10-2020-07-14" + }, + "operations": { + "QueryCompatibleOperation": { + "name": "QueryCompatibleOperation", + "http": { + "method": "POST", + "requestUri": "/" + }, + "errors": [ + { + "shape": "CustomCodeError" + }, + { + "shape": "NoCustomCodeError" + } + ], + "idempotent": true + } + }, + "shapes": { + "CustomCodeError": { + "type": "structure", + "members": { + "message": { + "shape": "String" + } + }, + "error": { + "code": "Customized", + "httpStatusCode": 402, + "senderFault": true + }, + "exception": true + }, + "NoCustomCodeError": { + "type": "structure", + "members": { + "message": { + "shape": "String" + } + }, + "exception": true + }, + "String": { + "type": "string" + } + } +} diff --git a/test/protocol-tests/src/main/resources/codegen-resources/rpcv2-nonquerycompatible/customization.config b/test/protocol-tests/src/main/resources/codegen-resources/rpcv2-nonquerycompatible/customization.config new file mode 100644 index 000000000000..ec7c8d355d50 --- /dev/null +++ b/test/protocol-tests/src/main/resources/codegen-resources/rpcv2-nonquerycompatible/customization.config @@ -0,0 +1,3 @@ +{ + "skipEndpointTestGeneration": true +} diff --git a/test/protocol-tests/src/main/resources/codegen-resources/rpcv2-nonquerycompatible/endpoint-rule-set.json b/test/protocol-tests/src/main/resources/codegen-resources/rpcv2-nonquerycompatible/endpoint-rule-set.json new file mode 100644 index 000000000000..b26b9dba1f11 --- /dev/null +++ b/test/protocol-tests/src/main/resources/codegen-resources/rpcv2-nonquerycompatible/endpoint-rule-set.json @@ -0,0 +1,30 @@ +{ + "version": "1.3", + "parameters": { + "Region": { + "builtIn": "AWS::Region", + "required": true, + "documentation": "The AWS region used to dispatch the request.", + "type": "String" + } + }, + "rules": [ + { + "conditions": [], + "endpoint": { + "url": "http://localhost/", + "properties": { + "authSchemes": [ + { + "name": "sigv4", + "signingRegion": "{Region}", + "signingName": "jsonrpc" + } + ] + }, + "headers": {} + }, + "type": "endpoint" + } + ] +} diff --git a/test/protocol-tests/src/main/resources/codegen-resources/rpcv2-nonquerycompatible/endpoint-tests.json b/test/protocol-tests/src/main/resources/codegen-resources/rpcv2-nonquerycompatible/endpoint-tests.json new file mode 100644 index 000000000000..a4f720cee35e --- /dev/null +++ b/test/protocol-tests/src/main/resources/codegen-resources/rpcv2-nonquerycompatible/endpoint-tests.json @@ -0,0 +1,5 @@ +{ + "testCases": [ + ], + "version": "1.0" +} diff --git a/test/protocol-tests/src/main/resources/codegen-resources/rpcv2-nonquerycompatible/service-2.json b/test/protocol-tests/src/main/resources/codegen-resources/rpcv2-nonquerycompatible/service-2.json new file mode 100644 index 000000000000..46a425d98a0b --- /dev/null +++ b/test/protocol-tests/src/main/resources/codegen-resources/rpcv2-nonquerycompatible/service-2.json @@ -0,0 +1,31 @@ +{ + "version": "2.0", + "metadata": { + "apiVersion": "2025-06-20", + "auth": [ + "aws.auth#sigv4" + ], + "endpointPrefix": "non-query-compatible-rpcv2", + "protocol": "smithy-rpc-v2-cbor", + "protocols": [ + "smithy-rpc-v2-cbor" + ], + "serviceFullName": "Non Query Compatible RpcV2 Protocol Service", + "serviceId": "Non Query Compatible RpcV2 Protocol", + "signatureVersion": "v4", + "signingName": "non-query-compatible-rpcv2", + "targetPrefix": "NonQueryCompatibleRpcV2Protocol", + "uid": "non-query-compatible-rpcv2-protocol-2025-06-20" + }, + "operations": { + "QueryIncompatibleOperation": { + "name": "QueryIncompatibleOperation", + "http": { + "method": "POST", + "requestUri": "/" + }, + "idempotent": true + } + }, + "shapes": {} +} diff --git a/test/protocol-tests/src/main/resources/codegen-resources/rpcv2-querycompatible/customization.config b/test/protocol-tests/src/main/resources/codegen-resources/rpcv2-querycompatible/customization.config new file mode 100644 index 000000000000..ec7c8d355d50 --- /dev/null +++ b/test/protocol-tests/src/main/resources/codegen-resources/rpcv2-querycompatible/customization.config @@ -0,0 +1,3 @@ +{ + "skipEndpointTestGeneration": true +} diff --git a/test/protocol-tests/src/main/resources/codegen-resources/rpcv2-querycompatible/endpoint-rule-set.json b/test/protocol-tests/src/main/resources/codegen-resources/rpcv2-querycompatible/endpoint-rule-set.json new file mode 100644 index 000000000000..b26b9dba1f11 --- /dev/null +++ b/test/protocol-tests/src/main/resources/codegen-resources/rpcv2-querycompatible/endpoint-rule-set.json @@ -0,0 +1,30 @@ +{ + "version": "1.3", + "parameters": { + "Region": { + "builtIn": "AWS::Region", + "required": true, + "documentation": "The AWS region used to dispatch the request.", + "type": "String" + } + }, + "rules": [ + { + "conditions": [], + "endpoint": { + "url": "http://localhost/", + "properties": { + "authSchemes": [ + { + "name": "sigv4", + "signingRegion": "{Region}", + "signingName": "jsonrpc" + } + ] + }, + "headers": {} + }, + "type": "endpoint" + } + ] +} diff --git a/test/protocol-tests/src/main/resources/codegen-resources/rpcv2-querycompatible/endpoint-tests.json b/test/protocol-tests/src/main/resources/codegen-resources/rpcv2-querycompatible/endpoint-tests.json new file mode 100644 index 000000000000..f94902ff9d99 --- /dev/null +++ b/test/protocol-tests/src/main/resources/codegen-resources/rpcv2-querycompatible/endpoint-tests.json @@ -0,0 +1,5 @@ +{ + "testCases": [ + ], + "version": "1.0" +} \ No newline at end of file diff --git a/test/protocol-tests/src/main/resources/codegen-resources/rpcv2-querycompatible/service-2.json b/test/protocol-tests/src/main/resources/codegen-resources/rpcv2-querycompatible/service-2.json new file mode 100644 index 000000000000..eaed847ca4f9 --- /dev/null +++ b/test/protocol-tests/src/main/resources/codegen-resources/rpcv2-querycompatible/service-2.json @@ -0,0 +1,67 @@ +{ + "version": "2.0", + "metadata": { + "apiVersion": "2025-06-20", + "auth": [ + "aws.auth#sigv4" + ], + "awsQueryCompatible": {}, + "endpointPrefix": "query-compatible-rpcv2", + "protocol": "smithy-rpc-v2-cbor", + "protocols": [ + "smithy-rpc-v2-cbor" + ], + "serviceFullName": "Query Compatible RpcV2 Protocol Service", + "serviceId": "Query Compatible RpcV2 Protocol", + "signatureVersion": "v4", + "signingName": "query-compatible-rpcv2", + "targetPrefix": "QueryCompatibleRpcV2Protocol", + "uid": "query-compatible-rpcv2-protocol-2025-06-20" + }, + "operations": { + "QueryCompatibleOperation": { + "name": "QueryCompatibleOperation", + "http": { + "method": "POST", + "requestUri": "/" + }, + "errors": [ + { + "shape": "NoCustomCodeError" + }, + { + "shape": "CustomCodeError" + } + ], + "idempotent": true + } + }, + "shapes": { + "CustomCodeError": { + "type": "structure", + "members": { + "message": { + "shape": "String" + } + }, + "error": { + "code": "Customized", + "httpStatusCode": 402, + "senderFault": true + }, + "exception": true + }, + "NoCustomCodeError": { + "type": "structure", + "members": { + "message": { + "shape": "String" + } + }, + "exception": true + }, + "String": { + "type": "string" + } + } +} diff --git a/test/protocol-tests/src/test/java/software/amazon/awssdk/protocol/tests/JsonQueryCompatibleProtocolTest.java b/test/protocol-tests/src/test/java/software/amazon/awssdk/protocol/tests/JsonQueryCompatibleProtocolTest.java new file mode 100644 index 000000000000..aabc4298b064 --- /dev/null +++ b/test/protocol-tests/src/test/java/software/amazon/awssdk/protocol/tests/JsonQueryCompatibleProtocolTest.java @@ -0,0 +1,51 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package software.amazon.awssdk.protocol.tests; + +import java.io.IOException; +import java.util.List; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import software.amazon.awssdk.protocol.ProtocolTestSuiteLoader; +import software.amazon.awssdk.protocol.model.TestCase; +import software.amazon.awssdk.protocol.runners.ProtocolTestRunner; + +@RunWith(Parameterized.class) +public class JsonQueryCompatibleProtocolTest extends ProtocolTestBase { + + private static final ProtocolTestSuiteLoader TEST_SUITE_LOADER = new ProtocolTestSuiteLoader(); + private static ProtocolTestRunner testRunner; + + @Parameterized.Parameter + public TestCase testCase; + + @Parameterized.Parameters(name = "{0}") + public static List data() throws IOException { + return TEST_SUITE_LOADER.load("json-querycompatible-suite.json"); + } + + @BeforeClass + public static void setupFixture() { + testRunner = new ProtocolTestRunner("/models/query-compatible-jsonrpc10-2020-07-14-intermediate.json"); + } + + @Test + public void runProtocolTest() throws Exception { + testRunner.runTest(testCase); + } +} diff --git a/test/protocol-tests/src/test/java/software/amazon/awssdk/protocol/tests/SmithyRpcV2CborNonQueryCompatibleProtocolTest.java b/test/protocol-tests/src/test/java/software/amazon/awssdk/protocol/tests/SmithyRpcV2CborNonQueryCompatibleProtocolTest.java new file mode 100644 index 000000000000..b099a82932c7 --- /dev/null +++ b/test/protocol-tests/src/test/java/software/amazon/awssdk/protocol/tests/SmithyRpcV2CborNonQueryCompatibleProtocolTest.java @@ -0,0 +1,51 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package software.amazon.awssdk.protocol.tests; + +import java.io.IOException; +import java.util.List; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import software.amazon.awssdk.protocol.ProtocolTestSuiteLoader; +import software.amazon.awssdk.protocol.model.TestCase; +import software.amazon.awssdk.protocol.runners.ProtocolTestRunner; + +@RunWith(Parameterized.class) +public class SmithyRpcV2CborNonQueryCompatibleProtocolTest extends ProtocolTestBase { + + private static final ProtocolTestSuiteLoader TEST_SUITE_LOADER = new ProtocolTestSuiteLoader(); + private static ProtocolTestRunner testRunner; + + @Parameterized.Parameter + public TestCase testCase; + + @Parameterized.Parameters(name = "{0}") + public static List data() throws IOException { + return TEST_SUITE_LOADER.load("smithy-rpcv2-nonquerycompatible-suite.json"); + } + + @BeforeClass + public static void setupFixture() { + testRunner = new ProtocolTestRunner("/models/non-query-compatible-rpcv2-2025-06-20-intermediate.json"); + } + + @Test + public void runProtocolTest() throws Exception { + testRunner.runTest(testCase); + } +} diff --git a/test/protocol-tests/src/test/java/software/amazon/awssdk/protocol/tests/SmithyRpcV2CborQueryCompatibleProtocolTest.java b/test/protocol-tests/src/test/java/software/amazon/awssdk/protocol/tests/SmithyRpcV2CborQueryCompatibleProtocolTest.java new file mode 100644 index 000000000000..a81a8f3a424b --- /dev/null +++ b/test/protocol-tests/src/test/java/software/amazon/awssdk/protocol/tests/SmithyRpcV2CborQueryCompatibleProtocolTest.java @@ -0,0 +1,51 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package software.amazon.awssdk.protocol.tests; + +import java.io.IOException; +import java.util.List; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import software.amazon.awssdk.protocol.ProtocolTestSuiteLoader; +import software.amazon.awssdk.protocol.model.TestCase; +import software.amazon.awssdk.protocol.runners.ProtocolTestRunner; + +@RunWith(Parameterized.class) +public class SmithyRpcV2CborQueryCompatibleProtocolTest extends ProtocolTestBase { + + private static final ProtocolTestSuiteLoader TEST_SUITE_LOADER = new ProtocolTestSuiteLoader(); + private static ProtocolTestRunner testRunner; + + @Parameterized.Parameter + public TestCase testCase; + + @Parameterized.Parameters(name = "{0}") + public static List data() throws IOException { + return TEST_SUITE_LOADER.load("smithy-rpcv2-querycompatible-suite.json"); + } + + @BeforeClass + public static void setupFixture() { + testRunner = new ProtocolTestRunner("/models/query-compatible-rpcv2-2025-06-20-intermediate.json"); + } + + @Test + public void runProtocolTest() throws Exception { + testRunner.runTest(testCase); + } +} From c9a018ba96bbaf9b7075150a77978397b49b3011 Mon Sep 17 00:00:00 2001 From: hdavidh Date: Tue, 1 Jul 2025 13:35:43 -0700 Subject: [PATCH 2/9] Update test cases --- .../amazon/awssdk/protocol/model/Then.java | 5 +- .../cases/json-querycompatible-input.json | 64 +++----- .../cases/json-querycompatible-output.json | 149 ++++------------- ...smithy-rpcv2-nonquerycompatible-input.json | 60 +++---- .../smithy-rpcv2-querycompatible-input.json | 61 +++---- .../smithy-rpcv2-querycompatible-output.json | 151 ++++-------------- 6 files changed, 124 insertions(+), 366 deletions(-) diff --git a/test/protocol-tests-core/src/main/java/software/amazon/awssdk/protocol/model/Then.java b/test/protocol-tests-core/src/main/java/software/amazon/awssdk/protocol/model/Then.java index 0f6bc1268bd1..d1586ec08805 100644 --- a/test/protocol-tests-core/src/main/java/software/amazon/awssdk/protocol/model/Then.java +++ b/test/protocol-tests-core/src/main/java/software/amazon/awssdk/protocol/model/Then.java @@ -32,10 +32,11 @@ public class Then { @JsonCreator public Then(@JsonProperty("serializedAs") SerializedAs serializedAs, - @JsonProperty("deserializedAs") JsonNode deserializedAs) { + @JsonProperty("deserializedAs") JsonNode deserializedAs, + @JsonProperty("errorDeserializedAs") JsonNode errorDeserializedAs) { this.serializedAs = serializedAs; this.deserializedAs = new UnmarshalledResultAssertion(deserializedAs); - this.errorDeserializedAs = new UnmarshalledErrorAssertion(deserializedAs); + this.errorDeserializedAs = new UnmarshalledErrorAssertion(errorDeserializedAs); } /** diff --git a/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/json-querycompatible-input.json b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/json-querycompatible-input.json index a67e9a772d1e..fdd06eceb887 100644 --- a/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/json-querycompatible-input.json +++ b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/json-querycompatible-input.json @@ -1,50 +1,28 @@ [ { - "description": "Test cases for QueryCompatibleOperation operation", - "metadata": { - "apiVersion": "2020-07-14", - "auth": [ - "aws.auth#sigv4" - ], - "awsQueryCompatible": {}, - "endpointPrefix": "querycompatiblejsonrpc10", - "jsonVersion": "1.0", - "protocol": "json", - "protocols": [ - "json" - ], - "serviceFullName": "QueryCompatibleJsonRpc10", - "serviceId": "Query Compatible JSON RPC 10", - "signatureVersion": "v4", - "signingName": "QueryCompatibleJsonRpc10", - "targetPrefix": "QueryCompatibleJsonRpc10", - "uid": "query-compatible-json-rpc-10-2020-07-14" + "description": "Clients for query-compatible services MUST send the x-amzn-query-mode header.", + "given": { + "input": {} }, - "shapes": {}, - "cases": [ - { - "id": "QueryCompatibleAwsJson10CborSendsQueryModeHeader", - "given": { - "name": "QueryCompatibleOperation", - "http": { - "method": "POST", - "requestUri": "/" - }, - "idempotent": true - }, - "description": "Clients for query-compatible services MUST send the x-amzn-query-mode header.", - "params": {}, - "serialized": { - "method": "POST", - "uri": "/", - "body": "{}", - "headers": { - "Content-Type": "application/x-amz-json-1.0", + "when": { + "action": "marshall", + "operation": "QueryCompatibleOperation" + }, + "then": { + "serializedAs": { + "method": "POST", + "headers": { + "contains": { "X-Amz-Target": "QueryCompatibleJsonRpc10.QueryCompatibleOperation", - "x-amzn-query-mode": "true" + "x-amzn-query-mode": "true", + "Content-Type": "application/x-amz-json-1.0" } - } + }, + "body": { + "jsonEquals": "{}" + }, + "uri": "/" } - ] + } } -] \ No newline at end of file +] diff --git a/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/json-querycompatible-output.json b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/json-querycompatible-output.json index 746aa0da0248..b0332816ae58 100644 --- a/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/json-querycompatible-output.json +++ b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/json-querycompatible-output.json @@ -1,142 +1,51 @@ [ { - "description": "Test cases for QueryCompatibleOperation operation", - "metadata": { - "apiVersion": "2020-07-14", - "auth": [ - "aws.auth#sigv4" - ], - "awsQueryCompatible": {}, - "endpointPrefix": "querycompatiblejsonrpc10", - "jsonVersion": "1.0", - "protocol": "json", - "protocols": [ - "json" - ], - "serviceFullName": "QueryCompatibleJsonRpc10", - "serviceId": "Query Compatible JSON RPC 10", - "signatureVersion": "v4", - "signingName": "QueryCompatibleJsonRpc10", - "targetPrefix": "QueryCompatibleJsonRpc10", - "uid": "query-compatible-json-rpc-10-2020-07-14" - }, - "shapes": { - "NoCustomCodeError": { - "type": "structure", - "members": { - "message": { - "shape": "String" - } + "description": "Parses simple errors with no query error code", + "given": { + "response": { + "status_code": 400, + "headers": { + "Content-Type": "application/x-amz-json-1.0" }, - "exception": true - }, - "String": { - "type": "string" + "body": "{\n \"__type\": \"aws.protocoltests.json10#NoCustomCodeError\",\n \"Message\": \"Hi\"\n}" } }, - "cases": [ - { - "id": "QueryCompatibleAwsJson10CborNoCustomCodeError", - "given": { - "name": "QueryCompatibleOperation", - "http": { - "method": "POST", - "requestUri": "/" - }, - "idempotent": true, - "errors": [ - { - "shape": "NoCustomCodeError" - } - ] - }, - "description": "Parses simple errors with no query error code", + "when": { + "action": "unmarshall", + "operation": "QueryCompatibleOperation" + }, + "then": { + "errorDeserializedAs": { "errorCode": "NoCustomCodeError", - "errorMessage": "Hi", "error": { "message": "Hi" - }, - "response": { - "status_code": 400, - "headers": { - "Content-Type": "application/x-amz-json-1.0" - }, - "body": "{\n \"__type\": \"aws.protocoltests.json10#NoCustomCodeError\",\n \"Message\": \"Hi\"\n}" } } - ] + } }, { - "description": "Test cases for QueryCompatibleOperation operation", - "metadata": { - "apiVersion": "2020-07-14", - "auth": [ - "aws.auth#sigv4" - ], - "awsQueryCompatible": {}, - "endpointPrefix": "querycompatiblejsonrpc10", - "jsonVersion": "1.0", - "protocol": "json", - "protocols": [ - "json" - ], - "serviceFullName": "QueryCompatibleJsonRpc10", - "serviceId": "Query Compatible JSON RPC 10", - "signatureVersion": "v4", - "signingName": "QueryCompatibleJsonRpc10", - "targetPrefix": "QueryCompatibleJsonRpc10", - "uid": "query-compatible-json-rpc-10-2020-07-14" - }, - "shapes": { - "CustomCodeError": { - "type": "structure", - "members": { - "message": { - "shape": "String" - } + "description": "Parses simple errors with query error code", + "given": { + "response": { + "status_code": 400, + "headers": { + "x-amzn-query-error": "Customized;Sender", + "Content-Type": "application/x-amz-json-1.0" }, - "error": { - "code": "Customized", - "httpStatusCode": 402, - "senderFault": true - }, - "exception": true - }, - "String": { - "type": "string" + "body": "{\n \"__type\": \"aws.protocoltests.json10#CustomCodeError\",\n \"Message\": \"Hi\"\n}" } }, - "cases": [ - { - "id": "QueryCompatibleAwsJson10CustomCodeError", - "given": { - "name": "QueryCompatibleOperation", - "http": { - "method": "POST", - "requestUri": "/" - }, - "idempotent": true, - "errors": [ - { - "shape": "CustomCodeError" - } - ] - }, - "description": "Parses simple errors with query error code", + "when": { + "action": "unmarshall", + "operation": "QueryCompatibleOperation" + }, + "then": { + "errorDeserializedAs": { "errorCode": "Customized", - "errorMessage": "Hi", "error": { "message": "Hi" - }, - "response": { - "status_code": 400, - "headers": { - "Content-Type": "application/x-amz-json-1.0", - "x-amzn-query-error": "Customized;Sender" - }, - "body": "{\n \"__type\": \"aws.protocoltests.json10#CustomCodeError\",\n \"Message\": \"Hi\"\n}" } } - ] + } } ] diff --git a/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-nonquerycompatible-input.json b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-nonquerycompatible-input.json index a096fc93f80b..f95f7c0ca428 100644 --- a/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-nonquerycompatible-input.json +++ b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-nonquerycompatible-input.json @@ -1,50 +1,30 @@ [ { - "description": "Test cases for QueryIncompatibleOperation operation", - "metadata": { - "apiVersion": "2025-06-20", - "auth": [ - "aws.auth#sigv4" - ], - "endpointPrefix": "nonquerycompatiblerpcv2protocol", - "protocol": "smithy-rpc-v2-cbor", - "protocols": [ - "smithy-rpc-v2-cbor" - ], - "serviceFullName": "NonQueryCompatibleRpcV2Protocol", - "serviceId": "Non Query Compatible RpcV2 Protocol", - "signatureVersion": "v4", - "signingName": "NonQueryCompatibleRpcV2Protocol", - "targetPrefix": "NonQueryCompatibleRpcV2Protocol", - "uid": "non-query-compatible-rpcv2-protocol-2025-06-20" + "description": "The query mode header MUST NOT be set on non-query-compatible services.", + "given": { + "input": {} }, - "shapes": {}, - "cases": [ - { - "id": "NonQueryCompatibleRpcV2CborForbidsQueryModeHeader", - "given": { - "name": "QueryIncompatibleOperation", - "http": { - "method": "POST", - "requestUri": "/" - }, - "idempotent": true - }, - "description": "The query mode header MUST NOT be set on non-query-compatible services.", - "params": {}, - "serialized": { - "method": "POST", - "uri": "/service/NonQueryCompatibleRpcV2Protocol/operation/QueryIncompatibleOperation", - "body": "{}", - "headers": { + "when": { + "action": "marshall", + "operation": "NonQueryCompatibleOperation" + }, + "then": { + "serializedAs": { + "method": "POST", + "headers": { + "contains": { "Accept": "application/cbor", "smithy-protocol": "rpc-v2-cbor" }, - "forbidHeaders": [ + "doesNotContain": [ "x-amzn-query-mode" ] - } + }, + "body": { + "encodedEquals": "" + }, + "uri": "/service/NonQueryCompatibleRpcV2Protocol/operation/QueryIncompatibleOperation" } - ] + } } -] +] \ No newline at end of file diff --git a/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-querycompatible-input.json b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-querycompatible-input.json index e679ee727aec..1f1b4fc04824 100644 --- a/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-querycompatible-input.json +++ b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-querycompatible-input.json @@ -1,53 +1,32 @@ [ { - "description": "Test cases for QueryCompatibleOperation operation", - "metadata": { - "apiVersion": "2025-06-20", - "auth": [ - "aws.auth#sigv4" - ], - "awsQueryCompatible": {}, - "endpointPrefix": "querycompatiblerpcv2protocol", - "protocol": "smithy-rpc-v2-cbor", - "protocols": [ - "smithy-rpc-v2-cbor" - ], - "serviceFullName": "QueryCompatibleRpcV2Protocol", - "serviceId": "Query Compatible RpcV2 Protocol", - "signatureVersion": "v4", - "signingName": "QueryCompatibleRpcV2Protocol", - "targetPrefix": "QueryCompatibleRpcV2Protocol", - "uid": "query-compatible-rpcv2-protocol-2025-06-20" + "description": "Clients for query-compatible services MUST send the x-amzn-query-mode header.", + "given": { + "input": {} }, - "shapes": {}, - "cases": [ - { - "id": "QueryCompatibleRpcV2CborSendsQueryModeHeader", - "given": { - "name": "QueryCompatibleOperation", - "http": { - "method": "POST", - "requestUri": "/" - }, - "idempotent": true - }, - "description": "Clients for query-compatible services MUST send the x-amzn-query-mode header.", - "params": {}, - "serialized": { - "method": "POST", - "uri": "/service/QueryCompatibleRpcV2Protocol/operation/QueryCompatibleOperation", - "body": "", - "headers": { - "Accept": "application/cbor", + "when": { + "action": "marshall", + "operation": "QueryCompatibleOperation" + }, + "then": { + "serializedAs": { + "method": "POST", + "headers": { + "contains": { "smithy-protocol": "rpc-v2-cbor", + "Accept": "application/cbor", "x-amzn-query-mode": "true" }, - "forbidHeaders": [ + "doesNotContain": [ "Content-Type", "X-Amz-Target" ] - } + }, + "body": { + "encodedEquals": "" + }, + "uri": "/service/QueryCompatibleRpcV2Protocol/operation/QueryCompatibleOperation" } - ] + } } ] diff --git a/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-querycompatible-output.json b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-querycompatible-output.json index 91625926bfab..521b4c1c5dee 100644 --- a/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-querycompatible-output.json +++ b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-querycompatible-output.json @@ -1,142 +1,53 @@ [ { - "description": "Test cases for QueryCompatibleOperation operation", - "metadata": { - "apiVersion": "2025-06-20", - "auth": [ - "aws.auth#sigv4" - ], - "awsQueryCompatible": {}, - "endpointPrefix": "querycompatiblerpcv2protocol", - "protocol": "smithy-rpc-v2-cbor", - "protocols": [ - "smithy-rpc-v2-cbor" - ], - "serviceFullName": "QueryCompatibleRpcV2Protocol", - "serviceId": "Query Compatible RpcV2 Protocol", - "signatureVersion": "v4", - "signingName": "QueryCompatibleRpcV2Protocol", - "targetPrefix": "QueryCompatibleRpcV2Protocol", - "uid": "query-compatible-rpcv2-protocol-2025-06-20" - }, - "shapes": { - "NoCustomCodeError": { - "type": "structure", - "members": { - "message": { - "shape": "String" - } + "description": "Parses simple RpcV2 CBOR errors with no query error code", + "given": { + "response": { + "status_code": 400, + "headers": { + "smithy-protocol": "rpc-v2-cbor", + "Content-Type": "application/cbor" }, - "exception": true - }, - "String": { - "type": "string" + "body": "uQACZl9fdHlwZXgtYXdzLnByb3RvY29sdGVzdHMucnBjdjJjYm9yI05vQ3VzdG9tQ29kZUVycm9yZ01lc3NhZ2ViSGk=" } }, - "cases": [ - { - "id": "QueryCompatibleRpcV2CborNoCustomCodeError", - "given": { - "name": "QueryCompatibleOperation", - "http": { - "method": "POST", - "requestUri": "/" - }, - "idempotent": true, - "errors": [ - { - "shape": "NoCustomCodeError" - } - ] - }, - "description": "Parses simple RpcV2 CBOR errors with no query error code", + "when": { + "action": "unmarshall", + "operation": "QueryCompatibleOperation" + }, + "then": { + "errorDeserializedAs": { "errorCode": "NoCustomCodeError", - "errorMessage": "Hi", "error": { "message": "Hi" - }, - "response": { - "status_code": 400, - "headers": { - "Content-Type": "application/cbor", - "smithy-protocol": "rpc-v2-cbor" - }, - "body": "uQACZl9fdHlwZXgtYXdzLnByb3RvY29sdGVzdHMucnBjdjJjYm9yI05vQ3VzdG9tQ29kZUVycm9yZ01lc3NhZ2ViSGk=" } } - ] + } }, { - "description": "Test cases for QueryCompatibleOperation operation", - "metadata": { - "apiVersion": "2025-06-20", - "auth": [ - "aws.auth#sigv4" - ], - "awsQueryCompatible": {}, - "endpointPrefix": "querycompatiblerpcv2protocol", - "protocol": "smithy-rpc-v2-cbor", - "protocols": [ - "smithy-rpc-v2-cbor" - ], - "serviceFullName": "QueryCompatibleRpcV2Protocol", - "serviceId": "Query Compatible RpcV2 Protocol", - "signatureVersion": "v4", - "signingName": "QueryCompatibleRpcV2Protocol", - "targetPrefix": "QueryCompatibleRpcV2Protocol", - "uid": "query-compatible-rpcv2-protocol-2025-06-20" - }, - "shapes": { - "CustomCodeError": { - "type": "structure", - "members": { - "message": { - "shape": "String" - } + "description": "Parses simple RpcV2 CBOR errors with query error code", + "given": { + "response": { + "status_code": 400, + "headers": { + "x-amzn-query-error": "Customized;Sender", + "smithy-protocol": "rpc-v2-cbor", + "Content-Type": "application/cbor" }, - "error": { - "code": "Customized", - "httpStatusCode": 402, - "senderFault": true - }, - "exception": true - }, - "String": { - "type": "string" + "body": "uQACZl9fdHlwZXgrYXdzLnByb3RvY29sdGVzdHMucnBjdjJjYm9yI0N1c3RvbUNvZGVFcnJvcmdNZXNzYWdlYkhp" } }, - "cases": [ - { - "id": "QueryCompatibleRpcV2CborCustomCodeError", - "given": { - "name": "QueryCompatibleOperation", - "http": { - "method": "POST", - "requestUri": "/" - }, - "idempotent": true, - "errors": [ - { - "shape": "CustomCodeError" - } - ] - }, - "description": "Parses simple RpcV2 CBOR errors with query error code", + "when": { + "action": "unmarshall", + "operation": "QueryCompatibleOperation" + }, + "then": { + "errorDeserializedAs": { "errorCode": "Customized", - "errorMessage": "Hi", "error": { "message": "Hi" - }, - "response": { - "status_code": 400, - "headers": { - "Content-Type": "application/cbor", - "smithy-protocol": "rpc-v2-cbor", - "x-amzn-query-error": "Customized;Sender" - }, - "body": "uQACZl9fdHlwZXgrYXdzLnByb3RvY29sdGVzdHMucnBjdjJjYm9yI0N1c3RvbUNvZGVFcnJvcmdNZXNzYWdlYkhp" } } - ] + } } ] From 84228885b040738e92316a0e186f81b6cd4ba703 Mon Sep 17 00:00:00 2001 From: hdavidh Date: Tue, 1 Jul 2025 13:57:30 -0700 Subject: [PATCH 3/9] Add support for test case id --- .../amazon/awssdk/protocol/model/TestCase.java | 10 +++++++++- .../awssdk/protocol/runners/ProtocolTestRunner.java | 2 +- .../suites/cases/json-querycompatible-input.json | 1 + .../suites/cases/json-querycompatible-output.json | 2 ++ .../cases/smithy-rpcv2-nonquerycompatible-input.json | 3 ++- .../cases/smithy-rpcv2-querycompatible-input.json | 1 + .../cases/smithy-rpcv2-querycompatible-output.json | 2 ++ 7 files changed, 18 insertions(+), 3 deletions(-) diff --git a/test/protocol-tests-core/src/main/java/software/amazon/awssdk/protocol/model/TestCase.java b/test/protocol-tests-core/src/main/java/software/amazon/awssdk/protocol/model/TestCase.java index 51647cdd6291..a56291a4b5f8 100644 --- a/test/protocol-tests-core/src/main/java/software/amazon/awssdk/protocol/model/TestCase.java +++ b/test/protocol-tests-core/src/main/java/software/amazon/awssdk/protocol/model/TestCase.java @@ -17,12 +17,20 @@ public class TestCase { + private String id; private String description; // Given is optional private Given given = new Given(); private When when; private Then then; + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } public String getDescription() { return description; } @@ -57,7 +65,7 @@ public void setThen(Then then) { @Override public String toString() { - return description; + return id; } } diff --git a/test/protocol-tests-core/src/main/java/software/amazon/awssdk/protocol/runners/ProtocolTestRunner.java b/test/protocol-tests-core/src/main/java/software/amazon/awssdk/protocol/runners/ProtocolTestRunner.java index 6c86766b1796..954b7482e321 100644 --- a/test/protocol-tests-core/src/main/java/software/amazon/awssdk/protocol/runners/ProtocolTestRunner.java +++ b/test/protocol-tests-core/src/main/java/software/amazon/awssdk/protocol/runners/ProtocolTestRunner.java @@ -66,7 +66,7 @@ public void runTests(List tests) throws Exception { } public void runTest(TestCase testCase) throws Exception { - log.info("Running test: {}", testCase.getDescription()); + log.info("Running test: [{}] {}", testCase.getId(), testCase.getDescription()); switch (testCase.getWhen().getAction()) { case MARSHALL: marshallingTestRunner.runTest(testCase); diff --git a/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/json-querycompatible-input.json b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/json-querycompatible-input.json index fdd06eceb887..cf9980c89604 100644 --- a/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/json-querycompatible-input.json +++ b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/json-querycompatible-input.json @@ -1,5 +1,6 @@ [ { + "id": "QueryCompatibleAwsJson10CborSendsQueryModeHeader", "description": "Clients for query-compatible services MUST send the x-amzn-query-mode header.", "given": { "input": {} diff --git a/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/json-querycompatible-output.json b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/json-querycompatible-output.json index b0332816ae58..4c11a5d8e1c7 100644 --- a/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/json-querycompatible-output.json +++ b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/json-querycompatible-output.json @@ -1,5 +1,6 @@ [ { + "id": "QueryCompatibleRpcV2CborNoCustomCodeError", "description": "Parses simple errors with no query error code", "given": { "response": { @@ -24,6 +25,7 @@ } }, { + "id": "QueryCompatibleRpcV2CborCustomCodeError", "description": "Parses simple errors with query error code", "given": { "response": { diff --git a/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-nonquerycompatible-input.json b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-nonquerycompatible-input.json index f95f7c0ca428..b4fea52b0e74 100644 --- a/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-nonquerycompatible-input.json +++ b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-nonquerycompatible-input.json @@ -1,12 +1,13 @@ [ { + "id": "NonQueryCompatibleRpcV2CborForbidsQueryModeHeader", "description": "The query mode header MUST NOT be set on non-query-compatible services.", "given": { "input": {} }, "when": { "action": "marshall", - "operation": "NonQueryCompatibleOperation" + "operation": "QueryIncompatibleOperation" }, "then": { "serializedAs": { diff --git a/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-querycompatible-input.json b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-querycompatible-input.json index 1f1b4fc04824..362acb35f482 100644 --- a/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-querycompatible-input.json +++ b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-querycompatible-input.json @@ -1,5 +1,6 @@ [ { + "id": "QueryCompatibleRpcV2CborSendsQueryModeHeader", "description": "Clients for query-compatible services MUST send the x-amzn-query-mode header.", "given": { "input": {} diff --git a/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-querycompatible-output.json b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-querycompatible-output.json index 521b4c1c5dee..1f9b764b2dfc 100644 --- a/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-querycompatible-output.json +++ b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-querycompatible-output.json @@ -1,5 +1,6 @@ [ { + "id": "QueryCompatibleAwsJson10CborNoCustomCodeError", "description": "Parses simple RpcV2 CBOR errors with no query error code", "given": { "response": { @@ -25,6 +26,7 @@ } }, { + "id": "QueryCompatibleAwsJson10CustomCodeError", "description": "Parses simple RpcV2 CBOR errors with query error code", "given": { "response": { From b789220d4214b5832e7ac447dcddc34e4c880b26 Mon Sep 17 00:00:00 2001 From: hdavidh Date: Tue, 1 Jul 2025 14:56:12 -0700 Subject: [PATCH 4/9] Update output test cases --- .../amazon/awssdk/protocol/model/Then.java | 5 ++--- .../cases/json-querycompatible-output.json | 22 ++++++++----------- .../smithy-rpcv2-querycompatible-output.json | 22 ++++++++----------- 3 files changed, 20 insertions(+), 29 deletions(-) diff --git a/test/protocol-tests-core/src/main/java/software/amazon/awssdk/protocol/model/Then.java b/test/protocol-tests-core/src/main/java/software/amazon/awssdk/protocol/model/Then.java index d1586ec08805..0f6bc1268bd1 100644 --- a/test/protocol-tests-core/src/main/java/software/amazon/awssdk/protocol/model/Then.java +++ b/test/protocol-tests-core/src/main/java/software/amazon/awssdk/protocol/model/Then.java @@ -32,11 +32,10 @@ public class Then { @JsonCreator public Then(@JsonProperty("serializedAs") SerializedAs serializedAs, - @JsonProperty("deserializedAs") JsonNode deserializedAs, - @JsonProperty("errorDeserializedAs") JsonNode errorDeserializedAs) { + @JsonProperty("deserializedAs") JsonNode deserializedAs) { this.serializedAs = serializedAs; this.deserializedAs = new UnmarshalledResultAssertion(deserializedAs); - this.errorDeserializedAs = new UnmarshalledErrorAssertion(errorDeserializedAs); + this.errorDeserializedAs = new UnmarshalledErrorAssertion(deserializedAs); } /** diff --git a/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/json-querycompatible-output.json b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/json-querycompatible-output.json index 4c11a5d8e1c7..39950b6965e5 100644 --- a/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/json-querycompatible-output.json +++ b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/json-querycompatible-output.json @@ -13,14 +13,12 @@ }, "when": { "action": "unmarshall", - "operation": "QueryCompatibleOperation" + "operation": "QueryCompatibleOperation", + "error": "NoCustomCodeError" }, "then": { - "errorDeserializedAs": { - "errorCode": "NoCustomCodeError", - "error": { - "message": "Hi" - } + "deserializedAs": { + "message": "Hi" } } }, @@ -39,15 +37,13 @@ }, "when": { "action": "unmarshall", - "operation": "QueryCompatibleOperation" + "operation": "QueryCompatibleOperation", + "error": "Customized" }, "then": { - "errorDeserializedAs": { - "errorCode": "Customized", - "error": { - "message": "Hi" - } + "deserializedAs": { + "message": "Hi" } } } -] +] \ No newline at end of file diff --git a/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-querycompatible-output.json b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-querycompatible-output.json index 1f9b764b2dfc..1fe18098a23e 100644 --- a/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-querycompatible-output.json +++ b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-querycompatible-output.json @@ -14,14 +14,12 @@ }, "when": { "action": "unmarshall", - "operation": "QueryCompatibleOperation" + "operation": "QueryCompatibleOperation", + "error": "NoCustomCodeError" }, "then": { - "errorDeserializedAs": { - "errorCode": "NoCustomCodeError", - "error": { - "message": "Hi" - } + "deserializedAs": { + "message": "Hi" } } }, @@ -41,15 +39,13 @@ }, "when": { "action": "unmarshall", - "operation": "QueryCompatibleOperation" + "operation": "QueryCompatibleOperation", + "error": "Customized" }, "then": { - "errorDeserializedAs": { - "errorCode": "Customized", - "error": { - "message": "Hi" - } + "deserializedAs": { + "message": "Hi" } } } -] +] \ No newline at end of file From 532e6f3b5a728992bb5cea61fbf30d8ba6e7cfe6 Mon Sep 17 00:00:00 2001 From: hdavidh Date: Tue, 1 Jul 2025 17:03:21 -0700 Subject: [PATCH 5/9] Fix test cases --- .../protocol/suites/cases/json-querycompatible-output.json | 6 +++--- .../suites/cases/smithy-rpcv2-querycompatible-output.json | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/json-querycompatible-output.json b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/json-querycompatible-output.json index 39950b6965e5..f6ae104fc61d 100644 --- a/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/json-querycompatible-output.json +++ b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/json-querycompatible-output.json @@ -12,7 +12,7 @@ } }, "when": { - "action": "unmarshall", + "action": "errorUnmarshall", "operation": "QueryCompatibleOperation", "error": "NoCustomCodeError" }, @@ -36,9 +36,9 @@ } }, "when": { - "action": "unmarshall", + "action": "errorUnmarshall", "operation": "QueryCompatibleOperation", - "error": "Customized" + "error": "CustomCodeError" }, "then": { "deserializedAs": { diff --git a/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-querycompatible-output.json b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-querycompatible-output.json index 1fe18098a23e..034bd41c0608 100644 --- a/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-querycompatible-output.json +++ b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-querycompatible-output.json @@ -13,7 +13,7 @@ } }, "when": { - "action": "unmarshall", + "action": "errorUnmarshall", "operation": "QueryCompatibleOperation", "error": "NoCustomCodeError" }, @@ -38,9 +38,9 @@ } }, "when": { - "action": "unmarshall", + "action": "errorUnmarshall", "operation": "QueryCompatibleOperation", - "error": "Customized" + "error": "CustomCodeError" }, "then": { "deserializedAs": { From dc3b96c94a13f70d4863c481e623eaa866a3c557 Mon Sep 17 00:00:00 2001 From: hdavidh Date: Tue, 1 Jul 2025 19:03:43 -0700 Subject: [PATCH 6/9] Update tests --- ...smithy-rpcv2-nonquerycompatible-input.json | 4 +- .../endpoint-rule-set.json | 59 ++++++++++++++----- .../rpcv2-nonquerycompatible/service-2.json | 11 ++-- .../endpoint-rule-set.json | 59 ++++++++++++++----- .../rpcv2-querycompatible/service-2.json | 6 +- ...cV2CborNonQueryCompatibleProtocolTest.java | 2 +- ...yRpcV2CborQueryCompatibleProtocolTest.java | 2 +- 7 files changed, 101 insertions(+), 42 deletions(-) diff --git a/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-nonquerycompatible-input.json b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-nonquerycompatible-input.json index b4fea52b0e74..7a62f6522c64 100644 --- a/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-nonquerycompatible-input.json +++ b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-nonquerycompatible-input.json @@ -7,7 +7,7 @@ }, "when": { "action": "marshall", - "operation": "QueryIncompatibleOperation" + "operation": "NonQueryCompatibleOperation" }, "then": { "serializedAs": { @@ -24,7 +24,7 @@ "body": { "encodedEquals": "" }, - "uri": "/service/NonQueryCompatibleRpcV2Protocol/operation/QueryIncompatibleOperation" + "uri": "/service/NonQueryCompatibleRpcV2Protocol/operation/NonQueryCompatibleOperation" } } } diff --git a/test/protocol-tests/src/main/resources/codegen-resources/rpcv2-nonquerycompatible/endpoint-rule-set.json b/test/protocol-tests/src/main/resources/codegen-resources/rpcv2-nonquerycompatible/endpoint-rule-set.json index b26b9dba1f11..5846e263b355 100644 --- a/test/protocol-tests/src/main/resources/codegen-resources/rpcv2-nonquerycompatible/endpoint-rule-set.json +++ b/test/protocol-tests/src/main/resources/codegen-resources/rpcv2-nonquerycompatible/endpoint-rule-set.json @@ -6,25 +6,54 @@ "required": true, "documentation": "The AWS region used to dispatch the request.", "type": "String" + }, + "UseDualStack": { + "builtIn": "AWS::UseDualStack", + "required": true, + "default": false, + "documentation": "When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.", + "type": "Boolean" + }, + "UseFIPS": { + "builtIn": "AWS::UseFIPS", + "required": true, + "default": false, + "documentation": "When true, send this request to the FIPS-compliant regional endpoint. If the configured endpoint does not have a FIPS compliant endpoint, dispatching the request will return an error.", + "type": "Boolean" + }, + "Endpoint": { + "builtIn": "SDK::Endpoint", + "required": false, + "documentation": "Override the endpoint used to send this request", + "type": "String" } }, "rules": [ { - "conditions": [], - "endpoint": { - "url": "http://localhost/", - "properties": { - "authSchemes": [ - { - "name": "sigv4", - "signingRegion": "{Region}", - "signingName": "jsonrpc" - } - ] - }, - "headers": {} - }, - "type": "endpoint" + "conditions": [ + ], + "type": "tree", + "rules": [ + { + "conditions": [], + "endpoint": { + "url": { + "ref": "Endpoint" + }, + "properties": { + "authSchemes": [ + { + "name": "sigv4", + "signingRegion": "{Region}", + "signingName": "jsonrpc" + } + ] + }, + "headers": {} + }, + "type": "endpoint" + } + ] } ] } diff --git a/test/protocol-tests/src/main/resources/codegen-resources/rpcv2-nonquerycompatible/service-2.json b/test/protocol-tests/src/main/resources/codegen-resources/rpcv2-nonquerycompatible/service-2.json index 46a425d98a0b..5e2eac0ae380 100644 --- a/test/protocol-tests/src/main/resources/codegen-resources/rpcv2-nonquerycompatible/service-2.json +++ b/test/protocol-tests/src/main/resources/codegen-resources/rpcv2-nonquerycompatible/service-2.json @@ -5,21 +5,21 @@ "auth": [ "aws.auth#sigv4" ], - "endpointPrefix": "non-query-compatible-rpcv2", + "endpointPrefix": "nonquerycompatiblerpcv2protocol", "protocol": "smithy-rpc-v2-cbor", "protocols": [ "smithy-rpc-v2-cbor" ], - "serviceFullName": "Non Query Compatible RpcV2 Protocol Service", + "serviceFullName": "NonQueryCompatibleRpcV2Protocol", "serviceId": "Non Query Compatible RpcV2 Protocol", "signatureVersion": "v4", - "signingName": "non-query-compatible-rpcv2", + "signingName": "NonQueryCompatibleRpcV2Protocol", "targetPrefix": "NonQueryCompatibleRpcV2Protocol", "uid": "non-query-compatible-rpcv2-protocol-2025-06-20" }, "operations": { - "QueryIncompatibleOperation": { - "name": "QueryIncompatibleOperation", + "NonQueryCompatibleOperation": { + "name": "NonQueryCompatibleOperation", "http": { "method": "POST", "requestUri": "/" @@ -29,3 +29,4 @@ }, "shapes": {} } + diff --git a/test/protocol-tests/src/main/resources/codegen-resources/rpcv2-querycompatible/endpoint-rule-set.json b/test/protocol-tests/src/main/resources/codegen-resources/rpcv2-querycompatible/endpoint-rule-set.json index b26b9dba1f11..5846e263b355 100644 --- a/test/protocol-tests/src/main/resources/codegen-resources/rpcv2-querycompatible/endpoint-rule-set.json +++ b/test/protocol-tests/src/main/resources/codegen-resources/rpcv2-querycompatible/endpoint-rule-set.json @@ -6,25 +6,54 @@ "required": true, "documentation": "The AWS region used to dispatch the request.", "type": "String" + }, + "UseDualStack": { + "builtIn": "AWS::UseDualStack", + "required": true, + "default": false, + "documentation": "When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.", + "type": "Boolean" + }, + "UseFIPS": { + "builtIn": "AWS::UseFIPS", + "required": true, + "default": false, + "documentation": "When true, send this request to the FIPS-compliant regional endpoint. If the configured endpoint does not have a FIPS compliant endpoint, dispatching the request will return an error.", + "type": "Boolean" + }, + "Endpoint": { + "builtIn": "SDK::Endpoint", + "required": false, + "documentation": "Override the endpoint used to send this request", + "type": "String" } }, "rules": [ { - "conditions": [], - "endpoint": { - "url": "http://localhost/", - "properties": { - "authSchemes": [ - { - "name": "sigv4", - "signingRegion": "{Region}", - "signingName": "jsonrpc" - } - ] - }, - "headers": {} - }, - "type": "endpoint" + "conditions": [ + ], + "type": "tree", + "rules": [ + { + "conditions": [], + "endpoint": { + "url": { + "ref": "Endpoint" + }, + "properties": { + "authSchemes": [ + { + "name": "sigv4", + "signingRegion": "{Region}", + "signingName": "jsonrpc" + } + ] + }, + "headers": {} + }, + "type": "endpoint" + } + ] } ] } diff --git a/test/protocol-tests/src/main/resources/codegen-resources/rpcv2-querycompatible/service-2.json b/test/protocol-tests/src/main/resources/codegen-resources/rpcv2-querycompatible/service-2.json index eaed847ca4f9..7a50c96afb4c 100644 --- a/test/protocol-tests/src/main/resources/codegen-resources/rpcv2-querycompatible/service-2.json +++ b/test/protocol-tests/src/main/resources/codegen-resources/rpcv2-querycompatible/service-2.json @@ -6,15 +6,15 @@ "aws.auth#sigv4" ], "awsQueryCompatible": {}, - "endpointPrefix": "query-compatible-rpcv2", + "endpointPrefix": "querycompatiblerpcv2protocol", "protocol": "smithy-rpc-v2-cbor", "protocols": [ "smithy-rpc-v2-cbor" ], - "serviceFullName": "Query Compatible RpcV2 Protocol Service", + "serviceFullName": "QueryCompatibleRpcV2Protocol", "serviceId": "Query Compatible RpcV2 Protocol", "signatureVersion": "v4", - "signingName": "query-compatible-rpcv2", + "signingName": "QueryCompatibleRpcV2Protocol", "targetPrefix": "QueryCompatibleRpcV2Protocol", "uid": "query-compatible-rpcv2-protocol-2025-06-20" }, diff --git a/test/protocol-tests/src/test/java/software/amazon/awssdk/protocol/tests/SmithyRpcV2CborNonQueryCompatibleProtocolTest.java b/test/protocol-tests/src/test/java/software/amazon/awssdk/protocol/tests/SmithyRpcV2CborNonQueryCompatibleProtocolTest.java index b099a82932c7..517e592a7455 100644 --- a/test/protocol-tests/src/test/java/software/amazon/awssdk/protocol/tests/SmithyRpcV2CborNonQueryCompatibleProtocolTest.java +++ b/test/protocol-tests/src/test/java/software/amazon/awssdk/protocol/tests/SmithyRpcV2CborNonQueryCompatibleProtocolTest.java @@ -41,7 +41,7 @@ public static List data() throws IOException { @BeforeClass public static void setupFixture() { - testRunner = new ProtocolTestRunner("/models/non-query-compatible-rpcv2-2025-06-20-intermediate.json"); + testRunner = new ProtocolTestRunner("/models/nonquerycompatiblerpcv2protocol-2025-06-20-intermediate.json"); } @Test diff --git a/test/protocol-tests/src/test/java/software/amazon/awssdk/protocol/tests/SmithyRpcV2CborQueryCompatibleProtocolTest.java b/test/protocol-tests/src/test/java/software/amazon/awssdk/protocol/tests/SmithyRpcV2CborQueryCompatibleProtocolTest.java index a81a8f3a424b..e7b32323b9f0 100644 --- a/test/protocol-tests/src/test/java/software/amazon/awssdk/protocol/tests/SmithyRpcV2CborQueryCompatibleProtocolTest.java +++ b/test/protocol-tests/src/test/java/software/amazon/awssdk/protocol/tests/SmithyRpcV2CborQueryCompatibleProtocolTest.java @@ -41,7 +41,7 @@ public static List data() throws IOException { @BeforeClass public static void setupFixture() { - testRunner = new ProtocolTestRunner("/models/query-compatible-rpcv2-2025-06-20-intermediate.json"); + testRunner = new ProtocolTestRunner("/models/querycompatiblerpcv2protocol-2025-06-20-intermediate.json"); } @Test From 067b9422f1c87c3eaaf7494dc069a41e9c964fe2 Mon Sep 17 00:00:00 2001 From: hdavidh Date: Tue, 1 Jul 2025 19:10:39 -0700 Subject: [PATCH 7/9] Update tests --- .../protocol/suites/cases/json-querycompatible-output.json | 4 ++-- .../suites/cases/smithy-rpcv2-querycompatible-output.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/json-querycompatible-output.json b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/json-querycompatible-output.json index f6ae104fc61d..26fc7774b07c 100644 --- a/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/json-querycompatible-output.json +++ b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/json-querycompatible-output.json @@ -1,6 +1,6 @@ [ { - "id": "QueryCompatibleRpcV2CborNoCustomCodeError", + "id": "QueryCompatibleAwsJson10CborNoCustomCodeError", "description": "Parses simple errors with no query error code", "given": { "response": { @@ -23,7 +23,7 @@ } }, { - "id": "QueryCompatibleRpcV2CborCustomCodeError", + "id": "QueryCompatibleAwsJson10CustomCodeError", "description": "Parses simple errors with query error code", "given": { "response": { diff --git a/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-querycompatible-output.json b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-querycompatible-output.json index 034bd41c0608..c75be7a9eced 100644 --- a/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-querycompatible-output.json +++ b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-querycompatible-output.json @@ -1,6 +1,6 @@ [ { - "id": "QueryCompatibleAwsJson10CborNoCustomCodeError", + "id": "QueryCompatibleRpcV2CborNoCustomCodeError", "description": "Parses simple RpcV2 CBOR errors with no query error code", "given": { "response": { @@ -24,7 +24,7 @@ } }, { - "id": "QueryCompatibleAwsJson10CustomCodeError", + "id": "QueryCompatibleRpcV2CborCustomCodeError", "description": "Parses simple RpcV2 CBOR errors with query error code", "given": { "response": { From f3d3476a1150a857e3e35e68dc2b995e774672a4 Mon Sep 17 00:00:00 2001 From: hdavidh Date: Wed, 2 Jul 2025 16:25:11 -0700 Subject: [PATCH 8/9] Update tests --- .../awssdk/protocol/model/TestCase.java | 1 + .../amazon/awssdk/protocol/model/Then.java | 13 ++++++++- .../runners/UnmarshallingTestRunner.java | 29 +++++++++++++++++-- .../cases/json-querycompatible-output.json | 3 +- .../smithy-rpcv2-querycompatible-output.json | 3 +- .../json-querycompatible/service-2.json | 6 ++-- .../rpcv2-nonquerycompatible/service-2.json | 1 - .../JsonQueryCompatibleProtocolTest.java | 2 +- 8 files changed, 48 insertions(+), 10 deletions(-) diff --git a/test/protocol-tests-core/src/main/java/software/amazon/awssdk/protocol/model/TestCase.java b/test/protocol-tests-core/src/main/java/software/amazon/awssdk/protocol/model/TestCase.java index a56291a4b5f8..c7f9127552c1 100644 --- a/test/protocol-tests-core/src/main/java/software/amazon/awssdk/protocol/model/TestCase.java +++ b/test/protocol-tests-core/src/main/java/software/amazon/awssdk/protocol/model/TestCase.java @@ -31,6 +31,7 @@ public String getId() { public void setId(String id) { this.id = id; } + public String getDescription() { return description; } diff --git a/test/protocol-tests-core/src/main/java/software/amazon/awssdk/protocol/model/Then.java b/test/protocol-tests-core/src/main/java/software/amazon/awssdk/protocol/model/Then.java index 0f6bc1268bd1..ce24a5a47de0 100644 --- a/test/protocol-tests-core/src/main/java/software/amazon/awssdk/protocol/model/Then.java +++ b/test/protocol-tests-core/src/main/java/software/amazon/awssdk/protocol/model/Then.java @@ -29,13 +29,16 @@ public class Then { private final MarshallingAssertion serializedAs; private final UnmarshallingAssertion deserializedAs; private final UnmarshallingAssertion errorDeserializedAs; + private final String errorCode; @JsonCreator public Then(@JsonProperty("serializedAs") SerializedAs serializedAs, - @JsonProperty("deserializedAs") JsonNode deserializedAs) { + @JsonProperty("deserializedAs") JsonNode deserializedAs, + @JsonProperty("errorCode") String errorCode) { this.serializedAs = serializedAs; this.deserializedAs = new UnmarshalledResultAssertion(deserializedAs); this.errorDeserializedAs = new UnmarshalledErrorAssertion(deserializedAs); + this.errorCode = errorCode; } /** @@ -59,4 +62,12 @@ public UnmarshallingAssertion getUnmarshallingAssertion() { public UnmarshallingAssertion getErrorUnmarshallingAssertion() { return errorDeserializedAs; } + + /** + * + * @return The errorCode String to use for error unmarshalling tests + */ + public String getErrorCode() { + return errorCode; + } } diff --git a/test/protocol-tests-core/src/main/java/software/amazon/awssdk/protocol/runners/UnmarshallingTestRunner.java b/test/protocol-tests-core/src/main/java/software/amazon/awssdk/protocol/runners/UnmarshallingTestRunner.java index 967b4823bd90..12918c131e8d 100644 --- a/test/protocol-tests-core/src/main/java/software/amazon/awssdk/protocol/runners/UnmarshallingTestRunner.java +++ b/test/protocol-tests-core/src/main/java/software/amazon/awssdk/protocol/runners/UnmarshallingTestRunner.java @@ -25,6 +25,9 @@ import com.github.tomakehurst.wiremock.client.WireMock; import java.lang.reflect.InvocationTargetException; import java.util.Base64; +import org.junit.Assert; +import software.amazon.awssdk.awscore.exception.AwsErrorDetails; +import software.amazon.awssdk.awscore.exception.AwsServiceException; import software.amazon.awssdk.codegen.model.intermediate.IntermediateModel; import software.amazon.awssdk.codegen.model.intermediate.Metadata; import software.amazon.awssdk.core.sync.ResponseTransformer; @@ -32,6 +35,7 @@ import software.amazon.awssdk.protocol.asserts.unmarshalling.UnmarshallingTestContext; import software.amazon.awssdk.protocol.model.GivenResponse; import software.amazon.awssdk.protocol.model.TestCase; +import software.amazon.awssdk.protocol.model.Then; import software.amazon.awssdk.protocol.reflect.ClientReflector; import software.amazon.awssdk.protocol.reflect.ShapeModelReflector; import software.amazon.awssdk.utils.IoUtils; @@ -90,9 +94,30 @@ private void runErrorUnmarshallTest(TestCase testCase) throws Exception { throw new IllegalStateException("Test case expected client to throw error"); } catch (InvocationTargetException t) { String errorName = testCase.getWhen().getErrorName(); - testCase.getThen().getErrorUnmarshallingAssertion().assertMatches( - createErrorContext(operationName, errorName), t.getCause()); + Throwable cause = t.getCause(); + Then then = testCase.getThen(); + + then.getErrorUnmarshallingAssertion().assertMatches( + createErrorContext(operationName, errorName), cause); + + validateErrorCodeIfPresent(then, cause); + } + } + + private void validateErrorCodeIfPresent(Then then, Throwable cause) { + String expectedErrorCode = then.getErrorCode(); + if (expectedErrorCode != null) { + String actualErrorCode = extractErrorCode(cause); + Assert.assertEquals(expectedErrorCode, actualErrorCode); + } + } + + private String extractErrorCode(Throwable cause) { + if (!(cause instanceof AwsServiceException)) { + return null; } + AwsErrorDetails awsErrorDetails = ((AwsServiceException) cause).awsErrorDetails(); + return awsErrorDetails.errorCode(); } private UnmarshallingTestContext createErrorContext(String operationName, String errorName) { diff --git a/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/json-querycompatible-output.json b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/json-querycompatible-output.json index 26fc7774b07c..2405cb06b49c 100644 --- a/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/json-querycompatible-output.json +++ b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/json-querycompatible-output.json @@ -43,7 +43,8 @@ "then": { "deserializedAs": { "message": "Hi" - } + }, + "errorCode": "Customized" } } ] \ No newline at end of file diff --git a/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-querycompatible-output.json b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-querycompatible-output.json index c75be7a9eced..2d808777596f 100644 --- a/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-querycompatible-output.json +++ b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-querycompatible-output.json @@ -45,7 +45,8 @@ "then": { "deserializedAs": { "message": "Hi" - } + }, + "errorCode": "Customized" } } ] \ No newline at end of file diff --git a/test/protocol-tests/src/main/resources/codegen-resources/json-querycompatible/service-2.json b/test/protocol-tests/src/main/resources/codegen-resources/json-querycompatible/service-2.json index 9e2ac282e569..2b4b234cf852 100644 --- a/test/protocol-tests/src/main/resources/codegen-resources/json-querycompatible/service-2.json +++ b/test/protocol-tests/src/main/resources/codegen-resources/json-querycompatible/service-2.json @@ -6,16 +6,16 @@ "aws.auth#sigv4" ], "awsQueryCompatible": {}, - "endpointPrefix": "query-compatible-jsonrpc10", + "endpointPrefix": "querycompatiblejsonrpc10", "jsonVersion": "1.0", "protocol": "json", "protocols": [ "json" ], - "serviceFullName": "Query Compatible Json 1.0 Protocol Service", + "serviceFullName": "QueryCompatibleJsonRpc10", "serviceId": "Query Compatible JSON RPC 10", "signatureVersion": "v4", - "signingName": "query-compatible-jsonrpc10", + "signingName": "QueryCompatibleJsonRpc10", "targetPrefix": "QueryCompatibleJsonRpc10", "uid": "query-compatible-json-rpc-10-2020-07-14" }, diff --git a/test/protocol-tests/src/main/resources/codegen-resources/rpcv2-nonquerycompatible/service-2.json b/test/protocol-tests/src/main/resources/codegen-resources/rpcv2-nonquerycompatible/service-2.json index 5e2eac0ae380..a2d852f13f3e 100644 --- a/test/protocol-tests/src/main/resources/codegen-resources/rpcv2-nonquerycompatible/service-2.json +++ b/test/protocol-tests/src/main/resources/codegen-resources/rpcv2-nonquerycompatible/service-2.json @@ -29,4 +29,3 @@ }, "shapes": {} } - diff --git a/test/protocol-tests/src/test/java/software/amazon/awssdk/protocol/tests/JsonQueryCompatibleProtocolTest.java b/test/protocol-tests/src/test/java/software/amazon/awssdk/protocol/tests/JsonQueryCompatibleProtocolTest.java index aabc4298b064..c97f4c868449 100644 --- a/test/protocol-tests/src/test/java/software/amazon/awssdk/protocol/tests/JsonQueryCompatibleProtocolTest.java +++ b/test/protocol-tests/src/test/java/software/amazon/awssdk/protocol/tests/JsonQueryCompatibleProtocolTest.java @@ -41,7 +41,7 @@ public static List data() throws IOException { @BeforeClass public static void setupFixture() { - testRunner = new ProtocolTestRunner("/models/query-compatible-jsonrpc10-2020-07-14-intermediate.json"); + testRunner = new ProtocolTestRunner("/models/querycompatiblejsonrpc10-2020-07-14-intermediate.json"); } @Test From 14f1c53bf15f59cf4a1c7d6084ed4bf387e99223 Mon Sep 17 00:00:00 2001 From: Alex Woods Date: Thu, 3 Jul 2025 09:23:06 -0700 Subject: [PATCH 9/9] Add binaryBody - query compat cbor output tests now pass --- .../suites/cases/smithy-rpcv2-querycompatible-output.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-querycompatible-output.json b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-querycompatible-output.json index 2d808777596f..6ca7d2127162 100644 --- a/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-querycompatible-output.json +++ b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/smithy-rpcv2-querycompatible-output.json @@ -9,7 +9,7 @@ "smithy-protocol": "rpc-v2-cbor", "Content-Type": "application/cbor" }, - "body": "uQACZl9fdHlwZXgtYXdzLnByb3RvY29sdGVzdHMucnBjdjJjYm9yI05vQ3VzdG9tQ29kZUVycm9yZ01lc3NhZ2ViSGk=" + "binaryBody": "uQACZl9fdHlwZXgtYXdzLnByb3RvY29sdGVzdHMucnBjdjJjYm9yI05vQ3VzdG9tQ29kZUVycm9yZ01lc3NhZ2ViSGk=" } }, "when": { @@ -34,7 +34,7 @@ "smithy-protocol": "rpc-v2-cbor", "Content-Type": "application/cbor" }, - "body": "uQACZl9fdHlwZXgrYXdzLnByb3RvY29sdGVzdHMucnBjdjJjYm9yI0N1c3RvbUNvZGVFcnJvcmdNZXNzYWdlYkhp" + "binaryBody": "uQACZl9fdHlwZXgrYXdzLnByb3RvY29sdGVzdHMucnBjdjJjYm9yI0N1c3RvbUNvZGVFcnJvcmdNZXNzYWdlYkhp" } }, "when": {