diff options
author | Jon Marius Venstad <jonmv@gmail.com> | 2022-04-06 12:56:01 +0200 |
---|---|---|
committer | Jon Marius Venstad <jonmv@gmail.com> | 2022-04-06 12:56:01 +0200 |
commit | 51535b82b7b6e7516144980d424410615a026037 (patch) | |
tree | 14c6938d20b63faa330cc25d9a37bb9b56ae478b /container-core/src/test/java/com/yahoo/restapi | |
parent | 0a9fa49f691cec760cefc61af664e0506d0e7ef5 (diff) |
Simplify Path by using HttpURL.Path for segments, and adding default validation
Diffstat (limited to 'container-core/src/test/java/com/yahoo/restapi')
-rw-r--r-- | container-core/src/test/java/com/yahoo/restapi/PathTest.java | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/container-core/src/test/java/com/yahoo/restapi/PathTest.java b/container-core/src/test/java/com/yahoo/restapi/PathTest.java index 5cbf80ff2ad..065b02be0e4 100644 --- a/container-core/src/test/java/com/yahoo/restapi/PathTest.java +++ b/container-core/src/test/java/com/yahoo/restapi/PathTest.java @@ -6,6 +6,7 @@ import org.junit.Test; import java.net.URI; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertThrows; import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; @@ -65,10 +66,12 @@ public class PathTest { @Test public void testUrlEncodedPath() { assertTrue(new Path(URI.create("/a/%62/c")).matches("/a/b/c")); - assertFalse(new Path(URI.create("/a/b%2fc")).matches("/a/b/c")); - assertFalse(new Path(URI.create("/foo")).matches("/foo/bar/%2e%2e")); + assertFalse(new Path(URI.create("/a/b%2fc"), __ -> { }).matches("/a/b/c")); + assertThrows("path segments cannot be \"\", \".\", or \"..\", but got: '..'", + IllegalArgumentException.class, + () -> new Path(URI.create("/foo")).matches("/foo/bar/%2e%2e")); - Path path = new Path(URI.create("/%61/%2f/%63")); + Path path = new Path(URI.create("/%61/%2f/%63"), __ -> { }); assertTrue(path.matches("/a/{slash}/{c}")); assertEquals("/", path.get("slash")); assertEquals("c", path.get("c")); |