-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow same origin CORS requests without 3rd party origins being confi…
…gured
- Loading branch information
1 parent
7949e33
commit f4dde34
Showing
3 changed files
with
44 additions
and
4 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
...t/src/test/java/io/quarkus/vertx/http/cors/CORSSameOriginWithoutOriginConfigTestCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package io.quarkus.vertx.http.cors; | ||
|
||
import static io.restassured.RestAssured.given; | ||
import static org.hamcrest.Matchers.nullValue; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
class CORSSameOriginWithoutOriginConfigTestCase { | ||
|
||
@RegisterExtension | ||
static QuarkusUnitTest runner = new QuarkusUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(BeanRegisteringRoute.class) | ||
.addAsResource("conf/cors-same-origin-only.properties", "application.properties")); | ||
|
||
@Test | ||
void corsSameOriginRequest() { | ||
String origin = "http://localhost:8081"; | ||
given().header("Origin", origin) | ||
.get("/test").then() | ||
.statusCode(200) | ||
.header("Access-Control-Allow-Origin", origin); | ||
} | ||
|
||
@Test | ||
void corsInvalidSameOriginRequest() { | ||
String origin = "http://externalhost:8081"; | ||
given().header("Origin", origin) | ||
.get("/test").then() | ||
.statusCode(403) | ||
.header("Access-Control-Allow-Origin", nullValue()); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
extensions/vertx-http/deployment/src/test/resources/conf/cors-same-origin-only.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
quarkus.http.cors=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters