mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(apigateway): allow idempotent custom-id tags (#3430)
* fix(apigateway): allow idempotent custom-id tags * fix(apigatewayv2): allow idempotent custom-id tags
This commit is contained in:
1 parent
4471e92a0f
commit
eb622254bc
5 files changed
+98
-15
No files matched your search
+34
-4
@@ -395,6 +395,36 @@ class ApiGatewayIntegrationTest {
|
||||
}
|
||||
|
||||
@Test @Order(51)
|
||||
void tagRestApi_customIdTag_isIdempotent() {
|
||||
String arn = "arn:aws:apigateway:us-east-1::/restapis/MYCUSTOMNAME";
|
||||
given()
|
||||
.contentType(ContentType.JSON)
|
||||
.body("""
|
||||
{"tags":{"_custom_id_":"MYCUSTOMNAME","repeat":"accepted"}}
|
||||
""")
|
||||
.when().put("/tags/" + arn)
|
||||
.then()
|
||||
.statusCode(204);
|
||||
|
||||
given()
|
||||
.when().get("/restapis/MYCUSTOMNAME")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("tags._custom_id_", nullValue())
|
||||
.body("tags.repeat", equalTo("accepted"));
|
||||
|
||||
given()
|
||||
.contentType(ContentType.JSON)
|
||||
.body("""
|
||||
{"tags":{"_custom_id_":"DIFFERENT"}}
|
||||
""")
|
||||
.when().put("/tags/" + arn)
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("message", containsString("can only be supplied during resource creation"));
|
||||
}
|
||||
|
||||
@Test @Order(52)
|
||||
void getRestApi_customId_resolvesById() {
|
||||
given()
|
||||
.when().get("/restapis/MYCUSTOMNAME")
|
||||
@@ -406,7 +436,7 @@ class ApiGatewayIntegrationTest {
|
||||
|
||||
// ──────────────────────────── floci:override-id tag ────────────────────────────
|
||||
|
||||
@Test @Order(52)
|
||||
@Test @Order(53)
|
||||
void createRestApi_flociOverrideIdTag_usesTagValueAsApiId() {
|
||||
String body = """
|
||||
{"name":"override-id-api","tags":{"floci:override-id":"MYOVERRIDEID"}}
|
||||
@@ -422,7 +452,7 @@ class ApiGatewayIntegrationTest {
|
||||
.body("tags.'floci:override-id'", nullValue());
|
||||
}
|
||||
|
||||
@Test @Order(53)
|
||||
@Test @Order(54)
|
||||
void createRestApi_bothOverrideKeys_prefersFlociOverrideId() {
|
||||
String body = """
|
||||
{"name":"both-keys-api","tags":{"floci:override-id":"WINNER","_custom_id_":"LOSER"}}
|
||||
@@ -436,7 +466,7 @@ class ApiGatewayIntegrationTest {
|
||||
.body("id", equalTo("WINNER"));
|
||||
}
|
||||
|
||||
@Test @Order(54)
|
||||
@Test @Order(55)
|
||||
void createRestApi_blankOverrideId_isRejected() {
|
||||
String body = """
|
||||
{"name":"blank-override-api","tags":{"floci:override-id":" "}}
|
||||
@@ -450,7 +480,7 @@ class ApiGatewayIntegrationTest {
|
||||
.body("message", containsString("must not be blank"));
|
||||
}
|
||||
|
||||
@Test @Order(55)
|
||||
@Test @Order(56)
|
||||
void createRestApi_overrideIdWithPathSeparator_isRejected() {
|
||||
String body = """
|
||||
{"name":"bad-override-api","tags":{"floci:override-id":"has/slash"}}
|
||||
|
||||
+41
-6
@@ -504,7 +504,45 @@ class ApiGatewayV2IntegrationTest {
|
||||
}
|
||||
|
||||
@Test @Order(105)
|
||||
void tagApi_withOverrideKey_isRejectedAfterCreation() {
|
||||
void tagApi_withOverrideKey_isIdempotent() {
|
||||
given()
|
||||
.contentType(ContentType.JSON)
|
||||
.body("""
|
||||
{"tags":{"floci:override-id":"MYV2OVERRIDE","repeat":"accepted"}}
|
||||
""")
|
||||
.when().post("/v2/tags/arn:aws:apigateway:us-east-1::/apis/MYV2OVERRIDE")
|
||||
.then()
|
||||
.statusCode(201);
|
||||
|
||||
given()
|
||||
.when().get("/v2/tags/arn:aws:apigateway:us-east-1::/apis/MYV2OVERRIDE")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("tags.'floci:override-id'", nullValue())
|
||||
.body("tags.repeat", equalTo("accepted"));
|
||||
}
|
||||
|
||||
@Test @Order(106)
|
||||
void tagApi_withDeprecatedCustomIdKey_isIdempotent() {
|
||||
given()
|
||||
.contentType(ContentType.JSON)
|
||||
.body("""
|
||||
{"tags":{"_custom_id_":"MYV2CUSTOM","repeat":"accepted"}}
|
||||
""")
|
||||
.when().post("/v2/tags/arn:aws:apigateway:us-east-1::/apis/MYV2CUSTOM")
|
||||
.then()
|
||||
.statusCode(201);
|
||||
|
||||
given()
|
||||
.when().get("/v2/tags/arn:aws:apigateway:us-east-1::/apis/MYV2CUSTOM")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("tags._custom_id_", nullValue())
|
||||
.body("tags.repeat", equalTo("accepted"));
|
||||
}
|
||||
|
||||
@Test @Order(107)
|
||||
void tagApi_withChangedOverrideId_isRejected() {
|
||||
given()
|
||||
.contentType(ContentType.JSON)
|
||||
.body("""
|
||||
@@ -513,21 +551,18 @@ class ApiGatewayV2IntegrationTest {
|
||||
.when().post("/v2/tags/arn:aws:apigateway:us-east-1::/apis/MYV2OVERRIDE")
|
||||
.then()
|
||||
.statusCode(400);
|
||||
}
|
||||
|
||||
@Test @Order(106)
|
||||
void tagApi_withDeprecatedCustomIdKey_isRejectedAfterCreation() {
|
||||
given()
|
||||
.contentType(ContentType.JSON)
|
||||
.body("""
|
||||
{"tags":{"_custom_id_":"TOOLATE"}}
|
||||
""")
|
||||
.when().post("/v2/tags/arn:aws:apigateway:us-east-1::/apis/MYV2OVERRIDE")
|
||||
.when().post("/v2/tags/arn:aws:apigateway:us-east-1::/apis/MYV2CUSTOM")
|
||||
.then()
|
||||
.statusCode(400);
|
||||
}
|
||||
|
||||
@Test @Order(107)
|
||||
@Test @Order(108)
|
||||
void deleteApis_customAndOverrideId() {
|
||||
given().when().delete("/v2/apis/MYV2CUSTOM").then().statusCode(204);
|
||||
given().when().delete("/v2/apis/MYV2OVERRIDE").then().statusCode(204);
|
||||
|
||||
Reference in new issue
Block a user