Light, fluffy, and always free - The AWS Local Emulator alternative
fix(sqs): drop uppercase "Tags" read from CreateQueue JSON handler (#752)
Kenshin Okinaka7a036fdf5998
diff --git a/src/main/java/io/github/hectorvent/floci/services/sqs/SqsJsonHandler.java b/src/main/java/io/github/hectorvent/floci/services/sqs/SqsJsonHandler.javaindex f91d10346a..38c67fec85 100644--- a/src/main/java/io/github/hectorvent/floci/services/sqs/SqsJsonHandler.java+++ b/src/main/java/io/github/hectorvent/floci/services/sqs/SqsJsonHandler.java@@ -66,10 +66,7 @@ public class SqsJsonHandler {private Response handleCreateQueue(JsonNode request, String region) {String queueName = request.path("QueueName").asText(null);Map<String, String> attributes = jsonNodeToMap(request.path("Attributes"));- // Botocore sends "tags" (lowercase) for CreateQueue but "Tags" (uppercase) for TagQueue.- // Merge both to handle any client regardless of casing.- Map<String, String> tags = new HashMap<>(jsonNodeToMap(request.path("Tags")));- tags.putAll(jsonNodeToMap(request.path("tags")));+ Map<String, String> tags = jsonNodeToMap(request.path("tags"));Queue queue = sqsService.createQueue(queueName, attributes, tags, region);ObjectNode response = objectMapper.createObjectNode();diff --git a/src/test/java/io/github/hectorvent/floci/services/sqs/SqsIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/sqs/SqsIntegrationTest.javaindex d8a253f77a..8e73515fac 100644--- a/src/test/java/io/github/hectorvent/floci/services/sqs/SqsIntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/sqs/SqsIntegrationTest.java@@ -272,28 +272,103 @@ class SqsIntegrationTest {.body(containsString(taggedQueueName)).extract().xmlPath().getString("CreateQueueResponse.CreateQueueResult.QueueUrl");- given()- .contentType("application/x-www-form-urlencoded")- .formParam("Action", "ListQueueTags")- .formParam("QueueUrl", taggedQueueUrl)+ try {+ given()+ .contentType("application/x-www-form-urlencoded")+ .formParam("Action", "ListQueueTags")+ .formParam("QueueUrl", taggedQueueUrl)+ .when()+ .post("/")+ .then()+ .statusCode(200)+ .body(containsString("k1"))+ .body(containsString("v1"))+ .body(containsString("k2"))+ .body(containsString("v2"));+ } finally {+ given()+ .contentType("application/x-www-form-urlencoded")+ .formParam("Action", "DeleteQueue")+ .formParam("QueueUrl", taggedQueueUrl)+ .when()+ .post("/");+ }+ }++ @Test+ void createQueue_jsonProtocol_withLowercaseTags_tagsReturnedByListQueueTags() {+ // SQS JSON 1.0 schema uses lowercase "tags" for CreateQueue (cf. uppercase "Tags" for TagQueue).+ String taggedQueueName = "tagged-queue-json-integration-test";++ String taggedQueueUrl = given()+ .contentType("application/x-amz-json-1.0")+ .header("X-Amz-Target", "AmazonSQS.CreateQueue")+ .body("{\"QueueName\": \"" + taggedQueueName + "\", \"tags\": {\"k1\": \"v1\", \"k2\": \"v2\"}}").when().post("/").then().statusCode(200)- .body(containsString("k1"))- .body(containsString("v1"))- .body(containsString("k2"))- .body(containsString("v2"));+ .extract().jsonPath().getString("QueueUrl");- // cleanup- given()- .contentType("application/x-www-form-urlencoded")- .formParam("Action", "DeleteQueue")- .formParam("QueueUrl", taggedQueueUrl)+ try {+ given()+ .contentType("application/x-www-form-urlencoded")+ .formParam("Action", "ListQueueTags")+ .formParam("QueueUrl", taggedQueueUrl)+ .when()+ .post("/")+ .then()+ .statusCode(200)+ .body(containsString("k1"))+ .body(containsString("v1"))+ .body(containsString("k2"))+ .body(containsString("v2"));+ } finally {+ given()+ .contentType("application/x-www-form-urlencoded")+ .formParam("Action", "DeleteQueue")+ .formParam("QueueUrl", taggedQueueUrl)+ .when()+ .post("/");+ }+ }++ @Test+ void createQueue_jsonProtocol_withUppercaseTags_tagsAreIgnored() {+ // SQS JSON 1.0 only defines lowercase "tags" for CreateQueue; uppercase "Tags" belongs to+ // TagQueue and must be treated as an unknown field here, matching real AWS.+ String taggedQueueName = "ignored-uppercase-tags-queue";++ String taggedQueueUrl = given()+ .contentType("application/x-amz-json-1.0")+ .header("X-Amz-Target", "AmazonSQS.CreateQueue")+ .body("{\"QueueName\": \"" + taggedQueueName + "\", \"Tags\": {\"k1\": \"v1\"}}").when().post("/").then()- .statusCode(200);+ .statusCode(200)+ .extract().jsonPath().getString("QueueUrl");++ try {+ given()+ .contentType("application/x-www-form-urlencoded")+ .formParam("Action", "ListQueueTags")+ .formParam("QueueUrl", taggedQueueUrl)+ .when()+ .post("/")+ .then()+ .statusCode(200)+ .body(not(containsString("<Tag>")))+ .body(not(containsString("k1")))+ .body(not(containsString("v1")));+ } finally {+ given()+ .contentType("application/x-www-form-urlencoded")+ .formParam("Action", "DeleteQueue")+ .formParam("QueueUrl", taggedQueueUrl)+ .when()+ .post("/");+ }}@Test