Search in sources :

Example 11 with SubmitInput

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);
}
Also used : SubmitInput(com.google.gerrit.extensions.api.changes.SubmitInput) BranchInfo(com.google.gerrit.extensions.api.projects.BranchInfo) ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) CherryPickInput(com.google.gerrit.extensions.api.changes.CherryPickInput) BranchInput(com.google.gerrit.extensions.api.projects.BranchInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 12 with SubmitInput

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);
}
Also used : SubmitInput(com.google.gerrit.extensions.api.changes.SubmitInput) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) GerritConfig(com.google.gerrit.acceptance.GerritConfig) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 13 with SubmitInput

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);
}
Also used : SubmitInput(com.google.gerrit.extensions.api.changes.SubmitInput) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 14 with SubmitInput

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);
}
Also used : SubmitInput(com.google.gerrit.extensions.api.changes.SubmitInput) ChangeData(com.google.gerrit.server.query.change.ChangeData) PatchSetApproval(com.google.gerrit.reviewdb.client.PatchSetApproval) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 15 with SubmitInput

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");
}
Also used : SubmitInput(com.google.gerrit.extensions.api.changes.SubmitInput) Project(com.google.gerrit.reviewdb.client.Project) InMemoryRepository(org.eclipse.jgit.internal.storage.dfs.InMemoryRepository) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Aggregations

SubmitInput (com.google.gerrit.extensions.api.changes.SubmitInput)19 Test (org.junit.Test)16 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)14 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)11 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)9 Change (com.google.gerrit.reviewdb.client.Change)7 TestSubmitInput (com.google.gerrit.server.change.Submit.TestSubmitInput)5 ObjectId (org.eclipse.jgit.lib.ObjectId)5 PatchSet (com.google.gerrit.reviewdb.client.PatchSet)4 Repository (org.eclipse.jgit.lib.Repository)4 RevCommit (org.eclipse.jgit.revwalk.RevCommit)4 RevWalk (org.eclipse.jgit.revwalk.RevWalk)4 Project (com.google.gerrit.reviewdb.client.Project)3 InMemoryRepository (org.eclipse.jgit.internal.storage.dfs.InMemoryRepository)3 ProjectConfig (com.google.gerrit.server.git.ProjectConfig)2 GerritConfig (com.google.gerrit.acceptance.GerritConfig)1 GitUtil.getChangeId (com.google.gerrit.acceptance.GitUtil.getChangeId)1 TestProjectInput (com.google.gerrit.acceptance.TestProjectInput)1 CherryPickInput (com.google.gerrit.extensions.api.changes.CherryPickInput)1 BranchInfo (com.google.gerrit.extensions.api.projects.BranchInfo)1