fix(cloudfront): return modeled UpdateFunction ETtag header (#6801)

This commit is contained in:
Jimmy Liu Jia authored and GitHub committed 2026-10-28 07:08:18 -04:00
1 parent da517acc65
commit 7332c69c7d
2 files changed
+38 -1

No files matched your search

@@ -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);
}
@@ -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);
}
@Test
void createOriginAccessControlDoesNotDefaultRequiredConfiguration() {
String body = """