mirror of
https://github.com/floci-io/floci.git
synced 2026-11-28 08:09:43 -05:00
fix(sqs): page ListQueues with MaxResults and NextToken (#6222)
ListQueues ignored MaxResults and NextToken on every protocol path and returned all matching queues without a token. The paging now lives in SqsService, so the Query, JSON and CBOR paths share it. It follows the API reference and the botocore model: MaxResults must be 1 to 1000, a NextToken is returned only when MaxResults was set and more queues remain, and without MaxResults the response holds at most 1,000 queues and no token. Queues are ordered by name, the token is the shared Pagination cursor under its own namespace, and QueueNamePrefix filtering applies before paging. An out-of-range MaxResults or an unreadable NextToken returns InvalidParameterValue. Fixes #6219
This commit is contained in:
1 parent
007ac9268e
commit
f74d7a34a3
7 files changed
+385
-5
No files matched your search
@@ -390,4 +390,42 @@ class SqsTest {
|
||||
queueUrl = null;
|
||||
dlqUrl = null;
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(22)
|
||||
void listQueuesPaginatorVisitsEveryQueueOnce() {
|
||||
List<String> created = new ArrayList<>();
|
||||
try {
|
||||
for (String suffix : List.of("a", "b", "c")) {
|
||||
created.add(sqs.createQueue(CreateQueueRequest.builder()
|
||||
.queueName("sdk-list-paging-" + suffix)
|
||||
.build()).queueUrl());
|
||||
}
|
||||
|
||||
List<ListQueuesResponse> pages = new ArrayList<>();
|
||||
sqs.listQueuesPaginator(ListQueuesRequest.builder()
|
||||
.queueNamePrefix("sdk-list-paging-")
|
||||
.maxResults(1)
|
||||
.build()).forEach(pages::add);
|
||||
|
||||
assertThat(pages).hasSize(3);
|
||||
assertThat(pages).allSatisfy(p -> assertThat(p.queueUrls()).hasSize(1));
|
||||
assertThat(pages.get(2).nextToken()).isNull();
|
||||
assertThat(pages.stream().flatMap(p -> p.queueUrls().stream()).toList())
|
||||
.containsExactlyElementsOf(created);
|
||||
|
||||
assertThatThrownBy(() -> sqs.listQueues(ListQueuesRequest.builder().maxResults(1001).build()))
|
||||
.isInstanceOf(SqsException.class)
|
||||
.satisfies(e -> assertThat(((SqsException) e).awsErrorDetails().errorCode())
|
||||
.isEqualTo("InvalidParameterValue"));
|
||||
} finally {
|
||||
for (String url : created) {
|
||||
try {
|
||||
sqs.deleteQueue(DeleteQueueRequest.builder().queueUrl(url).build());
|
||||
} catch (QueueDoesNotExistException ignored) {
|
||||
// Already gone, which is the state cleanup wants; any other failure propagates.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user