Search in sources :

Example 11 with PermissionRange

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

the class RefControlTest method blockLabelRange_ParentBlocksChildEvenIfAlreadyBlockedInChild.

@Test
public void blockLabelRange_ParentBlocksChildEvenIfAlreadyBlockedInChild() {
    allow(local, LABEL + "Code-Review", -2, +2, DEVS, "refs/heads/*");
    block(local, LABEL + "Code-Review", -2, +2, DEVS, "refs/heads/*");
    block(parent, LABEL + "Code-Review", -2, +2, DEVS, "refs/heads/*");
    ProjectControl u = user(local, DEVS);
    PermissionRange range = u.controlForRef("refs/heads/master").getRange(LABEL + "Code-Review");
    assertCanVote(-1, range);
    assertCanVote(1, range);
    assertCannotVote(-2, range);
    assertCannotVote(2, range);
}
Also used : PermissionRange(com.google.gerrit.common.data.PermissionRange) Test(org.junit.Test)

Example 12 with PermissionRange

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

the class RefControlTest method unblockInLocalRange_Fails.

@Test
public void unblockInLocalRange_Fails() {
    block(parent, LABEL + "Code-Review", -1, 1, ANONYMOUS_USERS, "refs/heads/*");
    allow(local, LABEL + "Code-Review", -2, +2, DEVS, "refs/heads/*");
    ProjectControl u = user(local, DEVS);
    PermissionRange range = u.controlForRef("refs/heads/master").getRange(LABEL + "Code-Review");
    assertCannotVote(-2, range);
    assertCannotVote(2, range);
}
Also used : PermissionRange(com.google.gerrit.common.data.PermissionRange) Test(org.junit.Test)

Example 13 with PermissionRange

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

the class RefControlTest method unblockRangeForNotChangeOwner.

@Test
public void unblockRangeForNotChangeOwner() {
    allow(local, LABEL + "Code-Review", -2, +2, CHANGE_OWNER, "refs/heads/*");
    ProjectControl u = user(local, DEVS);
    PermissionRange range = u.controlForRef("refs/heads/master").getRange(LABEL + "Code-Review");
    assertCannotVote(-2, range);
    assertCannotVote(2, range);
}
Also used : PermissionRange(com.google.gerrit.common.data.PermissionRange) Test(org.junit.Test)

Example 14 with PermissionRange

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

the class RefControlTest method unblockRangeOnLargerScope_Fails.

@Test
public void unblockRangeOnLargerScope_Fails() {
    block(local, LABEL + "Code-Review", -1, +1, ANONYMOUS_USERS, "refs/heads/master");
    allow(local, LABEL + "Code-Review", -2, +2, DEVS, "refs/heads/*");
    ProjectControl u = user(local, DEVS);
    PermissionRange range = u.controlForRef("refs/heads/master").getRange(LABEL + "Code-Review");
    assertCannotVote(-2, range);
    assertCannotVote(2, range);
}
Also used : PermissionRange(com.google.gerrit.common.data.PermissionRange) Test(org.junit.Test)

Aggregations

PermissionRange (com.google.gerrit.common.data.PermissionRange)14 Test (org.junit.Test)8 PermissionRule (com.google.gerrit.common.data.PermissionRule)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 LabelType (com.google.gerrit.common.data.LabelType)1 LabelTypes (com.google.gerrit.common.data.LabelTypes)1 SubmitRecord (com.google.gerrit.common.data.SubmitRecord)1 AuthException (com.google.gerrit.extensions.restapi.AuthException)1 PatchSet (com.google.gerrit.reviewdb.client.PatchSet)1 PatchSetApproval (com.google.gerrit.reviewdb.client.PatchSetApproval)1 LabelPermission (com.google.gerrit.server.permissions.LabelPermission)1 SubmitRuleEvaluator (com.google.gerrit.server.project.SubmitRuleEvaluator)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1