summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@sonymobile.com>2015-08-03 11:50:56 +0900
committerDavid Pursehouse <david.pursehouse@sonymobile.com>2015-08-04 09:49:16 +0000
commit777d3a9ac0fb6978ece37e960e8dc510ab8c395b (patch)
tree48c97b2a26049f3fe55685f2587bc41fa1187ef7
parent4a5deb521ddde271ad6d122284dd083b754beed4 (diff)
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
-rw-r--r--gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/AbstractDaemonTest.java16
-rw-r--r--gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/git/AbstractPushForReview.java26
2 files changed, 42 insertions, 0 deletions
diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/AbstractDaemonTest.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/AbstractDaemonTest.java
index 4a803e6ec4..d890fa4488 100644
--- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/AbstractDaemonTest.java
+++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/AbstractDaemonTest.java
@@ -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());
diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/git/AbstractPushForReview.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/git/AbstractPushForReview.java
index b1561abc7d..8893ecb940 100644
--- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/git/AbstractPushForReview.java
+++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/git/AbstractPushForReview.java
@@ -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");
+ }
}