-
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.
Access-Control-Allow-Credentials default value
Update docs/src/main/asciidoc/http-reference.adoc Co-authored-by: Guillaume Smet <[email protected]> config type + tests change origin match rules change config to Optional<Boolean>
- Loading branch information
Showing
9 changed files
with
95 additions
and
2 deletions.
There are no files selected for viewing
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
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
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
65 changes: 65 additions & 0 deletions
65
...eployment/src/test/java/io/quarkus/vertx/http/cors/CORSHandlerTestWildcardOriginCase.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,65 @@ | ||
package io.quarkus.vertx.http.cors; | ||
|
||
import static io.restassured.RestAssured.given; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
class CORSHandlerTestWildcardOriginCase { | ||
|
||
@RegisterExtension | ||
static QuarkusUnitTest runner = new QuarkusUnitTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(BeanRegisteringRoute.class) | ||
.addAsResource("conf/cors-config-wildcard-origins.properties", "application.properties")); | ||
|
||
@Test | ||
@DisplayName("Returns true 'Access-Control-Allow-Credentials' header on matching origin") | ||
void corsMatchingOrigin() { | ||
String origin = "http://custom.origin.quarkus"; | ||
String methods = "GET,POST"; | ||
String headers = "X-Custom"; | ||
given().header("Origin", origin) | ||
.header("Access-Control-Request-Method", methods) | ||
.header("Access-Control-Request-Headers", headers) | ||
.when() | ||
.options("/test").then() | ||
.statusCode(200) | ||
.header("Access-Control-Allow-Credentials", "true"); | ||
} | ||
|
||
@Test | ||
@DisplayName("Returns false 'Access-Control-Allow-Credentials' header on matching origin") | ||
void corsNotMatchingOrigin() { | ||
String origin = "http://non.matching.origin.quarkus"; | ||
String methods = "GET,POST"; | ||
String headers = "X-Custom"; | ||
given().header("Origin", origin) | ||
.header("Access-Control-Request-Method", methods) | ||
.header("Access-Control-Request-Headers", headers) | ||
.when() | ||
.options("/test").then() | ||
.statusCode(200) | ||
.header("Access-Control-Allow-Credentials", "false"); | ||
} | ||
|
||
@Test | ||
@DisplayName("Returns false 'Access-Control-Allow-Credentials' header on matching origin '*'") | ||
void corsMatchingOriginWithWildcard() { | ||
String origin = "*"; | ||
String methods = "GET,POST"; | ||
String headers = "X-Custom"; | ||
given().header("Origin", origin) | ||
.header("Access-Control-Request-Method", methods) | ||
.header("Access-Control-Request-Headers", headers) | ||
.when() | ||
.options("/test").then() | ||
.statusCode(200) | ||
.header("Access-Control-Allow-Credentials", "false"); | ||
} | ||
} |
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
3 changes: 3 additions & 0 deletions
3
...ons/vertx-http/deployment/src/test/resources/conf/cors-config-wildcard-origins.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,3 @@ | ||
quarkus.http.cors=true | ||
quarkus.http.cors.origins=http://custom.origin.quarkus,* | ||
quarkus.http.cors.methods=GET,OPTIONS,POST |
1 change: 1 addition & 0 deletions
1
extensions/vertx-http/deployment/src/test/resources/conf/cors-config.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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
quarkus.http.cors=true | ||
# whitespaces added to test that they are not taken into account config is parsed | ||
quarkus.http.cors.methods=GET, OPTIONS, POST | ||
quarkus.http.cors.access-control-allow-credentials=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
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