Search in sources :

Example 1 with AccessSectionInfo

use of com.google.gerrit.extensions.api.access.AccessSectionInfo 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 AccessSectionInfo

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

the class AccessIT method createDefaultAccessSectionInfo.

private AccessSectionInfo createDefaultAccessSectionInfo() {
    AccessSectionInfo accessSection = newAccessSectionInfo();
    PermissionInfo push = newPermissionInfo();
    PermissionRuleInfo pri = new PermissionRuleInfo(PermissionRuleInfo.Action.ALLOW, false);
    push.rules.put(SystemGroupBackend.REGISTERED_USERS.get(), pri);
    accessSection.permissions.put(Permission.PUSH, push);
    PermissionInfo codeReview = newPermissionInfo();
    codeReview.label = LABEL_CODE_REVIEW;
    pri = new PermissionRuleInfo(PermissionRuleInfo.Action.DENY, false);
    codeReview.rules.put(SystemGroupBackend.REGISTERED_USERS.get(), pri);
    pri = new PermissionRuleInfo(PermissionRuleInfo.Action.ALLOW, false);
    pri.max = 1;
    pri.min = -1;
    codeReview.rules.put(SystemGroupBackend.PROJECT_OWNERS.get(), pri);
    accessSection.permissions.put(Permission.LABEL + LABEL_CODE_REVIEW, codeReview);
    return accessSection;
}
Also used : PermissionInfo(com.google.gerrit.extensions.api.access.PermissionInfo) PermissionRuleInfo(com.google.gerrit.extensions.api.access.PermissionRuleInfo) AccessSectionInfo(com.google.gerrit.extensions.api.access.AccessSectionInfo)

Example 3 with AccessSectionInfo

use of com.google.gerrit.extensions.api.access.AccessSectionInfo 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 4 with AccessSectionInfo

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

the class AccessIT method createAccessSectionInfoDenyAll.

private AccessSectionInfo createAccessSectionInfoDenyAll() {
    AccessSectionInfo accessSection = newAccessSectionInfo();
    PermissionInfo read = newPermissionInfo();
    PermissionRuleInfo pri = new PermissionRuleInfo(PermissionRuleInfo.Action.DENY, false);
    read.rules.put(SystemGroupBackend.ANONYMOUS_USERS.get(), pri);
    accessSection.permissions.put(Permission.READ, read);
    return accessSection;
}
Also used : PermissionInfo(com.google.gerrit.extensions.api.access.PermissionInfo) PermissionRuleInfo(com.google.gerrit.extensions.api.access.PermissionRuleInfo) AccessSectionInfo(com.google.gerrit.extensions.api.access.AccessSectionInfo)

Example 5 with AccessSectionInfo

use of com.google.gerrit.extensions.api.access.AccessSectionInfo 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)

Aggregations

AccessSectionInfo (com.google.gerrit.extensions.api.access.AccessSectionInfo)19 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)13 ProjectAccessInput (com.google.gerrit.extensions.api.access.ProjectAccessInput)13 Test (org.junit.Test)13 PermissionInfo (com.google.gerrit.extensions.api.access.PermissionInfo)9 PermissionRuleInfo (com.google.gerrit.extensions.api.access.PermissionRuleInfo)7 AccountGroup (com.google.gerrit.reviewdb.client.AccountGroup)3 Permission (com.google.gerrit.common.data.Permission)2 PermissionRule (com.google.gerrit.common.data.PermissionRule)2 ProjectAccessInfo (com.google.gerrit.extensions.api.access.ProjectAccessInfo)2 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)1 AccessSection (com.google.gerrit.common.data.AccessSection)1 GroupDescription (com.google.gerrit.common.data.GroupDescription)1 UnprocessableEntityException (com.google.gerrit.extensions.restapi.UnprocessableEntityException)1 Project (com.google.gerrit.reviewdb.client.Project)1 GlobalPermission (com.google.gerrit.server.permissions.GlobalPermission)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 InMemoryRepository (org.eclipse.jgit.internal.storage.dfs.InMemoryRepository)1 Config (org.eclipse.jgit.lib.Config)1