From 2dca5239079af22948e53a27d1a4bc2fdcb8809b Mon Sep 17 00:00:00 2001 From: GitMarco Date: Wed, 8 Apr 2026 06:13:39 +0200 Subject: [PATCH] Fix/sns put timestamp in message envelope (#268) * Fixes DynamoDB support for adding values to a list for the SET ... ADD query/command * Revert "Fixes DynamoDB support for adding values to a list for the SET ... ADD query/command" * Fixes SNS/SQS enveloped message missing Timestamp in Body field. * Fixes SNS/SQS enveloped message missing Timestamp in Body field. --- .../hectorvent/floci/services/sns/SnsService.java | 2 ++ .../floci/services/sns/SnsIntegrationTest.java | 13 ++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/java/io/github/hectorvent/floci/services/sns/SnsService.java b/src/main/java/io/github/hectorvent/floci/services/sns/SnsService.java index aaf48c0844..c4d73ddfea 100644 --- a/src/main/java/io/github/hectorvent/floci/services/sns/SnsService.java +++ b/src/main/java/io/github/hectorvent/floci/services/sns/SnsService.java @@ -682,10 +682,12 @@ public class SnsService { Map messageAttributes, String topicArn, String messageId) { try { + String timestamp = DateTimeFormatter.ISO_INSTANT.format(Instant.now()); ObjectNode node = objectMapper.createObjectNode(); node.put("Type", "Notification"); node.put("MessageId", messageId); node.put("TopicArn", topicArn); + node.put("Timestamp", timestamp); if (subject != null) { node.put("Subject", subject); } diff --git a/src/test/java/io/github/hectorvent/floci/services/sns/SnsIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/sns/SnsIntegrationTest.java index 17eec88693..4385c59209 100644 --- a/src/test/java/io/github/hectorvent/floci/services/sns/SnsIntegrationTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/sns/SnsIntegrationTest.java @@ -12,6 +12,7 @@ import java.util.UUID; import static io.restassured.RestAssured.given; import static org.hamcrest.Matchers.*; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Integration tests for SNS via the query (form-encoded) protocol. @@ -191,7 +192,7 @@ class SnsIntegrationTest { .body(containsString("")); // Verify the message arrived in the SQS queue - given() + String jsonBodyInResponse = given() .contentType("application/x-www-form-urlencoded") .formParam("Action", "ReceiveMessage") .formParam("QueueUrl", sqsQueueUrl) @@ -200,8 +201,14 @@ class SnsIntegrationTest { .post("/") .then() .statusCode(200) - .body(containsString("Hello from SNS!")) - .body(containsString("Notification")); + .log().body() + .body(containsString("Hello from SNS!")) + .body(containsString("Notification")) + .extract().xmlPath().getString( + "ReceiveMessageResponse.ReceiveMessageResult.Message.Body"); + ; + + assertTrue(jsonBodyInResponse.contains("\"Timestamp\"")); } @Test