test(route53): reuse hosted zone helper in CloudFormation and SES (#6984)

This commit is contained in:
Jimmy Liu Jia authored and GitHub committed 2026-10-29 23:24:05 -04:00
1 parent ec3bd3184f
commit 5b0fb7057d
3 files changed
+18 -33

No files matched your search

@@ -1,6 +1,7 @@
package io.github.hectorvent.floci.services.cloudformation;
import io.github.hectorvent.floci.core.common.AwsException;
import io.github.hectorvent.floci.services.route53.Route53HostedZoneTestSupport;
import io.github.hectorvent.floci.services.route53.Route53Service;
import io.github.hectorvent.floci.testing.CfnStackWaits;
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
@@ -234,20 +235,7 @@ class CloudFormationRoute53RecordSetIntegrationTest {
}
private String createHostedZone(String zoneName, String callerReference) {
String location = given()
.contentType("application/xml")
.header("Authorization", ROUTE53_AUTH)
.body("""
<?xml version="1.0" encoding="UTF-8"?>
<CreateHostedZoneRequest xmlns="https://route53.amazonaws.com/doc/2013-04-01/">
<Name>%s</Name>
<CallerReference>%s</CallerReference>
</CreateHostedZoneRequest>
""".formatted(zoneName, callerReference))
.when().post("/2013-04-01/hostedzone")
.then().statusCode(201)
.extract().header("Location");
return location.substring(location.lastIndexOf('/') + 1);
return Route53HostedZoneTestSupport.createZone(zoneName, callerReference, ROUTE53_AUTH);
}
private void changeRecordSet(String zoneId, String action, String name, String address) {
@@ -1,19 +1,29 @@
package io.github.hectorvent.floci.services.route53;
import io.restassured.specification.RequestSpecification;
import static io.restassured.RestAssured.given;
final class Route53HostedZoneTestSupport {
public final class Route53HostedZoneTestSupport {
private Route53HostedZoneTestSupport() {}
static String createZone(String name, String callerReference) {
public static String createZone(String name, String callerReference) {
return createZone(name, callerReference, null);
}
public static String createZone(String name, String callerReference, String authorization) {
String request = """
<CreateHostedZoneRequest xmlns="https://route53.amazonaws.com/doc/2013-04-01/">
<Name>%s</Name>
<CallerReference>%s</CallerReference>
</CreateHostedZoneRequest>
""".formatted(name, callerReference);
String location = given().contentType("application/xml").body(request)
RequestSpecification specification = given().contentType("application/xml").body(request);
if (authorization != null) {
specification.header("Authorization", authorization);
}
String location = specification
.post("/2013-04-01/hostedzone")
.then().statusCode(201).extract().header("Location");
return location.substring(location.lastIndexOf('/') + 1);
@@ -1,5 +1,7 @@
package io.github.hectorvent.floci.services.ses;
import io.github.hectorvent.floci.services.route53.Route53HostedZoneTestSupport;
import java.util.List;
import java.util.UUID;
@@ -33,21 +35,7 @@ final class SesDomainIdentityTestHelper {
}
static String publishDkimRecords(String domain, List<String> tokens) {
String location = given()
.contentType("application/xml")
.body("""
<?xml version="1.0" encoding="UTF-8"?>
<CreateHostedZoneRequest xmlns="https://route53.amazonaws.com/doc/2013-04-01/">
<Name>%s</Name>
<CallerReference>%s</CallerReference>
</CreateHostedZoneRequest>
""".formatted(domain, UUID.randomUUID()))
.when()
.post("/2013-04-01/hostedzone")
.then()
.statusCode(201)
.extract()
.header("Location");
String zoneId = Route53HostedZoneTestSupport.createZone(domain, UUID.randomUUID().toString());
StringBuilder changes = new StringBuilder();
for (String token : tokens) {
@@ -65,7 +53,6 @@ final class SesDomainIdentityTestHelper {
</Change>
""".formatted(token, domain, token));
}
String zoneId = location.substring(location.lastIndexOf('/') + 1);
given()
.contentType("application/xml")
.body("""