From f76fee63ed9cb3a30d3c0c092d860b1cb93a481b Mon Sep 17 00:00:00 2001
From: Gerard Smyth <gerard.smyth@gmail.com>
Date: Thu, 08 May 2014 13:09:30 -0400
Subject: [PATCH] Updated the SyndicationServlet to provide an additional option to return details of the tags in the repository instead of the commits. This uses a new 'ot' request parameter to indicate the object type of the content to return, which can be ither TAG or COMMIT. If this is not provided, then COMMIT is assumed to maintain backwards compatability. If tags are returned, then the paging parameters, 'l' and 'pg' are still supported, but searching options are currently ignored.

---
 src/test/java/com/gitblit/tests/GitServletTest.java |   48 +++++++++++++++++++++++-------------------------
 1 files changed, 23 insertions(+), 25 deletions(-)

diff --git a/src/test/java/com/gitblit/tests/GitServletTest.java b/src/test/java/com/gitblit/tests/GitServletTest.java
index b197a91..705684a 100644
--- a/src/test/java/com/gitblit/tests/GitServletTest.java
+++ b/src/test/java/com/gitblit/tests/GitServletTest.java
@@ -177,7 +177,7 @@
 		model.authorizationControl = AuthorizationControl.NAMED;
 		UserModel user = new UserModel("james");
 		user.password = "james";
-		gitblit().updateUserModel(user.username, user, true);
+		gitblit().addUser(user);
 		repositories().updateRepositoryModel(model.name, model, false);
 
 		FileUtils.delete(ticgit2Folder, FileUtils.RECURSIVE);
@@ -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 {
@@ -431,7 +419,7 @@
 		// grant user push permission
 		user.setRepositoryPermission(model.name, AccessPermission.PUSH);
 
-		gitblit().updateUserModel(user.username, user, true);
+		gitblit().addUser(user);
 		repositories().updateRepositoryModel(model.name, model, false);
 
 		// clone temp bare repo to working copy
@@ -516,7 +504,7 @@
 		// grant user push permission
 		user.setRepositoryPermission(model.name, AccessPermission.PUSH);
 
-		gitblit().updateUserModel(user.username, user, true);
+		gitblit().addUser(user);
 		repositories().updateRepositoryModel(model.name, model, false);
 
 		// clone temp bare repo to working copy
@@ -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;
@@ -659,11 +657,11 @@
 		// grant user specified
 		user.setRepositoryPermission(model.name, permission);
 
-		gitblit().updateUserModel(user.username, user, true);
+		gitblit().addUser(user);
 		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);
 		}
@@ -829,7 +827,7 @@
 		user.canCreate = canCreate;
 		user.canAdmin = canAdmin;
 
-		gitblit().updateUserModel(user.username, user, true);
+		gitblit().addUser(user);
 
 		CredentialsProvider cp = new UsernamePasswordCredentialsProvider(user.username, user.password);
 

--
Gitblit v1.9.1