fix: implement read APIs required by Steampipe resource collection (#1538)

* fix: implement read APIs required by Steampipe resource collection

IAM ListMFADevices, ECR BatchGetRepositoryScanningConfiguration, and CloudWatch Logs GetDataProtectionPolicy returned UnsupportedOperation (400). Each is invoked per-item by the Steampipe AWS plugin to enrich aws_iam_user, aws_ecr_repository, and aws_cloudwatch_log_group; the 400 aborted the whole table hydration, so those tables collected zero rows against Floci.

Implement minimal, wire-accurate responses:
- IAM ListMFADevices -> empty MFADevices list (IsTruncated=false)
- ECR BatchGetRepositoryScanningConfiguration -> reuse describeRepositories, return MANUAL scan config
- CloudWatch Logs GetDataProtectionPolicy -> empty policy at HTTP 200 (the steampipe aws plugin hydrate does not tolerate ResourceNotFound, so 200 is required for collection to succeed)

Adds focused tests for each handler.

* docs: ground read-API handler comments in AWS wire behavior

Rewrite the ListMFADevices, BatchGetRepositoryScanningConfiguration, and
GetDataProtectionPolicy handler comments to describe real AWS response shapes,
enum values, and error semantics (NoSuchEntity 404, scanFrequency enum,
ResourceNotFoundException 400) instead of referencing a specific consumer.
Note the known deviations (200-empty vs error, batch-fail vs failures[]).
This commit is contained in:
Abhishek Dubey authored and GitHub committed 2026-06-25 19:14:43 -05:00
1 parent 952dec060f
commit e7b7839d85
6 files changed
+120

No files matched your search

@@ -70,6 +70,32 @@ class CloudWatchLogsHandlerTest {
assertEquals(STREAM, streams.get(0).path("logStreamName").asText());
}
// ──────────────────────────── GetDataProtectionPolicy ────────────────────────────
@Test
void getDataProtectionPolicyReturnsEmptyPolicyWith200() {
ObjectNode request = MAPPER.createObjectNode();
request.put("logGroupIdentifier", GROUP);
Response response = handler.handle("GetDataProtectionPolicy", request, REGION);
assertEquals(200, response.getStatus());
JsonNode body = (JsonNode) response.getEntity();
assertEquals(GROUP, body.path("logGroupIdentifier").asText());
assertTrue(body.path("policyDocument").isMissingNode());
}
@Test
void getDataProtectionPolicyByNameAlsoSucceeds() {
ObjectNode request = MAPPER.createObjectNode();
request.put("logGroupName", GROUP);
Response response = handler.handle("GetDataProtectionPolicy", request, REGION);
assertEquals(200, response.getStatus());
assertEquals(GROUP, ((JsonNode) response.getEntity()).path("logGroupIdentifier").asText());
}
@Test
void describeLogStreamsByLogGroupIdentifierArnWithWildcardSuffix() {
ObjectNode request = MAPPER.createObjectNode();
@@ -156,6 +156,27 @@ class EcrIntegrationTest {
@Test
@Order(8)
void batchGetRepositoryScanningConfiguration() {
given()
.header("X-Amz-Target", PREFIX + "BatchGetRepositoryScanningConfiguration")
.contentType(CT)
.body("""
{ "repositoryNames": ["%s"] }
""".formatted(REPO))
.when()
.post("/")
.then()
.statusCode(200)
.body("scanningConfigurations[0].repositoryName", equalTo(REPO))
.body("scanningConfigurations[0].repositoryArn", startsWith("arn:aws:ecr:"))
.body("scanningConfigurations[0].scanOnPush", equalTo(false))
.body("scanningConfigurations[0].scanFrequency", equalTo("MANUAL"))
.body("scanningConfigurations[0].appliedScanFilters", empty())
.body("failures", empty());
}
@Test
@Order(9)
void deleteRepositoryForce() {
given()
.header("X-Amz-Target", PREFIX + "DeleteRepository")
@@ -369,6 +369,22 @@ class IamIntegrationTest {
// Users
// =========================================================================
@Test
@Order(50)
void listMfaDevicesReturnsEmptyList() {
given()
.formParam("Action", "ListMFADevices")
.formParam("UserName", "any-user")
.header("Authorization",
"AWS4-HMAC-SHA256 Credential=test/20260227/us-east-1/iam/aws4_request")
.when()
.post("/")
.then()
.statusCode(200)
.contentType("application/xml")
.body("ListMFADevicesResponse.ListMFADevicesResult.IsTruncated", equalTo("false"));
}
@Test
@Order(10)
void createUser() {