AssigneeIT: Add tests for setting assignee with and without permission
Change-Id: I2c9503cf5d7c013c5a6699287529f92c2572b919
This commit is contained in:
@@ -16,6 +16,7 @@ package com.google.gerrit.acceptance.rest.change;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.TruthJUnit.assume;
|
||||
import static com.google.gerrit.server.group.SystemGroupBackend.REGISTERED_USERS;
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
@@ -23,6 +24,7 @@ import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.NoHttpd;
|
||||
import com.google.gerrit.acceptance.PushOneCommit;
|
||||
import com.google.gerrit.acceptance.Sandboxed;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
import com.google.gerrit.extensions.api.changes.AssigneeInput;
|
||||
import com.google.gerrit.extensions.client.ReviewerState;
|
||||
import com.google.gerrit.extensions.common.AccountInfo;
|
||||
@@ -150,6 +152,23 @@ public class AssigneeIT extends AbstractDaemonTest {
|
||||
setAssignee(r, user.email);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setAssigneeNotAllowedWithoutPermission() throws Exception {
|
||||
PushOneCommit.Result r = createChange();
|
||||
setApiUser(user);
|
||||
exception.expect(AuthException.class);
|
||||
exception.expectMessage("not permitted");
|
||||
setAssignee(r, user.email);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setAssigneeAllowedWithPermission() throws Exception {
|
||||
PushOneCommit.Result r = createChange();
|
||||
grant(Permission.EDIT_ASSIGNEE, project, "refs/heads/master", false, REGISTERED_USERS);
|
||||
setApiUser(user);
|
||||
assertThat(setAssignee(r, user.email)._accountId).isEqualTo(user.getId().get());
|
||||
}
|
||||
|
||||
private AccountInfo getAssignee(PushOneCommit.Result r) throws Exception {
|
||||
return gApi.changes().id(r.getChange().getId().get()).getAssignee();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user