mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(apigateway): decode the ~0 JSON Pointer escape in stage method-settings patch paths (#3526)
This commit is contained in:
1 parent
a6f1751dfb
commit
bc44fc9106
2 files changed
+36
-1
No files matched your search
+26
@@ -136,6 +136,32 @@ class ApiGatewayIntegrationReadBackTest {
|
||||
.body("methodSettings.'widget/POST'.throttlingBurstLimit", equalTo(77));
|
||||
}
|
||||
|
||||
@Test
|
||||
void methodSettingsUnescapeTheJsonPointerTildeEscape() {
|
||||
String deploymentId = given().contentType(ContentType.JSON).body("{}")
|
||||
.when().post("/restapis/" + apiId + "/deployments")
|
||||
.then().statusCode(201).extract().path("id");
|
||||
given().contentType(ContentType.JSON)
|
||||
.body("{\"stageName\":\"tilde\",\"deploymentId\":\"" + deploymentId + "\"}")
|
||||
.when().post("/restapis/" + apiId + "/stages")
|
||||
.then().statusCode(201);
|
||||
|
||||
// RFC 6901 escapes a literal "~" as ~0 and "/" as ~1. "/~1pets~0promo/GET/..." therefore
|
||||
// addresses the resource "/pets~promo"; only ~1 used to be decoded, leaving a stray "~0".
|
||||
// "~01" is an escaped literal "~1", not a slash, so decoding order matters too.
|
||||
given().contentType(ContentType.JSON)
|
||||
.body("{\"patchOperations\":["
|
||||
+ "{\"op\":\"replace\",\"path\":\"/~1pets~0promo/GET/throttling/burstLimit\",\"value\":\"12\"},"
|
||||
+ "{\"op\":\"replace\",\"path\":\"/~1v~01/POST/throttling/rateLimit\",\"value\":\"3.5\"}]}")
|
||||
.when().patch("/restapis/" + apiId + "/stages/tilde")
|
||||
.then().statusCode(200);
|
||||
|
||||
given().when().get("/restapis/" + apiId + "/stages/tilde")
|
||||
.then().statusCode(200)
|
||||
.body("methodSettings.'pets~promo/GET'.throttlingBurstLimit", equalTo(12))
|
||||
.body("methodSettings.'v~1/POST'.throttlingRateLimit", equalTo(3.5f));
|
||||
}
|
||||
|
||||
@Test
|
||||
void anIntegrationWithNoTypeReportsRatherThanCrashing() {
|
||||
given().contentType(ContentType.JSON).body("{\"authorizationType\":\"NONE\"}")
|
||||
|
||||
Reference in new issue
Block a user