forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request quarkusio#26954 from geoand/quarkusio#26828
Ensure that HTTP OPTIONS handling involves the proper handler chain
- Loading branch information
Showing
2 changed files
with
66 additions
and
2 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
...est/java/io/quarkus/resteasy/reactive/server/test/customproviders/OptionsRequestTest.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,64 @@ | ||
package io.quarkus.resteasy.reactive.server.test.customproviders; | ||
|
||
import static io.restassured.RestAssured.when; | ||
import static org.hamcrest.Matchers.contains; | ||
import static org.hamcrest.Matchers.emptyOrNullString; | ||
import static org.hamcrest.Matchers.equalTo; | ||
import static org.hamcrest.Matchers.is; | ||
|
||
import java.util.function.Supplier; | ||
|
||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.container.ContainerResponseContext; | ||
|
||
import org.assertj.core.api.Assertions; | ||
import org.jboss.resteasy.reactive.server.ServerResponseFilter; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class OptionsRequestTest { | ||
|
||
@RegisterExtension | ||
static QuarkusUnitTest test = new QuarkusUnitTest() | ||
.setArchiveProducer(new Supplier<>() { | ||
@Override | ||
public JavaArchive get() { | ||
return ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(Resource.class, Filters.class); | ||
} | ||
}); | ||
|
||
@Test | ||
public void testJsonHeaderAdded() { | ||
String allowValue = when() | ||
.options("/test") | ||
.then() | ||
.statusCode(200) | ||
.header("Foo", equalTo("Bar")) | ||
.body(is(emptyOrNullString())) | ||
.extract().header("Allow"); | ||
|
||
Assertions.assertThat(allowValue).contains("GET", "HEAD", "OPTIONS"); | ||
} | ||
|
||
@Path("test") | ||
public static class Resource { | ||
|
||
@GET | ||
public String hello() { | ||
return "hello"; | ||
} | ||
} | ||
|
||
public static class Filters { | ||
@ServerResponseFilter | ||
public void preMatchingFilter(ContainerResponseContext context) { | ||
context.getHeaders().putSingle("Foo", "Bar"); | ||
} | ||
} | ||
} |
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