PermissionRange: Interpret allowMin > allowMax as disallow

Set min and max to 0 if min > max.

Bug: Issue 11059
Change-Id: I492ef61322dfb82273dc1ed1fe6ae86640541f11
This commit is contained in:
Sven Selberg
2019-06-24 17:35:22 +02:00
parent 8b0339f3ae
commit d4830ae84d
2 changed files with 12 additions and 2 deletions

View File

@@ -70,8 +70,8 @@ public class PermissionRange implements Comparable<PermissionRange> {
this.min = min;
this.max = max;
} else {
this.min = max;
this.max = min;
this.min = 0;
this.max = 0;
}
}

View File

@@ -584,6 +584,16 @@ public class RefControlTest {
assertCannotUpdate("refs/tags/V10", u);
}
@Test
public void blockPartialRangeLocally() {
block(local, LABEL + "Code-Review", +1, +2, DEVS, "refs/heads/master");
ProjectControl u = user(local, DEVS);
PermissionRange range = u.controlForRef("refs/heads/master").getRange(LABEL + "Code-Review");
assertCannotVote(2, range);
}
@Test
public void blockLabelRange_ParentBlocksChild() {
allow(local, LABEL + "Code-Review", -2, +2, DEVS, "refs/heads/*");