use of org.opengrok.indexer.configuration.Project in project OpenGrok by OpenGrok.
the class ProjectsControllerTest method testIndexed.
@Test
void testIndexed() throws IOException {
String projectName = "mercurial";
// When a project is added, it should be marked as not indexed.
addProject(projectName);
assertFalse(env.getProjects().get(projectName).isIndexed());
// Get repository info for the project.
Project project = env.getProjects().get(projectName);
assertNotNull(project);
List<RepositoryInfo> riList = env.getProjectRepositoriesMap().get(project);
assertNotNull(riList);
assertEquals(1, riList.size(), "there should be just 1 repository");
RepositoryInfo ri = riList.get(0);
assertNotNull(ri);
assertTrue(ri.getCurrentVersion().contains("8b340409b3a8"));
// Add some changes to the repository.
File mercurialRoot = new File(repository.getSourceRoot() + File.separator + "mercurial");
// copy file from jar to a temp file
Path temp = Files.createTempFile("opengrok", "temp");
Files.copy(HistoryGuru.getInstance().getClass().getResourceAsStream("/history/hg-export-subdir.txt"), temp, StandardCopyOption.REPLACE_EXISTING);
// prevent 'uncommitted changes' error
MercurialRepositoryTest.runHgCommand(mercurialRoot, "revert", "--all");
MercurialRepositoryTest.runHgCommand(mercurialRoot, "import", temp.toString());
assertTrue(temp.toFile().delete());
// Test that the project's indexed flag becomes true only after
// the message is applied.
assertEquals(markIndexed(projectName).getStatusInfo().getFamily(), Response.Status.Family.SUCCESSFUL);
assertTrue(env.getProjects().get(projectName).isIndexed(), "indexed flag should be set to true");
// Test that the "indexed" message triggers refresh of current version
// info in related repositories.
riList = env.getProjectRepositoriesMap().get(project);
assertNotNull(riList);
ri = riList.get(0);
assertNotNull(ri);
assertTrue(ri.getCurrentVersion().contains("c78fa757c524"), "current version should be refreshed");
}
use of org.opengrok.indexer.configuration.Project 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.configuration.Project in project OpenGrok by OpenGrok.
the class UserPluginTest method testUser.
@Test
public void testUser() {
HttpServletRequest req;
assertTrue(plugin.isAllowed(req = createRequest("007"), new Group()));
assertEquals("007", ((User) req.getAttribute(UserPlugin.REQUEST_ATTR)).getUsername());
assertTrue(plugin.isAllowed(req = createRequest("008"), new Project()));
assertEquals("008", ((User) req.getAttribute(UserPlugin.REQUEST_ATTR)).getUsername());
assertTrue(plugin.isAllowed(req = createRequest("009"), createGroup("some group")));
assertEquals("009", ((User) req.getAttribute(UserPlugin.REQUEST_ATTR)).getUsername());
assertTrue(plugin.isAllowed(req = createRequest("00A"), createProject("some project")));
assertEquals("00A", ((User) req.getAttribute(UserPlugin.REQUEST_ATTR)).getUsername());
}
use of org.opengrok.indexer.configuration.Project in project OpenGrok by OpenGrok.
the class UserPluginTest method createProject.
protected Project createProject(String name) {
Project g = new Project();
g.setName(name);
return g;
}
use of org.opengrok.indexer.configuration.Project in project OpenGrok by OpenGrok.
the class LdapAttrPluginTest method makeProject.
private Project makeProject(String name) {
Project p = new Project();
p.setName(name);
return p;
}
Aggregations