Light, fluffy, and always free - The AWS Local Emulator alternative
fix(cloudfront): return modeled UpdateFunction ETtag header (#6801)
Jimmy Liu Jia7332c69c7d8f
diff --git a/src/main/java/io/github/hectorvent/floci/services/cloudfront/CloudFrontController.java b/src/main/java/io/github/hectorvent/floci/services/cloudfront/CloudFrontController.javaindex eeb22659ca..458bf0fcc4 100644--- a/src/main/java/io/github/hectorvent/floci/services/cloudfront/CloudFrontController.java+++ b/src/main/java/io/github/hectorvent/floci/services/cloudfront/CloudFrontController.java@@ -894,7 +894,7 @@ public class CloudFrontController {}CloudFrontFunction fn = parseFunction(body);fn = service.updateFunction(name, ifMatch, fn);- return Response.ok(xmlFunctionResponse(fn), XML).header("ETag", fn.getEtag()).build();+ return Response.ok(xmlFunctionResponse(fn), XML).header("ETtag", fn.getEtag()).build();} catch (AwsException e) {return xmlErrorResponse(e);}diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudfront/CloudFrontManagementProtocolTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudfront/CloudFrontManagementProtocolTest.javaindex 37f3577132..9b08ac1047 100644--- a/src/test/java/io/github/hectorvent/floci/services/cloudfront/CloudFrontManagementProtocolTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/cloudfront/CloudFrontManagementProtocolTest.java@@ -13,6 +13,7 @@ import java.util.UUID;import static io.restassured.RestAssured.given;import static org.hamcrest.Matchers.equalTo;import static org.hamcrest.Matchers.not;+import static org.hamcrest.Matchers.notNullValue;import static org.hamcrest.xml.HasXPath.hasXPath;/** Verifies CloudFront REST XML payload roots against the AWS service model. */@@ -265,6 +266,42 @@ class CloudFrontManagementProtocolTest {.statusCode(204);}+ @Test+ void updateFunctionReturnsTheHeaderNameModeledByAwsSdks() {+ String name = "update-header-" + UUID.randomUUID();+ String createBody = """+ <CreateFunctionRequest xmlns="http://cloudfront.amazonaws.com/doc/2020-05-31/">+ <Name>%s</Name>+ <FunctionConfig><Comment>first</Comment><Runtime>cloudfront-js-2.0</Runtime></FunctionConfig>+ <FunctionCode>YWJj</FunctionCode>+ </CreateFunctionRequest>+ """.formatted(name);+ String updateBody = """+ <UpdateFunctionRequest xmlns="http://cloudfront.amazonaws.com/doc/2020-05-31/">+ <FunctionConfig><Comment>second</Comment><Runtime>cloudfront-js-2.0</Runtime></FunctionConfig>+ <FunctionCode>ZGVm</FunctionCode>+ </UpdateFunctionRequest>+ """;++ String createdEtag = given().contentType("application/xml").body(createBody)+ .when().post(API + "function")+ .then().statusCode(201).extract().header("ETag");++ String updatedEtag = given().contentType("application/xml")+ .header("If-Match", createdEtag).body(updateBody)+ .when().put(API + "function/" + name)+ .then().statusCode(200).header("ETtag", notNullValue())+ .extract().header("ETtag");++ given().queryParam("Stage", "DEVELOPMENT")+ .when().get(API + "function/" + name + "/describe")+ .then().statusCode(200).header("ETag", equalTo(updatedEtag));++ given().header("If-Match", updatedEtag)+ .when().delete(API + "function/" + name)+ .then().statusCode(204);+ }+@Testvoid createOriginAccessControlDoesNotDefaultRequiredConfiguration() {String body = """