Search in sources :

Example 11 with PermissionRule

use of com.google.gerrit.common.data.PermissionRule in project gerrit by GerritCodeReview.

the class RefControlTest method unblockForceWithAllowNoForce_NotPossible.

@Test
public void unblockForceWithAllowNoForce_NotPossible() {
    PermissionRule r = block(local, PUSH, ANONYMOUS_USERS, "refs/heads/*");
    r.setForce(true);
    allow(local, PUSH, DEVS, "refs/heads/*");
    ProjectControl u = user(local, DEVS);
    assertCannotForceUpdate("refs/heads/master", u);
}
Also used : PermissionRule(com.google.gerrit.common.data.PermissionRule) Test(org.junit.Test)

Example 12 with PermissionRule

use of com.google.gerrit.common.data.PermissionRule in project gerrit by GerritCodeReview.

the class Util method newRule.

public static PermissionRule newRule(ProjectConfig project, AccountGroup.UUID groupUUID) {
    GroupReference group = new GroupReference(groupUUID, groupUUID.get());
    group = project.resolve(group);
    return new PermissionRule(group);
}
Also used : PermissionRule(com.google.gerrit.common.data.PermissionRule) GroupReference(com.google.gerrit.common.data.GroupReference)

Example 13 with PermissionRule

use of com.google.gerrit.common.data.PermissionRule in project gerrit by GerritCodeReview.

the class Util method allow.

public static PermissionRule allow(ProjectConfig project, String permissionName, int min, int max, AccountGroup.UUID group, String ref) {
    PermissionRule rule = newRule(project, group);
    rule.setMin(min);
    rule.setMax(max);
    return grant(project, permissionName, rule, ref);
}
Also used : PermissionRule(com.google.gerrit.common.data.PermissionRule)

Example 14 with PermissionRule

use of com.google.gerrit.common.data.PermissionRule in project gerrit by GerritCodeReview.

the class Util method block.

public static PermissionRule block(ProjectConfig project, String permissionName, int min, int max, AccountGroup.UUID group, String ref) {
    PermissionRule rule = newRule(project, group);
    rule.setMin(min);
    rule.setMax(max);
    PermissionRule r = grant(project, permissionName, rule, ref);
    r.setBlock();
    return r;
}
Also used : PermissionRule(com.google.gerrit.common.data.PermissionRule)

Example 15 with PermissionRule

use of com.google.gerrit.common.data.PermissionRule in project gerrit by GerritCodeReview.

the class Util method allow.

public static PermissionRule allow(ProjectConfig project, String capabilityName, AccountGroup.UUID group) {
    PermissionRule rule = newRule(project, group);
    project.getAccessSection(AccessSection.GLOBAL_CAPABILITIES, true).getPermission(capabilityName, true).add(rule);
    if (GlobalCapability.hasRange(capabilityName)) {
        PermissionRange.WithDefaults range = GlobalCapability.getRange(capabilityName);
        if (range != null) {
            rule.setRange(range.getDefaultMin(), range.getDefaultMax());
        }
    }
    return rule;
}
Also used : PermissionRange(com.google.gerrit.common.data.PermissionRange) PermissionRule(com.google.gerrit.common.data.PermissionRule)

Aggregations

PermissionRule (com.google.gerrit.common.data.PermissionRule)51 Permission (com.google.gerrit.common.data.Permission)18 AccessSection (com.google.gerrit.common.data.AccessSection)14 GroupReference (com.google.gerrit.common.data.GroupReference)11 ProjectConfig (com.google.gerrit.server.git.ProjectConfig)10 ArrayList (java.util.ArrayList)9 MetaDataUpdate (com.google.gerrit.server.git.MetaDataUpdate)8 ContributorAgreement (com.google.gerrit.common.data.ContributorAgreement)6 HashSet (java.util.HashSet)6 PermissionRange (com.google.gerrit.common.data.PermissionRange)5 AccountGroup (com.google.gerrit.reviewdb.client.AccountGroup)5 Project (com.google.gerrit.reviewdb.client.Project)4 HashMap (java.util.HashMap)4 Test (org.junit.Test)4 GroupDescription (com.google.gerrit.common.data.GroupDescription)3 ConfigInvalidException (org.eclipse.jgit.errors.ConfigInvalidException)3 NoSuchGroupException (com.google.gerrit.common.errors.NoSuchGroupException)2 AccessSectionInfo (com.google.gerrit.extensions.api.access.AccessSectionInfo)2 PermissionInfo (com.google.gerrit.extensions.api.access.PermissionInfo)2 PermissionRuleInfo (com.google.gerrit.extensions.api.access.PermissionRuleInfo)2