test: retire two redundant test profiles and revive three CORS tests that never ran (#4609)

S3BlockPublicAccessEnforcementIntegrationTest moves onto the shared S3EnforceAuthProfile it duplicated, and EksRoute53DnsDockerIntegrationTest drops a profile that restated the configured embedded-dns default.

The two static nested test classes in GlobalCorsFilterIntegrationTest were never selected by surefire, which excludes nested classes. Their tests now live in top-level classes: the default-config pair on the default profile, and the private-network test on a new shared ExtraCorsOriginProfile, which ApiGatewayPreflightRoutingIntegrationTest's identical nested profile also moves onto.

Part of #4542.
This commit is contained in:
Priamo Germosen authored and GitHub committed 2026-09-28 22:02:42 -05:00
1 parent 240fd865f0
commit 8c2ceb5aa1
7 files changed
+123 -107

No files matched your search

@@ -0,0 +1,48 @@
package io.github.hectorvent.floci.core.common;
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
import io.quarkus.test.junit.QuarkusTest;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.nullValue;
/**
* With the configured defaults, no extra origin is allowed, so the global filter adds no CORS
* headers for a browser origin, on a preflight or on the actual request.
*/
@QuarkusTest
class GlobalCorsFilterDefaultIntegrationTest {
@BeforeAll
static void configureRestAssured() {
RestAssuredJsonUtils.configureAwsContentTypes();
}
@Test
void preflightReturnsForbiddenWithoutCorsHeaders() {
given()
.header("Origin", "http://localhost:3000")
.header("Access-Control-Request-Method", "PUT")
.when()
.options("/my-bucket/some-key")
.then()
.statusCode(403)
.header("Access-Control-Allow-Origin", nullValue());
}
@Test
void actualRequestGetsNoCorsHeaders() {
given()
.header("Origin", "http://localhost:3000")
.header("X-Amz-Target", "DynamoDB_20120810.ListTables")
.contentType("application/x-amz-json-1.0")
.body("{}")
.when()
.post("/")
.then()
.statusCode(200)
.header("Access-Control-Allow-Origin", nullValue());
}
}
@@ -146,76 +146,4 @@ class GlobalCorsFilterIntegrationTest {
"floci.security.cors-allow-private-network", "true");
}
}
@QuarkusTest
@TestProfile(PrivateNetworkDefaultOffTest.CorsPnaDefaultProfile.class)
static class PrivateNetworkDefaultOffTest {
@BeforeAll
static void configureRestAssured() {
RestAssuredJsonUtils.configureAwsContentTypes();
}
@Test
void privateNetworkAccessNotGrantedByDefault() {
given()
.header("Origin", "http://localhost:3000")
.header("Access-Control-Request-Method", "POST")
.header("Access-Control-Request-Private-Network", "true")
.when()
.options("/")
.then()
.statusCode(204)
.header("Access-Control-Allow-Origin", equalTo("http://localhost:3000"))
.header("Access-Control-Allow-Private-Network", nullValue());
}
// Only origins set — cors-allow-private-network left at its (off) default.
public static final class CorsPnaDefaultProfile implements QuarkusTestProfile {
@Override
public Map<String, String> getConfigOverrides() {
return Map.of("floci.security.extra-cors-allowed-origins", "http://localhost:3000");
}
}
}
@QuarkusTest
@TestProfile(DisabledGlobalCorsFilterTest.DisabledCorsProfile.class)
static class DisabledGlobalCorsFilterTest {
@BeforeAll
static void configureRestAssured() {
RestAssuredJsonUtils.configureAwsContentTypes();
}
@Test
void preflightReturnsForbiddenWithoutCorsHeaders() {
given()
.header("Origin", "http://localhost:3000")
.header("Access-Control-Request-Method", "PUT")
.when()
.options("/my-bucket/some-key")
.then()
.statusCode(403)
.header("Access-Control-Allow-Origin", nullValue());
}
@Test
void actualRequestGetsNoCorsHeaders() {
given()
.header("Origin", "http://localhost:3000")
.header("X-Amz-Target", "DynamoDB_20120810.ListTables")
.contentType("application/x-amz-json-1.0")
.body("{}")
.when()
.post("/")
.then()
.statusCode(200)
.header("Access-Control-Allow-Origin", nullValue());
}
public static final class DisabledCorsProfile implements QuarkusTestProfile {
// No config overrides, testing default application.yml values
}
}
}
@@ -0,0 +1,40 @@
package io.github.hectorvent.floci.core.common;
import io.github.hectorvent.floci.testing.ExtraCorsOriginProfile;
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.junit.TestProfile;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.nullValue;
/**
* An extra allowed origin on its own does not grant private network access:
* {@code cors-allow-private-network} stays at its off default.
*/
@QuarkusTest
@TestProfile(ExtraCorsOriginProfile.class)
class GlobalCorsFilterPrivateNetworkDefaultIntegrationTest {
@BeforeAll
static void configureRestAssured() {
RestAssuredJsonUtils.configureAwsContentTypes();
}
@Test
void privateNetworkAccessNotGrantedByDefault() {
given()
.header("Origin", ExtraCorsOriginProfile.ORIGIN)
.header("Access-Control-Request-Method", "POST")
.header("Access-Control-Request-Private-Network", "true")
.when()
.options("/")
.then()
.statusCode(204)
.header("Access-Control-Allow-Origin", equalTo(ExtraCorsOriginProfile.ORIGIN))
.header("Access-Control-Allow-Private-Network", nullValue());
}
}
@@ -1,7 +1,7 @@
package io.github.hectorvent.floci.services.apigateway;
import io.github.hectorvent.floci.testing.ExtraCorsOriginProfile;
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.junit.QuarkusTestProfile;
import io.quarkus.test.junit.TestProfile;
import io.restassured.http.ContentType;
import org.junit.jupiter.api.MethodOrderer;
@@ -9,8 +9,6 @@ import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import java.util.Map;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.notNullValue;
@@ -26,13 +24,16 @@ import static org.hamcrest.Matchers.notNullValue;
* {@code /execute-api/...} path must be skipped by the filter and routed all the way to the
* integration. This test drives that full chain — filter skip → route match → OPTIONS/ANY
* method resolution → integration invocation — so a regression in any single stage fails here.</p>
*
* <p>Global CORS has to be on for this to mean anything: without the deployed-path exclusion, the
* filter would answer the preflight itself and the integration would never run.</p>
*/
@QuarkusTest
@TestProfile(ApiGatewayPreflightRoutingIntegrationTest.CorsEnabledProfile.class)
@TestProfile(ExtraCorsOriginProfile.class)
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
class ApiGatewayPreflightRoutingIntegrationTest {
private static final String ORIGIN = "http://localhost:3000";
private static final String ORIGIN = ExtraCorsOriginProfile.ORIGIN;
private static final String STAGE = "cors";
private static String apiId;
@@ -261,13 +262,4 @@ class ApiGatewayPreflightRoutingIntegrationTest {
given().when().delete("/restapis/" + apiId).then().statusCode(202);
given().when().delete("/v2/apis/" + httpApiId).then().statusCode(204);
}
public static final class CorsEnabledProfile implements QuarkusTestProfile {
@Override
public Map<String, String> getConfigOverrides() {
// Global CORS on: without the deployed-path exclusion, this filter would answer the
// preflight itself and the integration would never run.
return Map.of("floci.security.extra-cors-allowed-origins", ORIGIN);
}
}
}
@@ -11,8 +11,6 @@ import io.github.hectorvent.floci.services.route53.model.ResourceRecord;
import io.github.hectorvent.floci.services.route53.model.ResourceRecordSet;
import io.github.hectorvent.floci.services.route53.model.VpcAssociation;
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.junit.QuarkusTestProfile;
import io.quarkus.test.junit.TestProfile;
import jakarta.inject.Inject;
import org.jboss.logging.Logger;
import org.junit.jupiter.api.AfterEach;
@@ -29,18 +27,15 @@ import java.util.UUID;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Enables embedded DNS on the container it starts itself, so it needs no profile and runs on the
* default one alongside the other EKS Docker classes. It needs Docker and a bound embedded DNS
* server, and that server only binds when Floci itself runs in a container, so anywhere else the
* class skips.
*/
@QuarkusTest
@TestProfile(EksRoute53DnsDockerIntegrationTest.Profile.class)
class EksRoute53DnsDockerIntegrationTest {
public static final class Profile implements QuarkusTestProfile {
@Override
public Map<String, String> getConfigOverrides() {
return Map.of(
"floci.services.eks.embedded-dns", "true");
}
}
private static final Logger LOG = Logger.getLogger(EksRoute53DnsDockerIntegrationTest.class);
private static final String TEST_IMAGE = "alpine:3.21";
@@ -1,12 +1,11 @@
package io.github.hectorvent.floci.services.s3;
import io.github.hectorvent.floci.testing.S3EnforceAuthProfile;
import io.github.hectorvent.floci.testutil.S3RequestSigner;
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.junit.QuarkusTestProfile;
import io.quarkus.test.junit.TestProfile;
import org.junit.jupiter.api.Test;
import java.util.Map;
import java.util.UUID;
import static io.restassured.RestAssured.given;
@@ -21,7 +20,7 @@ import static org.hamcrest.Matchers.equalTo;
* turns on.
*/
@QuarkusTest
@TestProfile(S3BlockPublicAccessEnforcementIntegrationTest.EnforcementProfile.class)
@TestProfile(S3EnforceAuthProfile.class)
class S3BlockPublicAccessEnforcementIntegrationTest {
private static final S3RequestSigner OWNER = S3RequestSigner.signedAs("test", "test");
@@ -32,13 +31,6 @@ class S3BlockPublicAccessEnforcementIntegrationTest {
"Resource":["arn:aws:s3:::%1$s","arn:aws:s3:::%1$s/*"]}]}
""";
public static final class EnforcementProfile implements QuarkusTestProfile {
@Override
public Map<String, String> getConfigOverrides() {
return Map.of("floci.services.s3.enforce-auth", "true");
}
}
@Test
void anonymousGetSucceedsOnAPublicPolicyWithoutRestrictPublicBuckets() {
String bucket = bucketWithPublicPolicy();
@@ -0,0 +1,21 @@
package io.github.hectorvent.floci.testing;
import io.quarkus.test.junit.QuarkusTestProfile;
import java.util.Map;
/**
* Allows one extra CORS origin, {@link #ORIGIN}, and leaves every other CORS setting at its
* default, including {@code cors-allow-private-network}. Quarkus restarts and re-augments the
* application once per distinct profile class, so the classes that need only this override share
* this one rather than each declaring an identical nested profile.
*/
public class ExtraCorsOriginProfile implements QuarkusTestProfile {
public static final String ORIGIN = "http://localhost:3000";
@Override
public Map<String, String> getConfigOverrides() {
return Map.of("floci.security.extra-cors-allowed-origins", ORIGIN);
}
}