use of org.opengrok.indexer.web.DummyHttpServletRequest in project OpenGrok by OpenGrok.
the class ProjectHelperExtendedTest method setupPageConfigRequest.
private void setupPageConfigRequest(final String cookie) {
cfg = PageConfig.get(new DummyHttpServletRequest() {
@Override
public Cookie[] getCookies() {
Cookie[] ret = new Cookie[1];
ret[0] = new Cookie("OpenGrokProject", cookie);
return ret;
}
});
helper = cfg.getProjectHelper();
}
use of org.opengrok.indexer.web.DummyHttpServletRequest in project OpenGrok by OpenGrok.
the class PageConfigTest method testCheckSourceRootExistence5.
/**
* Test a successful check.
* @throws IOException I/O exception
*/
@Test
public void testCheckSourceRootExistence5() throws IOException {
HttpServletRequest req = new DummyHttpServletRequest();
PageConfig cfg = PageConfig.get(req);
String path = RuntimeEnvironment.getInstance().getSourceRootPath();
File temp = File.createTempFile("opengrok", "-test-file.tmp");
temp.delete();
temp.mkdirs();
RuntimeEnvironment.getInstance().setSourceRoot(temp.getAbsolutePath());
cfg.checkSourceRootExistence();
RuntimeEnvironment.getInstance().setSourceRoot(path);
temp.deleteOnExit();
PageConfig.cleanup(req);
}
use of org.opengrok.indexer.web.DummyHttpServletRequest in project OpenGrok by OpenGrok.
the class PageConfigTest method testGetRequestedRevision.
@Test
public void testGetRequestedRevision() {
final String[] revisions = { "6c5588de", "", "6c5588de", "6c5588de", "6c5588de" };
for (int i = 0; i < revisions.length; i++) {
final int index = i;
DummyHttpServletRequest req = new DummyHttpServletRequest() {
@Override
public String getParameter(String name) {
if (name.equals("r")) {
return revisions[index];
}
return null;
}
};
PageConfig cfg = PageConfig.get(req);
String rev = cfg.getRequestedRevision();
assertNotNull(rev);
assertEquals(revisions[i], rev);
assertFalse(rev.contains("r="));
PageConfig.cleanup(req);
}
}
use of org.opengrok.indexer.web.DummyHttpServletRequest in project OpenGrok by OpenGrok.
the class PageConfigTest method testGetLatestRevisionValid.
@Test
public void testGetLatestRevisionValid() {
DummyHttpServletRequest req1 = new DummyHttpServletRequest() {
@Override
public String getPathInfo() {
return "/git/main.c";
}
};
PageConfig cfg = PageConfig.get(req1);
String rev = cfg.getLatestRevision();
assertEquals("aa35c258", rev);
}
use of org.opengrok.indexer.web.DummyHttpServletRequest 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));
}
Aggregations