@@ -1376,4 +1376,42 @@ public void testVirtualThreadPool() throws Exception
1376
1376
}
1377
1377
}
1378
1378
}
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
+ }
1379
1417
}
0 commit comments