From 3a9e76b63f09a32e0b6812e18ffff00fab8e58e6 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Fri, 29 Nov 2013 11:05:51 -0500
Subject: [PATCH] Flattened IGitblitManager, GitblitManager, and GitBlit classes

---
 src/test/java/com/gitblit/tests/GitServletTest.java |   38 ++++++++++++++++++--------------------
 1 files changed, 18 insertions(+), 20 deletions(-)

diff --git a/src/test/java/com/gitblit/tests/GitServletTest.java b/src/test/java/com/gitblit/tests/GitServletTest.java
index b197a91..ad61a67 100644
--- a/src/test/java/com/gitblit/tests/GitServletTest.java
+++ b/src/test/java/com/gitblit/tests/GitServletTest.java
@@ -380,27 +380,15 @@
 	public void testCommitterVerification() throws Exception {
 		UserModel user = getUser();
 
-		// account only uses account name to verify
-		testCommitterVerification(user, user.username, null, true);
-		// committer email address is ignored because account does not specify email
-		testCommitterVerification(user, user.username, "something", true);
-		// completely different committer
 		testCommitterVerification(user, "joe", null, false);
+		testCommitterVerification(user, "joe", user.emailAddress, false);
+		testCommitterVerification(user, user.username, null, false);
+		testCommitterVerification(user, user.username, user.emailAddress, true);
 
-		// test display name verification
 		user.displayName = "James Moger";
-		testCommitterVerification(user, user.displayName, null, true);
-		testCommitterVerification(user, user.displayName, "something", true);
-		testCommitterVerification(user, "joe", null, false);
-
-		// test email address verification
-		user.emailAddress = "something";
 		testCommitterVerification(user, user.displayName, null, false);
-		testCommitterVerification(user, user.displayName, "somethingelse", false);
+		testCommitterVerification(user, user.displayName, "something", false);
 		testCommitterVerification(user, user.displayName, user.emailAddress, true);
-
-		// use same email address but with different committer
-		testCommitterVerification(user, "joe", "somethingelse", false);
 	}
 
 	private void testCommitterVerification(UserModel user, String displayName, String emailAddress, boolean expectedSuccess) throws Exception {
@@ -624,18 +612,28 @@
 
 	private void testRefChange(AccessPermission permission, Status expectedCreate, Status expectedDelete, Status expectedRewind) throws Exception {
 
+		final String originName = "ticgit.git";
+		final String forkName = "refchecks/ticgit.git";
+		final String workingCopy = "refchecks/ticgit-wc";
+
+
+		// lower access restriction on origin repository
+		RepositoryModel origin = repositories().getRepositoryModel(originName);
+		origin.accessRestriction = AccessRestrictionType.NONE;
+		repositories().updateRepositoryModel(origin.name, origin, false);
+
 		UserModel user = getUser();
 		delete(user);
 
 		CredentialsProvider cp = new UsernamePasswordCredentialsProvider(user.username, user.password);
 
 		// fork from original to a temporary bare repo
-		File refChecks = new File(GitBlitSuite.REPOSITORIES, "refchecks/ticgit.git");
+		File refChecks = new File(GitBlitSuite.REPOSITORIES, forkName);
 		if (refChecks.exists()) {
 			FileUtils.delete(refChecks, FileUtils.RECURSIVE);
 		}
 		CloneCommand clone = Git.cloneRepository();
-		clone.setURI(MessageFormat.format("{0}/ticgit.git", url));
+		clone.setURI(url + "/" + originName);
 		clone.setDirectory(refChecks);
 		clone.setBare(true);
 		clone.setCloneAllBranches(true);
@@ -643,7 +641,7 @@
 		GitBlitSuite.close(clone.call());
 
 		// elevate repository to clone permission
-		RepositoryModel model = repositories().getRepositoryModel("refchecks/ticgit.git");
+		RepositoryModel model = repositories().getRepositoryModel(forkName);
 		switch (permission) {
 			case VIEW:
 				model.accessRestriction = AccessRestrictionType.CLONE;
@@ -663,7 +661,7 @@
 		repositories().updateRepositoryModel(model.name, model, false);
 
 		// clone temp bare repo to working copy
-		File local = new File(GitBlitSuite.REPOSITORIES, "refchecks/ticgit-wc");
+		File local = new File(GitBlitSuite.REPOSITORIES, workingCopy);
 		if (local.exists()) {
 			FileUtils.delete(local, FileUtils.RECURSIVE);
 		}

--
Gitblit v1.9.1