diff --git a/docs/services/cloudmap.md b/docs/services/cloudmap.md
index 26a5c25237..3528632abd 100644
--- a/docs/services/cloudmap.md
+++ b/docs/services/cloudmap.md
@@ -17,6 +17,19 @@ hosted zones are created: public and private DNS namespaces are assigned a
synthetic `HostedZoneId` so SDK and CLI clients can exercise the full Cloud Map
control flow locally.
+`ListNamespaces`, `ListServices`, and `ListOperations` accept `MaxResults` from
+1 to 100 (default 100) and an opaque `NextToken`. Final and empty collections
+omit the token. Tokens are scoped to the action, account, region, and effective
+filters; changing the page size while continuing is supported. Invalid or
+oversized tokens (over 4096 characters) return `InvalidInput`.
+
+As in AWS, filters apply after selecting each page, so a filtered page can be
+empty and still include `NextToken`. Continue until the token is absent.
+Namespace filters remain unsupported. Service filtering uses the first
+`NAMESPACE_ID` value. Operation filters match values for `STATUS`, `TYPE`,
+`NAMESPACE_ID`, and `SERVICE_ID`; filter conditions and unknown names are
+ignored. These existing filter limitations are unchanged.
+
### DNS resolution
A DNS namespace is answerable, not just storable. Floci's embedded DNS server
diff --git a/pom.xml b/pom.xml
index 83fe5b954c..493dfbce64 100644
--- a/pom.xml
+++ b/pom.xml
@@ -396,6 +396,12 @@
${aws.sdk.version}
test
+
+ software.amazon.awssdk
+ servicediscovery
+ ${aws.sdk.version}
+ test
+
software.amazon.awssdk
redshift
diff --git a/src/main/java/io/github/hectorvent/floci/core/common/Pagination.java b/src/main/java/io/github/hectorvent/floci/core/common/Pagination.java
index 9f42d4918a..16edc56049 100644
--- a/src/main/java/io/github/hectorvent/floci/core/common/Pagination.java
+++ b/src/main/java/io/github/hectorvent/floci/core/common/Pagination.java
@@ -1,5 +1,7 @@
package io.github.hectorvent.floci.core.common;
+import com.fasterxml.jackson.databind.JsonNode;
+
import java.util.Comparator;
import java.util.List;
import java.util.function.Function;
@@ -71,6 +73,45 @@ public final class Pagination {
return slice(all, cursorOf, limit, decodeCursor(nextToken, prefix, invalidToken), prefix);
}
+ /** Validates service-specific bounds before applying the existing namespaced cursor format. */
+ public static PaginatedResult paginate(List all, Function cursorOf,
+ Integer maxResults, String nextToken,
+ int defaultPageSize, int maxResultsLimit, int maxTokenLength,
+ String errorCode, String namespace) {
+ if (maxResults != null && (maxResults < 1 || maxResults > maxResultsLimit)) {
+ throw new AwsException(errorCode, "Page size must be between 1 and " + maxResultsLimit + ".", 400);
+ }
+ if (nextToken != null && nextToken.length() > maxTokenLength) {
+ throw new AwsException(errorCode, "Pagination token must not exceed " + maxTokenLength + " characters.", 400);
+ }
+ return paginate(all, cursorOf, maxResults == null ? defaultPageSize : maxResults, nextToken, namespace,
+ token -> new AwsException(errorCode, "Invalid pagination token.", 400));
+ }
+
+ /** Reads an optional JSON page size without coercing strings, fractions, or overflowing integers. */
+ public static Integer parseMaxResults(JsonNode request, String field, String errorCode) {
+ JsonNode value = request.get(field);
+ if (value == null || value.isNull()) {
+ return null;
+ }
+ if (!value.isIntegralNumber() || !value.canConvertToInt()) {
+ throw new AwsException(errorCode, field + " must be an integer.", 400);
+ }
+ return value.intValue();
+ }
+
+ /** Reads an optional JSON cursor; bounds and scope are checked by the namespaced pager. */
+ public static String parseNextToken(JsonNode request, String field, String errorCode) {
+ JsonNode value = request.get(field);
+ if (value == null || value.isNull()) {
+ return null;
+ }
+ if (!value.isTextual()) {
+ throw new AwsException(errorCode, field + " must be a string.", 400);
+ }
+ return value.textValue();
+ }
+
private static PaginatedResult slice(List all, Function cursorOf, int limit,
String after, String tokenPrefix) {
List sorted = all.stream().sorted(Comparator.comparing(cursorOf)).collect(Collectors.toList());
diff --git a/src/main/java/io/github/hectorvent/floci/services/bcmdataexports/BcmDataExportsJsonHandler.java b/src/main/java/io/github/hectorvent/floci/services/bcmdataexports/BcmDataExportsJsonHandler.java
index e14ff389c5..a247d5bd1b 100644
--- a/src/main/java/io/github/hectorvent/floci/services/bcmdataexports/BcmDataExportsJsonHandler.java
+++ b/src/main/java/io/github/hectorvent/floci/services/bcmdataexports/BcmDataExportsJsonHandler.java
@@ -7,6 +7,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
import io.github.hectorvent.floci.core.common.AwsErrorResponse;
import io.github.hectorvent.floci.core.common.AwsException;
import io.github.hectorvent.floci.core.common.PaginatedResult;
+import io.github.hectorvent.floci.core.common.Pagination;
import io.github.hectorvent.floci.services.bcmdataexports.model.DataQuery;
import io.github.hectorvent.floci.services.bcmdataexports.model.DestinationConfiguration;
import io.github.hectorvent.floci.services.bcmdataexports.model.Export;
@@ -86,7 +87,9 @@ public class BcmDataExportsJsonHandler {
}
private Response handleList(JsonNode request) {
- PaginatedResult page = service.listExports(maxResults(request), nextToken(request));
+ PaginatedResult page = service.listExports(
+ Pagination.parseMaxResults(request, "MaxResults", "ValidationException"),
+ Pagination.parseNextToken(request, "NextToken", "ValidationException"));
ObjectNode response = objectMapper.createObjectNode();
ArrayNode arr = response.putArray("Exports");
for (Export export : page.items()) {
@@ -122,7 +125,9 @@ public class BcmDataExportsJsonHandler {
private Response handleListExecutions(JsonNode request) {
String arn = stringOrNull(request, "ExportArn");
- PaginatedResult page = service.listExecutions(arn, maxResults(request), nextToken(request));
+ PaginatedResult page = service.listExecutions(arn,
+ Pagination.parseMaxResults(request, "MaxResults", "ValidationException"),
+ Pagination.parseNextToken(request, "NextToken", "ValidationException"));
ObjectNode response = objectMapper.createObjectNode();
ArrayNode arr = response.putArray("Executions");
for (ExportExecution exec : page.items()) {
@@ -134,28 +139,6 @@ public class BcmDataExportsJsonHandler {
return Response.ok(response).build();
}
- private static Integer maxResults(JsonNode request) {
- JsonNode value = request.get("MaxResults");
- if (value == null || value.isNull()) {
- return null;
- }
- if (!value.isIntegralNumber() || !value.canConvertToInt()) {
- throw new AwsException("ValidationException", "MaxResults must be an integer between 1 and 300.", 400);
- }
- return value.intValue();
- }
-
- private static String nextToken(JsonNode request) {
- JsonNode value = request.get("NextToken");
- if (value == null || value.isNull()) {
- return null;
- }
- if (!value.isTextual()) {
- throw new AwsException("ValidationException", "NextToken must be a string.", 400);
- }
- return value.textValue();
- }
-
private Response handleGetExecution(JsonNode request) {
String arn = stringOrNull(request, "ExportArn");
String executionId = stringOrNull(request, "ExecutionId");
diff --git a/src/main/java/io/github/hectorvent/floci/services/bcmdataexports/BcmDataExportsService.java b/src/main/java/io/github/hectorvent/floci/services/bcmdataexports/BcmDataExportsService.java
index 6510923f0f..6950999238 100644
--- a/src/main/java/io/github/hectorvent/floci/services/bcmdataexports/BcmDataExportsService.java
+++ b/src/main/java/io/github/hectorvent/floci/services/bcmdataexports/BcmDataExportsService.java
@@ -26,7 +26,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
-import java.util.function.Function;
import java.util.regex.Pattern;
/**
@@ -118,7 +117,8 @@ public class BcmDataExportsService {
/** Returns one account-scoped page for {@code ListExports}. */
public PaginatedResult listExports(Integer maxResults, String nextToken) {
- return paginate(exportStore.scan(key -> true), Export::getExportArn, maxResults, nextToken,
+ return Pagination.paginate(exportStore.scan(key -> true), Export::getExportArn, maxResults, nextToken,
+ MAX_PAGE_SIZE, MAX_PAGE_SIZE, 8192, "ValidationException",
"ListExports:" + regionResolver.getAccountId());
}
@@ -199,21 +199,9 @@ public class BcmDataExportsService {
"Export " + exportArn + " not found.", 400);
}
String prefix = exportArn + "::";
- return paginate(executionStore.scan(key -> key.startsWith(prefix)), ExportExecution::getExecutionId,
- maxResults, nextToken, "ListExecutions:" + regionResolver.getAccountId() + ":" + exportArn);
- }
-
- private static PaginatedResult paginate(List items, Function cursorOf,
- Integer maxResults, String nextToken, String namespace) {
- int limit = maxResults != null ? maxResults : MAX_PAGE_SIZE;
- if (limit < 1 || limit > MAX_PAGE_SIZE) {
- throw new AwsException("ValidationException", "MaxResults must be between 1 and 300.", 400);
- }
- if (nextToken != null && nextToken.length() > 8192) {
- throw new AwsException("ValidationException", "NextToken must not exceed 8192 characters.", 400);
- }
- return Pagination.paginate(items, cursorOf, limit, nextToken, namespace,
- token -> new AwsException("ValidationException", "Invalid NextToken.", 400));
+ return Pagination.paginate(executionStore.scan(key -> key.startsWith(prefix)), ExportExecution::getExecutionId,
+ maxResults, nextToken, MAX_PAGE_SIZE, MAX_PAGE_SIZE, 8192, "ValidationException",
+ "ListExecutions:" + regionResolver.getAccountId() + ":" + exportArn);
}
/** {@code GetExecution} — returns one execution record. */
diff --git a/src/main/java/io/github/hectorvent/floci/services/cloudmap/CloudMapHandler.java b/src/main/java/io/github/hectorvent/floci/services/cloudmap/CloudMapHandler.java
index 2835eacf45..7b8972ad14 100644
--- a/src/main/java/io/github/hectorvent/floci/services/cloudmap/CloudMapHandler.java
+++ b/src/main/java/io/github/hectorvent/floci/services/cloudmap/CloudMapHandler.java
@@ -7,6 +7,8 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
import io.github.hectorvent.floci.core.common.AwsErrorResponse;
import io.github.hectorvent.floci.core.common.AwsException;
import io.github.hectorvent.floci.core.common.AwsJson11Controller;
+import io.github.hectorvent.floci.core.common.PaginatedResult;
+import io.github.hectorvent.floci.core.common.Pagination;
import io.github.hectorvent.floci.services.cloudmap.model.Instance;
import io.github.hectorvent.floci.services.cloudmap.model.Namespace;
import io.github.hectorvent.floci.services.cloudmap.model.Operation;
@@ -53,7 +55,7 @@ public class CloudMapHandler {
text(request, "Name"), text(request, "Vpc"), text(request, "CreatorRequestId"),
text(request, "Description"), parseTags(request), region));
case "GetNamespace" -> handleGetNamespace(request);
- case "ListNamespaces" -> handleListNamespaces(region);
+ case "ListNamespaces" -> handleListNamespaces(request, region);
case "DeleteNamespace" -> opResponse(service.deleteNamespace(text(request, "Id"), region));
case "GetOperation" -> handleGetOperation(request);
case "ListOperations" -> handleListOperations(request, region);
@@ -100,12 +102,18 @@ public class CloudMapHandler {
return Response.ok(response).build();
}
- private Response handleListNamespaces(String region) {
+ private Response handleListNamespaces(JsonNode request, String region) {
+ PaginatedResult page = service.listNamespaces(region,
+ Pagination.parseMaxResults(request, "MaxResults", "InvalidInput"),
+ Pagination.parseNextToken(request, "NextToken", "InvalidInput"));
ObjectNode response = objectMapper.createObjectNode();
ArrayNode arr = response.putArray("Namespaces");
- for (Namespace ns : service.listNamespaces(region)) {
+ for (Namespace ns : page.items()) {
arr.add(buildNamespaceNode(ns));
}
+ if (page.nextToken() != null) {
+ response.put("NextToken", page.nextToken());
+ }
return Response.ok(response).build();
}
@@ -120,14 +128,20 @@ public class CloudMapHandler {
private Response handleListOperations(JsonNode request, String region) {
Map> filters = parseFilters(request);
+ PaginatedResult page = service.listOperations(
+ region, filters, Pagination.parseMaxResults(request, "MaxResults", "InvalidInput"),
+ Pagination.parseNextToken(request, "NextToken", "InvalidInput"));
ObjectNode response = objectMapper.createObjectNode();
ArrayNode arr = response.putArray("Operations");
- for (Operation op : service.listOperations(region, filters)) {
+ for (Operation op : page.items()) {
ObjectNode node = objectMapper.createObjectNode();
node.put("Id", op.getId());
node.put("Status", op.getStatus());
arr.add(node);
}
+ if (page.nextToken() != null) {
+ response.put("NextToken", page.nextToken());
+ }
return Response.ok(response).build();
}
@@ -155,11 +169,17 @@ public class CloudMapHandler {
Map> filters = parseFilters(request);
String namespaceId = filters.containsKey("NAMESPACE_ID") && !filters.get("NAMESPACE_ID").isEmpty()
? filters.get("NAMESPACE_ID").get(0) : null;
+ PaginatedResult page = service.listServices(
+ region, namespaceId, Pagination.parseMaxResults(request, "MaxResults", "InvalidInput"),
+ Pagination.parseNextToken(request, "NextToken", "InvalidInput"));
ObjectNode response = objectMapper.createObjectNode();
ArrayNode arr = response.putArray("Services");
- for (Service s : service.listServices(region, namespaceId)) {
+ for (Service s : page.items()) {
arr.add(buildServiceSummaryNode(s));
}
+ if (page.nextToken() != null) {
+ response.put("NextToken", page.nextToken());
+ }
return Response.ok(response).build();
}
@@ -426,4 +446,4 @@ public class CloudMapHandler {
LOG.warnv("Failed to parse stored {0} JSON; field omitted. Value: {1}", field, rawJson);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/io/github/hectorvent/floci/services/cloudmap/CloudMapService.java b/src/main/java/io/github/hectorvent/floci/services/cloudmap/CloudMapService.java
index bed7eaa3b8..a2348f5ab7 100644
--- a/src/main/java/io/github/hectorvent/floci/services/cloudmap/CloudMapService.java
+++ b/src/main/java/io/github/hectorvent/floci/services/cloudmap/CloudMapService.java
@@ -9,6 +9,9 @@ import com.fasterxml.jackson.databind.node.MissingNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import io.github.hectorvent.floci.config.EmulatorConfig;
import io.github.hectorvent.floci.core.common.AwsException;
+import io.github.hectorvent.floci.core.common.Digests;
+import io.github.hectorvent.floci.core.common.PaginatedResult;
+import io.github.hectorvent.floci.core.common.Pagination;
import io.github.hectorvent.floci.core.common.RegionResolver;
import io.github.hectorvent.floci.core.common.dns.DnsAnswer;
import io.github.hectorvent.floci.core.common.dns.DnsRecord;
@@ -35,11 +38,13 @@ import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
+import java.util.TreeMap;
import java.util.UUID;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.TimeUnit;
+import java.util.function.Function;
/**
* Cloud Map (AWS service discovery) business logic. Mirrors the EventBridge service
@@ -166,6 +171,11 @@ public class CloudMapService {
return result;
}
+ public PaginatedResult listNamespaces(String region, Integer maxResults, String nextToken) {
+ return paginate(listNamespaces(region), Namespace::getId, maxResults, nextToken,
+ "ListNamespaces", region, null);
+ }
+
public void updateNamespace(String id, String description) {
Namespace ns = requireNamespace(id);
ns.setDescription(description);
@@ -256,6 +266,16 @@ public class CloudMapService {
return result;
}
+ public PaginatedResult listServices(String region, String namespaceIdFilter,
+ Integer maxResults, String nextToken) {
+ PaginatedResult page = paginate(listServices(region, null), Service::getId,
+ maxResults, nextToken, "ListServices", region, namespaceIdFilter);
+ // AWS applies filters after selecting the page, so an empty page can still have a token.
+ List items = page.items().stream()
+ .filter(s -> namespaceIdFilter == null || namespaceIdFilter.equals(s.getNamespaceId())).toList();
+ return new PaginatedResult<>(items, page.nextToken());
+ }
+
/**
* Only the TTLs of the existing DNS records can change, as on AWS: any other DnsConfig change
* (record types or count, RoutingPolicy), or a DnsConfig for a service without one, is rejected.
@@ -728,6 +748,26 @@ public class CloudMapService {
return result;
}
+ public PaginatedResult listOperations(String region, Map> filters,
+ Integer maxResults, String nextToken) {
+ Map> normalized = new TreeMap<>();
+ if (filters != null) {
+ filters.forEach((name, values) -> normalized.put(name, values.stream().distinct().sorted().toList()));
+ }
+ PaginatedResult page = paginate(listOperations(region, null), Operation::getId,
+ maxResults, nextToken, "ListOperations", region, normalized);
+ List items = page.items().stream().filter(op -> matchesOperationFilters(op, filters)).toList();
+ return new PaginatedResult<>(items, page.nextToken());
+ }
+
+ private PaginatedResult paginate(List items, Function cursorOf,
+ Integer maxResults, String nextToken,
+ String action, String region, Object query) {
+ String namespace = action + ":" + regionResolver.getAccountId() + ":" + region + ":"
+ + Digests.sha256Hex(objectMapper.valueToTree(query).toString());
+ return Pagination.paginate(items, cursorOf, maxResults, nextToken, 100, 100, 4096, "InvalidInput", namespace);
+ }
+
private boolean matchesOperationFilters(Operation op, Map> filters) {
if (filters == null || filters.isEmpty()) {
return true;
diff --git a/src/test/java/io/github/hectorvent/floci/core/common/PaginationTest.java b/src/test/java/io/github/hectorvent/floci/core/common/PaginationTest.java
index 7611732f3f..19354d5c6e 100644
--- a/src/test/java/io/github/hectorvent/floci/core/common/PaginationTest.java
+++ b/src/test/java/io/github/hectorvent/floci/core/common/PaginationTest.java
@@ -1,6 +1,8 @@
package io.github.hectorvent.floci.core.common;
+import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.function.Executable;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
@@ -19,6 +21,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
class PaginationTest {
+ private static final ObjectMapper MAPPER = new ObjectMapper();
private static final List ITEMS = List.of("c", "a", "b");
private static final AwsException INVALID = new AwsException("BadRequestException", "bad", 400);
private static final Function INVALID_TOKEN = token -> INVALID;
@@ -114,6 +117,81 @@ class PaginationTest {
assertFalse(Pagination.tokenStartsWith("", ""));
}
+ @Test
+ void boundedNamespacedPaging_usesTheDefaultAndCanChangePageSize() {
+ PaginatedResult first = bounded(null, null);
+ assertEquals(List.of("a", "b"), first.items());
+ PaginatedResult last = bounded(3, first.nextToken());
+ assertEquals(List.of("c"), last.items());
+ assertNull(last.nextToken());
+ }
+
+ @Test
+ void boundedNamespacedPaging_refusesOutOfRangeSizes() {
+ for (int size : new int[] {-1, 0, 4}) {
+ assertInvalid(() -> bounded(size, null));
+ }
+ }
+
+ @Test
+ void boundedNamespacedPaging_refusesLongTokensEvenWhenTheirScopeIsValid() {
+ String boundary = Base64.getUrlEncoder().withoutPadding()
+ .encodeToString(("ns:" + "z".repeat(21)).getBytes(StandardCharsets.UTF_8));
+ assertEquals(32, boundary.length());
+ assertTrue(bounded(1, boundary).items().isEmpty());
+ String token = Base64.getUrlEncoder().withoutPadding()
+ .encodeToString(("ns:" + "a".repeat(100)).getBytes(StandardCharsets.UTF_8));
+ assertInvalid(() -> bounded(1, token));
+ }
+
+ @Test
+ void boundedNamespacedPaging_refusesMalformedAndForeignTokens() {
+ assertInvalid(() -> bounded(1, "!!!"));
+ assertInvalid(() -> bounded(1, page(1, null, "other").nextToken()));
+ }
+
+ @Test
+ void jsonPageSize_preservesOmittedNullZeroAndIntegerValues() throws Exception {
+ for (String field : List.of("MaxResults", "PageSize")) {
+ assertNull(Pagination.parseMaxResults(MAPPER.readTree("{}"), field, "InvalidInput"));
+ assertNull(Pagination.parseMaxResults(MAPPER.readTree("{\"" + field + "\":null}"), field, "InvalidInput"));
+ assertEquals(0, Pagination.parseMaxResults(MAPPER.readTree("{\"" + field + "\":0}"), field, "InvalidInput"));
+ assertEquals(2, Pagination.parseMaxResults(MAPPER.readTree("{\"" + field + "\":2}"), field, "InvalidInput"));
+ }
+ }
+
+ @Test
+ void jsonPageSize_refusesOverflowAndCoercibleNonIntegers() throws Exception {
+ for (String value : List.of("4294967297", "1.5", "\"1\"", "{}", "[]", "true")) {
+ assertInvalid(() -> Pagination.parseMaxResults(MAPPER.readTree("{\"MaxResults\":" + value + "}"),
+ "MaxResults", "InvalidInput"));
+ }
+ }
+
+ @Test
+ void jsonToken_preservesNullEmptyAndTextButRefusesOtherShapes() throws Exception {
+ for (String field : List.of("NextToken", "PageToken")) {
+ assertNull(Pagination.parseNextToken(MAPPER.readTree("{}"), field, "InvalidInput"));
+ assertNull(Pagination.parseNextToken(MAPPER.readTree("{\"" + field + "\":null}"), field, "InvalidInput"));
+ assertEquals("", Pagination.parseNextToken(MAPPER.readTree("{\"" + field + "\":\"\"}"), field, "InvalidInput"));
+ assertEquals("token", Pagination.parseNextToken(MAPPER.readTree("{\"" + field + "\":\"token\"}"), field, "InvalidInput"));
+ for (String value : List.of("1", "true", "{}", "[]")) {
+ assertInvalid(() -> Pagination.parseNextToken(MAPPER.readTree("{\"" + field + "\":" + value + "}"),
+ field, "InvalidInput"));
+ }
+ }
+ }
+
+ private static PaginatedResult bounded(Integer size, String token) {
+ return Pagination.paginate(ITEMS, Function.identity(), size, token, 2, 3, 32, "InvalidInput", "ns");
+ }
+
+ private static void assertInvalid(Executable call) {
+ AwsException error = assertThrows(AwsException.class, call);
+ assertEquals("InvalidInput", error.getErrorCode());
+ assertEquals(400, error.getHttpStatus());
+ }
+
private static PaginatedResult page(int limit, String token, String namespace) {
return Pagination.paginate(ITEMS, Function.identity(), limit, token, namespace, INVALID_TOKEN);
}
diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudmap/CloudMapPaginationIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudmap/CloudMapPaginationIntegrationTest.java
new file mode 100644
index 0000000000..7ec2c4a439
--- /dev/null
+++ b/src/test/java/io/github/hectorvent/floci/services/cloudmap/CloudMapPaginationIntegrationTest.java
@@ -0,0 +1,337 @@
+package io.github.hectorvent.floci.services.cloudmap;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import io.github.hectorvent.floci.core.storage.AccountAwareStorageBackend;
+import io.github.hectorvent.floci.core.storage.StorageFactory;
+import io.github.hectorvent.floci.services.cloudmap.model.Namespace;
+import io.github.hectorvent.floci.services.cloudmap.model.Operation;
+import io.github.hectorvent.floci.services.cloudmap.model.Service;
+import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
+import io.quarkus.test.common.http.TestHTTPResource;
+import io.quarkus.test.junit.QuarkusTest;
+import jakarta.inject.Inject;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
+import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
+import software.amazon.awssdk.awscore.exception.AwsServiceException;
+import software.amazon.awssdk.regions.Region;
+import software.amazon.awssdk.services.servicediscovery.ServiceDiscoveryClient;
+import software.amazon.awssdk.services.servicediscovery.model.ListNamespacesResponse;
+import software.amazon.awssdk.services.servicediscovery.model.ListOperationsResponse;
+import software.amazon.awssdk.services.servicediscovery.model.ListServicesResponse;
+import software.amazon.awssdk.services.servicediscovery.model.OperationFilter;
+import software.amazon.awssdk.services.servicediscovery.model.ServiceFilter;
+
+import java.net.URI;
+import java.nio.charset.StandardCharsets;
+import java.time.Instant;
+import java.util.ArrayList;
+import java.util.Base64;
+import java.util.List;
+import java.util.Map;
+
+import static io.restassured.RestAssured.given;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+@QuarkusTest
+class CloudMapPaginationIntegrationTest {
+
+ private static final String ACCOUNT = "741660100001";
+ private static final String OTHER_ACCOUNT = "741660100002";
+ private static final Region REGION = Region.US_EAST_1;
+ private static final List ACTIONS = List.of("ListNamespaces", "ListServices", "ListOperations");
+
+ @Inject
+ StorageFactory storageFactory;
+
+ @TestHTTPResource
+ URI endpoint;
+
+ private AccountAwareStorageBackend namespaces;
+ private AccountAwareStorageBackend services;
+ private AccountAwareStorageBackend operations;
+ private final List created = new ArrayList<>();
+ private ServiceDiscoveryClient client;
+
+ @BeforeAll
+ static void configureRestAssured() {
+ RestAssuredJsonUtils.configureAwsContentTypes();
+ }
+
+ @BeforeEach
+ void setUp() {
+ namespaces = storageFactory.create("cloudmap", "cloudmap-namespaces.json",
+ new TypeReference