Search in sources :

Example 1 with IAuthorizationPlugin

use of org.opengrok.indexer.authorization.IAuthorizationPlugin 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)

Aggregations

HttpServletRequest (jakarta.servlet.http.HttpServletRequest)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 AuthorizationFramework (org.opengrok.indexer.authorization.AuthorizationFramework)1 IAuthorizationPlugin (org.opengrok.indexer.authorization.IAuthorizationPlugin)1 TestPlugin (org.opengrok.indexer.authorization.TestPlugin)1 Group (org.opengrok.indexer.configuration.Group)1 Project (org.opengrok.indexer.configuration.Project)1 DummyHttpServletRequest (org.opengrok.indexer.web.DummyHttpServletRequest)1