diff --git a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/cors/CORSRegexTestCase.java b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/cors/CORSRegexTestCase.java new file mode 100644 index 0000000000000..7c841062ac5ef --- /dev/null +++ b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/cors/CORSRegexTestCase.java @@ -0,0 +1,36 @@ +package io.quarkus.vertx.http.cors; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.core.IsNull.nullValue; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; + +import io.quarkus.test.QuarkusUnitTest; + +public class CORSRegexTestCase { + + @RegisterExtension + static QuarkusUnitTest runner = new QuarkusUnitTest() + .withApplicationRoot((jar) -> jar + .addClasses(BeanRegisteringRoute.class) + .addAsResource("conf/cors-regex.properties", "application.properties")); + + @Test + public void corsRegexValidOriginTest() { + given().header("Origin", "https://asdf.domain.com") + .when() + .get("/test").then() + .statusCode(200) + .header("Access-Control-Allow-Origin", "https://asdf.domain.com"); + } + + @Test + public void corsRegexInvalidOriginTest() { + given().header("Origin", "https://asdfdomain.com") + .when() + .get("/test").then() + .statusCode(403) + .header("Access-Control-Allow-Origin", nullValue()); + } +} diff --git a/extensions/vertx-http/deployment/src/test/resources/conf/cors-regex.properties b/extensions/vertx-http/deployment/src/test/resources/conf/cors-regex.properties new file mode 100644 index 0000000000000..38571679f275e --- /dev/null +++ b/extensions/vertx-http/deployment/src/test/resources/conf/cors-regex.properties @@ -0,0 +1,2 @@ +quarkus.http.cors=true +quarkus.http.cors.origins=/https:\\/\\/(?:[a-z0-9\\-]+\\\\.)*domain\\\\.com/ \ No newline at end of file