Test pushing with non-existing forged author/committer

This is to verify that the behavior is the same as for pushing with
non-visible forged author/committer so that users cannot probe whether
an author/committer account exists.

Signed-off-by: Edwin Kempin <ekempin@google.com>
Release-Notes: skip
Change-Id: I6bc6692b7907773a4482fb8aeaa0a1f391b0e5d4
diff --git a/javatests/com/google/gerrit/acceptance/git/AbstractPushForReview.java b/javatests/com/google/gerrit/acceptance/git/AbstractPushForReview.java
index a27218f..3b94a50 100644
--- a/javatests/com/google/gerrit/acceptance/git/AbstractPushForReview.java
+++ b/javatests/com/google/gerrit/acceptance/git/AbstractPushForReview.java
@@ -1169,6 +1169,24 @@
   }
 
   @Test
+  public void pushForMasterWithNonExistingForgedAuthorAndCommitter() throws Exception {
+    // Create a commit with different forged author and committer.
+    RevCommit c =
+        commitBuilder()
+            .author(new PersonIdent("author", "author@example.com"))
+            .committer(new PersonIdent("committer", "committer@example.com"))
+            .add(PushOneCommit.FILE_NAME, PushOneCommit.FILE_CONTENT)
+            .message(PushOneCommit.SUBJECT)
+            .create();
+    // Push commit as "Administrator".
+    pushHead(testRepo, "refs/for/master");
+
+    String changeId = GitUtil.getChangeId(testRepo, c).get();
+    assertThat(getOwnerEmail(changeId)).isEqualTo(admin.email());
+    assertThat(getReviewerEmails(changeId, ReviewerState.CC)).isEmpty();
+  }
+
+  @Test
   @GerritConfig(name = "accounts.visibility", value = "SAME_GROUP")
   public void pushForMasterWithNonVisibleForgedAuthorAndCommitter() throws Exception {
     // Define readable names for the users we use in this test.
@@ -1241,6 +1259,25 @@
   }
 
   @Test
+  public void pushNewPatchSetForMasterWithNonExistingForgedAuthorAndCommitter() throws Exception {
+    // First patch set has author and committer matching change owner.
+    PushOneCommit.Result r = pushTo("refs/for/master");
+
+    assertThat(getOwnerEmail(r.getChangeId())).isEqualTo(admin.email());
+    assertThat(getReviewerEmails(r.getChangeId(), ReviewerState.REVIEWER)).isEmpty();
+
+    amendBuilder()
+        .author(new PersonIdent("author", "author@example.com"))
+        .committer(new PersonIdent("committer", "committer@example.com"))
+        .add(PushOneCommit.FILE_NAME, PushOneCommit.FILE_CONTENT + "2")
+        .create();
+    pushHead(testRepo, "refs/for/master");
+
+    assertThat(getOwnerEmail(r.getChangeId())).isEqualTo(admin.email());
+    assertThat(getReviewerEmails(r.getChangeId(), ReviewerState.CC)).isEmpty();
+  }
+
+  @Test
   @GerritConfig(name = "accounts.visibility", value = "SAME_GROUP")
   public void pushNewPatchSetForMasterWithNonVisibleForgedAuthorAndCommitter() throws Exception {
     // Define readable names for the users we use in this test.