Merge "Create "Revert" permission" into stable-3.2
This commit is contained in:
@@ -25,6 +25,7 @@ import com.google.gerrit.acceptance.PushOneCommit;
|
||||
import com.google.gerrit.acceptance.UseClockStep;
|
||||
import com.google.gerrit.acceptance.config.GerritConfig;
|
||||
import com.google.gerrit.acceptance.testsuite.group.GroupOperations;
|
||||
import com.google.gerrit.acceptance.testsuite.project.ProjectOperations;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.common.RawInputUtil;
|
||||
import com.google.gerrit.common.data.ContributorAgreement;
|
||||
@@ -63,6 +64,7 @@ public class AgreementsIT extends AbstractDaemonTest {
|
||||
private ContributorAgreement caNoAutoVerify;
|
||||
@Inject private GroupOperations groupOperations;
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
@Inject private ProjectOperations projectOperations;
|
||||
|
||||
protected void setUseContributorAgreements(InheritableBoolean value) throws Exception {
|
||||
try (MetaDataUpdate md = metaDataUpdateFactory.create(project)) {
|
||||
|
||||
@@ -446,6 +446,22 @@ public class RevertIT extends AbstractDaemonTest {
|
||||
assertThat(thrown).hasMessageThat().contains("Not found: " + r.getChangeId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void revertNotAllowedForOwnerWithoutRevertPermission() throws Exception {
|
||||
projectOperations
|
||||
.project(project)
|
||||
.forUpdate()
|
||||
.add(block(Permission.REVERT).ref("refs/heads/master").group(REGISTERED_USERS))
|
||||
.update();
|
||||
|
||||
PushOneCommit.Result result = createChange();
|
||||
approve(result.getChangeId());
|
||||
gApi.changes().id(result.getChangeId()).current().submit();
|
||||
AuthException thrown =
|
||||
assertThrows(AuthException.class, () -> gApi.changes().id(result.getChangeId()).revert());
|
||||
assertThat(thrown).hasMessageThat().contains("revert not permitted");
|
||||
}
|
||||
|
||||
@Test
|
||||
@GerritConfig(name = "change.submitWholeTopic", value = "true")
|
||||
public void cantCreateRevertSubmissionWithoutProjectWritePermission() throws Exception {
|
||||
@@ -564,6 +580,25 @@ public class RevertIT extends AbstractDaemonTest {
|
||||
assertThat(authException).hasMessageThat().isEqualTo("read not permitted");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void revertSubmissionNotAllowedForOwnerWithoutRevertPermission() throws Exception {
|
||||
projectOperations
|
||||
.project(project)
|
||||
.forUpdate()
|
||||
.add(block(Permission.REVERT).ref("refs/heads/master").group(REGISTERED_USERS))
|
||||
.update();
|
||||
|
||||
PushOneCommit.Result result = createChange();
|
||||
approve(result.getChangeId());
|
||||
gApi.changes().id(result.getChangeId()).current().submit();
|
||||
requestScopeOperations.setApiUser(user.id());
|
||||
|
||||
AuthException thrown =
|
||||
assertThrows(
|
||||
AuthException.class, () -> gApi.changes().id(result.getChangeId()).revertSubmission());
|
||||
assertThat(thrown).hasMessageThat().contains("revert not permitted");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void revertSubmissionPreservesReviewersAndCcs() throws Exception {
|
||||
String change = createChange("first change", "a.txt", "message").getChangeId();
|
||||
|
||||
Reference in New Issue
Block a user