CreateBranch: Test that branches cannot be created under 'refs/for/'

This increases the test coverage of the CreateBranch REST endpoint.

Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: I7593ff7031e46f6ca53510f9622d974a31d7382e
diff --git a/javatests/com/google/gerrit/acceptance/rest/project/CreateBranchIT.java b/javatests/com/google/gerrit/acceptance/rest/project/CreateBranchIT.java
index 5632b50..0cd4964 100644
--- a/javatests/com/google/gerrit/acceptance/rest/project/CreateBranchIT.java
+++ b/javatests/com/google/gerrit/acceptance/rest/project/CreateBranchIT.java
@@ -45,6 +45,7 @@
 import com.google.gerrit.server.events.RefReceivedEvent;
 import com.google.gerrit.server.git.validators.RefOperationValidationListener;
 import com.google.gerrit.server.git.validators.ValidationMessage;
+import com.google.gerrit.server.util.MagicBranch;
 import com.google.gerrit.server.validators.ValidationException;
 import com.google.inject.Inject;
 import java.io.IOException;
@@ -328,6 +329,14 @@
   }
 
   @Test
+  public void cannotCreateBranchInMagicBranchNamespace() throws Exception {
+    assertCreateFails(
+        BranchNameKey.create(project, MagicBranch.NEW_CHANGE + "foo"),
+        BadRequestException.class,
+        "not allowed to create branches under \"" + MagicBranch.NEW_CHANGE + "\"");
+  }
+
+  @Test
   public void createBranchLeadingSlashesAreRemoved() throws Exception {
     BranchNameKey expectedNameKey = BranchNameKey.create(project, "test");