Search in sources :

Example 86 with Project

use of org.opengrok.indexer.configuration.Project in project OpenGrok by OpenGrok.

the class ProjectHelperTestBase method setUp.

@BeforeEach
public void setUp() {
    assertEquals(4, env.getGroups().size(), "Should contain 4 groups");
    assertEquals(40, env.getProjects().size(), "Should contain 40 project");
    assertEquals(20, env.getRepositories().size(), "Should contain 20 repositories");
    assertNotNull(env.getProjectRepositoriesMap(), "Repository map should not be null");
    assertEquals(20, env.getProjectRepositoriesMap().size(), "Repository map should contain 20 project");
    env.setAuthorizationFramework(new AuthorizationFramework());
    env.getAuthorizationFramework().reload();
    IAuthorizationPlugin plugin = new TestPlugin() {

        @Override
        public boolean isAllowed(HttpServletRequest request, Project project) {
            return project.getName().startsWith("allowed");
        }

        @Override
        public boolean isAllowed(HttpServletRequest request, Group group) {
            return group.getName().startsWith("allowed");
        }
    };
    invokeAddPlugin(plugin);
    cfg = PageConfig.get(getRequest());
    helper = cfg.getProjectHelper();
}
Also used : HttpServletRequest(jakarta.servlet.http.HttpServletRequest) DummyHttpServletRequest(org.opengrok.indexer.web.DummyHttpServletRequest) Project(org.opengrok.indexer.configuration.Project) Group(org.opengrok.indexer.configuration.Group) AuthorizationFramework(org.opengrok.indexer.authorization.AuthorizationFramework) IAuthorizationPlugin(org.opengrok.indexer.authorization.IAuthorizationPlugin) TestPlugin(org.opengrok.indexer.authorization.TestPlugin) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 87 with Project

use of org.opengrok.indexer.configuration.Project in project OpenGrok by OpenGrok.

the class ProjectHelperTestBase method createRepository.

protected static Project createRepository(int index, int number, int cnt, boolean grouped, boolean allowed, List<RepositoryInfo> rps, Map<String, Project> prjs, Map<Project, List<RepositoryInfo>> map) {
    Project p = createProject(index, number, grouped, allowed, true, rps, prjs, map);
    for (int i = 0; i < cnt; i++) {
        RepositoryInfo info = new RepoRepository();
        info.setParent(p.getName() + "_" + i);
        info.setDirectoryNameRelative(p.getPath());
        rps.add(info);
        List<RepositoryInfo> infos = map.get(p);
        if (infos == null) {
            infos = new ArrayList<>();
        }
        infos.add(info);
        map.put(p, infos);
    }
    return p;
}
Also used : Project(org.opengrok.indexer.configuration.Project) RepositoryInfo(org.opengrok.indexer.history.RepositoryInfo) RepoRepository(org.opengrok.indexer.history.RepoRepository)

Example 88 with Project

use of org.opengrok.indexer.configuration.Project in project OpenGrok by OpenGrok.

the class PageConfigRequestedProjectsTest method setUp.

@BeforeEach
public void setUp() {
    oldProjects = env.getProjects();
    oldGroups = env.getGroups();
    oldPluginStack = env.getPluginStack();
    Set<Group> groups = new TreeSet<>();
    Map<String, Project> projects = new TreeMap<>();
    for (int i = 0; i < 10; i++) {
        Project project = new Project();
        project.setName("project-" + i);
        project.setPath("/project-" + i);
        project.setIndexed(true);
        projects.put("project-" + i, project);
    }
    Group group;
    group = new Group();
    group.setName("group-1-2-3");
    group.setPattern("project-(1|2|3)");
    groups.add(group);
    group = new Group();
    group.setName("group-7-8-9");
    group.setPattern("project-(7|8|9)");
    groups.add(group);
    env.setGroups(groups);
    env.setProjects(projects);
    env.setProjectsEnabled(true);
    env.setPluginStack(null);
    env.applyConfig(false, CommandTimeoutType.INDEXER);
}
Also used : Group(org.opengrok.indexer.configuration.Group) Project(org.opengrok.indexer.configuration.Project) TreeSet(java.util.TreeSet) TreeMap(java.util.TreeMap) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

Project (org.opengrok.indexer.configuration.Project)88 Test (org.junit.jupiter.api.Test)42 RuntimeEnvironment (org.opengrok.indexer.configuration.RuntimeEnvironment)27 File (java.io.File)22 Group (org.opengrok.indexer.configuration.Group)20 RepositoryInfo (org.opengrok.indexer.history.RepositoryInfo)17 ArrayList (java.util.ArrayList)16 TreeSet (java.util.TreeSet)11 IOException (java.io.IOException)10 DummyHttpServletRequest (org.opengrok.indexer.web.DummyHttpServletRequest)10 List (java.util.List)8 HttpServletRequest (jakarta.servlet.http.HttpServletRequest)7 Path (jakarta.ws.rs.Path)7 HistoryGuru (org.opengrok.indexer.history.HistoryGuru)7 Path (java.nio.file.Path)6 Map (java.util.Map)6 Paths (java.nio.file.Paths)5 Set (java.util.Set)5 Collectors (java.util.stream.Collectors)5 MercurialRepositoryTest (org.opengrok.indexer.history.MercurialRepositoryTest)5