mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
feat: implement read-only describe/list APIs for resource collection (#1581)
* feat: implement read-only describe/list APIs for resource collection
Several read-only AWS actions returned UnsupportedOperation (HTTP 400) — or,
where no route existed, a 404 the AWS SDKs deserialize to a retryable
UnknownError. Both break clients that enumerate an account read-only: the 400
aborts the collection of the whole resource type, and the 404 sends the SDK
through its full retry/backoff schedule (~9 attempts, minutes) on every call.
Implement minimal, wire-accurate responses that mirror each service's documented
contract so SDK clients complete the read:
- IAM
- GetLoginProfile -> NoSuchEntity (404), the documented result when a user has
no console password; clients branch on it, so a 200 or 400 misleads them.
- GetAccessKeyLastUsed -> the "never used" shape (ServiceName/Region = N/A, no
LastUsedDate).
- ListSAMLProviders / ListOpenIDConnectProviders / ListServerCertificates ->
empty lists (non-paginated; ListServerCertificates carries IsTruncated=false).
- RDS: DescribeDBSnapshots / DescribeDBProxies / DescribeDBClusterSnapshots ->
empty results (empty wrapper, no Marker).
- DocDB: DescribeDBClusterSnapshots -> empty result (RDS namespace).
- ElastiCache: DescribeCacheSubnetGroups / DescribeCacheParameterGroups -> empty.
- Glue: GetJobs / GetCrawlers / ListDataQualityRulesets /
GetSecurityConfigurations / GetTags -> empty result under each result key.
- SSM: ListDocuments / ListAssociations / DescribeMaintenanceWindows -> empty
(NextToken omitted).
- AWS Backup: GetBackupVaultNotifications / GetBackupVaultAccessPolicy ->
ResourceNotFoundException (400), the documented "not configured" signal.
- S3 Control: ListAccessPoints -> empty AccessPointList (200), replacing the
missing-route 404 that triggered the SDK retry storm.
Responses are grounded in the AWS API reference for each action (error codes,
HTTP statuses, and "empty"/"never used" shapes). Adds focused unit and
integration tests for each handler.
* docs: ground ListAccessPoints comment in the S3 Control contract
Drop the consumer-specific retry magnitude ("~9 attempts") from the
ListAccessPoints comment and justify the empty-200 response purely on the AWS
contract: ListAccessPoints documents a single success path — HTTP 200 with an
AccessPointList (empty when the account has none) and an optional NextToken.
404 is not a documented outcome for the operation, so a missing route leaves
SDK clients unable to map the response to the expected result or a known error.
* fix(glue): keep GetTags delegating to the schema registry
The earlier commit replaced Glue GetTags with a hardcoded empty {"Tags":{}},
which regressed the schema-registry tagging path: GetTags must return the tags
stored for a registry/schema ARN and InvalidInputException for an unknown ARN.
Restore the original handleGetTags delegation and drop the empty-stub test for
it. GetTags was already implemented — only GetJobs/GetCrawlers/
ListDataQualityRulesets/GetSecurityConfigurations were genuine gaps, and those
remain empty stubs.
Fixes GlueSchemaRegistryMetadataAndTagsIntegrationTest (getTagsReturnsAddedTags,
untagResourceRemovesKey, getTagsOnUnknownArnReturnsInvalidInput) and the
sdk-test-java GlueSchemaRegistryTest compat failure.
* fix(iam): omit empty UserName from GetAccessKeyLastUsed
UserName is optional in the IAM model and its type is non-empty
(length 1-128). The emulator has no AccessKeyId->UserName lookup, so
emitting an empty <UserName></UserName> could be rejected by a strict
client. Omit the element entirely instead; callers that need the owner
already have it from the preceding ListAccessKeys response.
* fix(backup): drop unused headers param from vault notification/access-policy stubs
* test(iam): cover GetLoginProfile, ListSAMLProviders, ListOpenIDConnectProviders, ListServerCertificates
This commit is contained in:
1 parent
94a2ff3993
commit
a40dc52f4d
15 files changed
+565
No files matched your search
@@ -82,6 +82,34 @@ class BackupIntegrationTest {
|
||||
.statusCode(400);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(14)
|
||||
void getBackupVaultNotificationsReturnsResourceNotFound() {
|
||||
// Notifications are never configured in the emulator; the AWS Backup API returns
|
||||
// ResourceNotFoundException (HTTP 400) in that case, which clients branch on.
|
||||
given()
|
||||
.header("Authorization", AUTH)
|
||||
.when()
|
||||
.get("/backup-vaults/" + VAULT_NAME + "/notification-configuration")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("ResourceNotFoundException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(15)
|
||||
void getBackupVaultAccessPolicyReturnsResourceNotFound() {
|
||||
// Access policy is never configured in the emulator; the AWS Backup API returns
|
||||
// ResourceNotFoundException (HTTP 400) in that case, which clients branch on.
|
||||
given()
|
||||
.header("Authorization", AUTH)
|
||||
.when()
|
||||
.get("/backup-vaults/" + VAULT_NAME + "/access-policy")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("ResourceNotFoundException"));
|
||||
}
|
||||
|
||||
// ── Plan ───────────────────────────────────────────────────────────────────
|
||||
|
||||
@Test
|
||||
|
||||
@@ -258,6 +258,20 @@ class DocDbIntegrationTest {
|
||||
.body(containsString("DBClusterNotFoundFault"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(15)
|
||||
void describeClusterSnapshotsReturnsEmptyList() {
|
||||
given()
|
||||
.header("Authorization", AUTH)
|
||||
.contentType(FORM)
|
||||
.formParam("Action", "DescribeDBClusterSnapshots")
|
||||
.when().post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body(containsString("DescribeDBClusterSnapshotsResult"))
|
||||
.body(containsString("DBClusterSnapshots"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(16)
|
||||
void unsupportedAction() {
|
||||
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
package io.github.hectorvent.floci.services.elasticache;
|
||||
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
import io.github.hectorvent.floci.services.elasticache.proxy.SigV4Validator;
|
||||
import jakarta.ws.rs.core.MultivaluedHashMap;
|
||||
import jakarta.ws.rs.core.MultivaluedMap;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
/**
|
||||
* Verifies the empty-list read responses for the subnet/parameter group describes, so
|
||||
* SDK clients get a valid 200 instead of failing with UnsupportedOperation (400).
|
||||
*/
|
||||
class ElastiCacheQueryHandlerTest {
|
||||
|
||||
private ElastiCacheQueryHandler handler;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
SigV4Validator sigV4Validator = mock(SigV4Validator.class);
|
||||
ElastiCacheService service = mock(ElastiCacheService.class);
|
||||
ElastiCacheMemcachedService memcachedService = mock(ElastiCacheMemcachedService.class);
|
||||
RegionResolver regionResolver = mock(RegionResolver.class);
|
||||
handler = new ElastiCacheQueryHandler(sigV4Validator, service, memcachedService, regionResolver);
|
||||
}
|
||||
|
||||
@Test
|
||||
void describeCacheSubnetGroups_returnsEmptyWrapperWithoutMarker() {
|
||||
Response response = handler.handle("DescribeCacheSubnetGroups", params());
|
||||
|
||||
assertEquals(200, response.getStatus());
|
||||
String body = (String) response.getEntity();
|
||||
assertTrue(body.contains("<DescribeCacheSubnetGroupsResult><CacheSubnetGroups></CacheSubnetGroups></DescribeCacheSubnetGroupsResult>"),
|
||||
"Expected empty CacheSubnetGroups wrapper inside the Result element");
|
||||
assertFalse(body.contains("<Marker>"), "Empty list must omit Marker");
|
||||
}
|
||||
|
||||
@Test
|
||||
void describeCacheParameterGroups_returnsEmptyWrapperWithoutMarker() {
|
||||
Response response = handler.handle("DescribeCacheParameterGroups", params());
|
||||
|
||||
assertEquals(200, response.getStatus());
|
||||
String body = (String) response.getEntity();
|
||||
assertTrue(body.contains("<DescribeCacheParameterGroupsResult><CacheParameterGroups></CacheParameterGroups></DescribeCacheParameterGroupsResult>"),
|
||||
"Expected empty CacheParameterGroups wrapper inside the Result element");
|
||||
assertFalse(body.contains("<Marker>"), "Empty list must omit Marker");
|
||||
}
|
||||
|
||||
@Test
|
||||
void unsupportedOperationStillReturnsQueryError() {
|
||||
Response response = handler.handle("NoSuchAction", params());
|
||||
|
||||
assertEquals(400, response.getStatus());
|
||||
assertTrue(((String) response.getEntity()).contains("UnsupportedOperation"));
|
||||
}
|
||||
|
||||
private static MultivaluedMap<String, String> params() {
|
||||
return new MultivaluedHashMap<>();
|
||||
}
|
||||
}
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
package io.github.hectorvent.floci.services.glue;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
import io.github.hectorvent.floci.core.storage.InMemoryStorage;
|
||||
import io.github.hectorvent.floci.core.storage.StorageBackend;
|
||||
import io.github.hectorvent.floci.core.storage.StorageFactory;
|
||||
import io.github.hectorvent.floci.services.glue.schemaregistry.GlueSchemaRegistryService;
|
||||
import io.github.hectorvent.floci.services.resourcegroupstagging.ResourceGroupsTaggingService;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* Verifies the wire-accurate empty-list responses for the read-only Glue actions on resources
|
||||
* the emulator does not model (GetJobs, GetCrawlers, ListDataQualityRulesets, GetSecurityConfigurations).
|
||||
* Each must return HTTP 200, an empty list under its result key, and omit NextToken.
|
||||
*/
|
||||
class GlueJsonHandlerEmptyListTest {
|
||||
|
||||
private static final String REGION = "us-east-1";
|
||||
private static final String ACCOUNT_ID = "000000000000";
|
||||
|
||||
private GlueJsonHandler handler;
|
||||
private ObjectMapper mapper;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
mapper = new ObjectMapper();
|
||||
RegionResolver regionResolver = new RegionResolver(REGION, ACCOUNT_ID);
|
||||
StorageFactory storageFactory = new InMemoryStorageFactory();
|
||||
GlueSchemaRegistryService schemaRegistryService =
|
||||
new GlueSchemaRegistryService(storageFactory, regionResolver);
|
||||
GlueService glueService = new GlueService(
|
||||
storageFactory, schemaRegistryService, regionResolver, new ResourceGroupsTaggingService());
|
||||
handler = new GlueJsonHandler(glueService, schemaRegistryService, mapper);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getJobsReturnsEmptyJobsList() throws Exception {
|
||||
assertEmptyList("GetJobs", "Jobs");
|
||||
}
|
||||
|
||||
@Test
|
||||
void getCrawlersReturnsEmptyCrawlersList() throws Exception {
|
||||
assertEmptyList("GetCrawlers", "Crawlers");
|
||||
}
|
||||
|
||||
@Test
|
||||
void listDataQualityRulesetsReturnsEmptyRulesetsList() throws Exception {
|
||||
assertEmptyList("ListDataQualityRulesets", "Rulesets");
|
||||
}
|
||||
|
||||
@Test
|
||||
void getSecurityConfigurationsReturnsEmptyList() throws Exception {
|
||||
assertEmptyList("GetSecurityConfigurations", "SecurityConfigurations");
|
||||
}
|
||||
|
||||
private void assertEmptyList(String action, String listKey) throws Exception {
|
||||
Response response = handler.handle(action, mapper.createObjectNode(), REGION);
|
||||
|
||||
assertEquals(200, response.getStatus());
|
||||
|
||||
JsonNode body = mapper.valueToTree(response.getEntity());
|
||||
assertTrue(body.has(listKey), action + " response must contain " + listKey);
|
||||
assertTrue(body.get(listKey).isArray(), listKey + " must be a JSON array");
|
||||
assertEquals(0, body.get(listKey).size(), listKey + " must be empty");
|
||||
assertFalse(body.has("NextToken"), action + " response must omit NextToken");
|
||||
assertEquals(1, body.size(), action + " response must contain only " + listKey);
|
||||
}
|
||||
|
||||
private static final class InMemoryStorageFactory extends StorageFactory {
|
||||
private InMemoryStorageFactory() {
|
||||
super(null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <V> StorageBackend<String, V> create(String serviceName,
|
||||
String fileName,
|
||||
TypeReference<Map<String, V>> typeReference) {
|
||||
return new InMemoryStorage<>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -404,6 +404,85 @@ class IamIntegrationTest {
|
||||
.body("ListMFADevicesResponse.ListMFADevicesResult.IsTruncated", equalTo("false"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(51)
|
||||
void getAccessKeyLastUsedReturnsNeverUsedShape() {
|
||||
given()
|
||||
.formParam("Action", "GetAccessKeyLastUsed")
|
||||
.formParam("AccessKeyId", "AKIAEXAMPLE")
|
||||
.header("Authorization",
|
||||
"AWS4-HMAC-SHA256 Credential=test/20260227/us-east-1/iam/aws4_request")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.contentType("application/xml")
|
||||
.body("GetAccessKeyLastUsedResponse.GetAccessKeyLastUsedResult"
|
||||
+ ".AccessKeyLastUsed.ServiceName", equalTo("N/A"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(52)
|
||||
void getLoginProfileReturnsNoSuchEntity() {
|
||||
given()
|
||||
.formParam("Action", "GetLoginProfile")
|
||||
.formParam("UserName", "any-user")
|
||||
.header("Authorization",
|
||||
"AWS4-HMAC-SHA256 Credential=test/20260227/us-east-1/iam/aws4_request")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(404)
|
||||
.contentType("application/xml")
|
||||
.body("ErrorResponse.Error.Code", equalTo("NoSuchEntity"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(53)
|
||||
void listSamlProvidersReturnsEmptyList() {
|
||||
given()
|
||||
.formParam("Action", "ListSAMLProviders")
|
||||
.header("Authorization",
|
||||
"AWS4-HMAC-SHA256 Credential=test/20260227/us-east-1/iam/aws4_request")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.contentType("application/xml")
|
||||
.body("ListSAMLProvidersResponse.ListSAMLProvidersResult.SAMLProviderList", isEmptyOrNullString());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(54)
|
||||
void listOpenIdConnectProvidersReturnsEmptyList() {
|
||||
given()
|
||||
.formParam("Action", "ListOpenIDConnectProviders")
|
||||
.header("Authorization",
|
||||
"AWS4-HMAC-SHA256 Credential=test/20260227/us-east-1/iam/aws4_request")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.contentType("application/xml")
|
||||
.body("ListOpenIDConnectProvidersResponse.ListOpenIDConnectProvidersResult"
|
||||
+ ".OpenIDConnectProviderList", isEmptyOrNullString());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(55)
|
||||
void listServerCertificatesReturnsEmptyPaginatedList() {
|
||||
given()
|
||||
.formParam("Action", "ListServerCertificates")
|
||||
.header("Authorization",
|
||||
"AWS4-HMAC-SHA256 Credential=test/20260227/us-east-1/iam/aws4_request")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.contentType("application/xml")
|
||||
.body("ListServerCertificatesResponse.ListServerCertificatesResult.IsTruncated", equalTo("false"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(10)
|
||||
void createUser() {
|
||||
|
||||
@@ -649,6 +649,41 @@ class RdsQueryHandlerTest {
|
||||
assertTrue(body.contains("<DBSubnetGroupArn>arn:aws:rds:us-east-1:123456789012:subgrp:default</DBSubnetGroupArn>"));
|
||||
}
|
||||
|
||||
// ──────────────────────────── Snapshots & Proxies (empty lists) ─────────────
|
||||
|
||||
@Test
|
||||
void describeDbSnapshots_returnsEmptyListWith200() {
|
||||
Response response = handler.handle("DescribeDBSnapshots", params());
|
||||
|
||||
String body = (String) response.getEntity();
|
||||
assertEquals(200, response.getStatus());
|
||||
assertTrue(body.contains("<DescribeDBSnapshotsResult>"));
|
||||
assertTrue(body.contains("<DBSnapshots></DBSnapshots>"));
|
||||
assertFalse(body.contains("<Marker>"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void describeDbProxies_returnsEmptyListWith200() {
|
||||
Response response = handler.handle("DescribeDBProxies", params());
|
||||
|
||||
String body = (String) response.getEntity();
|
||||
assertEquals(200, response.getStatus());
|
||||
assertTrue(body.contains("<DescribeDBProxiesResult>"));
|
||||
assertTrue(body.contains("<DBProxies></DBProxies>"));
|
||||
assertFalse(body.contains("<Marker>"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void describeDbClusterSnapshots_returnsEmptyListWith200() {
|
||||
Response response = handler.handle("DescribeDBClusterSnapshots", params());
|
||||
|
||||
String body = (String) response.getEntity();
|
||||
assertEquals(200, response.getStatus());
|
||||
assertTrue(body.contains("<DescribeDBClusterSnapshotsResult>"));
|
||||
assertTrue(body.contains("<DBClusterSnapshots></DBClusterSnapshots>"));
|
||||
assertFalse(body.contains("<Marker>"));
|
||||
}
|
||||
|
||||
// ──────────────────────────── Helpers ────────────────────────────
|
||||
|
||||
private static MultivaluedMap<String, String> params() {
|
||||
|
||||
@@ -316,6 +316,50 @@ class SsmIntegrationTest {
|
||||
.body("BaselineId", startsWith("pb-"));
|
||||
}
|
||||
|
||||
// ── Read-only list operations for resources not modeled (empty results) ──
|
||||
|
||||
@Test
|
||||
void listDocuments_returnsEmptyList() {
|
||||
given()
|
||||
.header("X-Amz-Target", "AmazonSSM.ListDocuments")
|
||||
.contentType(SSM_CONTENT_TYPE)
|
||||
.body("{}")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("DocumentIdentifiers.size()", equalTo(0))
|
||||
.body("$", not(hasKey("NextToken")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void listAssociations_returnsEmptyList() {
|
||||
given()
|
||||
.header("X-Amz-Target", "AmazonSSM.ListAssociations")
|
||||
.contentType(SSM_CONTENT_TYPE)
|
||||
.body("{}")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("Associations.size()", equalTo(0))
|
||||
.body("$", not(hasKey("NextToken")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void describeMaintenanceWindows_returnsEmptyList() {
|
||||
given()
|
||||
.header("X-Amz-Target", "AmazonSSM.DescribeMaintenanceWindows")
|
||||
.contentType(SSM_CONTENT_TYPE)
|
||||
.body("{}")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("WindowIdentities.size()", equalTo(0))
|
||||
.body("$", not(hasKey("NextToken")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void unsupportedOperation() {
|
||||
given()
|
||||
|
||||
Reference in new issue
Block a user