use of org.opengrok.indexer.configuration.Project in project OpenGrok by OpenGrok.
the class UserWhiteListPluginTest method shouldAllowWhitelistedUserForAnyProject.
@ParameterizedTest
@MethodSource("parameters")
public void shouldAllowWhitelistedUserForAnyProject(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);
Project randomProject = new Project(RandomStringUtils.randomAlphanumeric(10));
boolean projectAllowed = plugin.isAllowed(req, randomProject);
assertTrue(projectAllowed, "should allow OK entity for random project 1");
randomProject = new Project(RandomStringUtils.randomAlphanumeric(10));
projectAllowed = plugin.isAllowed(req, randomProject);
assertTrue(projectAllowed, "should allow OK entity for random project 2");
}
use of org.opengrok.indexer.configuration.Project in project OpenGrok by OpenGrok.
the class IndexerTest method testDefaultProjectsSingleProject.
/**
* Should include the existing project.
* @throws Exception
*/
@Test
void testDefaultProjectsSingleProject() throws Exception {
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
env.setSourceRoot(repository.getSourceRoot());
env.setDataRoot(repository.getDataRoot());
env.setHistoryEnabled(false);
Indexer.getInstance().prepareIndexer(env, true, true, false, null, null);
env.setDefaultProjectsFromNames(new TreeSet<>(Collections.singletonList("/c")));
assertEquals(1, env.getDefaultProjects().size());
assertEquals(new TreeSet<>(Collections.singletonList("c")), env.getDefaultProjects().stream().map(Project::getName).collect(Collectors.toSet()));
}
use of org.opengrok.indexer.configuration.Project in project OpenGrok by OpenGrok.
the class IndexerTest method testBug11896.
/**
* Test that named pipes are not indexed.
* @throws Exception
*/
@Test
@EnabledIf("mkfifoInPath")
void testBug11896() throws Exception {
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
env.setSourceRoot(repository.getSourceRoot());
env.setDataRoot(repository.getDataRoot());
Executor executor;
executor = new Executor(new String[] { "mkdir", "-p", repository.getSourceRoot() + "/testBug11896" });
executor.exec(true);
executor = new Executor(new String[] { "mkfifo", repository.getSourceRoot() + "/testBug11896/FIFO" });
executor.exec(true);
Project project = new Project("testBug11896");
project.setPath("/testBug11896");
IndexDatabase idb = new IndexDatabase(project);
assertNotNull(idb);
MyIndexChangeListener listener = new MyIndexChangeListener();
idb.addIndexChangedListener(listener);
System.out.println("Trying to index a special file - FIFO in this case.");
idb.update();
assertEquals(0, listener.files.size());
}
use of org.opengrok.indexer.configuration.Project in project OpenGrok by OpenGrok.
the class IndexerTest method testBug3430.
@Test
void testBug3430() throws Exception {
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
env.setSourceRoot(repository.getSourceRoot());
env.setDataRoot(repository.getDataRoot());
Project project = new Project("bug3430");
project.setPath("/bug3430");
IndexDatabase idb = new IndexDatabase(project);
assertNotNull(idb);
MyIndexChangeListener listener = new MyIndexChangeListener();
idb.addIndexChangedListener(listener);
idb.update();
assertEquals(1, listener.files.size());
}
use of org.opengrok.indexer.configuration.Project in project OpenGrok by OpenGrok.
the class IndexerRepoTest method testPerProjectHistory.
private void testPerProjectHistory(boolean globalOn) throws IndexerException, IOException, HistoryException {
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
// Make sure we start from scratch.
Path dataRoot = Files.createTempDirectory("dataForPerProjectHistoryTest");
env.setDataRoot(dataRoot.toString());
env.setProjectsEnabled(true);
env.setHistoryEnabled(globalOn);
Project proj = new Project("mercurial", "/mercurial");
proj.setHistoryEnabled(!globalOn);
env.getProjects().clear();
env.getProjects().put("mercurial", proj);
Indexer.getInstance().prepareIndexer(env, // search for repositories
true, // scan and add projects
true, // don't create dictionary
false, // subFiles - not needed since we don't list files
null, // repositories - not needed when not refreshing history
null);
File repoRoot = new File(env.getSourceRootFile(), "git");
File fileInRepo = new File(repoRoot, "main.c");
assertTrue(fileInRepo.exists());
if (globalOn) {
assertNotNull(HistoryGuru.getInstance().getHistory(fileInRepo));
} else {
assertNull(HistoryGuru.getInstance().getHistory(fileInRepo));
}
repoRoot = new File(env.getSourceRootFile(), "mercurial");
fileInRepo = new File(repoRoot, "main.c");
assertTrue(fileInRepo.exists());
if (globalOn) {
assertNull(HistoryGuru.getInstance().getHistory(fileInRepo));
} else {
assertNotNull(HistoryGuru.getInstance().getHistory(fileInRepo));
}
IOUtils.removeRecursive(dataRoot);
}
Aggregations