Search in sources :

Example 1 with PluginClassLoader

use of org.opengrok.indexer.framework.PluginClassLoader in project OpenGrok by OpenGrok.

the class PluginClassLoaderTest method testProhibitedNames.

@Test
public void testProhibitedNames() throws ClassNotFoundException {
    PluginClassLoader instance = new PluginClassLoader(null);
    instance.loadClass("org.opengrok.indexer.configuration.Group");
    instance.loadClass("org.opengrok.indexer.configuration.Project");
    instance.loadClass("org.opengrok.indexer.authorization.IAuthorizationPlugin");
    instance.loadClass("org.opengrok.indexer.configuration.RuntimeEnvironment");
}
Also used : PluginClassLoader(org.opengrok.indexer.framework.PluginClassLoader) Test(org.junit.jupiter.api.Test)

Example 2 with PluginClassLoader

use of org.opengrok.indexer.framework.PluginClassLoader in project OpenGrok by OpenGrok.

the class PluginClassLoaderTest method testFalsePlugin.

@Test
public void testFalsePlugin() {
    PluginClassLoader instance = new PluginClassLoader(pluginDirectory);
    Class<?> clazz = loadClass(instance, "opengrok.auth.plugin.FalsePlugin");
    IAuthorizationPlugin plugin = getNewInstance(clazz);
    Group g = new Group("group1");
    Project p = new Project("project1");
    assertFalse(plugin.isAllowed(new DummyHttpServletRequest(), g));
    assertFalse(plugin.isAllowed(new DummyHttpServletRequest(), p));
}
Also used : Group(org.opengrok.indexer.configuration.Group) Project(org.opengrok.indexer.configuration.Project) DummyHttpServletRequest(org.opengrok.indexer.web.DummyHttpServletRequest) PluginClassLoader(org.opengrok.indexer.framework.PluginClassLoader) Test(org.junit.jupiter.api.Test)

Example 3 with PluginClassLoader

use of org.opengrok.indexer.framework.PluginClassLoader in project OpenGrok by OpenGrok.

the class PluginClassLoaderTest method testTruePlugin.

@Test
public void testTruePlugin() {
    PluginClassLoader instance = new PluginClassLoader(pluginDirectory);
    Class<?> clazz = loadClass(instance, "opengrok.auth.plugin.TruePlugin");
    IAuthorizationPlugin plugin = getNewInstance(clazz);
    Group g = new Group("group1");
    Project p = new Project("project1");
    assertTrue(plugin.isAllowed(new DummyHttpServletRequest(), g));
    assertTrue(plugin.isAllowed(new DummyHttpServletRequest(), p));
}
Also used : Group(org.opengrok.indexer.configuration.Group) Project(org.opengrok.indexer.configuration.Project) DummyHttpServletRequest(org.opengrok.indexer.web.DummyHttpServletRequest) PluginClassLoader(org.opengrok.indexer.framework.PluginClassLoader) Test(org.junit.jupiter.api.Test)

Example 4 with PluginClassLoader

use of org.opengrok.indexer.framework.PluginClassLoader in project OpenGrok by OpenGrok.

the class PluginClassLoaderTest method testProhibitedPackages.

@Test
public void testProhibitedPackages() {
    PluginClassLoader instance = new PluginClassLoader(null);
    assertThrows(SecurityException.class, () -> instance.loadClass("java.lang.plugin.MyPlugin"));
    assertThrows(SecurityException.class, () -> instance.loadClass("javax.servlet.HttpServletRequest"));
    assertThrows(SecurityException.class, () -> instance.loadClass("org.w3c.plugin.MyPlugin"));
    assertThrows(SecurityException.class, () -> instance.loadClass("org.xml.plugin.MyPlugin"));
    assertThrows(SecurityException.class, () -> instance.loadClass("org.omg.plugin.MyPlugin"));
    assertThrows(SecurityException.class, () -> instance.loadClass("sun.org.plugin.MyPlugin"));
}
Also used : PluginClassLoader(org.opengrok.indexer.framework.PluginClassLoader) Test(org.junit.jupiter.api.Test)

Example 5 with PluginClassLoader

use of org.opengrok.indexer.framework.PluginClassLoader in project OpenGrok by OpenGrok.

the class PluginClassLoaderTest method testNonExistingPlugin.

@Test
public void testNonExistingPlugin() {
    PluginClassLoader instance = new PluginClassLoader(pluginDirectory);
    loadClass(instance, "org.sample.plugin.NoPlugin", true);
}
Also used : PluginClassLoader(org.opengrok.indexer.framework.PluginClassLoader) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)5 PluginClassLoader (org.opengrok.indexer.framework.PluginClassLoader)5 Group (org.opengrok.indexer.configuration.Group)2 Project (org.opengrok.indexer.configuration.Project)2 DummyHttpServletRequest (org.opengrok.indexer.web.DummyHttpServletRequest)2