Search in sources :

Example 11 with ProjectAccessInput

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

the class AccessIT method addAccessSection.

@Test
public void addAccessSection() throws Exception {
    Project.NameKey p = new Project.NameKey(newProjectName);
    RevCommit initialHead = getRemoteHead(p, RefNames.REFS_CONFIG);
    ProjectAccessInput accessInput = newProjectAccessInput();
    AccessSectionInfo accessSectionInfo = createDefaultAccessSectionInfo();
    accessInput.add.put(REFS_HEADS, accessSectionInfo);
    pApi.access(accessInput);
    assertThat(pApi.access().local).isEqualTo(accessInput.add);
    RevCommit updatedHead = getRemoteHead(p, RefNames.REFS_CONFIG);
    eventRecorder.assertRefUpdatedEvents(p.get(), RefNames.REFS_CONFIG, null, initialHead, initialHead, updatedHead);
}
Also used : Project(com.google.gerrit.reviewdb.client.Project) AccessSectionInfo(com.google.gerrit.extensions.api.access.AccessSectionInfo) ProjectAccessInput(com.google.gerrit.extensions.api.access.ProjectAccessInput) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 12 with ProjectAccessInput

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

the class AccessIT method updateParentAsUser.

@Test
public void updateParentAsUser() throws Exception {
    // Create child
    String newParentProjectName = createProject(PROJECT_NAME + "PA").get();
    // Set new parent
    ProjectAccessInput accessInput = newProjectAccessInput();
    accessInput.parent = newParentProjectName;
    setApiUser(user);
    exception.expect(AuthException.class);
    exception.expectMessage("administrate server not permitted");
    gApi.projects().name(newProjectName).access(accessInput);
}
Also used : ProjectAccessInput(com.google.gerrit.extensions.api.access.ProjectAccessInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 13 with ProjectAccessInput

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

the class AccessIT method addGlobalCapabilityAsUser.

@Test
public void addGlobalCapabilityAsUser() throws Exception {
    ProjectAccessInput accessInput = newProjectAccessInput();
    AccessSectionInfo accessSectionInfo = createDefaultGlobalCapabilitiesAccessSectionInfo();
    accessInput.add.put(AccessSection.GLOBAL_CAPABILITIES, accessSectionInfo);
    setApiUser(user);
    exception.expect(AuthException.class);
    gApi.projects().name(allProjects.get()).access(accessInput);
}
Also used : AccessSectionInfo(com.google.gerrit.extensions.api.access.AccessSectionInfo) ProjectAccessInput(com.google.gerrit.extensions.api.access.ProjectAccessInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 14 with ProjectAccessInput

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

the class AccessIT method removeGlobalCapabilityAsUser.

@Test
public void removeGlobalCapabilityAsUser() throws Exception {
    ProjectAccessInput accessInput = newProjectAccessInput();
    AccessSectionInfo accessSectionInfo = createDefaultGlobalCapabilitiesAccessSectionInfo();
    accessInput.remove.put(AccessSection.GLOBAL_CAPABILITIES, accessSectionInfo);
    setApiUser(user);
    exception.expect(AuthException.class);
    gApi.projects().name(allProjects.get()).access(accessInput);
}
Also used : AccessSectionInfo(com.google.gerrit.extensions.api.access.AccessSectionInfo) ProjectAccessInput(com.google.gerrit.extensions.api.access.ProjectAccessInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 15 with ProjectAccessInput

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

the class AccessIT method removeGlobalCapabilityAsAdmin.

@Test
public void removeGlobalCapabilityAsAdmin() throws Exception {
    AccountGroup adminGroup = groupCache.get(new AccountGroup.NameKey("Administrators"));
    ProjectAccessInput accessInput = newProjectAccessInput();
    AccessSectionInfo accessSectionInfo = newAccessSectionInfo();
    PermissionInfo permissionInfo = newPermissionInfo();
    permissionInfo.rules.put(adminGroup.getGroupUUID().get(), null);
    accessSectionInfo.permissions.put(GlobalCapability.ACCESS_DATABASE, permissionInfo);
    // Add and validate first as removing existing privileges such as
    // administrateServer would break upcoming tests
    accessInput.add.put(AccessSection.GLOBAL_CAPABILITIES, accessSectionInfo);
    ProjectAccessInfo updatedProjectAccessInfo = gApi.projects().name(allProjects.get()).access(accessInput);
    assertThat(updatedProjectAccessInfo.local.get(AccessSection.GLOBAL_CAPABILITIES).permissions.keySet()).containsAllIn(accessSectionInfo.permissions.keySet());
    // Remove
    accessInput.add.clear();
    accessInput.remove.put(AccessSection.GLOBAL_CAPABILITIES, accessSectionInfo);
    updatedProjectAccessInfo = gApi.projects().name(allProjects.get()).access(accessInput);
    assertThat(updatedProjectAccessInfo.local.get(AccessSection.GLOBAL_CAPABILITIES).permissions.keySet()).containsNoneIn(accessSectionInfo.permissions.keySet());
}
Also used : AccountGroup(com.google.gerrit.reviewdb.client.AccountGroup) PermissionInfo(com.google.gerrit.extensions.api.access.PermissionInfo) ProjectAccessInfo(com.google.gerrit.extensions.api.access.ProjectAccessInfo) AccessSectionInfo(com.google.gerrit.extensions.api.access.AccessSectionInfo) ProjectAccessInput(com.google.gerrit.extensions.api.access.ProjectAccessInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Aggregations

ProjectAccessInput (com.google.gerrit.extensions.api.access.ProjectAccessInput)16 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)15 Test (org.junit.Test)15 AccessSectionInfo (com.google.gerrit.extensions.api.access.AccessSectionInfo)13 PermissionInfo (com.google.gerrit.extensions.api.access.PermissionInfo)4 PermissionRuleInfo (com.google.gerrit.extensions.api.access.PermissionRuleInfo)2 ProjectAccessInfo (com.google.gerrit.extensions.api.access.ProjectAccessInfo)2 AccountGroup (com.google.gerrit.reviewdb.client.AccountGroup)2 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)1 Project (com.google.gerrit.reviewdb.client.Project)1 InMemoryRepository (org.eclipse.jgit.internal.storage.dfs.InMemoryRepository)1 Config (org.eclipse.jgit.lib.Config)1 RevCommit (org.eclipse.jgit.revwalk.RevCommit)1