mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(apigateway): filter GetUsagePlans by keyId (#7655)
This commit is contained in:
1 parent
062389b370
commit
413f490d8c
4 files changed
+61
-4
No files matched your search
+38
@@ -19,8 +19,10 @@ import software.amazon.awssdk.services.apigateway.model.UsagePlan;
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
@QuarkusTest
|
||||
class ApiGatewayUsagePlanSdkIntegrationTest {
|
||||
@@ -68,4 +70,40 @@ class ApiGatewayUsagePlanSdkIntegrationTest {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Measured on API Gateway: a key in no plan and an unknown key both answer an empty list, and an
|
||||
// empty or whitespace-only keyId lists every plan.
|
||||
@Test
|
||||
void getUsagePlansFiltersByKeyId() {
|
||||
try (ApiGatewayClient client = client()) {
|
||||
String first = client.createUsagePlan(r -> r.name("key-filter-first")).id();
|
||||
String second = client.createUsagePlan(r -> r.name("key-filter-second")).id();
|
||||
String inPlan = client.createApiKey(r -> r.name("key-filter-in-plan")).id();
|
||||
String inNoPlan = client.createApiKey(r -> r.name("key-filter-in-no-plan")).id();
|
||||
try {
|
||||
client.createUsagePlanKey(r -> r.usagePlanId(first).keyId(inPlan).keyType("API_KEY"));
|
||||
|
||||
assertEquals(List.of(first), usagePlanIds(client, inPlan));
|
||||
assertEquals(List.of(), usagePlanIds(client, inNoPlan));
|
||||
assertEquals(List.of(), usagePlanIds(client, "missing"));
|
||||
assertTrue(usagePlanIds(client, null).containsAll(List.of(first, second)));
|
||||
assertTrue(usagePlanIds(client, " ").containsAll(List.of(first, second)));
|
||||
|
||||
client.createUsagePlanKey(r -> r.usagePlanId(second).keyId(inPlan).keyType("API_KEY"));
|
||||
assertEquals(Set.of(first, second), Set.copyOf(usagePlanIds(client, inPlan)));
|
||||
|
||||
client.deleteUsagePlanKey(r -> r.usagePlanId(first).keyId(inPlan));
|
||||
assertEquals(List.of(second), usagePlanIds(client, inPlan));
|
||||
} finally {
|
||||
client.deleteApiKey(r -> r.apiKey(inPlan));
|
||||
client.deleteApiKey(r -> r.apiKey(inNoPlan));
|
||||
client.deleteUsagePlan(r -> r.usagePlanId(first));
|
||||
client.deleteUsagePlan(r -> r.usagePlanId(second));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static List<String> usagePlanIds(ApiGatewayClient client, String keyId) {
|
||||
return client.getUsagePlans(r -> r.keyId(keyId).limit(500)).items().stream().map(UsagePlan::id).toList();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user