test(route53): share hosted zone creation helper (#6973)

This commit is contained in:
Jimmy Liu Jia authored and GitHub committed 2026-10-29 21:53:52 -04:00
1 parent 9e7bcc4029
commit 358f34b72f
3 files changed
+23 -26

No files matched your search

@@ -8,6 +8,7 @@ import org.junit.jupiter.params.provider.MethodSource;
import java.util.stream.Stream;
import static io.github.hectorvent.floci.services.route53.Route53HostedZoneTestSupport.createZone;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
@@ -398,17 +399,4 @@ class Route53ChangeResourceRecordSetsIntegrationTest {
Arguments.of("EmptyChanges", emptyChanges),
Arguments.of("NoChangeBatch", noChangeBatch));
}
private static String createZone(String name, String callerReference) {
String create = """
<CreateHostedZoneRequest xmlns="https://route53.amazonaws.com/doc/2013-04-01/">
<Name>%s</Name>
<CallerReference>%s</CallerReference>
</CreateHostedZoneRequest>
""".formatted(name, callerReference);
String location = given().contentType(XML).body(create)
.post("/2013-04-01/hostedzone")
.then().statusCode(201).extract().header("Location");
return location.substring(location.lastIndexOf('/') + 1);
}
}
@@ -0,0 +1,21 @@
package io.github.hectorvent.floci.services.route53;
import static io.restassured.RestAssured.given;
final class Route53HostedZoneTestSupport {
private Route53HostedZoneTestSupport() {}
static String createZone(String name, String callerReference) {
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)
.post("/2013-04-01/hostedzone")
.then().statusCode(201).extract().header("Location");
return location.substring(location.lastIndexOf('/') + 1);
}
}
@@ -117,18 +117,6 @@ class Route53HostedZonesPaginationIntegrationTest {
}
private String createZone(String name) {
String request = """
<CreateHostedZoneRequest xmlns="https://route53.amazonaws.com/doc/2013-04-01/">
<Name>%s</Name>
<CallerReference>pagination-%s-%s</CallerReference>
</CreateHostedZoneRequest>
""".formatted(name, name, System.nanoTime());
String location = given()
.contentType("application/xml")
.body(request)
.when().post("/2013-04-01/hostedzone")
.then().statusCode(201)
.extract().header("Location");
return location.substring(location.lastIndexOf('/') + 1);
return Route53HostedZoneTestSupport.createZone(name, "pagination-" + name + "-" + System.nanoTime());
}
}