use of org.opengrok.indexer.web.DummyHttpServletRequest 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));
}
use of org.opengrok.indexer.web.DummyHttpServletRequest in project OpenGrok by OpenGrok.
the class FalsePluginTest method shouldNotAllowRandomUserForAnyProject.
@Test
void shouldNotAllowRandomUserForAnyProject() {
DummyHttpServletRequest req = new DummyHttpServletRequest();
req.setAttribute(UserPlugin.REQUEST_ATTR, new User(RandomStringUtils.randomAlphanumeric(8)));
Project randomProject = new Project(RandomStringUtils.randomAlphanumeric(10));
boolean projectAllowed = plugin.isAllowed(req, randomProject);
assertFalse(projectAllowed, "should not allow rando for random project 1");
randomProject = new Project(RandomStringUtils.randomAlphanumeric(10));
projectAllowed = plugin.isAllowed(req, randomProject);
assertFalse(projectAllowed, "should not allow rando for random project 2");
}
use of org.opengrok.indexer.web.DummyHttpServletRequest in project OpenGrok by OpenGrok.
the class FalsePluginTest method shouldNotAllowRandomUserForAnyGroup.
@Test
void shouldNotAllowRandomUserForAnyGroup() {
DummyHttpServletRequest req = new DummyHttpServletRequest();
req.setAttribute(UserPlugin.REQUEST_ATTR, new User(RandomStringUtils.randomAlphanumeric(8)));
Group randomGroup = new Group(RandomStringUtils.randomAlphanumeric(10));
boolean projectAllowed = plugin.isAllowed(req, randomGroup);
assertFalse(projectAllowed, "should not allow rando for random group 1");
randomGroup = new Group(RandomStringUtils.randomAlphanumeric(10));
projectAllowed = plugin.isAllowed(req, randomGroup);
assertFalse(projectAllowed, "should not allow rando for random group 2");
}
use of org.opengrok.indexer.web.DummyHttpServletRequest in project OpenGrok by OpenGrok.
the class UserWhiteListPluginTest method shouldNotAllowRandomUserForAnyGroup.
@ParameterizedTest
@MethodSource("parameters")
public void shouldNotAllowRandomUserForAnyGroup(String param) {
init(param);
plugin.load(validPluginParameters);
DummyHttpServletRequest req = new DummyHttpServletRequest();
req.setAttribute(UserPlugin.REQUEST_ATTR, new User(RandomStringUtils.randomAlphanumeric(8)));
Group randomGroup = new Group(RandomStringUtils.randomAlphanumeric(10));
boolean projectAllowed = plugin.isAllowed(req, randomGroup);
assertFalse(projectAllowed, "should not allow random group 1");
randomGroup = new Group(RandomStringUtils.randomAlphanumeric(10));
projectAllowed = plugin.isAllowed(req, randomGroup);
assertFalse(projectAllowed, "should not allow random group 2");
}
use of org.opengrok.indexer.web.DummyHttpServletRequest in project OpenGrok by OpenGrok.
the class UserWhiteListPluginTest method shouldAllowWhitelistedUserForAnyGroup.
@ParameterizedTest
@MethodSource("parameters")
public void shouldAllowWhitelistedUserForAnyGroup(String param) {
init(param);
plugin.load(validPluginParameters);
DummyHttpServletRequest req = new DummyHttpServletRequest();
User user;
if (param.equals(UserWhiteListPlugin.USERNAME_FIELD)) {
user = new User(OK_USER);
} else {
user = new User("blurb", OK_ID);
}
req.setAttribute(UserPlugin.REQUEST_ATTR, user);
Group randomGroup = new Group(RandomStringUtils.randomAlphanumeric(10));
boolean groupAllowed = plugin.isAllowed(req, randomGroup);
assertTrue(groupAllowed, "should allow OK entity for random group 1");
randomGroup = new Group(RandomStringUtils.randomAlphanumeric(10));
groupAllowed = plugin.isAllowed(req, randomGroup);
assertTrue(groupAllowed, "should allow OK entity for random group 2");
}
Aggregations