Search in sources :

Example 1 with PermissionRange

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

the class RefControlTest method unionOfBlockedVotes.

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

Example 2 with PermissionRange

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

the class RefControlTest method blockLabelRange_ParentBlocksChildEvenIfAlreadyBlockedInChild.

@Test
public void blockLabelRange_ParentBlocksChildEvenIfAlreadyBlockedInChild() throws Exception {
    projectOperations.project(localKey).forUpdate().add(allowLabel(LabelId.CODE_REVIEW).ref("refs/heads/*").group(DEVS).range(-2, +2)).add(blockLabel(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 3 with PermissionRange

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

the class RefControlTest method blockChangeOwnerVote.

@Test
public void blockChangeOwnerVote() throws Exception {
    projectOperations.project(localKey).forUpdate().add(blockLabel(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)

Example 4 with PermissionRange

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

the class RefControlTest method unblockRangeOnLargerScope_Fails.

@Test
public void unblockRangeOnLargerScope_Fails() throws Exception {
    projectOperations.project(localKey).forUpdate().add(blockLabel(LabelId.CODE_REVIEW).ref("refs/heads/master").group(ANONYMOUS_USERS).range(-1, +1)).add(allowLabel(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);
    assertCannotVote(-2, range);
    assertCannotVote(2, range);
}
Also used : PermissionRange(com.google.gerrit.entities.PermissionRange) Test(org.junit.Test)

Example 5 with PermissionRange

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

the class RefControlTest method nonconfiguredCannotVote.

@Test
public void nonconfiguredCannotVote() throws Exception {
    projectOperations.project(localKey).forUpdate().add(allowLabel(LabelId.CODE_REVIEW).ref("refs/heads/*").group(DEVS).range(-2, +2)).update();
    ProjectControl u = user(localKey, REGISTERED_USERS);
    PermissionRange range = u.controlForRef("refs/heads/master").getRange(LABEL + LabelId.CODE_REVIEW);
    assertCannotVote(-1, range);
    assertCannotVote(1, 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