mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
fix(ssm): send DescribeDocument's CreatedDate as epoch seconds (#8139)
This commit is contained in:
1 parent
1bdc839350
commit
f3c6d8e809
2 files changed
+41
-1
No files matched your search
@@ -1602,7 +1602,7 @@ public class SsmJsonHandler {
|
||||
documentNode.put("Content", effectiveContent);
|
||||
documentNode.put("Status", document.getStatus());
|
||||
if (document.getCreatedDate() != null) {
|
||||
documentNode.put("CreatedDate", document.getCreatedDate().toString());
|
||||
documentNode.put("CreatedDate", EpochSeconds.fromInstant(document.getCreatedDate()));
|
||||
}
|
||||
response.set("Document", documentNode);
|
||||
return Response.ok(response).build();
|
||||
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
package io.floci.aws.services.ssm;
|
||||
|
||||
import io.floci.aws.testing.AwsTestClients;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import software.amazon.awssdk.regions.Region;
|
||||
import software.amazon.awssdk.services.ssm.SsmClient;
|
||||
import software.amazon.awssdk.services.ssm.model.DocumentDescription;
|
||||
import software.amazon.awssdk.services.ssm.model.DocumentType;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
@QuarkusTest
|
||||
class SsmDescribeDocumentCreatedDateIntegrationTest {
|
||||
|
||||
private static final String CONTENT = "{\"schemaVersion\":\"2.2\",\"description\":\"d\",\"mainSteps\":[{"
|
||||
+ "\"action\":\"aws:runShellScript\",\"name\":\"s\",\"inputs\":{\"runCommand\":[\"echo hi\"]}}]}";
|
||||
|
||||
@Test
|
||||
void theSdkReadsTheCreationDateOfADescribedDocument() {
|
||||
String name = "created-date-" + UUID.randomUUID();
|
||||
try (SsmClient ssm = AwsTestClients.create(SsmClient.builder(), "100000008138", Region.US_EAST_1)) {
|
||||
Instant before = Instant.now().minusSeconds(1);
|
||||
ssm.createDocument(r -> r.name(name).documentType(DocumentType.COMMAND).content(CONTENT));
|
||||
try {
|
||||
DocumentDescription document = ssm.describeDocument(r -> r.name(name)).document();
|
||||
|
||||
Duration age = Duration.between(before, document.createdDate());
|
||||
assertTrue(!age.isNegative() && age.compareTo(Duration.ofMinutes(1)) < 0,
|
||||
document.createdDate().toString());
|
||||
} finally {
|
||||
ssm.deleteDocument(r -> r.name(name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user