fix: DynamoDB DeleteTable status and PartiQL scan, add SecretsManager RestoreSecret (#915)

* fix(dynamodb): return current table status on DeleteTable and support PartiQL scan pagination

DeleteTable now builds the response before removing the table, returning
the ACTIVE status that AWS documents. PartiQL SELECT without a WHERE
clause performs a full table scan with Limit/NextToken pagination support.

* feat(secretsmanager): implement RestoreSecret operation

Cancels a scheduled deletion by clearing the deletedDate on a
soft-deleted secret, matching the AWS RestoreSecret API contract.
This commit is contained in:
Federico Mariani authored and GitHub committed 2026-05-19 18:05:06 -05:00
1 parent 040ef033b4
commit 291a201efa
7 files changed
+232 -13

No files matched your search

@@ -171,6 +171,6 @@ class DynamoDbCborIntegrationTest {
.extract().asByteArray();
JsonNode response = CBOR_MAPPER.readTree(responseBytes);
assertThat(response.path("TableDescription").path("TableStatus").asText(), equalTo("DELETING"));
assertThat(response.path("TableDescription").path("TableStatus").asText(), equalTo("ACTIVE"));
}
}
@@ -777,6 +777,44 @@ class DynamoDbIntegrationTest {
.body("Table.GlobalSecondaryIndexes", nullValue());
}
/**
* AWS DynamoDB DeleteTable returns the table description with its current status (ACTIVE)
* at the time of the call. The transition to DELETING happens asynchronously after the response.
*
* @see <a href="https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_DeleteTable.html">DeleteTable API Reference</a>
*/
@Test
@Order(26)
void deleteTableReturnsActiveStatus() {
given()
.header("X-Amz-Target", "DynamoDB_20120810.CreateTable")
.contentType(DYNAMODB_CONTENT_TYPE)
.body("""
{
"TableName": "DeleteStatusTestTable",
"KeySchema": [{"AttributeName": "id", "KeyType": "HASH"}],
"AttributeDefinitions": [{"AttributeName": "id", "AttributeType": "S"}]
}
""")
.when()
.post("/")
.then()
.statusCode(200)
.body("TableDescription.TableStatus", equalTo("ACTIVE"));
given()
.header("X-Amz-Target", "DynamoDB_20120810.DeleteTable")
.contentType(DYNAMODB_CONTENT_TYPE)
.body("""
{"TableName": "DeleteStatusTestTable"}
""")
.when()
.post("/")
.then()
.statusCode(200)
.body("TableDescription.TableStatus", equalTo("ACTIVE"));
}
// --- Cleanup ---
@Test
@@ -792,7 +830,7 @@ class DynamoDbIntegrationTest {
.post("/")
.then()
.statusCode(200)
.body("TableDescription.TableStatus", equalTo("DELETING"));
.body("TableDescription.TableStatus", equalTo("ACTIVE"));
// Verify it's gone
given()
@@ -2136,4 +2174,99 @@ given()
assertEquals(Set.of("ITEM_a", "ITEM_b", "ITEM_c", "ITEM_d", "ITEM_e"), new HashSet<>(allCollected));
assertEquals(3, pages, "Expected ceil(5/2)=3 pages");
}
@Test
void partiqlSelectWithoutWhereClausePerformsScan() throws Exception {
ObjectMapper mapper = new ObjectMapper();
String tableName = "PartiqlScanTable";
given()
.header("X-Amz-Target", "DynamoDB_20120810.CreateTable")
.contentType(DYNAMODB_CONTENT_TYPE)
.body("""
{
"TableName": "%s",
"KeySchema": [{"AttributeName": "pk", "KeyType": "HASH"}],
"AttributeDefinitions": [{"AttributeName": "pk", "AttributeType": "S"}],
"BillingMode": "PAY_PER_REQUEST"
}
""".formatted(tableName))
.when().post("/")
.then().statusCode(200);
for (String pk : new String[]{"a", "b", "c"}) {
given()
.header("X-Amz-Target", "DynamoDB_20120810.PutItem")
.contentType(DYNAMODB_CONTENT_TYPE)
.body("""
{
"TableName": "%s",
"Item": {"pk": {"S": "%s"}, "data": {"S": "val-%s"}}
}
""".formatted(tableName, pk, pk))
.when().post("/")
.then().statusCode(200);
}
// SELECT * without WHERE → full table scan, all 3 items
String selectAll = given()
.header("X-Amz-Target", "DynamoDB_20120810.ExecuteStatement")
.contentType(DYNAMODB_CONTENT_TYPE)
.body("""
{"Statement": "SELECT * FROM \\"%s\\""}
""".formatted(tableName))
.when().post("/")
.then()
.statusCode(200)
.extract().body().asString();
JsonNode selectAllResult = mapper.readTree(selectAll);
assertEquals(3, selectAllResult.path("Items").size(),
"SELECT * without WHERE should return all items");
// SELECT * with Limit=2 → 2 items + NextToken
String limitedSelect = given()
.header("X-Amz-Target", "DynamoDB_20120810.ExecuteStatement")
.contentType(DYNAMODB_CONTENT_TYPE)
.body("""
{"Statement": "SELECT * FROM \\"%s\\"", "Limit": 2}
""".formatted(tableName))
.when().post("/")
.then()
.statusCode(200)
.extract().body().asString();
JsonNode limitedResult = mapper.readTree(limitedSelect);
assertEquals(2, limitedResult.path("Items").size(),
"SELECT * with Limit=2 should return 2 items");
assertNotNull(limitedResult.get("NextToken"),
"Paginated response must include NextToken");
// Use NextToken to get the remaining item
String nextToken = limitedResult.get("NextToken").asText();
String nextPage = given()
.header("X-Amz-Target", "DynamoDB_20120810.ExecuteStatement")
.contentType(DYNAMODB_CONTENT_TYPE)
.body("""
{"Statement": "SELECT * FROM \\"%s\\"", "NextToken": "%s"}
""".formatted(tableName, nextToken))
.when().post("/")
.then()
.statusCode(200)
.extract().body().asString();
JsonNode nextPageResult = mapper.readTree(nextPage);
assertEquals(1, nextPageResult.path("Items").size(),
"Second page should return the remaining 1 item");
// Cleanup
given()
.header("X-Amz-Target", "DynamoDB_20120810.DeleteTable")
.contentType(DYNAMODB_CONTENT_TYPE)
.body("""
{"TableName": "%s"}
""".formatted(tableName))
.when().post("/")
.then().statusCode(200);
}
}