forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix path segment handling of encoded values
Fixes: quarkusio#34586 (cherry picked from commit c2285ec)
- Loading branch information
Showing
2 changed files
with
59 additions
and
1 deletion.
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
58 changes: 58 additions & 0 deletions
58
...src/test/java/org/jboss/resteasy/reactive/server/vertx/test/matching/PathSegmentTest.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,58 @@ | ||
package org.jboss.resteasy.reactive.server.vertx.test.matching; | ||
|
||
import static io.restassured.RestAssured.given; | ||
import static org.hamcrest.CoreMatchers.is; | ||
|
||
import java.util.List; | ||
import java.util.function.Supplier; | ||
|
||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.PathParam; | ||
import jakarta.ws.rs.core.PathSegment; | ||
|
||
import org.jboss.resteasy.reactive.server.vertx.test.framework.ResteasyReactiveUnitTest; | ||
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; | ||
|
||
public class PathSegmentTest { | ||
|
||
@RegisterExtension | ||
static ResteasyReactiveUnitTest test = new ResteasyReactiveUnitTest() | ||
.setArchiveProducer(new Supplier<>() { | ||
@Override | ||
public JavaArchive get() { | ||
return ShrinkWrap.create(JavaArchive.class) | ||
.addClass(Resource.class); | ||
} | ||
}); | ||
|
||
@Test | ||
public void testRegularMatch() { | ||
given() | ||
.when().get("/test/list/{seg1}/{seg2}", "key1", "key2") | ||
.then() | ||
.statusCode(200) | ||
.body(is("Path(2): [key1, key2]")); | ||
} | ||
|
||
@Test | ||
public void testEncodedPath() { | ||
given() | ||
.when().get("/test/list/{seg1}/{seg2}", "key/1", "key/2") | ||
.then() | ||
.statusCode(200) | ||
.body(is("Path(2): [key/1, key/2]")); | ||
} | ||
|
||
@Path("/test") | ||
public static class Resource { | ||
@GET | ||
@Path("/list/{primaryKey: .+}") | ||
public String pathAsList(@PathParam("primaryKey") List<PathSegment> path) { | ||
return String.format("Path(%d): %s", path.size(), path); | ||
} | ||
} | ||
} |