This is an automated email from the ASF dual-hosted git repository.

jamesnetherton pushed a commit to branch 2.13.x
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git

commit 702574794cff1bf6b72529a603bb12e042a2fb05
Author: James Netherton <[email protected]>
AuthorDate: Wed Jan 25 10:19:22 2023 +0000

    Add test for REST DSL returning CORS headers for OPTIONS request
---
 .../camel/quarkus/component/rest/it/RestTest.java     | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git 
a/integration-tests/rest/src/test/java/org/apache/camel/quarkus/component/rest/it/RestTest.java
 
b/integration-tests/rest/src/test/java/org/apache/camel/quarkus/component/rest/it/RestTest.java
index 7f9d59e49b..8414a4d1a9 100644
--- 
a/integration-tests/rest/src/test/java/org/apache/camel/quarkus/component/rest/it/RestTest.java
+++ 
b/integration-tests/rest/src/test/java/org/apache/camel/quarkus/component/rest/it/RestTest.java
@@ -56,9 +56,11 @@ class RestTest {
                 .body(body)
                 .request(method, "/rest")
                 .then()
+                .header("Access-Control-Allow-Credentials", equalTo("true"))
                 .header("Access-Control-Allow-Headers", 
matchesPattern(".*Access-Control.*"))
-                .header("Access-Control-Allow-Methods", matchesPattern("GET, 
POST"))
-                .header("Access-Control-Allow-Credentials", equalTo("true"));
+                .header("Access-Control-Allow-Methods", equalTo("GET, POST"))
+                .header("Access-Control-Allow-Origin", equalTo("*"))
+                .header("Access-Control-Max-Age", equalTo("3600"));
 
         if (method.equals("HEAD")) {
             // Response body is ignored for HEAD so verify response headers
@@ -246,4 +248,17 @@ class RestTest {
             Files.deleteIfExists(csvFile);
         }
     }
+
+    @Test
+    public void corsOptionsRequest() {
+        RestAssured.given()
+                .options("/rest")
+                .then()
+                .header("Access-Control-Allow-Credentials", equalTo("true"))
+                .header("Access-Control-Allow-Headers", 
matchesPattern(".*Access-Control.*"))
+                .header("Access-Control-Allow-Methods", equalTo("GET, POST"))
+                .header("Access-Control-Allow-Origin", equalTo("*"))
+                .header("Access-Control-Max-Age", equalTo("3600"))
+                .statusCode(204);
+    }
 }

Reply via email to