Search in sources :

Example 11 with PermissionRange

use of com.google.gerrit.entities.PermissionRange in project gerrit by GerritCodeReview.

the class RefControlTest method unblockRangeForChangeOwner.

@Test
public void unblockRangeForChangeOwner() throws Exception {
    projectOperations.project(localKey).forUpdate().add(allowLabel(LabelId.CODE_REVIEW).ref("refs/heads/*").group(CHANGE_OWNER).range(-2, +2)).update();
    ProjectControl u = user(localKey, DEVS);
    PermissionRange range = u.controlForRef("refs/heads/master").getRange(LABEL + LabelId.CODE_REVIEW, true);
    assertCanVote(-2, range);
    assertCanVote(2, range);
}
Also used : PermissionRange(com.google.gerrit.entities.PermissionRange) Test(org.junit.Test)

Example 12 with PermissionRange

use of com.google.gerrit.entities.PermissionRange in project gerrit by GerritCodeReview.

the class RefControlTest method blockLabelRange_ParentBlocksChild.

@Test
public void blockLabelRange_ParentBlocksChild() throws Exception {
    projectOperations.project(localKey).forUpdate().add(allowLabel(LabelId.CODE_REVIEW).ref("refs/heads/*").group(DEVS).range(-2, +2)).update();
    projectOperations.project(parentKey).forUpdate().add(blockLabel(LabelId.CODE_REVIEW).ref("refs/heads/*").group(DEVS).range(-2, +2)).update();
    ProjectControl u = user(localKey, DEVS);
    PermissionRange range = u.controlForRef("refs/heads/master").getRange(LABEL + LabelId.CODE_REVIEW);
    assertCanVote(-1, range);
    assertCanVote(1, range);
    assertCannotVote(-2, range);
    assertCannotVote(2, range);
}
Also used : PermissionRange(com.google.gerrit.entities.PermissionRange) Test(org.junit.Test)

Example 13 with PermissionRange

use of com.google.gerrit.entities.PermissionRange in project gerrit by GerritCodeReview.

the class RefControlTest method unblockVoteMoreSpecificRefWithExclusiveFlag.

@Test
public void unblockVoteMoreSpecificRefWithExclusiveFlag() throws Exception {
    projectOperations.project(localKey).forUpdate().add(blockLabel(LabelId.CODE_REVIEW).ref("refs/heads/*").group(ANONYMOUS_USERS).range(-1, 1)).add(allowLabel(LabelId.CODE_REVIEW).ref("refs/heads/master").group(DEVS).range(-2, 2)).setExclusiveGroup(labelPermissionKey(LabelId.CODE_REVIEW).ref("refs/heads/master"), true).update();
    ProjectControl u = user(localKey, DEVS);
    PermissionRange range = u.controlForRef("refs/heads/master").getRange(LABEL + LabelId.CODE_REVIEW);
    assertCanVote(-2, range);
}
Also used : PermissionRange(com.google.gerrit.entities.PermissionRange) Test(org.junit.Test)

Example 14 with PermissionRange

use of com.google.gerrit.entities.PermissionRange in project gerrit by GerritCodeReview.

the class RefControlTest method unionOfPermissibleVotesPermissionOrder.

@Test
public void unionOfPermissibleVotesPermissionOrder() throws Exception {
    projectOperations.project(localKey).forUpdate().add(allowLabel(LabelId.CODE_REVIEW).ref("refs/heads/*").group(REGISTERED_USERS).range(-2, +2)).add(allowLabel(LabelId.CODE_REVIEW).ref("refs/heads/*").group(DEVS).range(-1, +1)).update();
    ProjectControl u = user(localKey, DEVS);
    PermissionRange range = u.controlForRef("refs/heads/master").getRange(LABEL + LabelId.CODE_REVIEW);
    assertCanVote(-2, range);
    assertCanVote(2, range);
}
Also used : PermissionRange(com.google.gerrit.entities.PermissionRange) Test(org.junit.Test)

Example 15 with PermissionRange

use of com.google.gerrit.entities.PermissionRange in project gerrit by GerritCodeReview.

the class RefControlTest method unblockRangeForNotChangeOwner.

@Test
public void unblockRangeForNotChangeOwner() throws Exception {
    projectOperations.project(localKey).forUpdate().add(allowLabel(LabelId.CODE_REVIEW).ref("refs/heads/*").group(CHANGE_OWNER).range(-2, +2)).update();
    ProjectControl u = user(localKey, DEVS);
    PermissionRange range = u.controlForRef("refs/heads/master").getRange(LABEL + LabelId.CODE_REVIEW);
    assertCannotVote(-2, range);
    assertCannotVote(2, range);
}
Also used : PermissionRange(com.google.gerrit.entities.PermissionRange) Test(org.junit.Test)

Aggregations

PermissionRange (com.google.gerrit.entities.PermissionRange)17 Test (org.junit.Test)15 PermissionRule (com.google.gerrit.entities.PermissionRule)2 ImmutableList (com.google.common.collect.ImmutableList)1 Permission (com.google.gerrit.entities.Permission)1 List (java.util.List)1