Skip to content

Commit b89398d

Browse files
Issue #10388 - add DistributionTest for InetAccessHandler
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
1 parent 764c817 commit b89398d

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/DistributionTests.java

+38
Original file line numberDiff line numberDiff line change
@@ -1376,4 +1376,42 @@ public void testVirtualThreadPool() throws Exception
13761376
}
13771377
}
13781378
}
1379+
1380+
@Test
1381+
public void testInetAccessHandler() throws Exception
1382+
{
1383+
String jettyVersion = System.getProperty("jettyVersion");
1384+
JettyHomeTester distribution = JettyHomeTester.Builder.newInstance()
1385+
.jettyVersion(jettyVersion)
1386+
.mavenLocalRepository(System.getProperty("mavenRepoPath"))
1387+
.build();
1388+
1389+
try (JettyHomeTester.Run run1 = distribution.start("--add-modules=inetaccess,http"))
1390+
{
1391+
assertTrue(run1.awaitFor(10, TimeUnit.SECONDS));
1392+
assertEquals(0, run1.getExitValue());
1393+
1394+
int httpPort = distribution.freePort();
1395+
List<String> args = List.of(
1396+
"jetty.inetaccess.exclude=|/excludedPath/*",
1397+
"jetty.http.port=" + httpPort);
1398+
try (JettyHomeTester.Run run2 = distribution.start(args))
1399+
{
1400+
assertTrue(run2.awaitConsoleLogsFor("Started Server@", 10, TimeUnit.SECONDS));
1401+
startHttpClient();
1402+
1403+
// Excluded path returns 403 response.
1404+
ContentResponse response = client.newRequest("http://localhost:" + httpPort +"/excludedPath")
1405+
.timeout(15, TimeUnit.SECONDS)
1406+
.send();
1407+
assertEquals(HttpStatus.FORBIDDEN_403, response.getStatus());
1408+
1409+
// Other paths return 404 response.
1410+
response = client.newRequest("http://localhost:" + httpPort +"/path")
1411+
.timeout(15, TimeUnit.SECONDS)
1412+
.send();
1413+
assertEquals(HttpStatus.NOT_FOUND_404, response.getStatus());
1414+
}
1415+
}
1416+
}
13791417
}

0 commit comments

Comments
 (0)