mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(servicequotas): curate real AWS VPC quota codes (#4997)
ServiceQuotas only curated codebuild, lambda and organizations; every other service code got three CRC-synthetic quotas, so real VPC codes such as L-FE5A380F answered NoSuchResourceException from GetServiceQuota and GetAWSDefaultServiceQuota. Terraform's aws_servicequotas_service_quota reads exactly these codes before requesting an increase. Add a curated "vpc" entry, plus its service name: - L-FE5A380F "NAT gateways per Availability Zone" = 5 - L-2AEEBF1A "Rules per network ACL" = 20 Values are the AWS defaults rather than the generous GENERIC_QUOTA_VALUE, following the organizations entry (L-E619E033 = 50): callers compare a desired value against these defaults to decide whether to request an increase, so a realistic default keeps them on the path they take against AWS. The emulator does not enforce either limit. The synthetic quotas are still appended.
This commit is contained in:
1 parent
8e98c087fd
commit
0260a42549
4 files changed
+71
-2
No files matched your search
+31
@@ -175,6 +175,37 @@ class ServiceQuotasIntegrationTest {
|
||||
.body("Quota.GlobalQuota", equalTo(true));
|
||||
}
|
||||
|
||||
@Test
|
||||
void vpcQuotasUseAwsQuotaCodesAsDefaultAndApplied() {
|
||||
for (String target : new String[] {"GetAWSDefaultServiceQuota", "GetServiceQuota"}) {
|
||||
given()
|
||||
.contentType(CONTENT_TYPE)
|
||||
.header("X-Amz-Target", "ServiceQuotasV20190624." + target)
|
||||
.header("Authorization", AUTH_HEADER)
|
||||
.body("{\"ServiceCode\":\"vpc\",\"QuotaCode\":\"L-FE5A380F\"}")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("Quota.QuotaCode", equalTo("L-FE5A380F"))
|
||||
.body("Quota.QuotaName", equalTo("NAT gateways per Availability Zone"))
|
||||
.body("Quota.Value", equalTo(5.0f));
|
||||
|
||||
given()
|
||||
.contentType(CONTENT_TYPE)
|
||||
.header("X-Amz-Target", "ServiceQuotasV20190624." + target)
|
||||
.header("Authorization", AUTH_HEADER)
|
||||
.body("{\"ServiceCode\":\"vpc\",\"QuotaCode\":\"L-2AEEBF1A\"}")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("Quota.QuotaCode", equalTo("L-2AEEBF1A"))
|
||||
.body("Quota.QuotaName", equalTo("Rules per network ACL"))
|
||||
.body("Quota.Value", equalTo(20.0f));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void listRequestedQuotaHistoryByQuotaReturnsEmptyHistoryForKnownQuota() {
|
||||
given()
|
||||
|
||||
+30
@@ -1,11 +1,14 @@
|
||||
package io.github.hectorvent.floci.services.servicequotas;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
@@ -42,6 +45,33 @@ class ServiceQuotasServiceTest {
|
||||
assertTrue(codes.contains("L-2DC20C30"), codes.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
void vpcResolvesRealQuotaCodesWithNamesThroughGetAndList() {
|
||||
Map<String, String> want = Map.of(
|
||||
"L-FE5A380F", "NAT gateways per Availability Zone",
|
||||
"L-2AEEBF1A", "Rules per network ACL");
|
||||
Map<String, Double> defaults = Map.of("L-FE5A380F", 5.0, "L-2AEEBF1A", 20.0);
|
||||
for (Map.Entry<String, String> e : want.entrySet()) {
|
||||
JsonNode quota = service.getServiceQuota("vpc", e.getKey(), "us-east-1", "000000000000").path("Quota");
|
||||
assertEquals(e.getKey(), quota.path("QuotaCode").asText());
|
||||
assertEquals(e.getValue(), quota.path("QuotaName").asText());
|
||||
assertEquals(defaults.get(e.getKey()), quota.path("Value").asDouble());
|
||||
assertEquals("Amazon Virtual Private Cloud (Amazon VPC)", quota.path("ServiceName").asText());
|
||||
}
|
||||
Map<String, String> listed = new HashMap<>();
|
||||
service.listServiceQuotas("vpc", null, null, 100, "us-east-1", "000000000000").withArray("Quotas")
|
||||
.forEach(q -> listed.put(q.path("QuotaCode").asText(), q.path("QuotaName").asText()));
|
||||
want.forEach((code, name) -> assertEquals(name, listed.get(code), listed.toString()));
|
||||
assertEquals(want.size() + 3, listed.size(), "synthetic quotas still appended: " + listed);
|
||||
}
|
||||
|
||||
@Test
|
||||
void vpcUnknownQuotaCodeStillThrowsNoSuchResource() {
|
||||
AwsException e = assertThrows(AwsException.class,
|
||||
() -> service.getServiceQuota("vpc", "L-DOESNOTEX", "us-east-1", "000000000000"));
|
||||
assertEquals("NoSuchResourceException", e.getErrorCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
void getServiceQuota_unknownCode_throwsNoSuchResource() {
|
||||
AwsException e = assertThrows(AwsException.class,
|
||||
|
||||
Reference in new issue
Block a user