Add more tests for branch deletion
Change-Id: Ic45e51bd3cc2dca4f494c2bb3cbe42f6a2c9a0b5 Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
@@ -36,6 +36,7 @@ public class DeleteBranchIT extends AbstractDaemonTest {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
project = createProject(name("p"));
|
||||
branch = new Branch.NameKey(project, "test");
|
||||
branch().create(new BranchInput());
|
||||
}
|
||||
@@ -73,10 +74,21 @@ public class DeleteBranchIT extends AbstractDaemonTest {
|
||||
assertDeleteForbidden();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deleteBranchByUserWithForcePushPermission() throws Exception {
|
||||
grantForcePush();
|
||||
setApiUser(user);
|
||||
assertDeleteSucceeds();
|
||||
}
|
||||
|
||||
private void blockForcePush() throws Exception {
|
||||
block(Permission.PUSH, ANONYMOUS_USERS, "refs/heads/*").setForce(true);
|
||||
}
|
||||
|
||||
private void grantForcePush() throws Exception {
|
||||
grant(Permission.PUSH, project, "refs/heads/*", true, ANONYMOUS_USERS);
|
||||
}
|
||||
|
||||
private void grantOwner() throws Exception {
|
||||
allow(Permission.OWNER, REGISTERED_USERS, "refs/*");
|
||||
}
|
||||
@@ -99,6 +111,7 @@ public class DeleteBranchIT extends AbstractDaemonTest {
|
||||
|
||||
private void assertDeleteForbidden() throws Exception {
|
||||
exception.expect(AuthException.class);
|
||||
exception.expectMessage("Cannot delete branch");
|
||||
branch().delete();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user