use of org.opengrok.indexer.configuration.Group in project OpenGrok by OpenGrok.
the class ProjectHelperExtendedTest method testHasAllowedSubgroupAllowedNoSubgroups.
@Test
public void testHasAllowedSubgroupAllowedNoSubgroups() {
Group g = getAllowedGroupWithoutSubgroups();
assertFalse(helper.hasAllowedSubgroup(g));
}
use of org.opengrok.indexer.configuration.Group in project OpenGrok by OpenGrok.
the class ProjectHelperExtendedTest method testGetAllowedGroupSubgroups.
@Test
public void testGetAllowedGroupSubgroups() {
Set<Group> result = helper.getSubgroups(getAllowedGroupWithSubgroups());
assertEquals(1, result.size());
for (Group p : result) {
assertTrue(p.getName().startsWith("allowed_"));
}
}
use of org.opengrok.indexer.configuration.Group in project OpenGrok by OpenGrok.
the class ProjectHelperExtendedTest method testHasAllowedSubgroupUnAllowedNoSubgroups.
@Test
public void testHasAllowedSubgroupUnAllowedNoSubgroups() {
Group g = getUnAllowedGroupWithoutSubgroups();
assertFalse(helper.hasAllowedSubgroup(g));
}
use of org.opengrok.indexer.configuration.Group 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.configuration.Group in project OpenGrok by OpenGrok.
the class ProjectsControllerTest method testAdd.
/**
* Verify that added project correctly inherits a property
* from configuration. Ideally, this should test all properties of Project.
*/
@Test
void testAdd() throws Exception {
assertTrue(env.getRepositories().isEmpty());
assertTrue(env.getProjects().isEmpty());
// Add a group matching the project to be added.
String groupName = "mercurialgroup";
Group group = new Group(groupName, "mercurial.*");
env.getGroups().add(group);
assertTrue(env.hasGroups());
assertEquals(1, env.getGroups().stream().filter(g -> g.getName().equals(groupName)).collect(Collectors.toSet()).size());
assertEquals(0, group.getRepositories().size());
assertEquals(0, group.getProjects().size());
// Add a sub-repository.
String repoPath = repository.getSourceRoot() + File.separator + "mercurial";
File mercurialRoot = new File(repoPath);
File subDir = new File(mercurialRoot, "usr");
assertTrue(subDir.mkdir());
String subRepoPath = repoPath + File.separator + "usr" + File.separator + "closed";
File mercurialSubRoot = new File(subRepoPath);
MercurialRepositoryTest.runHgCommand(mercurialRoot, "clone", mercurialRoot.getAbsolutePath(), subRepoPath);
// Add the project.
env.setScanningDepth(3);
addProject("mercurial");
// Check that the project was added properly.
assertTrue(env.getProjects().containsKey("mercurial"));
assertEquals(1, env.getProjects().size());
assertEquals(2, env.getRepositories().size());
assertEquals(1, group.getRepositories().size());
assertEquals(0, group.getProjects().size());
assertEquals(1, group.getRepositories().stream().filter(p -> p.getName().equals("mercurial")).collect(Collectors.toSet()).size());
// Check that HistoryGuru now includes the project in its list.
Set<String> directoryNames = HistoryGuru.getInstance().getRepositories().stream().map(RepositoryInfo::getDirectoryName).collect(Collectors.toSet());
assertTrue(directoryNames.contains(repoPath) || directoryNames.contains(mercurialRoot.getCanonicalPath()), "though it should contain the top root,");
assertTrue(directoryNames.contains(subRepoPath) || directoryNames.contains(mercurialSubRoot.getCanonicalPath()), "though it should contain the sub-root,");
// Add more projects and check that they have been added incrementally.
// At the same time, it checks that multiple projects can be added
// with single message.
addProject("git");
assertEquals(2, env.getProjects().size());
assertEquals(3, env.getRepositories().size());
assertTrue(env.getProjects().containsKey("git"));
assertFalse(HistoryGuru.getInstance().getRepositories().stream().map(RepositoryInfo::getDirectoryName).collect(Collectors.toSet()).contains("git"));
}
Aggregations