use of com.google.gerrit.extensions.api.changes.SubmitInput in project gerrit by GerritCodeReview.
the class AgreementsIT method cherrypickChangeWithoutCLA.
@Test
public void cherrypickChangeWithoutCLA() throws Exception {
assume().that(isContributorAgreementsEnabled()).isTrue();
// Create a new branch
setApiUser(admin);
BranchInfo dest = gApi.projects().name(project.get()).branch("cherry-pick-to").create(new BranchInput()).get();
// Create a change succeeds when agreement is not required
setUseContributorAgreements(InheritableBoolean.FALSE);
ChangeInfo change = gApi.changes().create(newChangeInput()).get();
// Approve and submit it
gApi.changes().id(change.changeId).current().review(ReviewInput.approve());
gApi.changes().id(change.changeId).current().submit(new SubmitInput());
// Cherry-pick is not allowed when CLA is required but not signed
setApiUser(user);
setUseContributorAgreements(InheritableBoolean.TRUE);
CherryPickInput in = new CherryPickInput();
in.destination = dest.ref;
in.message = change.subject;
exception.expect(AuthException.class);
exception.expectMessage("A Contributor Agreement must be completed");
gApi.changes().id(change.changeId).current().cherryPick(in);
}
use of com.google.gerrit.extensions.api.changes.SubmitInput in project gerrit by GerritCodeReview.
the class ImpersonationIT method submitOnBehalfOfInvisibleUserNotAllowed.
@GerritConfig(name = "accounts.visibility", value = "SAME_GROUP")
@Test
public void submitOnBehalfOfInvisibleUserNotAllowed() throws Exception {
allowSubmitOnBehalfOf();
setApiUser(accounts.user2());
assertThat(accountControlFactory.get().canSee(user.id)).isFalse();
PushOneCommit.Result r = createChange();
String changeId = project.get() + "~master~" + r.getChangeId();
gApi.changes().id(changeId).current().review(ReviewInput.approve());
SubmitInput in = new SubmitInput();
in.onBehalfOf = user.email;
exception.expect(UnprocessableEntityException.class);
exception.expectMessage("Account Not Found: " + in.onBehalfOf);
gApi.changes().id(changeId).current().submit(in);
}
use of com.google.gerrit.extensions.api.changes.SubmitInput in project gerrit by GerritCodeReview.
the class ImpersonationIT method submitOnBehalfOfFailsWhenUserCannotSeeDestinationRef.
@Test
public void submitOnBehalfOfFailsWhenUserCannotSeeDestinationRef() throws Exception {
blockRead(newGroup);
allowSubmitOnBehalfOf();
PushOneCommit.Result r = createChange();
String changeId = project.get() + "~master~" + r.getChangeId();
gApi.changes().id(changeId).current().review(ReviewInput.approve());
SubmitInput in = new SubmitInput();
in.onBehalfOf = user.email;
exception.expect(UnprocessableEntityException.class);
exception.expectMessage("on_behalf_of account " + user.id + " cannot see change");
gApi.changes().id(changeId).current().submit(in);
}
use of com.google.gerrit.extensions.api.changes.SubmitInput in project gerrit by GerritCodeReview.
the class ImpersonationIT method submitOnBehalfOf.
@Test
public void submitOnBehalfOf() throws Exception {
allowSubmitOnBehalfOf();
PushOneCommit.Result r = createChange();
String changeId = project.get() + "~master~" + r.getChangeId();
gApi.changes().id(changeId).current().review(ReviewInput.approve());
SubmitInput in = new SubmitInput();
in.onBehalfOf = admin2.email;
gApi.changes().id(changeId).current().submit(in);
ChangeData cd = r.getChange();
assertThat(cd.change().getStatus()).isEqualTo(Change.Status.MERGED);
PatchSetApproval submitter = approvalsUtil.getSubmitter(db, cd.notes(), cd.change().currentPatchSetId());
assertThat(submitter.getAccountId()).isEqualTo(admin2.id);
assertThat(submitter.getRealAccountId()).isEqualTo(admin.id);
}
use of com.google.gerrit.extensions.api.changes.SubmitInput in project gerrit by GerritCodeReview.
the class AbstractSubmit method submitNoPermission.
@Test
public void submitNoPermission() throws Exception {
// create project where submit is blocked
Project.NameKey p = createProject("p");
block(p, "refs/*", Permission.SUBMIT, REGISTERED_USERS);
TestRepository<InMemoryRepository> repo = cloneProject(p, admin);
PushOneCommit push = pushFactory.create(db, admin.getIdent(), repo);
PushOneCommit.Result result = push.to("refs/for/master");
result.assertOkStatus();
submit(result.getChangeId(), new SubmitInput(), AuthException.class, "submit not permitted");
}
Aggregations