mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(ssm): reject send-command timeouts below AWS minimum (#1511)
This commit is contained in:
1 parent
bb6ee4f69d
commit
0870f993a4
4 files changed
+71
-15
No files matched your search
+5
-5
@@ -102,11 +102,11 @@ class SsmCommandServiceDirectExecutionTest {
|
||||
void directTimeoutMarksCommandTimedOut() throws Exception {
|
||||
SsmDirectCommandExecutor executor = mock(SsmDirectCommandExecutor.class);
|
||||
Instant start = Instant.parse("2026-06-07T00:00:00Z");
|
||||
Instant end = Instant.parse("2026-06-07T00:00:05Z");
|
||||
Instant end = Instant.parse("2026-06-07T00:00:30Z");
|
||||
when(executor.supports(eq("i-timeout"), eq("AWS-RunShellScript"))).thenReturn(true);
|
||||
when(executor.executeIfSupported(eq("i-timeout"), eq("AWS-RunShellScript"), any(), eq(5)))
|
||||
when(executor.executeIfSupported(eq("i-timeout"), eq("AWS-RunShellScript"), any(), eq(30)))
|
||||
.thenReturn(Optional.of(new SsmDirectCommandExecutor.ExecutionResult(
|
||||
"TimedOut", "", "Timed out after 5s", -1, start, end)));
|
||||
"TimedOut", "", "Timed out after 30s", -1, start, end)));
|
||||
|
||||
SsmCommandService service = new SsmCommandService(
|
||||
new InMemoryStorageFactory(),
|
||||
@@ -121,7 +121,7 @@ class SsmCommandServiceDirectExecutionTest {
|
||||
"Parameters": {
|
||||
"commands": ["sleep 100"]
|
||||
},
|
||||
"TimeoutSeconds": 5
|
||||
"TimeoutSeconds": 30
|
||||
}
|
||||
"""), "us-west-2");
|
||||
|
||||
@@ -133,7 +133,7 @@ class SsmCommandServiceDirectExecutionTest {
|
||||
assertEquals("TimedOut", invocation.getStatus());
|
||||
assertEquals("Execution Timed Out", invocation.getStatusDetails());
|
||||
assertEquals(-1, invocation.getResponseCode());
|
||||
assertEquals("Timed out after 5s", invocation.getStandardErrorContent());
|
||||
assertEquals("Timed out after 30s", invocation.getStandardErrorContent());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+33
-8
@@ -95,6 +95,31 @@ class SsmSendCommandIntegrationTest {
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
void sendCommandRejectsTimeoutBelowAwsMinimum() {
|
||||
given()
|
||||
.header("X-Amz-Target", "AmazonSSM.SendCommand")
|
||||
.contentType(SSM_CT)
|
||||
.body("""
|
||||
{
|
||||
"InstanceIds": ["%s"],
|
||||
"DocumentName": "AWS-RunShellScript",
|
||||
"Parameters": {
|
||||
"commands": ["echo hello"]
|
||||
},
|
||||
"TimeoutSeconds": 1
|
||||
}
|
||||
""".formatted(INSTANCE_ID))
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("ValidationException"))
|
||||
.body("message", containsString("Value '1' at 'timeoutSeconds' failed to satisfy constraint"))
|
||||
.body("message", containsString("greater than or equal to 30"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
void sendCommandCreatesCommandRecord() {
|
||||
String response = given()
|
||||
.header("X-Amz-Target", "AmazonSSM.SendCommand")
|
||||
@@ -124,7 +149,7 @@ class SsmSendCommandIntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
@Order(5)
|
||||
void listCommandsReturnsCreatedCommand() {
|
||||
given()
|
||||
.header("X-Amz-Target", "AmazonSSM.ListCommands")
|
||||
@@ -139,7 +164,7 @@ class SsmSendCommandIntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(5)
|
||||
@Order(6)
|
||||
void listCommandInvocationsReturnsInvocation() {
|
||||
given()
|
||||
.header("X-Amz-Target", "AmazonSSM.ListCommandInvocations")
|
||||
@@ -159,7 +184,7 @@ class SsmSendCommandIntegrationTest {
|
||||
// ── ec2messages agent protocol ─────────────────────────────────────────
|
||||
|
||||
@Test
|
||||
@Order(6)
|
||||
@Order(7)
|
||||
void agentGetsEndpoint() {
|
||||
given()
|
||||
.header("X-Amz-Target", "AmazonSSMMessageDeliveryService.GetEndpoint")
|
||||
@@ -179,7 +204,7 @@ class SsmSendCommandIntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(7)
|
||||
@Order(8)
|
||||
void agentPollsAndGetsMessage() {
|
||||
given()
|
||||
.header("X-Amz-Target", "AmazonSSMMessageDeliveryService.GetMessages")
|
||||
@@ -202,7 +227,7 @@ class SsmSendCommandIntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(8)
|
||||
@Order(9)
|
||||
void agentAcknowledgesMessage() {
|
||||
// First poll to get the message ID
|
||||
String msgId = given()
|
||||
@@ -267,7 +292,7 @@ class SsmSendCommandIntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(9)
|
||||
@Order(10)
|
||||
void agentSendsReplyAndCommandStatusUpdates() {
|
||||
// Send a fresh command
|
||||
String resp = given()
|
||||
@@ -337,7 +362,7 @@ class SsmSendCommandIntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(10)
|
||||
@Order(11)
|
||||
void cancelCommandUpdatesStatus() {
|
||||
String resp = given()
|
||||
.header("X-Amz-Target", "AmazonSSM.SendCommand")
|
||||
@@ -379,7 +404,7 @@ class SsmSendCommandIntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(11)
|
||||
@Order(12)
|
||||
void sendCommandDirectlyExecutesForContainerBackedInstance() {
|
||||
Instant start = Instant.parse("2026-06-07T00:00:00Z");
|
||||
Instant end = Instant.parse("2026-06-07T00:00:01Z");
|
||||
|
||||
Reference in new issue
Block a user