From 0e44acbb2fec928a1606dc60f427a148fff405c9 Mon Sep 17 00:00:00 2001
From: Mohamed Ragab <moragab@gmail.com>
Date: Wed, 02 May 2012 11:15:01 -0400
Subject: [PATCH] Added a script to facilitate setting the proxy host and port and no proxy hosts, and then it concatenates all the java system properties for setting the java proxy configurations and puts the resulting string in an environment variable JAVA_PROXY_CONFIG, modified the scirpts gitblit, gitblit-ubuntu, and gitblit-centos to source the java-proxy-config.sh script and then include the resulting java proxy configuration in the java command
---
tests/com/gitblit/tests/GitBlitTest.java | 48 ++++++++++++++++++++++++++++++------------------
1 files changed, 30 insertions(+), 18 deletions(-)
diff --git a/tests/com/gitblit/tests/GitBlitTest.java b/tests/com/gitblit/tests/GitBlitTest.java
index 6d36d49..418f938 100644
--- a/tests/com/gitblit/tests/GitBlitTest.java
+++ b/tests/com/gitblit/tests/GitBlitTest.java
@@ -15,9 +15,14 @@
*/
package com.gitblit.tests;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
import java.util.List;
-import junit.framework.TestCase;
+import org.junit.Test;
import com.gitblit.Constants.AccessRestrictionType;
import com.gitblit.FileSettings;
@@ -25,8 +30,9 @@
import com.gitblit.models.RepositoryModel;
import com.gitblit.models.UserModel;
-public class GitBlitTest extends TestCase {
+public class GitBlitTest {
+ @Test
public void testRepositoryModel() throws Exception {
List<String> repositories = GitBlit.self().getRepositoryList();
assertTrue("Repository list is empty!", repositories.size() > 0);
@@ -37,23 +43,24 @@
RepositoryModel model = GitBlit.self().getRepositoryModel(
GitBlitSuite.getHelloworldRepository().getDirectory().getName());
assertTrue("Helloworld model is null!", model != null);
- assertTrue(model.toString().equals(
- GitBlitSuite.getHelloworldRepository().getDirectory().getName()));
+ assertEquals(GitBlitSuite.getHelloworldRepository().getDirectory().getName(), model.name);
assertTrue(GitBlit.self().calculateSize(model) > 22000L);
}
+ @Test
public void testUserModel() throws Exception {
List<String> users = GitBlit.self().getAllUsernames();
assertTrue("No users found!", users.size() > 0);
assertTrue("Admin not found", users.contains("admin"));
UserModel model = GitBlit.self().getUserModel("admin");
- assertTrue(model.toString().equals("admin"));
+ assertEquals("admin", model.toString());
assertTrue("Admin missing #admin role!", model.canAdmin);
model.canAdmin = false;
assertFalse("Admin should not have #admin!", model.canAdmin);
String repository = GitBlitSuite.getHelloworldRepository().getDirectory().getName();
- RepositoryModel repositoryModel = GitBlit.self().getRepositoryModel(model, repository);
- assertFalse("Admin can still access repository!", model.canAccessRepository(repositoryModel));
+ RepositoryModel repositoryModel = GitBlit.self().getRepositoryModel(repository);
+ assertFalse("Admin can still access repository!",
+ model.canAccessRepository(repositoryModel));
model.addRepository(repository);
assertTrue("Admin can't access repository!", model.canAccessRepository(repositoryModel));
assertEquals(GitBlit.self().getRepositoryModel(model, "pretend"), null);
@@ -61,6 +68,7 @@
assertTrue(GitBlit.self().getRepositoryModels(model).size() > 0);
}
+ @Test
public void testAccessRestrictionTypes() throws Exception {
assertTrue(AccessRestrictionType.PUSH.exceeds(AccessRestrictionType.NONE));
assertTrue(AccessRestrictionType.CLONE.exceeds(AccessRestrictionType.PUSH));
@@ -82,22 +90,23 @@
assertTrue(AccessRestrictionType.CLONE.toString().equals("CLONE"));
assertTrue(AccessRestrictionType.VIEW.toString().equals("VIEW"));
- assertTrue(AccessRestrictionType.fromName("none").equals(AccessRestrictionType.NONE));
- assertTrue(AccessRestrictionType.fromName("push").equals(AccessRestrictionType.PUSH));
- assertTrue(AccessRestrictionType.fromName("clone").equals(AccessRestrictionType.CLONE));
- assertTrue(AccessRestrictionType.fromName("view").equals(AccessRestrictionType.VIEW));
+ assertEquals(AccessRestrictionType.NONE, AccessRestrictionType.fromName("none"));
+ assertEquals(AccessRestrictionType.PUSH, AccessRestrictionType.fromName("push"));
+ assertEquals(AccessRestrictionType.CLONE, AccessRestrictionType.fromName("clone"));
+ assertEquals(AccessRestrictionType.VIEW, AccessRestrictionType.fromName("view"));
}
+ @Test
public void testFileSettings() throws Exception {
FileSettings settings = new FileSettings("distrib/gitblit.properties");
- assertTrue(settings.getBoolean("missing", true));
- assertTrue(settings.getString("missing", "default").equals("default"));
- assertTrue(settings.getInteger("missing", 10) == 10);
- assertTrue(settings.getInteger("realm.realmFile", 5) == 5);
+ assertEquals(true, settings.getBoolean("missing", true));
+ assertEquals("default", settings.getString("missing", "default"));
+ assertEquals(10, settings.getInteger("missing", 10));
+ assertEquals(5, settings.getInteger("realm.realmFile", 5));
assertTrue(settings.getBoolean("git.enableGitServlet", false));
- assertTrue(settings.getString("realm.userService", null).equals("users.conf"));
- assertTrue(settings.getInteger("realm.minPasswordLength", 0) == 5);
+ assertEquals("users.conf", settings.getString("realm.userService", null));
+ assertEquals(5, settings.getInteger("realm.minPasswordLength", 0));
List<String> mdExtensions = settings.getStrings("web.markdownExtensions");
assertTrue(mdExtensions.size() > 0);
assertTrue(mdExtensions.contains("md"));
@@ -109,6 +118,7 @@
assertTrue(settings.getChar("web.forwardSlashCharacter", ' ') == '/');
}
+ @Test
public void testGitblitSettings() throws Exception {
// These are already tested by above test method.
assertTrue(GitBlit.getBoolean("missing", true));
@@ -117,7 +127,7 @@
assertEquals(5, GitBlit.getInteger("realm.userService", 5));
assertTrue(GitBlit.getBoolean("git.enableGitServlet", false));
- assertEquals("distrib/users.conf", GitBlit.getString("realm.userService", null));
+ assertEquals("test-users.conf", GitBlit.getString("realm.userService", null));
assertEquals(5, GitBlit.getInteger("realm.minPasswordLength", 0));
List<String> mdExtensions = GitBlit.getStrings("web.markdownExtensions");
assertTrue(mdExtensions.size() > 0);
@@ -131,10 +141,12 @@
assertFalse(GitBlit.isDebugMode());
}
+ @Test
public void testAuthentication() throws Exception {
assertTrue(GitBlit.self().authenticate("admin", "admin".toCharArray()) != null);
}
+ @Test
public void testRepositories() throws Exception {
assertTrue(GitBlit.self().getRepository("missing") == null);
assertTrue(GitBlit.self().getRepositoryModel("missing") == null);
--
Gitblit v1.9.1