Add an acceptance test for pushing changes with Signed-off-by
I thought this functionality wasn't working, but while writing this test I realised it was simply because my account had the forge committer permission. Change-Id: I1e5cf3b92ecbb2ba296cf9874c3350ea57a123ee
This commit is contained in:
@@ -317,6 +317,15 @@ public abstract class AbstractDaemonTest {
|
||||
projectCache.evict(config.getProject());
|
||||
}
|
||||
|
||||
protected void setUseSignedOffBy(InheritableBoolean value)
|
||||
throws Exception {
|
||||
MetaDataUpdate md = metaDataUpdateFactory.create(project);
|
||||
ProjectConfig config = ProjectConfig.read(md);
|
||||
config.getProject().setUseSignedOffBy(value);
|
||||
config.commit(md);
|
||||
projectCache.evict(config.getProject());
|
||||
}
|
||||
|
||||
protected void deny(String permission, AccountGroup.UUID id, String ref)
|
||||
throws Exception {
|
||||
ProjectConfig cfg = projectCache.checkedGet(project).getConfig();
|
||||
@@ -362,6 +371,13 @@ public abstract class AbstractDaemonTest {
|
||||
saveProjectConfig(project, cfg);
|
||||
}
|
||||
|
||||
protected void blockForgeCommitter(Project.NameKey project, String ref)
|
||||
throws Exception {
|
||||
ProjectConfig cfg = projectCache.checkedGet(project).getConfig();
|
||||
block(cfg, Permission.FORGE_COMMITTER, REGISTERED_USERS, ref);
|
||||
saveProjectConfig(project, cfg);
|
||||
}
|
||||
|
||||
protected PushOneCommit.Result pushTo(String ref) throws GitAPIException,
|
||||
IOException {
|
||||
PushOneCommit push = pushFactory.create(db, admin.getIdent());
|
||||
|
@@ -25,6 +25,7 @@ import com.google.gerrit.acceptance.PushOneCommit;
|
||||
import com.google.gerrit.acceptance.TestAccount;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
import com.google.gerrit.extensions.api.projects.BranchInput;
|
||||
import com.google.gerrit.extensions.client.InheritableBoolean;
|
||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||
import com.google.gerrit.extensions.common.EditInfo;
|
||||
import com.google.gerrit.extensions.common.LabelInfo;
|
||||
@@ -343,4 +344,29 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest {
|
||||
assertThat(c1.changeId).isEqualTo(c2.changeId);
|
||||
assertThat(c1.currentRevision).isEqualTo(c2.currentRevision);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPushCommitUsingSignedOffBy() throws Exception {
|
||||
PushOneCommit push =
|
||||
pushFactory.create(db, admin.getIdent(), PushOneCommit.SUBJECT,
|
||||
"b.txt", "anotherContent");
|
||||
PushOneCommit.Result r = push.to(git, "refs/for/master");
|
||||
r.assertOkStatus();
|
||||
|
||||
setUseSignedOffBy(InheritableBoolean.TRUE);
|
||||
blockForgeCommitter(project, "refs/heads/master");
|
||||
|
||||
push = pushFactory.create(db, admin.getIdent(),
|
||||
PushOneCommit.SUBJECT + String.format(
|
||||
"\n\nSigned-off-by: %s <%s>", admin.fullName, admin.email),
|
||||
"b.txt", "anotherContent");
|
||||
r = push.to(git, "refs/for/master");
|
||||
r.assertOkStatus();
|
||||
|
||||
push = pushFactory.create(db, admin.getIdent(), PushOneCommit.SUBJECT,
|
||||
"b.txt", "anotherContent");
|
||||
r = push.to(git, "refs/for/master");
|
||||
r.assertErrorStatus(
|
||||
"not Signed-off-by author/committer/uploader in commit message footer");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user