From 64b6f382d35e1fea0172b222277dae0312f274e4 Mon Sep 17 00:00:00 2001 From: James Moger <james.moger@gitblit.com> Date: Mon, 25 Feb 2013 09:41:49 -0500 Subject: [PATCH] Merged LDAP user/team pre-fetching and synchronization enhancement from mschaefers --- tests/com/gitblit/tests/GitServletTest.java | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 47 insertions(+), 2 deletions(-) diff --git a/tests/com/gitblit/tests/GitServletTest.java b/tests/com/gitblit/tests/GitServletTest.java index 07771a2..a05b365 100644 --- a/tests/com/gitblit/tests/GitServletTest.java +++ b/tests/com/gitblit/tests/GitServletTest.java @@ -7,9 +7,11 @@ import java.io.BufferedWriter; import java.io.File; import java.io.FileOutputStream; +import java.io.IOException; import java.io.OutputStreamWriter; import java.text.MessageFormat; import java.util.Date; +import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; import org.eclipse.jgit.api.CloneCommand; @@ -18,6 +20,7 @@ import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.revwalk.RevCommit; +import org.eclipse.jgit.storage.file.FileRepository; import org.eclipse.jgit.transport.CredentialsProvider; import org.eclipse.jgit.transport.PushResult; import org.eclipse.jgit.transport.RefSpec; @@ -34,9 +37,12 @@ import com.gitblit.Constants.AuthorizationControl; import com.gitblit.GitBlit; import com.gitblit.Keys; +import com.gitblit.models.PushLogEntry; import com.gitblit.models.RepositoryModel; import com.gitblit.models.UserModel; +import com.gitblit.utils.ArrayUtils; import com.gitblit.utils.JGitUtils; +import com.gitblit.utils.PushLogUtils; public class GitServletTest { @@ -88,6 +94,11 @@ @Test public void testClone() throws Exception { + GitBlitSuite.close(ticgitFolder); + if (ticgitFolder.exists()) { + FileUtils.delete(ticgitFolder, FileUtils.RECURSIVE | FileUtils.RETRY); + } + CloneCommand clone = Git.cloneRepository(); clone.setURI(MessageFormat.format("{0}/git/ticgit.git", url)); clone.setDirectory(ticgitFolder); @@ -187,6 +198,20 @@ @Test public void testAnonymousPush() throws Exception { + GitBlitSuite.close(ticgitFolder); + if (ticgitFolder.exists()) { + FileUtils.delete(ticgitFolder, FileUtils.RECURSIVE | FileUtils.RETRY); + } + + CloneCommand clone = Git.cloneRepository(); + clone.setURI(MessageFormat.format("{0}/git/ticgit.git", url)); + clone.setDirectory(ticgitFolder); + clone.setBare(false); + clone.setCloneAllBranches(true); + clone.setCredentialsProvider(new UsernamePasswordCredentialsProvider(account, password)); + GitBlitSuite.close(clone.call()); + assertTrue(true); + Git git = Git.open(ticgitFolder); File file = new File(ticgitFolder, "TODO"); OutputStreamWriter os = new OutputStreamWriter(new FileOutputStream(file, true), Constants.CHARSET); @@ -201,6 +226,11 @@ @Test public void testSubfolderPush() throws Exception { + GitBlitSuite.close(jgitFolder); + if (jgitFolder.exists()) { + FileUtils.delete(jgitFolder, FileUtils.RECURSIVE | FileUtils.RETRY); + } + CloneCommand clone = Git.cloneRepository(); clone.setURI(MessageFormat.format("{0}/git/test/jgit.git", url)); clone.setDirectory(jgitFolder); @@ -224,6 +254,11 @@ @Test public void testPushToFrozenRepo() throws Exception { + GitBlitSuite.close(jgitFolder); + if (jgitFolder.exists()) { + FileUtils.delete(jgitFolder, FileUtils.RECURSIVE | FileUtils.RETRY); + } + CloneCommand clone = Git.cloneRepository(); clone.setURI(MessageFormat.format("{0}/git/test/jgit.git", url)); clone.setDirectory(jgitFolder); @@ -691,7 +726,7 @@ // confirm default personal repository permissions RepositoryModel model = GitBlit.self().getRepositoryModel(MessageFormat.format("~{0}/ticgit.git", user.username)); - assertEquals("Unexpected owner", user.username, model.owner); + assertEquals("Unexpected owner", user.username, ArrayUtils.toString(model.owners)); assertEquals("Unexpected authorization control", AuthorizationControl.NAMED, model.authorizationControl); assertEquals("Unexpected access restriction", AccessRestrictionType.VIEW, model.accessRestriction); @@ -715,7 +750,7 @@ // confirm default project repository permissions RepositoryModel model = GitBlit.self().getRepositoryModel("project/ticgit.git"); - assertEquals("Unexpected owner", user.username, model.owner); + assertEquals("Unexpected owner", user.username, ArrayUtils.toString(model.owners)); assertEquals("Unexpected authorization control", AuthorizationControl.fromName(GitBlit.getString(Keys.git.defaultAuthorizationControl, "NAMED")), model.authorizationControl); assertEquals("Unexpected access restriction", AccessRestrictionType.fromName(GitBlit.getString(Keys.git.defaultAccessRestriction, "NONE")), model.accessRestriction); @@ -727,4 +762,14 @@ GitBlitSuite.close(git); GitBlit.self().deleteUser(user.username); } + + @Test + public void testPushLog() throws IOException { + String name = "refchecks/ticgit.git"; + File refChecks = new File(GitBlitSuite.REPOSITORIES, name); + FileRepository repository = new FileRepository(refChecks); + List<PushLogEntry> pushes = PushLogUtils.getPushLog(name, repository); + GitBlitSuite.close(repository); + assertTrue("Repository has an empty push log!", pushes.size() > 0); + } } -- Gitblit v1.9.1