Search in sources :

Example 21 with ProjectAccessInfo

use of com.google.gerrit.extensions.api.access.ProjectAccessInfo in project gerrit by GerritCodeReview.

the class AccessIT method listAccessWithoutSpecifyingAnEmptyProjectName.

@Test
public void listAccessWithoutSpecifyingAnEmptyProjectName() throws Exception {
    RestResponse r = adminRestSession.get("/access/?p=");
    r.assertOK();
    Map<String, ProjectAccessInfo> infoByProject = newGson().fromJson(r.getReader(), new TypeToken<Map<String, ProjectAccessInfo>>() {
    }.getType());
    assertThat(infoByProject).isEmpty();
}
Also used : RestResponse(com.google.gerrit.acceptance.RestResponse) TypeToken(com.google.gson.reflect.TypeToken) ProjectAccessInfo(com.google.gerrit.extensions.api.access.ProjectAccessInfo) IdString(com.google.gerrit.extensions.restapi.IdString) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 22 with ProjectAccessInfo

use of com.google.gerrit.extensions.api.access.ProjectAccessInfo in project gerrit by GerritCodeReview.

the class AccessIT method listAccess.

@Test
public void listAccess() throws Exception {
    RestResponse r = adminRestSession.get("/access/?project=" + project.get());
    r.assertOK();
    Map<String, ProjectAccessInfo> infoByProject = newGson().fromJson(r.getReader(), new TypeToken<Map<String, ProjectAccessInfo>>() {
    }.getType());
    assertThat(infoByProject.keySet()).containsExactly(project.get());
}
Also used : RestResponse(com.google.gerrit.acceptance.RestResponse) TypeToken(com.google.gson.reflect.TypeToken) ProjectAccessInfo(com.google.gerrit.extensions.api.access.ProjectAccessInfo) IdString(com.google.gerrit.extensions.restapi.IdString) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 23 with ProjectAccessInfo

use of com.google.gerrit.extensions.api.access.ProjectAccessInfo in project gerrit by GerritCodeReview.

the class PluginAccessIT method setAccessAddPluginProjectPermissionSucceed.

@Test
public void setAccessAddPluginProjectPermissionSucceed() throws Exception {
    String pluginProjectPermission = "plugin-" + TEST_PLUGIN_NAME + "-" + TEST_PLUGIN_PROJECT_PERMISSION;
    String accessSection = "refs/heads/plugin-permission";
    ProjectAccessInput accessInput = createAccessInput(accessSection, pluginProjectPermission);
    ProjectAccessInfo projectAccessInfo = gApi.projects().name(allProjects.get()).access(accessInput);
    Set<String> permissions = projectAccessInfo.local.get(accessSection).permissions.keySet();
    assertThat(permissions).contains(pluginProjectPermission);
    // Verifies the plugin defined capability could be listed.
    assertThat(pluginPermissionsUtil.collectPluginProjectPermissions()).containsKey(pluginProjectPermission);
}
Also used : ProjectAccessInfo(com.google.gerrit.extensions.api.access.ProjectAccessInfo) ProjectAccessInput(com.google.gerrit.extensions.api.access.ProjectAccessInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Aggregations

ProjectAccessInfo (com.google.gerrit.extensions.api.access.ProjectAccessInfo)23 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)20 Test (org.junit.Test)20 AccessSectionInfo (com.google.gerrit.extensions.api.access.AccessSectionInfo)11 PermissionInfo (com.google.gerrit.extensions.api.access.PermissionInfo)9 ProjectAccessInput (com.google.gerrit.extensions.api.access.ProjectAccessInput)9 PermissionRuleInfo (com.google.gerrit.extensions.api.access.PermissionRuleInfo)7 IdString (com.google.gerrit.extensions.restapi.IdString)6 RestResponse (com.google.gerrit.acceptance.RestResponse)5 ProjectConfig (com.google.gerrit.server.project.ProjectConfig)5 TypeToken (com.google.gson.reflect.TypeToken)5 GroupReference (com.google.gerrit.entities.GroupReference)4 InMemoryRepository (org.eclipse.jgit.internal.storage.dfs.InMemoryRepository)4 Registration (com.google.gerrit.acceptance.ExtensionRegistry.Registration)3 ResourceNotFoundException (com.google.gerrit.extensions.restapi.ResourceNotFoundException)3 MetaDataUpdate (com.google.gerrit.server.git.meta.MetaDataUpdate)3 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)2 Project (com.google.gerrit.entities.Project)2 GroupInfo (com.google.gerrit.extensions.common.GroupInfo)2 AuthException (com.google.gerrit.extensions.restapi.AuthException)2