Search in sources :

Example 1 with ProjectAccessInput

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

the class AccessIT method addGlobalCapabilityForNonRootProject.

@Test
public void addGlobalCapabilityForNonRootProject() throws Exception {
    ProjectAccessInput accessInput = newProjectAccessInput();
    AccessSectionInfo accessSectionInfo = createDefaultGlobalCapabilitiesAccessSectionInfo();
    accessInput.add.put(AccessSection.GLOBAL_CAPABILITIES, accessSectionInfo);
    exception.expect(BadRequestException.class);
    pApi.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 2 with ProjectAccessInput

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

the class AccessIT method setPermissionsWithDisallowedUser.

@Test
public void setPermissionsWithDisallowedUser() throws Exception {
    // Add initial permission set
    ProjectAccessInput accessInput = newProjectAccessInput();
    AccessSectionInfo accessSectionInfo = createAccessSectionInfoDenyAll();
    // Disallow READ
    accessInput.add.put(REFS_ALL, accessSectionInfo);
    pApi.access(accessInput);
    // Create a change to apply
    ProjectAccessInput accessInfoToApply = newProjectAccessInput();
    AccessSectionInfo accessSectionInfoToApply = createDefaultAccessSectionInfo();
    accessInfoToApply.add.put(REFS_HEADS, accessSectionInfoToApply);
    setApiUser(user);
    exception.expect(ResourceNotFoundException.class);
    gApi.projects().name(newProjectName).access();
}
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 3 with ProjectAccessInput

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

the class AccessIT method getPermissionsWithDisallowedUser.

@Test
public void getPermissionsWithDisallowedUser() throws Exception {
    // Add initial permission set
    ProjectAccessInput accessInput = newProjectAccessInput();
    AccessSectionInfo accessSectionInfo = createAccessSectionInfoDenyAll();
    // Disallow READ
    accessInput.add.put(REFS_ALL, accessSectionInfo);
    pApi.access(accessInput);
    setApiUser(user);
    exception.expect(ResourceNotFoundException.class);
    gApi.projects().name(newProjectName).access();
}
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 4 with ProjectAccessInput

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

the class AccessIT method newProjectAccessInput.

private ProjectAccessInput newProjectAccessInput() {
    ProjectAccessInput p = new ProjectAccessInput();
    p.add = new HashMap<>();
    p.remove = new HashMap<>();
    return p;
}
Also used : ProjectAccessInput(com.google.gerrit.extensions.api.access.ProjectAccessInput)

Example 5 with ProjectAccessInput

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

the class AccessIT method addGlobalCapabilityAsAdmin.

@Test
public void addGlobalCapabilityAsAdmin() throws Exception {
    ProjectAccessInput accessInput = newProjectAccessInput();
    AccessSectionInfo accessSectionInfo = createDefaultGlobalCapabilitiesAccessSectionInfo();
    accessInput.add.put(AccessSection.GLOBAL_CAPABILITIES, accessSectionInfo);
    ProjectAccessInfo updatedAccessSectionInfo = gApi.projects().name(allProjects.get()).access(accessInput);
    assertThat(updatedAccessSectionInfo.local.get(AccessSection.GLOBAL_CAPABILITIES).permissions.keySet()).containsAllIn(accessSectionInfo.permissions.keySet());
}
Also used : 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