@Test public void testCantGetHiddenPage() throws Exception { stat.setIncludeHidden(false); testRequest(HttpMethod.GET, "/.hidden.html", 404, "Not Found"); }
@Test public void testCantGetHiddenPageSubdir() throws Exception { stat.setIncludeHidden(false); testRequest(HttpMethod.GET, "/somedir/.hidden.html", 404, "Not Found"); }
/** * Set whether hidden files should be served * @param includeHidden true if hidden files should be served * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.ext.web.handler.StaticHandler setIncludeHidden(boolean includeHidden) { delegate.setIncludeHidden(includeHidden); return this; }
/** * Set whether hidden files should be served * @param includeHidden true if hidden files should be served * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.ext.web.handler.StaticHandler setIncludeHidden(boolean includeHidden) { delegate.setIncludeHidden(includeHidden); return this; }
@Test public void testDirectoryListingTextNoHidden() throws Exception { stat.setDirectoryListing(true); stat.setIncludeHidden(false); Set<String> expected = new HashSet<>(Arrays.asList("foo.json", "a", "index.html", "otherpage.html", "somedir", "somedir2", "somedir3", "testCompressionSuffix.html", "file with spaces.html")); testRequest(HttpMethod.GET, "/", null, resp -> { resp.bodyHandler(buff -> { assertEquals("text/plain", resp.headers().get("content-type")); String sBuff = buff.toString(); String[] elems = sBuff.split("\n"); assertEquals(expected.size(), elems.length); for (String elem: elems) { assertTrue(expected.contains(elem)); } }); }, 200, "OK", null); }
@Test public void testDirectoryListingJsonNoHidden() throws Exception { stat.setDirectoryListing(true); stat.setIncludeHidden(false); Set<String> expected = new HashSet<>(Arrays.asList("foo.json", "a", "index.html", "otherpage.html", "somedir", "somedir2", "somedir3", "testCompressionSuffix.html", "file with spaces.html")); testRequest(HttpMethod.GET, "/", req -> { req.putHeader("accept", "application/json"); }, resp -> { resp.bodyHandler(buff -> { assertEquals("application/json", resp.headers().get("content-type")); String sBuff = buff.toString(); JsonArray arr = new JsonArray(sBuff); assertEquals(expected.size(), arr.size()); for (Object elem: arr) { assertTrue(expected.contains(elem)); } testComplete(); }); }, 200, "OK", null); await(); }
@Test public void testCantGetHiddenPage() throws Exception { stat.setIncludeHidden(false); testRequest(HttpMethod.GET, "/.hidden.html", 404, "Not Found"); }
@Test public void testCantGetHiddenPageSubdir() throws Exception { stat.setIncludeHidden(false); testRequest(HttpMethod.GET, "/somedir/.hidden.html", 404, "Not Found"); }
@Test public void testDirectoryListingTextNoHidden() throws Exception { stat.setDirectoryListing(true); stat.setIncludeHidden(false); Set<String> expected = new HashSet<>(Arrays.asList("foo.json", "a", "index.html", "otherpage.html", "somedir", "somedir2", "somedir3", "testCompressionSuffix.html", "file with spaces.html")); testRequest(HttpMethod.GET, "/", null, resp -> { resp.bodyHandler(buff -> { assertEquals("text/plain", resp.headers().get("content-type")); String sBuff = buff.toString(); String[] elems = sBuff.split("\n"); assertEquals(expected.size(), elems.length); for (String elem: elems) { assertTrue(expected.contains(elem)); } }); }, 200, "OK", null); }
@Test public void testDirectoryListingJsonNoHidden() throws Exception { stat.setDirectoryListing(true); stat.setIncludeHidden(false); Set<String> expected = new HashSet<>(Arrays.asList("foo.json", "a", "index.html", "otherpage.html", "somedir", "somedir2", "somedir3", "testCompressionSuffix.html", "file with spaces.html")); testRequest(HttpMethod.GET, "/", req -> { req.putHeader("accept", "application/json"); }, resp -> { resp.bodyHandler(buff -> { assertEquals("application/json", resp.headers().get("content-type")); String sBuff = buff.toString(); JsonArray arr = new JsonArray(sBuff); assertEquals(expected.size(), arr.size()); for (Object elem: arr) { assertTrue(expected.contains(elem)); } testComplete(); }); }, 200, "OK", null); await(); }