mirror of
https://github.com/yacy/yacy_search_server.git
synced 2026-10-25 05:54:15 +00:00
isolate Solr 9.0 Jetty client dependencies in a relocated bridge
This commit is contained in:
1 parent
edeb6162c4
commit
bfddfe5e7e
20 files changed
+1118
-152
No files matched your search
@@ -106,4 +106,41 @@ public class AdminSecurityTest {
|
||||
// a request from localhost referred by a remote page is not a localhost access
|
||||
Assert.assertFalse(AdminSecurity.isLocalhostAccess("127.0.0.1", "example.org"));
|
||||
}
|
||||
|
||||
/** Test the complete request-level policy used by the container adapter. */
|
||||
@Test
|
||||
public void testAdminAccessPolicy() {
|
||||
final String user = "admin";
|
||||
final String hash = AdminSecurity.calcHash(user + ":secret");
|
||||
final AdminAccessPolicy localAllowed = new AdminAccessPolicy(
|
||||
false, false, true, true, user, hash);
|
||||
|
||||
Assert.assertEquals(AdminAccessPolicy.Decision.PUBLIC,
|
||||
localAllowed.decide("/index.html", "192.0.2.1", null, null));
|
||||
Assert.assertEquals(AdminAccessPolicy.Decision.ADMIN_REQUIRED,
|
||||
localAllowed.decide("/Settings_p.html", "192.0.2.1", null, null));
|
||||
Assert.assertEquals(AdminAccessPolicy.Decision.LOCAL_BYPASS,
|
||||
localAllowed.decide("/Settings_p.html", "127.0.0.1", null, null));
|
||||
Assert.assertEquals(AdminAccessPolicy.Decision.ADMIN_REQUIRED,
|
||||
localAllowed.decide("/Settings_p.html", "127.0.0.1", "https://example.org/", null));
|
||||
|
||||
final AdminAccessPolicy loginRequired = new AdminAccessPolicy(
|
||||
false, false, true, false, user, hash);
|
||||
Assert.assertEquals(AdminAccessPolicy.Decision.ADMIN_REQUIRED,
|
||||
loginRequired.decide("/Settings_p.html", "127.0.0.1", null, null));
|
||||
final String lazyAuth = "Basic " + Base64Order.standardCoder.encodeString(user + ":" + hash);
|
||||
Assert.assertEquals(AdminAccessPolicy.Decision.LOCAL_BYPASS,
|
||||
loginRequired.decide("/Settings_p.html", "127.0.0.1", null, lazyAuth));
|
||||
}
|
||||
|
||||
/** The credential context is request-bound and fails closed after cleanup. */
|
||||
@Test
|
||||
public void testAdminAuthenticationContext() {
|
||||
AdminAuthenticationContext.clear();
|
||||
Assert.assertFalse(AdminAuthenticationContext.isLocalhostRequest());
|
||||
AdminAuthenticationContext.setSocketPeerIp("127.0.0.1");
|
||||
Assert.assertTrue(AdminAuthenticationContext.isLocalhostRequest());
|
||||
AdminAuthenticationContext.clear();
|
||||
Assert.assertFalse(AdminAuthenticationContext.isLocalhostRequest());
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,18 @@ import org.junit.Test;
|
||||
*/
|
||||
public class InetPathAccessHandlerTest {
|
||||
|
||||
@Test
|
||||
public void testPortableRuleParsing() {
|
||||
final InetPathAccessRule addressOnly = InetPathAccessRule.parse("192.168.1.0/24");
|
||||
Assert.assertEquals("192.168.1.0/24", addressOnly.addressPattern());
|
||||
Assert.assertEquals("/*", addressOnly.pathPattern());
|
||||
|
||||
final InetPathAccessRule addressAndPath = InetPathAccessRule.parse("127.0.0.1|/api/*");
|
||||
Assert.assertEquals("127.0.0.1", addressAndPath.addressPattern());
|
||||
Assert.assertEquals("/api/*", addressAndPath.pathPattern());
|
||||
Assert.assertEquals("127.0.0.1|/api/*", addressAndPath.asJettyPattern());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the handler allow the given ip/path pairs.
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user