summaryrefslogtreecommitdiffstats
path: root/src/test/java/com/gitblit/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/com/gitblit/tests')
-rw-r--r--src/test/java/com/gitblit/tests/ActivityTest.java2
-rw-r--r--src/test/java/com/gitblit/tests/ArrayUtilsTest.java10
-rw-r--r--src/test/java/com/gitblit/tests/FanoutServiceTest.java54
-rw-r--r--src/test/java/com/gitblit/tests/FederationTests.java18
-rw-r--r--src/test/java/com/gitblit/tests/FileUtilsTest.java4
-rw-r--r--src/test/java/com/gitblit/tests/GitBlitTest.java10
-rw-r--r--src/test/java/com/gitblit/tests/GitDaemonTest.java40
-rw-r--r--src/test/java/com/gitblit/tests/GitServletTest.java207
-rw-r--r--src/test/java/com/gitblit/tests/GroovyScriptTest.java62
-rw-r--r--src/test/java/com/gitblit/tests/HtpasswdUserServiceTest.java21
-rw-r--r--src/test/java/com/gitblit/tests/Issue0259Test.java60
-rw-r--r--src/test/java/com/gitblit/tests/Issue0271Test.java18
-rw-r--r--src/test/java/com/gitblit/tests/JGitUtilsTest.java30
-rw-r--r--src/test/java/com/gitblit/tests/JnaUtilsTest.java2
-rw-r--r--src/test/java/com/gitblit/tests/LdapUserServiceTest.java48
-rw-r--r--src/test/java/com/gitblit/tests/LuceneExecutorTest.java52
-rw-r--r--src/test/java/com/gitblit/tests/ModelUtilsTest.java4
-rw-r--r--src/test/java/com/gitblit/tests/PermissionsTest.java654
-rw-r--r--src/test/java/com/gitblit/tests/RedmineUserServiceTest.java6
-rw-r--r--src/test/java/com/gitblit/tests/RepositoryModelTest.java28
-rw-r--r--src/test/java/com/gitblit/tests/RpcTests.java14
-rw-r--r--src/test/java/com/gitblit/tests/StringUtilsTest.java2
-rw-r--r--src/test/java/com/gitblit/tests/SyndicationUtilsTest.java2
-rw-r--r--src/test/java/com/gitblit/tests/X509UtilsTest.java63
-rw-r--r--src/test/java/com/gitblit/tests/mock/MemorySettings.java8
25 files changed, 726 insertions, 693 deletions
diff --git a/src/test/java/com/gitblit/tests/ActivityTest.java b/src/test/java/com/gitblit/tests/ActivityTest.java
index 22713260..3c8d9902 100644
--- a/src/test/java/com/gitblit/tests/ActivityTest.java
+++ b/src/test/java/com/gitblit/tests/ActivityTest.java
@@ -27,7 +27,7 @@ import com.gitblit.utils.ActivityUtils;
public class ActivityTest {
@Test
- public void testGravatarProfile() throws IOException {
+ public void testGravatarProfile() throws IOException {
GravatarProfile profile = ActivityUtils.getGravatarProfile("beau@dentedreality.com.au");
assertEquals("beau", profile.preferredUsername);
}
diff --git a/src/test/java/com/gitblit/tests/ArrayUtilsTest.java b/src/test/java/com/gitblit/tests/ArrayUtilsTest.java
index 8a38afbb..45964a18 100644
--- a/src/test/java/com/gitblit/tests/ArrayUtilsTest.java
+++ b/src/test/java/com/gitblit/tests/ArrayUtilsTest.java
@@ -37,10 +37,10 @@ public class ArrayUtilsTest {
Object [] emptyArray = new Object[0];
assertTrue(ArrayUtils.isEmpty(emptyArray));
-
+
assertFalse(ArrayUtils.isEmpty(new String [] { "" }));
}
-
+
@Test
public void testLists() {
List<?> nullList = null;
@@ -48,11 +48,11 @@ public class ArrayUtilsTest {
List<?> emptyList = new ArrayList<Object>();
assertTrue(ArrayUtils.isEmpty(emptyList));
-
+
List<?> list = Arrays.asList("");
assertFalse(ArrayUtils.isEmpty(list));
}
-
+
@Test
public void testSets() {
Set<?> nullSet = null;
@@ -60,7 +60,7 @@ public class ArrayUtilsTest {
Set<?> emptySet = new HashSet<Object>();
assertTrue(ArrayUtils.isEmpty(emptySet));
-
+
Set<?> set = new HashSet<Object>(Arrays.asList(""));
assertFalse(ArrayUtils.isEmpty(set));
}
diff --git a/src/test/java/com/gitblit/tests/FanoutServiceTest.java b/src/test/java/com/gitblit/tests/FanoutServiceTest.java
index cd094dac..056a6c34 100644
--- a/src/test/java/com/gitblit/tests/FanoutServiceTest.java
+++ b/src/test/java/com/gitblit/tests/FanoutServiceTest.java
@@ -32,9 +32,9 @@ import com.gitblit.fanout.FanoutService;
import com.gitblit.fanout.FanoutSocketService;
public class FanoutServiceTest {
-
+
int fanoutPort = FanoutService.DEFAULT_PORT;
-
+
@Test
public void testNioPubSub() throws Exception {
testPubSub(new FanoutNioService(fanoutPort));
@@ -44,7 +44,7 @@ public class FanoutServiceTest {
public void testSocketPubSub() throws Exception {
testPubSub(new FanoutSocketService(fanoutPort));
}
-
+
@Test
public void testNioDisruptionAndRecovery() throws Exception {
testDisruption(new FanoutNioService(fanoutPort));
@@ -54,21 +54,21 @@ public class FanoutServiceTest {
public void testSocketDisruptionAndRecovery() throws Exception {
testDisruption(new FanoutSocketService(fanoutPort));
}
-
+
protected void testPubSub(FanoutService service) throws Exception {
System.out.println(MessageFormat.format("\n\n========================================\nPUBSUB TEST {0}\n========================================\n\n", service.toString()));
service.startSynchronously();
-
+
final Map<String, String> announcementsA = new ConcurrentHashMap<String, String>();
FanoutClient clientA = new FanoutClient("localhost", fanoutPort);
clientA.addListener(new FanoutAdapter() {
-
+
@Override
public void announcement(String channel, String message) {
announcementsA.put(channel, message);
}
});
-
+
clientA.startSynchronously();
final Map<String, String> announcementsB = new ConcurrentHashMap<String, String>();
@@ -81,23 +81,23 @@ public class FanoutServiceTest {
});
clientB.startSynchronously();
-
+
// subscribe clients A and B to the channels
clientA.subscribe("a");
clientA.subscribe("b");
clientA.subscribe("c");
-
+
clientB.subscribe("a");
clientB.subscribe("b");
clientB.subscribe("c");
-
+
// give async messages a chance to be delivered
Thread.sleep(1000);
-
+
clientA.announce("a", "apple");
clientA.announce("b", "banana");
clientA.announce("c", "cantelope");
-
+
clientB.announce("a", "avocado");
clientB.announce("b", "beet");
clientB.announce("c", "carrot");
@@ -114,16 +114,16 @@ public class FanoutServiceTest {
assertEquals("avocado", announcementsA.get("a"));
assertEquals("beet", announcementsA.get("b"));
assertEquals("carrot", announcementsA.get("c"));
-
+
clientA.stop();
clientB.stop();
- service.stop();
+ service.stop();
}
-
+
protected void testDisruption(FanoutService service) throws Exception {
System.out.println(MessageFormat.format("\n\n========================================\nDISRUPTION TEST {0}\n========================================\n\n", service.toString()));
service.startSynchronously();
-
+
final AtomicInteger pongCount = new AtomicInteger(0);
FanoutClient client = new FanoutClient("localhost", fanoutPort);
client.addListener(new FanoutAdapter() {
@@ -133,27 +133,27 @@ public class FanoutServiceTest {
}
});
client.startSynchronously();
-
+
// ping and wait for pong
- client.ping();
+ client.ping();
Thread.sleep(500);
-
+
// restart client
client.stop();
Thread.sleep(1000);
- client.startSynchronously();
-
+ client.startSynchronously();
+
// ping and wait for pong
- client.ping();
+ client.ping();
Thread.sleep(500);
-
+
assertEquals(2, pongCount.get());
-
+
// now disrupt service
- service.stop();
+ service.stop();
Thread.sleep(2000);
service.startSynchronously();
-
+
// wait for reconnect
Thread.sleep(2000);
@@ -164,7 +164,7 @@ public class FanoutServiceTest {
// kill all
client.stop();
service.stop();
-
+
// confirm expected pong count
assertEquals(3, pongCount.get());
}
diff --git a/src/test/java/com/gitblit/tests/FederationTests.java b/src/test/java/com/gitblit/tests/FederationTests.java
index 8475ffeb..688ae289 100644
--- a/src/test/java/com/gitblit/tests/FederationTests.java
+++ b/src/test/java/com/gitblit/tests/FederationTests.java
@@ -129,23 +129,23 @@ public class FederationTests {
assertNotNull(users);
// admin is excluded
assertEquals(0, users.size());
-
+
UserModel newUser = new UserModel("test");
newUser.password = "whocares";
assertTrue(RpcUtils.createUser(newUser, url, account, password.toCharArray()));
-
+
TeamModel team = new TeamModel("testteam");
team.addUser("test");
team.addRepositoryPermission("helloworld.git");
assertTrue(RpcUtils.createTeam(team, url, account, password.toCharArray()));
-
+
users = FederationUtils.getUsers(getRegistration());
assertNotNull(users);
assertEquals(1, users.size());
-
+
newUser = users.get(0);
- assertTrue(newUser.isTeamMember("testteam"));
-
+ assertTrue(newUser.isTeamMember("testteam"));
+
assertTrue(RpcUtils.deleteUser(newUser, url, account, password.toCharArray()));
assertTrue(RpcUtils.deleteTeam(team, url, account, password.toCharArray()));
}
@@ -156,14 +156,14 @@ public class FederationTests {
team.addUser("test");
team.addRepositoryPermission("helloworld.git");
assertTrue(RpcUtils.createTeam(team, url, account, password.toCharArray()));
-
+
List<TeamModel> teams = FederationUtils.getTeams(getRegistration());
assertNotNull(teams);
assertTrue(teams.size() > 0);
-
+
assertTrue(RpcUtils.deleteTeam(team, url, account, password.toCharArray()));
}
-
+
@Test
public void testPullScripts() throws Exception {
Map<String, String> scripts = FederationUtils.getScripts(getRegistration());
diff --git a/src/test/java/com/gitblit/tests/FileUtilsTest.java b/src/test/java/com/gitblit/tests/FileUtilsTest.java
index 26f81d52..f345690c 100644
--- a/src/test/java/com/gitblit/tests/FileUtilsTest.java
+++ b/src/test/java/com/gitblit/tests/FileUtilsTest.java
@@ -55,7 +55,7 @@ public class FileUtilsTest {
size = FileUtils.folderSize(file);
assertEquals("size is actually " + size, 11556L, size);
}
-
+
@Test
public void testStringSizes() throws Exception {
assertEquals(50 * FileUtils.KB, FileUtils.convertSizeToInt("50k", 0));
@@ -73,7 +73,7 @@ public class FileUtilsTest {
assertEquals(50L * FileUtils.KB, FileUtils.convertSizeToLong("50kb", 0));
assertEquals(50L * FileUtils.MB, FileUtils.convertSizeToLong("50mb", 0));
assertEquals(50L * FileUtils.GB, FileUtils.convertSizeToLong("50gb", 0));
-
+
assertEquals(50 * FileUtils.KB, FileUtils.convertSizeToInt("50 k", 0));
assertEquals(50 * FileUtils.MB, FileUtils.convertSizeToInt("50 m", 0));
assertEquals(2 * FileUtils.GB, FileUtils.convertSizeToInt("2 g", 0));
diff --git a/src/test/java/com/gitblit/tests/GitBlitTest.java b/src/test/java/com/gitblit/tests/GitBlitTest.java
index c7ec939f..4fb58642 100644
--- a/src/test/java/com/gitblit/tests/GitBlitTest.java
+++ b/src/test/java/com/gitblit/tests/GitBlitTest.java
@@ -70,20 +70,20 @@ public class GitBlitTest {
assertNotNull(GitBlit.self().getRepositoryModel(user, repository));
assertTrue(GitBlit.self().getRepositoryModels(user).size() > 0);
}
-
+
@Test
public void testUserModelVerification() throws Exception {
UserModel user = new UserModel("james");
user.displayName = "James Moger";
-
+
assertTrue(user.is("James", null));
assertTrue(user.is("James", ""));
assertTrue(user.is("JaMeS", "anything"));
-
+
assertTrue(user.is("james moger", null));
assertTrue(user.is("james moger", ""));
assertTrue(user.is("james moger", "anything"));
-
+
assertFalse(user.is("joe", null));
assertFalse(user.is("joe", ""));
assertFalse(user.is("joe", "anything"));
@@ -94,7 +94,7 @@ public class GitBlitTest {
assertFalse(user.is("James", null));
assertFalse(user.is("James", ""));
assertFalse(user.is("JaMeS", "anything"));
-
+
assertFalse(user.is("james moger", null));
assertFalse(user.is("james moger", ""));
assertFalse(user.is("james moger", "anything"));
diff --git a/src/test/java/com/gitblit/tests/GitDaemonTest.java b/src/test/java/com/gitblit/tests/GitDaemonTest.java
index 6b181d04..a283e6b0 100644
--- a/src/test/java/com/gitblit/tests/GitDaemonTest.java
+++ b/src/test/java/com/gitblit/tests/GitDaemonTest.java
@@ -43,11 +43,11 @@ import com.gitblit.models.RepositoryModel;
public class GitDaemonTest extends Assert {
static File ticgitFolder = new File(GitBlitSuite.REPOSITORIES, "working/ticgit");
-
+
static File ticgit2Folder = new File(GitBlitSuite.REPOSITORIES, "working/ticgit2");
static File jgitFolder = new File(GitBlitSuite.REPOSITORIES, "working/jgit");
-
+
static File jgit2Folder = new File(GitBlitSuite.REPOSITORIES, "working/jgit2");
String url = GitBlitSuite.gitDaemonUrl;
@@ -98,21 +98,21 @@ public class GitDaemonTest extends Assert {
model.accessRestriction = AccessRestrictionType.PUSH;
model.authorizationControl = AuthorizationControl.NAMED;
GitBlit.self().updateRepositoryModel(model.name, model, false);
-
+
CloneCommand clone = Git.cloneRepository();
clone.setURI(MessageFormat.format("{0}/ticgit.git", url));
clone.setDirectory(ticgitFolder);
clone.setBare(false);
clone.setCloneAllBranches(true);
- GitBlitSuite.close(clone.call());
+ GitBlitSuite.close(clone.call());
assertTrue(true);
-
+
// restore anonymous repository access
model.accessRestriction = AccessRestrictionType.NONE;
model.authorizationControl = AuthorizationControl.NAMED;
GitBlit.self().updateRepositoryModel(model.name, model, false);
}
-
+
@Test
public void testCloneRestrictedRepo() throws Exception {
GitBlitSuite.close(ticgit2Folder);
@@ -125,8 +125,8 @@ public class GitDaemonTest extends Assert {
model.accessRestriction = AccessRestrictionType.CLONE;
model.authorizationControl = AuthorizationControl.NAMED;
GitBlit.self().updateRepositoryModel(model.name, model, false);
-
- // delete any existing working folder
+
+ // delete any existing working folder
boolean cloned = false;
try {
CloneCommand clone = Git.cloneRepository();
@@ -143,7 +143,7 @@ public class GitDaemonTest extends Assert {
assertFalse("Anonymous was able to clone the repository?!", cloned);
FileUtils.delete(ticgit2Folder, FileUtils.RECURSIVE);
-
+
// restore anonymous repository access
model.accessRestriction = AccessRestrictionType.NONE;
model.authorizationControl = AuthorizationControl.NAMED;
@@ -168,9 +168,9 @@ public class GitDaemonTest extends Assert {
clone.setDirectory(ticgitFolder);
clone.setBare(false);
clone.setCloneAllBranches(true);
- GitBlitSuite.close(clone.call());
+ 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);
@@ -206,9 +206,9 @@ public class GitDaemonTest extends Assert {
clone.setDirectory(ticgitFolder);
clone.setBare(false);
clone.setCloneAllBranches(true);
- GitBlitSuite.close(clone.call());
+ 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);
@@ -232,7 +232,7 @@ public class GitDaemonTest extends Assert {
if (jgitFolder.exists()) {
FileUtils.delete(jgitFolder, FileUtils.RECURSIVE | FileUtils.RETRY);
}
-
+
CloneCommand clone = Git.cloneRepository();
clone.setURI(MessageFormat.format("{0}/test/jgit.git", url));
clone.setDirectory(jgitFolder);
@@ -240,7 +240,7 @@ public class GitDaemonTest extends Assert {
clone.setCloneAllBranches(true);
GitBlitSuite.close(clone.call());
assertTrue(true);
-
+
// freeze repo
RepositoryModel model = GitBlit.self().getRepositoryModel("test/jgit.git");
model.isFrozen = true;
@@ -254,14 +254,14 @@ public class GitDaemonTest extends Assert {
w.close();
git.add().addFilepattern(file.getName()).call();
git.commit().setMessage("test commit").call();
-
+
Iterable<PushResult> results = git.push().call();
for (PushResult result : results) {
for (RemoteRefUpdate update : result.getRemoteUpdates()) {
assertEquals(Status.REJECTED_OTHER_REASON, update.getStatus());
}
}
-
+
// unfreeze repo
model.isFrozen = false;
GitBlit.self().updateRepositoryModel(model.name, model, false);
@@ -274,14 +274,14 @@ public class GitDaemonTest extends Assert {
}
}
}
-
+
@Test
public void testPushToNonBareRepository() throws Exception {
GitBlitSuite.close(jgit2Folder);
if (jgit2Folder.exists()) {
FileUtils.delete(jgit2Folder, FileUtils.RECURSIVE | FileUtils.RETRY);
}
-
+
CloneCommand clone = Git.cloneRepository();
clone.setURI(MessageFormat.format("{0}/working/jgit", url));
clone.setDirectory(jgit2Folder);
@@ -301,7 +301,7 @@ public class GitDaemonTest extends Assert {
Iterable<PushResult> results = git.push().setPushAll().call();
GitBlitSuite.close(git);
-
+
for (PushResult result : results) {
for (RemoteRefUpdate update : result.getRemoteUpdates()) {
assertEquals(Status.REJECTED_OTHER_REASON, update.getStatus());
diff --git a/src/test/java/com/gitblit/tests/GitServletTest.java b/src/test/java/com/gitblit/tests/GitServletTest.java
index b6a58ac9..08c4a234 100644
--- a/src/test/java/com/gitblit/tests/GitServletTest.java
+++ b/src/test/java/com/gitblit/tests/GitServletTest.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2011 gitblit.com.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package com.gitblit.tests;
import static org.junit.Assert.assertEquals;
@@ -50,11 +65,11 @@ import com.gitblit.utils.RefLogUtils;
public class GitServletTest {
static File ticgitFolder = new File(GitBlitSuite.REPOSITORIES, "working/ticgit");
-
+
static File ticgit2Folder = new File(GitBlitSuite.REPOSITORIES, "working/ticgit2");
static File jgitFolder = new File(GitBlitSuite.REPOSITORIES, "working/jgit");
-
+
static File jgit2Folder = new File(GitBlitSuite.REPOSITORIES, "working/jgit2");
String url = GitBlitSuite.gitServletUrl;
@@ -62,7 +77,7 @@ public class GitServletTest {
String password = GitBlitSuite.password;
private static final AtomicBoolean started = new AtomicBoolean(false);
-
+
private static UserModel getUser() {
UserModel user = new UserModel("james");
user.displayName = "James Moger";
@@ -70,7 +85,7 @@ public class GitServletTest {
user.password = "james";
return user;
}
-
+
private static void delete(UserModel user) {
if (GitBlit.self().getUserModel(user.username) != null) {
GitBlit.self().deleteUser(user.username);
@@ -90,10 +105,10 @@ public class GitServletTest {
GitBlitSuite.stopGitblit();
deleteWorkingFolders();
}
-
+
delete(getUser());
}
-
+
public static void deleteWorkingFolders() throws Exception {
if (ticgitFolder.exists()) {
GitBlitSuite.close(ticgitFolder);
@@ -119,14 +134,14 @@ public class GitServletTest {
if (ticgitFolder.exists()) {
FileUtils.delete(ticgitFolder, FileUtils.RECURSIVE | FileUtils.RETRY);
}
-
+
CloneCommand clone = Git.cloneRepository();
clone.setURI(MessageFormat.format("{0}/ticgit.git", url));
clone.setDirectory(ticgitFolder);
clone.setBare(false);
clone.setCloneAllBranches(true);
clone.setCredentialsProvider(new UsernamePasswordCredentialsProvider(account, password));
- GitBlitSuite.close(clone.call());
+ GitBlitSuite.close(clone.call());
assertTrue(true);
}
@@ -137,7 +152,7 @@ public class GitServletTest {
model.accessRestriction = AccessRestrictionType.CLONE;
GitBlit.self().updateRepositoryModel(model.name, model, false);
- // delete any existing working folder
+ // delete any existing working folder
boolean cloned = false;
try {
CloneCommand clone = Git.cloneRepository();
@@ -158,7 +173,7 @@ public class GitServletTest {
assertFalse("Bogus login cloned a repository?!", cloned);
}
-
+
@Test
public void testUnauthorizedLoginClone() throws Exception {
// restrict repository access
@@ -171,8 +186,8 @@ public class GitServletTest {
GitBlit.self().updateRepositoryModel(model.name, model, false);
FileUtils.delete(ticgit2Folder, FileUtils.RECURSIVE);
-
- // delete any existing working folder
+
+ // delete any existing working folder
boolean cloned = false;
try {
CloneCommand clone = Git.cloneRepository();
@@ -190,11 +205,11 @@ public class GitServletTest {
assertFalse("Unauthorized login cloned a repository?!", cloned);
FileUtils.delete(ticgit2Folder, FileUtils.RECURSIVE);
-
+
// switch to authenticated
model.authorizationControl = AuthorizationControl.AUTHENTICATED;
GitBlit.self().updateRepositoryModel(model.name, model, false);
-
+
// try clone again
cloned = false;
CloneCommand clone = Git.cloneRepository();
@@ -207,15 +222,15 @@ public class GitServletTest {
cloned = true;
assertTrue("Authenticated login could not clone!", cloned);
-
+
FileUtils.delete(ticgit2Folder, FileUtils.RECURSIVE);
-
+
// restore anonymous repository access
model.accessRestriction = AccessRestrictionType.NONE;
model.authorizationControl = AuthorizationControl.NAMED;
GitBlit.self().updateRepositoryModel(model.name, model, false);
-
- delete(user);
+
+ delete(user);
}
@Test
@@ -235,9 +250,9 @@ public class GitServletTest {
clone.setBare(false);
clone.setCloneAllBranches(true);
clone.setCredentialsProvider(new UsernamePasswordCredentialsProvider(account, password));
- GitBlitSuite.close(clone.call());
+ 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);
@@ -261,7 +276,7 @@ public class GitServletTest {
if (jgitFolder.exists()) {
FileUtils.delete(jgitFolder, FileUtils.RECURSIVE | FileUtils.RETRY);
}
-
+
CloneCommand clone = Git.cloneRepository();
clone.setURI(MessageFormat.format("{0}/test/jgit.git", url));
clone.setDirectory(jgitFolder);
@@ -287,14 +302,14 @@ public class GitServletTest {
}
}
}
-
+
@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}/test/jgit.git", url));
clone.setDirectory(jgitFolder);
@@ -303,7 +318,7 @@ public class GitServletTest {
clone.setCredentialsProvider(new UsernamePasswordCredentialsProvider(account, password));
GitBlitSuite.close(clone.call());
assertTrue(true);
-
+
// freeze repo
RepositoryModel model = GitBlit.self().getRepositoryModel("test/jgit.git");
model.isFrozen = true;
@@ -317,14 +332,14 @@ public class GitServletTest {
w.close();
git.add().addFilepattern(file.getName()).call();
git.commit().setMessage("test commit").call();
-
+
Iterable<PushResult> results = git.push().setPushAll().setCredentialsProvider(new UsernamePasswordCredentialsProvider(account, password)).call();
for (PushResult result : results) {
for (RemoteRefUpdate update : result.getRemoteUpdates()) {
assertEquals(Status.REJECTED_OTHER_REASON, update.getStatus());
}
}
-
+
// unfreeze repo
model.isFrozen = false;
GitBlit.self().updateRepositoryModel(model.name, model, false);
@@ -337,7 +352,7 @@ public class GitServletTest {
}
}
}
-
+
@Test
public void testPushToNonBareRepository() throws Exception {
CloneCommand clone = Git.cloneRepository();
@@ -382,23 +397,23 @@ public class GitServletTest {
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, 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 {
-
+
delete(user);
-
+
CredentialsProvider cp = new UsernamePasswordCredentialsProvider(user.username, user.password);
-
+
// fork from original to a temporary bare repo
File verification = new File(GitBlitSuite.REPOSITORIES, "refchecks/verify-committer.git");
if (verification.exists()) {
@@ -411,16 +426,16 @@ public class GitServletTest {
clone.setCloneAllBranches(true);
clone.setCredentialsProvider(cp);
GitBlitSuite.close(clone.call());
-
+
// require push permissions and committer verification
RepositoryModel model = GitBlit.self().getRepositoryModel("refchecks/verify-committer.git");
model.authorizationControl = AuthorizationControl.NAMED;
model.accessRestriction = AccessRestrictionType.PUSH;
model.verifyCommitter = true;
-
+
// grant user push permission
user.setRepositoryPermission(model.name, AccessPermission.PUSH);
-
+
GitBlit.self().updateUserModel(user.username, user, true);
GitBlit.self().updateRepositoryModel(model.name, model, false);
@@ -436,14 +451,14 @@ public class GitServletTest {
clone.setCloneAllBranches(true);
clone.setCredentialsProvider(cp);
GitBlitSuite.close(clone.call());
-
+
Git git = Git.open(local);
-
+
// force an identity which may or may not match the account's identity
git.getRepository().getConfig().setString("user", null, "name", displayName);
git.getRepository().getConfig().setString("user", null, "email", emailAddress);
git.getRepository().getConfig().save();
-
+
// commit a file and push it
File file = new File(local, "PUSHCHK");
OutputStreamWriter os = new OutputStreamWriter(new FileOutputStream(file, true), Constants.CHARSET);
@@ -453,7 +468,7 @@ public class GitServletTest {
git.add().addFilepattern(file.getName()).call();
git.commit().setMessage("push test").call();
Iterable<PushResult> results = git.push().setCredentialsProvider(cp).setRemote("origin").call();
-
+
for (PushResult result : results) {
RemoteRefUpdate ref = result.getRemoteUpdate("refs/heads/master");
Status status = ref.getStatus();
@@ -463,27 +478,27 @@ public class GitServletTest {
assertTrue("Verification failed! User was able to push commit! " + status.name(), Status.REJECTED_OTHER_REASON.equals(status));
}
}
-
+
GitBlitSuite.close(git);
// close serving repository
GitBlitSuite.close(verification);
}
-
+
@Test
public void testMergeCommitterVerification() throws Exception {
-
+
testMergeCommitterVerification(false);
-
+
testMergeCommitterVerification(true);
}
-
+
private void testMergeCommitterVerification(boolean expectedSuccess) throws Exception {
UserModel user = getUser();
-
+
delete(user);
-
+
CredentialsProvider cp = new UsernamePasswordCredentialsProvider(user.username, user.password);
-
+
// fork from original to a temporary bare repo
File verification = new File(GitBlitSuite.REPOSITORIES, "refchecks/verify-committer.git");
if (verification.exists()) {
@@ -496,16 +511,16 @@ public class GitServletTest {
clone.setCloneAllBranches(true);
clone.setCredentialsProvider(cp);
GitBlitSuite.close(clone.call());
-
+
// require push permissions and committer verification
RepositoryModel model = GitBlit.self().getRepositoryModel("refchecks/verify-committer.git");
model.authorizationControl = AuthorizationControl.NAMED;
model.accessRestriction = AccessRestrictionType.PUSH;
model.verifyCommitter = true;
-
+
// grant user push permission
user.setRepositoryPermission(model.name, AccessPermission.PUSH);
-
+
GitBlit.self().updateUserModel(user.username, user, true);
GitBlit.self().updateRepositoryModel(model.name, model, false);
@@ -521,17 +536,17 @@ public class GitServletTest {
clone.setCloneAllBranches(true);
clone.setCredentialsProvider(cp);
GitBlitSuite.close(clone.call());
-
+
Git git = Git.open(local);
-
+
// checkout a mergetest branch
git.checkout().setCreateBranch(true).setName("mergetest").call();
-
+
// change identity
git.getRepository().getConfig().setString("user", null, "name", "mergetest");
git.getRepository().getConfig().setString("user", null, "email", "mergetest@merge.com");
git.getRepository().getConfig().save();
-
+
// commit a file
File file = new File(local, "MERGECHK2");
OutputStreamWriter os = new OutputStreamWriter(new FileOutputStream(file, true), Constants.CHARSET);
@@ -540,7 +555,7 @@ public class GitServletTest {
w.close();
git.add().addFilepattern(file.getName()).call();
RevCommit mergeTip = git.commit().setMessage(file.getName() + " test").call();
-
+
// return to master
git.checkout().setName("master").call();
@@ -559,14 +574,14 @@ public class GitServletTest {
w.close();
git.add().addFilepattern(file.getName()).call();
git.commit().setMessage(file.getName() + " test").call();
-
+
// merge the tip of the mergetest branch into master with --no-ff
MergeResult mergeResult = git.merge().setFastForward(FastForwardMode.NO_FF).include(mergeTip.getId()).call();
assertEquals(MergeResult.MergeStatus.MERGED, mergeResult.getMergeStatus());
-
+
// push the merged master to the origin
Iterable<PushResult> results = git.push().setCredentialsProvider(cp).setRemote("origin").call();
-
+
for (PushResult result : results) {
RemoteRefUpdate ref = result.getRemoteUpdate("refs/heads/master");
Status status = ref.getStatus();
@@ -576,7 +591,7 @@ public class GitServletTest {
assertTrue("Verification failed! User was able to push commit! " + status.name(), Status.REJECTED_OTHER_REASON.equals(status));
}
}
-
+
GitBlitSuite.close(git);
// close serving repository
GitBlitSuite.close(verification);
@@ -601,14 +616,14 @@ public class GitServletTest {
public void testBlockBranchDeletion() throws Exception {
testRefChange(AccessPermission.CREATE, Status.OK, Status.REJECTED_OTHER_REASON, null);
}
-
+
@Test
public void testBlockBranchRewind() throws Exception {
testRefChange(AccessPermission.DELETE, Status.OK, Status.OK, Status.REJECTED_OTHER_REASON);
}
@Test
- public void testBranchRewind() throws Exception {
+ public void testBranchRewind() throws Exception {
testRefChange(AccessPermission.REWIND, Status.OK, Status.OK, Status.OK);
}
@@ -616,9 +631,9 @@ public class GitServletTest {
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");
if (refChecks.exists()) {
@@ -645,7 +660,7 @@ public class GitServletTest {
model.accessRestriction = AccessRestrictionType.PUSH;
}
model.authorizationControl = AuthorizationControl.NAMED;
-
+
// grant user specified
user.setRepositoryPermission(model.name, permission);
@@ -663,7 +678,7 @@ public class GitServletTest {
clone.setBare(false);
clone.setCloneAllBranches(true);
clone.setCredentialsProvider(cp);
-
+
try {
GitBlitSuite.close(clone.call());
} catch (GitAPIException e) {
@@ -672,15 +687,15 @@ public class GitServletTest {
} else {
// close serving repository
GitBlitSuite.close(refChecks);
-
+
// user does not have clone permission
- assertTrue(e.getMessage(), e.getMessage().contains("not permitted"));
+ assertTrue(e.getMessage(), e.getMessage().contains("not permitted"));
return;
}
}
-
+
Git git = Git.open(local);
-
+
// commit a file and push it
File file = new File(local, "PUSHCHK");
OutputStreamWriter os = new OutputStreamWriter(new FileOutputStream(file, true), Constants.CHARSET);
@@ -698,14 +713,14 @@ public class GitServletTest {
} else {
// close serving repository
GitBlitSuite.close(refChecks);
-
+
// user does not have push permission
assertTrue(e.getMessage(), e.getMessage().contains("not permitted"));
GitBlitSuite.close(git);
return;
}
}
-
+
for (PushResult result : results) {
RemoteRefUpdate ref = result.getRemoteUpdate("refs/heads/master");
Status status = ref.getStatus();
@@ -721,8 +736,8 @@ public class GitServletTest {
return;
}
}
-
- // create a local branch and push the new branch back to the origin
+
+ // create a local branch and push the new branch back to the origin
git.branchCreate().setName("protectme").call();
RefSpec refSpec = new RefSpec("refs/heads/protectme:refs/heads/protectme");
results = git.push().setCredentialsProvider(cp).setRefSpecs(refSpec).setRemote("origin").call();
@@ -741,10 +756,10 @@ public class GitServletTest {
return;
}
}
-
+
// delete the branch locally
git.branchDelete().setBranchNames("protectme").call();
-
+
// push a delete ref command
refSpec = new RefSpec(":refs/heads/protectme");
results = git.push().setCredentialsProvider(cp).setRefSpecs(refSpec).setRemote("origin").call();
@@ -763,10 +778,10 @@ public class GitServletTest {
return;
}
}
-
+
// rewind master by two commits
git.reset().setRef("HEAD~2").setMode(ResetType.HARD).call();
-
+
// commit a change on this detached HEAD
file = new File(local, "REWINDCHK");
os = new OutputStreamWriter(new FileOutputStream(file, true), Constants.CHARSET);
@@ -775,11 +790,11 @@ public class GitServletTest {
w.close();
git.add().addFilepattern(file.getName()).call();
RevCommit commit = git.commit().setMessage("rewind master and new commit").call();
-
+
// Reset master to our new commit now we our local branch tip is no longer
// upstream of the remote branch tip. It is an alternate tip of the branch.
JGitUtils.setBranchRef(git.getRepository(), "refs/heads/master", commit.getName());
-
+
// Try pushing our new tip to the origin.
// This requires the server to "rewind" it's master branch and update it
// to point to our alternate tip. This leaves the original master tip
@@ -795,41 +810,41 @@ public class GitServletTest {
}
}
GitBlitSuite.close(git);
-
+
// close serving repository
GitBlitSuite.close(refChecks);
delete(user);
}
-
+
@Test
public void testCreateOnPush() throws Exception {
testCreateOnPush(false, false);
testCreateOnPush(true, false);
testCreateOnPush(false, true);
}
-
+
private void testCreateOnPush(boolean canCreate, boolean canAdmin) throws Exception {
UserModel user = new UserModel("sampleuser");
user.password = user.username;
-
+
delete(user);
-
+
user.canCreate = canCreate;
user.canAdmin = canAdmin;
-
+
GitBlit.self().updateUserModel(user.username, user, true);
CredentialsProvider cp = new UsernamePasswordCredentialsProvider(user.username, user.password);
-
+
// fork from original to a temporary bare repo
File tmpFolder = File.createTempFile("gitblit", "").getParentFile();
File createCheck = new File(tmpFolder, "ticgit.git");
if (createCheck.exists()) {
FileUtils.delete(createCheck, FileUtils.RECURSIVE);
}
-
+
File personalRepo = new File(GitBlitSuite.REPOSITORIES, MessageFormat.format("~{0}/ticgit.git", user.username));
GitBlitSuite.close(personalRepo);
if (personalRepo.exists()) {
@@ -849,9 +864,9 @@ public class GitServletTest {
clone.setCloneAllBranches(true);
clone.setCredentialsProvider(cp);
Git git = clone.call();
-
+
GitBlitSuite.close(personalRepo);
-
+
// add a personal repository remote and a project remote
git.getRepository().getConfig().setString("remote", "user", "url", MessageFormat.format("{0}/~{1}/ticgit.git", url, user.username));
git.getRepository().getConfig().setString("remote", "project", "url", MessageFormat.format("{0}/project/ticgit.git", url));
@@ -868,18 +883,18 @@ public class GitServletTest {
}
assertTrue("User canAdmin:" + user.canAdmin + " canCreate:" + user.canCreate, user.canAdmin || user.canCreate);
-
+
// confirm default personal repository permissions
RepositoryModel model = GitBlit.self().getRepositoryModel(MessageFormat.format("~{0}/ticgit.git", user.username));
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);
-
+
} catch (GitAPIException e) {
assertTrue(e.getMessage(), e.getMessage().contains("git-receive-pack not found"));
assertFalse("User canAdmin:" + user.canAdmin + " canCreate:" + user.canCreate, user.canAdmin || user.canCreate);
}
-
+
// push to non-existent project repository
try {
Iterable<PushResult> results = git.push().setRemote("project").setPushAll().setCredentialsProvider(cp).call();
@@ -890,9 +905,9 @@ public class GitServletTest {
Status status = ref.getStatus();
assertTrue("User failed to create repository?! " + status.name(), Status.OK.equals(status));
}
-
+
assertTrue("User canAdmin:" + user.canAdmin, user.canAdmin);
-
+
// confirm default project repository permissions
RepositoryModel model = GitBlit.self().getRepositoryModel("project/ticgit.git");
assertEquals("Unexpected owner", user.username, ArrayUtils.toString(model.owners));
@@ -907,7 +922,7 @@ public class GitServletTest {
GitBlitSuite.close(git);
delete(user);
}
-
+
@Test
public void testPushLog() throws IOException {
String name = "refchecks/ticgit.git";
diff --git a/src/test/java/com/gitblit/tests/GroovyScriptTest.java b/src/test/java/com/gitblit/tests/GroovyScriptTest.java
index 2954fa1d..2aa881f8 100644
--- a/src/test/java/com/gitblit/tests/GroovyScriptTest.java
+++ b/src/test/java/com/gitblit/tests/GroovyScriptTest.java
@@ -50,9 +50,9 @@ import com.gitblit.utils.StringUtils;
/**
* Test class for Groovy scripts. Mostly this is to facilitate development.
- *
+ *
* @author James Moger
- *
+ *
*/
public class GroovyScriptTest {
@@ -140,7 +140,7 @@ public class GroovyScriptTest {
assertEquals(5, m.toAddresses.size());
assertTrue(m.message.contains("BIT"));
}
-
+
@Test
public void testProtectRefsCreateBranch() throws Exception {
MockGitblit gitblit = new MockGitblit();
@@ -149,12 +149,12 @@ public class GroovyScriptTest {
List<ReceiveCommand> commands = new ArrayList<ReceiveCommand>();
commands.add(new ReceiveCommand(ObjectId.zeroId(), ObjectId
.fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), "refs/heads/master"));
-
- RepositoryModel repository = new RepositoryModel("ex@mple.git", "", "admin", new Date());
+
+ RepositoryModel repository = new RepositoryModel("ex@mple.git", "", "admin", new Date());
test("protect-refs.groovy", gitblit, logger, clientLogger, commands, repository);
}
-
+
@Test
public void testProtectRefsCreateTag() throws Exception {
MockGitblit gitblit = new MockGitblit();
@@ -163,13 +163,13 @@ public class GroovyScriptTest {
List<ReceiveCommand> commands = new ArrayList<ReceiveCommand>();
commands.add(new ReceiveCommand(ObjectId.zeroId(), ObjectId
.fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), "refs/tags/v1.0"));
-
- RepositoryModel repository = new RepositoryModel("ex@mple.git", "", "admin", new Date());
+
+ RepositoryModel repository = new RepositoryModel("ex@mple.git", "", "admin", new Date());
test("protect-refs.groovy", gitblit, logger, clientLogger, commands, repository);
assertEquals(0, logger.messages.size());
}
-
+
@Test
public void testProtectRefsFastForward() throws Exception {
MockGitblit gitblit = new MockGitblit();
@@ -179,13 +179,13 @@ public class GroovyScriptTest {
commands.add(new ReceiveCommand(ObjectId
.fromString("c18877690322dfc6ae3e37bb7f7085a24e94e887"), ObjectId
.fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), "refs/heads/master"));
-
- RepositoryModel repository = new RepositoryModel("ex@mple.git", "", "admin", new Date());
+
+ RepositoryModel repository = new RepositoryModel("ex@mple.git", "", "admin", new Date());
test("protect-refs.groovy", gitblit, logger, clientLogger, commands, repository);
assertEquals(0, logger.messages.size());
}
-
+
@Test
public void testProtectRefsDeleteMasterBranch() throws Exception {
MockGitblit gitblit = new MockGitblit();
@@ -196,14 +196,14 @@ public class GroovyScriptTest {
.fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), ObjectId.zeroId(),
"refs/heads/master");
commands.add(command);
-
- RepositoryModel repository = new RepositoryModel("ex@mple.git", "", "admin", new Date());
+
+ RepositoryModel repository = new RepositoryModel("ex@mple.git", "", "admin", new Date());
test("protect-refs.groovy", gitblit, logger, clientLogger, commands, repository);
assertEquals(ReceiveCommand.Result.REJECTED_NODELETE, command.getResult());
assertEquals(0, logger.messages.size());
}
-
+
@Test
public void testProtectRefsDeleteOtherBranch() throws Exception {
MockGitblit gitblit = new MockGitblit();
@@ -213,13 +213,13 @@ public class GroovyScriptTest {
commands.add(new ReceiveCommand(ObjectId
.fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), ObjectId.zeroId(),
"refs/heads/other"));
-
- RepositoryModel repository = new RepositoryModel("ex@mple.git", "", "admin", new Date());
+
+ RepositoryModel repository = new RepositoryModel("ex@mple.git", "", "admin", new Date());
test("protect-refs.groovy", gitblit, logger, clientLogger, commands, repository);
assertEquals(0, logger.messages.size());
}
-
+
@Test
public void testProtectRefsDeleteTag() throws Exception {
MockGitblit gitblit = new MockGitblit();
@@ -230,14 +230,14 @@ public class GroovyScriptTest {
.fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), ObjectId.zeroId(),
"refs/tags/v1.0");
commands.add(command);
-
- RepositoryModel repository = new RepositoryModel("ex@mple.git", "", "admin", new Date());
+
+ RepositoryModel repository = new RepositoryModel("ex@mple.git", "", "admin", new Date());
test("protect-refs.groovy", gitblit, logger, clientLogger, commands, repository);
assertEquals(ReceiveCommand.Result.REJECTED_NODELETE, command.getResult());
assertEquals(0, logger.messages.size());
}
-
+
@Test
public void testBlockPush() throws Exception {
MockGitblit gitblit = new MockGitblit();
@@ -247,8 +247,8 @@ public class GroovyScriptTest {
commands.add(new ReceiveCommand(ObjectId
.fromString("c18877690322dfc6ae3e37bb7f7085a24e94e887"), ObjectId
.fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), "refs/heads/master"));
-
- RepositoryModel repository = new RepositoryModel("ex@mple.git", "", "admin", new Date());
+
+ RepositoryModel repository = new RepositoryModel("ex@mple.git", "", "admin", new Date());
try {
test("blockpush.groovy", gitblit, logger, clientLogger, commands, repository);
@@ -257,7 +257,7 @@ public class GroovyScriptTest {
assertTrue(e.getMessage().contains("failed"));
}
}
-
+
@Test
public void testClientLogging() throws Exception {
MockGitblit gitblit = new MockGitblit();
@@ -267,15 +267,15 @@ public class GroovyScriptTest {
commands.add(new ReceiveCommand(ObjectId
.fromString("c18877690322dfc6ae3e37bb7f7085a24e94e887"), ObjectId
.fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), "refs/heads/master"));
-
+
RepositoryModel repository = new RepositoryModel("ex@mple.git", "", "admin", new Date());
-
+
File groovyDir = GitBlit.getGroovyScriptsFolder();
File tempScript = File.createTempFile("testClientLogging", "groovy", groovyDir);
tempScript.deleteOnExit();
-
+
BufferedWriter writer = new BufferedWriter(new FileWriter(tempScript));
-
+
writer.write("clientLogger.info('this is a test message')\n");
writer.flush();
writer.close();
@@ -356,18 +356,18 @@ public class GroovyScriptTest {
messages.add(message);
}
}
-
+
class MockClientLogger {
List<String> messages = new ArrayList<String>();
public void info(String message) {
messages.add(message);
}
-
+
public void error(String message) {
messages.add(message);
}
-
+
public void error(String message, Throwable t) {
PrintWriter writer = new PrintWriter(new StringWriter());
if (!StringUtils.isEmpty(message)) {
diff --git a/src/test/java/com/gitblit/tests/HtpasswdUserServiceTest.java b/src/test/java/com/gitblit/tests/HtpasswdUserServiceTest.java
index b5f85cd5..e223e6bb 100644
--- a/src/test/java/com/gitblit/tests/HtpasswdUserServiceTest.java
+++ b/src/test/java/com/gitblit/tests/HtpasswdUserServiceTest.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2013 gitblit.com.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package com.gitblit.tests;
import static org.junit.Assert.assertEquals;
@@ -77,7 +92,8 @@ public class HtpasswdUserServiceTest {
{
File dir = new File(RESOURCE_DIR);
FilenameFilter filter = new FilenameFilter() {
- public boolean accept(File dir, String file) {
+ @Override
+ public boolean accept(File dir, String file) {
return file.endsWith(".in");
}
};
@@ -92,7 +108,8 @@ public class HtpasswdUserServiceTest {
{
File dir = new File(RESOURCE_DIR);
FilenameFilter filter = new FilenameFilter() {
- public boolean accept(File dir, String file) {
+ @Override
+ public boolean accept(File dir, String file) {
return !(file.endsWith(".in"));
}
};
diff --git a/src/test/java/com/gitblit/tests/Issue0259Test.java b/src/test/java/com/gitblit/tests/Issue0259Test.java
index 72679716..8e2acaf8 100644
--- a/src/test/java/com/gitblit/tests/Issue0259Test.java
+++ b/src/test/java/com/gitblit/tests/Issue0259Test.java
@@ -29,14 +29,14 @@ import com.gitblit.models.UserModel;
/**
* https://code.google.com/p/gitblit/issues/detail?id=259
- *
+ *
* Reported Problem:
* We have an user with RWD access rights, but he can’t push.
- *
+ *
* @see src/test/resources/issue0259.conf
- *
+ *
* At the next day he try again and he can push to the project.
- *
+ *
* @author James Moger
*
*/
@@ -48,29 +48,29 @@ public class Issue0259Test extends Assert {
repo.accessRestriction = restriction;
return repo;
}
-
+
/**
* Test the provided users.conf file for expected access permissions.
- *
+ *
* @throws Exception
*/
@Test
public void testFile() throws Exception {
File realmFile = new File("src/test/resources/issue0259.conf");
ConfigUserService service = new ConfigUserService(realmFile);
-
+
RepositoryModel test = repo("test.git", AccessRestrictionType.VIEW);
RepositoryModel projects_test = repo("projects/test.git", AccessRestrictionType.VIEW);
-
+
UserModel a = service.getUserModel("a");
UserModel b = service.getUserModel("b");
UserModel c = service.getUserModel("c");
-
+
// assert RWD or RW+ for projects/test.git
assertEquals(AccessPermission.DELETE, a.getRepositoryPermission(projects_test).permission);
assertEquals(AccessPermission.DELETE, b.getRepositoryPermission(projects_test).permission);
assertEquals(AccessPermission.REWIND, c.getRepositoryPermission(projects_test).permission);
-
+
assertTrue(a.canPush(projects_test));
assertTrue(b.canPush(projects_test));
assertTrue(c.canPush(projects_test));
@@ -82,7 +82,7 @@ public class Issue0259Test extends Assert {
assertFalse(a.canRewindRef(projects_test));
assertFalse(b.canRewindRef(projects_test));
assertTrue(c.canRewindRef(projects_test));
-
+
// assert R for test.git
assertEquals(AccessPermission.CLONE, a.getRepositoryPermission(test).permission);
assertEquals(AccessPermission.CLONE, b.getRepositoryPermission(test).permission);
@@ -95,7 +95,7 @@ public class Issue0259Test extends Assert {
assertFalse(b.canPush(test));
assertTrue(c.canPush(test));
}
-
+
@Test
public void testTeamsOrder() throws Exception {
testTeams(false);
@@ -109,20 +109,20 @@ public class Issue0259Test extends Assert {
/**
* Tests multiple teams each with a regex permisson that will match. The
* highest matching permission should be used. Order should be irrelevant.
- *
+ *
* @param reverseOrder
* @throws Exception
*/
private void testTeams(boolean reverseOrder) throws Exception {
RepositoryModel test = repo("test.git", AccessRestrictionType.VIEW);
RepositoryModel projects_test = repo("projects/test.git", AccessRestrictionType.VIEW);
-
+
TeamModel t1 = new TeamModel("t1");
t1.setRepositoryPermission(".*", AccessPermission.CLONE);
-
+
TeamModel t2 = new TeamModel("t2");
- t2.setRepositoryPermission("projects/.*", AccessPermission.DELETE);
-
+ t2.setRepositoryPermission("projects/.*", AccessPermission.DELETE);
+
UserModel a = new UserModel("a");
if (reverseOrder) {
a.teams.add(t2);
@@ -131,7 +131,7 @@ public class Issue0259Test extends Assert {
a.teams.add(t1);
a.teams.add(t2);
}
-
+
// simulate a repository rename
a.setRepositoryPermission("projects/renamed.git", null);
t1.setRepositoryPermission("projects/renamed.git", null);
@@ -139,47 +139,47 @@ public class Issue0259Test extends Assert {
assertEquals(AccessPermission.CLONE, a.getRepositoryPermission(test).permission);
assertEquals(AccessPermission.DELETE, a.getRepositoryPermission(projects_test).permission);
-
+
assertTrue(a.canClone(test));
assertTrue(a.canClone(projects_test));
-
+
assertFalse(a.canDeleteRef(test));
assertTrue(a.canDeleteRef(projects_test));
}
-
+
@Test
public void testTeam() throws Exception {
- testTeam(false);
+ testTeam(false);
}
-
+
@Test
public void testTeamReverseOrder() throws Exception {
testTeam(true);
}
-
+
/**
* Test a single team that has multiple repository permissions that all match.
* Here defined order IS important. The first permission match wins so it is
* important to define permissions from most-specific match to least-specific
* match.
- *
+ *
* If the defined permissions are:
* R:.*
* RWD:projects/.*
* then the expected result is R for all repositories because it is first.
- *
+ *
* But if the defined permissions are:
* RWD:projects/.*
* R:.*
* then the expected result is RWD for projects/test.git and R for test.git
- *
+ *
* @param reverseOrder
* @throws Exception
*/
private void testTeam(boolean reverseOrder) throws Exception {
RepositoryModel test = repo("test.git", AccessRestrictionType.VIEW);
RepositoryModel projects_test = repo("projects/test.git", AccessRestrictionType.VIEW);
-
+
TeamModel t1 = new TeamModel("t1");
if (reverseOrder) {
t1.setRepositoryPermission("projects/.*", AccessPermission.DELETE);
@@ -194,7 +194,7 @@ public class Issue0259Test extends Assert {
// simulate a repository rename
a.setRepositoryPermission("projects/renamed.git", null);
t1.setRepositoryPermission("projects/renamed.git", null);
-
+
assertEquals(AccessPermission.CLONE, a.getRepositoryPermission(test).permission);
assertTrue(a.canClone(test));
assertFalse(a.canDeleteRef(test));
@@ -208,6 +208,6 @@ public class Issue0259Test extends Assert {
// R permission is found first
assertEquals(AccessPermission.CLONE, a.getRepositoryPermission(projects_test).permission);
assertFalse(a.canDeleteRef(projects_test));
- }
+ }
}
}
diff --git a/src/test/java/com/gitblit/tests/Issue0271Test.java b/src/test/java/com/gitblit/tests/Issue0271Test.java
index 437c5b9e..8bab8f2c 100644
--- a/src/test/java/com/gitblit/tests/Issue0271Test.java
+++ b/src/test/java/com/gitblit/tests/Issue0271Test.java
@@ -28,12 +28,12 @@ import com.gitblit.models.UserModel;
/**
* https://code.google.com/p/gitblit/issues/detail?id=271
- *
+ *
* Reported Problem:
* Inherited team permissions are incorrect.
- *
+ *
* @see src/test/resources/issue0270.conf
- *
+ *
* @author James Moger
*
*/
@@ -45,29 +45,29 @@ public class Issue0271Test extends Assert {
repo.accessRestriction = restriction;
return repo;
}
-
+
/**
* Test the provided users.conf file for expected access permissions.
- *
+ *
* @throws Exception
*/
@Test
public void testFile() throws Exception {
File realmFile = new File("src/test/resources/issue0271.conf");
ConfigUserService service = new ConfigUserService(realmFile);
-
+
RepositoryModel test = repo("test.git", AccessRestrictionType.VIEW);
RepositoryModel teama_test = repo("teama/test.git", AccessRestrictionType.VIEW);
-
+
UserModel a = service.getUserModel("a");
UserModel b = service.getUserModel("b");
UserModel c = service.getUserModel("c");
-
+
// assert V for test.git
assertEquals(AccessPermission.VIEW, a.getRepositoryPermission(test).permission);
assertEquals(AccessPermission.VIEW, b.getRepositoryPermission(test).permission);
assertEquals(AccessPermission.VIEW, c.getRepositoryPermission(test).permission);
-
+
// assert expected permissions for teama/test.git
assertEquals(AccessPermission.VIEW, a.getRepositoryPermission(teama_test).permission);
assertEquals(AccessPermission.PUSH, b.getRepositoryPermission(teama_test).permission);
diff --git a/src/test/java/com/gitblit/tests/JGitUtilsTest.java b/src/test/java/com/gitblit/tests/JGitUtilsTest.java
index 06fd674a..9f7cb31e 100644
--- a/src/test/java/com/gitblit/tests/JGitUtilsTest.java
+++ b/src/test/java/com/gitblit/tests/JGitUtilsTest.java
@@ -228,7 +228,7 @@ public class JGitUtilsTest {
String repositoryAll = "NewTestRepositoryAll.git";
String repositoryUmask = "NewTestRepositoryUmask.git";
String sgidParent = "sgid";
-
+
File parent = new File(GitBlitSuite.REPOSITORIES, sgidParent);
File folder = null;
boolean parentExisted = parent.exists();
@@ -243,21 +243,21 @@ public class JGitUtilsTest {
Repository repository = JGitUtils.createRepository(parent, repositoryAll, "all");
folder = FileKey.resolve(new File(parent, repositoryAll), FS.DETECTED);
assertNotNull(repository);
-
+
assertEquals("2", repository.getConfig().getString("core", null, "sharedRepository"));
-
+
assertTrue(folder.exists());
mode = JnaUtils.getFilemode(folder);
assertEquals(JnaUtils.S_ISGID, mode & JnaUtils.S_ISGID);
-
+
mode = JnaUtils.getFilemode(folder.getAbsolutePath() + "/HEAD");
assertEquals(JnaUtils.S_IRGRP | JnaUtils.S_IWGRP, mode & JnaUtils.S_IRWXG);
assertEquals(JnaUtils.S_IROTH, mode & JnaUtils.S_IRWXO);
-
+
mode = JnaUtils.getFilemode(folder.getAbsolutePath() + "/config");
assertEquals(JnaUtils.S_IRGRP | JnaUtils.S_IWGRP, mode & JnaUtils.S_IRWXG);
assertEquals(JnaUtils.S_IROTH, mode & JnaUtils.S_IRWXO);
-
+
repository.close();
RepositoryCache.close(repository);
@@ -266,13 +266,13 @@ public class JGitUtilsTest {
repository = JGitUtils.createRepository(parent, repositoryUmask, "umask");
folder = FileKey.resolve(new File(parent, repositoryUmask), FS.DETECTED);
assertNotNull(repository);
-
+
assertEquals(null, repository.getConfig().getString("core", null, "sharedRepository"));
-
+
assertTrue(folder.exists());
mode = JnaUtils.getFilemode(folder);
assertEquals(JnaUtils.S_ISGID, mode & JnaUtils.S_ISGID);
-
+
repository.close();
RepositoryCache.close(repository);
}
@@ -372,7 +372,7 @@ public class JGitUtilsTest {
assertEquals("183474d554e6f68478a02d9d7888b67a9338cdff", list.get(0).notesRef
.getReferencedObjectId().getName());
}
-
+
@Test
public void testRelinkHEAD() throws Exception {
Repository repository = GitBlitSuite.getJGitRepository();
@@ -381,7 +381,7 @@ public class JGitUtilsTest {
assertEquals("refs/heads/master", currentRef);
List<String> availableHeads = JGitUtils.getAvailableHeadTargets(repository);
assertTrue(availableHeads.size() > 0);
-
+
// set HEAD to stable-1.2
JGitUtils.setHEADtoRef(repository, "refs/heads/stable-1.2");
currentRef = JGitUtils.getHEADRef(repository);
@@ -391,19 +391,19 @@ public class JGitUtilsTest {
JGitUtils.setHEADtoRef(repository, "refs/heads/master");
currentRef = JGitUtils.getHEADRef(repository);
assertEquals("refs/heads/master", currentRef);
-
+
repository.close();
}
@Test
public void testRelinkBranch() throws Exception {
Repository repository = GitBlitSuite.getJGitRepository();
-
+
// create/set the branch
JGitUtils.setBranchRef(repository, "refs/heads/reftest", "3b358ce514ec655d3ff67de1430994d8428cdb04");
assertEquals(1, JGitUtils.getAllRefs(repository).get(ObjectId.fromString("3b358ce514ec655d3ff67de1430994d8428cdb04")).size());
assertEquals(null, JGitUtils.getAllRefs(repository).get(ObjectId.fromString("755dfdb40948f5c1ec79e06bde3b0a78c352f27f")));
-
+
// reset the branch
JGitUtils.setBranchRef(repository, "refs/heads/reftest", "755dfdb40948f5c1ec79e06bde3b0a78c352f27f");
assertEquals(null, JGitUtils.getAllRefs(repository).get(ObjectId.fromString("3b358ce514ec655d3ff67de1430994d8428cdb04")));
@@ -606,7 +606,7 @@ public class JGitUtilsTest {
assertTrue(zipFileB.length() > 0);
zipFileB.delete();
}
-
+
@Test
public void testPlots() throws Exception {
Repository repository = GitBlitSuite.getTicgitRepository();
diff --git a/src/test/java/com/gitblit/tests/JnaUtilsTest.java b/src/test/java/com/gitblit/tests/JnaUtilsTest.java
index 03c6aead..96782156 100644
--- a/src/test/java/com/gitblit/tests/JnaUtilsTest.java
+++ b/src/test/java/com/gitblit/tests/JnaUtilsTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 gitblit.com.
+ * Copyright 2013 gitblit.com.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/src/test/java/com/gitblit/tests/LdapUserServiceTest.java b/src/test/java/com/gitblit/tests/LdapUserServiceTest.java
index a928f4a5..ae8933ea 100644
--- a/src/test/java/com/gitblit/tests/LdapUserServiceTest.java
+++ b/src/test/java/com/gitblit/tests/LdapUserServiceTest.java
@@ -40,34 +40,34 @@ import com.unboundid.ldif.LDIFReader;
/**
* An Integration test for LDAP that tests going against an in-memory UnboundID
* LDAP server.
- *
+ *
* @author jcrygier
*
*/
public class LdapUserServiceTest {
-
+
private LdapUserService ldapUserService;
-
+
static int ldapPort = 1389;
-
+
@BeforeClass
public static void createInMemoryLdapServer() throws Exception {
InMemoryDirectoryServerConfig config = new InMemoryDirectoryServerConfig("dc=MyDomain");
config.addAdditionalBindCredentials("cn=Directory Manager", "password");
config.setListenerConfigs(InMemoryListenerConfig.createLDAPConfig("default", ldapPort));
config.setSchema(null);
-
+
InMemoryDirectoryServer ds = new InMemoryDirectoryServer(config);
ds.importFromLDIF(true, new LDIFReader(LdapUserServiceTest.class.getResourceAsStream("resources/ldapUserServiceSampleData.ldif")));
ds.startListening();
}
-
+
@Before
public void createLdapUserService() {
ldapUserService = new LdapUserService();
ldapUserService.setup(getSettings());
}
-
+
private MemorySettings getSettings() {
Map<String, Object> backingMap = new HashMap<String, Object>();
backingMap.put("realm.ldap.server", "ldap://localhost:" + ldapPort);
@@ -83,79 +83,79 @@ public class LdapUserServiceTest {
backingMap.put("realm.ldap.admins", "UserThree @Git_Admins \"@Git Admins\"");
backingMap.put("realm.ldap.displayName", "displayName");
backingMap.put("realm.ldap.email", "email");
-
+
MemorySettings ms = new MemorySettings(backingMap);
return ms;
}
-
+
@Test
- public void testAuthenticate() {
+ public void testAuthenticate() {
UserModel userOneModel = ldapUserService.authenticate("UserOne", "userOnePassword".toCharArray());
assertNotNull(userOneModel);
assertNotNull(userOneModel.getTeam("git_admins"));
assertNotNull(userOneModel.getTeam("git_users"));
assertTrue(userOneModel.canAdmin);
-
+
UserModel userOneModelFailedAuth = ldapUserService.authenticate("UserOne", "userTwoPassword".toCharArray());
assertNull(userOneModelFailedAuth);
-
+
UserModel userTwoModel = ldapUserService.authenticate("UserTwo", "userTwoPassword".toCharArray());
assertNotNull(userTwoModel);
assertNotNull(userTwoModel.getTeam("git_users"));
assertNull(userTwoModel.getTeam("git_admins"));
assertNotNull(userTwoModel.getTeam("git admins"));
assertTrue(userTwoModel.canAdmin);
-
+
UserModel userThreeModel = ldapUserService.authenticate("UserThree", "userThreePassword".toCharArray());
assertNotNull(userThreeModel);
assertNotNull(userThreeModel.getTeam("git_users"));
assertNull(userThreeModel.getTeam("git_admins"));
assertTrue(userThreeModel.canAdmin);
}
-
+
@Test
public void testDisplayName() {
UserModel userOneModel = ldapUserService.authenticate("UserOne", "userOnePassword".toCharArray());
assertNotNull(userOneModel);
assertEquals("User One", userOneModel.displayName);
-
+
// Test more complicated scenarios - concat
MemorySettings ms = getSettings();
ms.put("realm.ldap.displayName", "${personalTitle}. ${givenName} ${surname}");
ldapUserService = new LdapUserService();
ldapUserService.setup(ms);
-
+
userOneModel = ldapUserService.authenticate("UserOne", "userOnePassword".toCharArray());
assertNotNull(userOneModel);
assertEquals("Mr. User One", userOneModel.displayName);
}
-
+
@Test
public void testEmail() {
UserModel userOneModel = ldapUserService.authenticate("UserOne", "userOnePassword".toCharArray());
assertNotNull(userOneModel);
assertEquals("userone@gitblit.com", userOneModel.emailAddress);
-
+
// Test more complicated scenarios - concat
MemorySettings ms = getSettings();
ms.put("realm.ldap.email", "${givenName}.${surname}@gitblit.com");
ldapUserService = new LdapUserService();
ldapUserService.setup(ms);
-
+
userOneModel = ldapUserService.authenticate("UserOne", "userOnePassword".toCharArray());
assertNotNull(userOneModel);
assertEquals("User.One@gitblit.com", userOneModel.emailAddress);
}
-
+
@Test
public void testLdapInjection() {
// Inject so "(&(objectClass=person)(sAMAccountName=${username}))" becomes "(&(objectClass=person)(sAMAccountName=*)(userPassword=userOnePassword))"
// Thus searching by password
-
+
UserModel userOneModel = ldapUserService.authenticate("*)(userPassword=userOnePassword", "userOnePassword".toCharArray());
assertNull(userOneModel);
}
-
+
@Test
public void testLocalAccount() {
UserModel localAccount = new UserModel("bruce");
@@ -164,8 +164,8 @@ public class LdapUserServiceTest {
ldapUserService.deleteUser(localAccount.username);
assertTrue("Failed to add local account",
ldapUserService.updateUserModel(localAccount));
- assertEquals("Accounts are not equal!",
- localAccount,
+ assertEquals("Accounts are not equal!",
+ localAccount,
ldapUserService.authenticate(localAccount.username, "gimmesomesugar".toCharArray()));
assertTrue("Failed to delete local account!",
ldapUserService.deleteUser(localAccount.username));
diff --git a/src/test/java/com/gitblit/tests/LuceneExecutorTest.java b/src/test/java/com/gitblit/tests/LuceneExecutorTest.java
index 0b67f5dd..ec25c519 100644
--- a/src/test/java/com/gitblit/tests/LuceneExecutorTest.java
+++ b/src/test/java/com/gitblit/tests/LuceneExecutorTest.java
@@ -39,25 +39,25 @@ import com.gitblit.utils.JGitUtils;
/**
* Tests Lucene indexing and querying.
- *
+ *
* @author James Moger
- *
+ *
*/
public class LuceneExecutorTest {
LuceneExecutor lucene;
-
+
private LuceneExecutor newLuceneExecutor() {
Map<String, Object> map = new HashMap<String, Object>();
- MemorySettings settings = new MemorySettings(map);
+ MemorySettings settings = new MemorySettings(map);
return new LuceneExecutor(settings, GitBlitSuite.REPOSITORIES);
}
-
- private RepositoryModel newRepositoryModel(Repository repository) {
+
+ private RepositoryModel newRepositoryModel(Repository repository) {
RepositoryModel model = new RepositoryModel();
model.name = FileUtils.getRelativePath(GitBlitSuite.REPOSITORIES, repository.getDirectory());
model.hasCommits = JGitUtils.hasCommits(repository);
-
+
// index all local branches
model.indexedBranches = new ArrayList<String>();
for (RefModel ref : JGitUtils.getLocalBranches(repository, true, -1)) {
@@ -65,17 +65,17 @@ public class LuceneExecutorTest {
}
return model;
}
-
+
@Before
public void setup() {
lucene = newLuceneExecutor();
}
-
+
@After
public void tearDown() {
lucene.close();
}
-
+
@Test
public void testIndex() throws Exception {
// reindex helloworld
@@ -83,11 +83,11 @@ public class LuceneExecutorTest {
RepositoryModel model = newRepositoryModel(repository);
lucene.reindex(model, repository);
repository.close();
-
- SearchResult result = lucene.search("type:blob AND path:bit.bit", 1, 1, model.name).get(0);
+
+ SearchResult result = lucene.search("type:blob AND path:bit.bit", 1, 1, model.name).get(0);
assertEquals("Mike Donaghy", result.author);
- result = lucene.search("type:blob AND path:clipper.prg", 1, 1, model.name).get(0);
- assertEquals("tinogomes", result.author);
+ result = lucene.search("type:blob AND path:clipper.prg", 1, 1, model.name).get(0);
+ assertEquals("tinogomes", result.author);
// reindex JGit
repository = GitBlitSuite.getJGitRepository();
@@ -99,10 +99,10 @@ public class LuceneExecutorTest {
@Test
public void testQuery() throws Exception {
// 2 occurrences on the master branch
- Repository repository = GitBlitSuite.getHelloworldRepository();
+ Repository repository = GitBlitSuite.getHelloworldRepository();
RepositoryModel model = newRepositoryModel(repository);
repository.close();
-
+
List<SearchResult> results = lucene.search("ada", 1, 10, model.name);
assertEquals(2, results.size());
for (SearchResult res : results) {
@@ -112,37 +112,37 @@ public class LuceneExecutorTest {
// author test
results = lucene.search("author: tinogomes AND type:commit", 1, 10, model.name);
assertEquals(2, results.size());
-
+
// blob test
results = lucene.search("type: blob AND \"import std.stdio\"", 1, 10, model.name);
assertEquals(1, results.size());
assertEquals("d.D", results.get(0).path);
-
+
// commit test
repository = GitBlitSuite.getJGitRepository();
model = newRepositoryModel(repository);
repository.close();
-
+
results = lucene.search("\"initial jgit contribution to eclipse.org\"", 1, 10, model.name);
assertEquals(1, results.size());
assertEquals("Git Development Community", results.get(0).author);
assertEquals("1a6964c8274c50f0253db75f010d78ef0e739343", results.get(0).commitId);
assertEquals("refs/heads/master", results.get(0).branch);
-
+
// hash id tests
results = lucene.search("type:commit AND commit:1a6964c8274c50f0253db75f010d78ef0e739343", 1, 10, model.name);
assertEquals(1, results.size());
results = lucene.search("type:commit AND commit:1a6964c8274*", 1, 10, model.name);
assertEquals("Shawn O. Pearce", results.get(0).committer);
- assertEquals(1, results.size());
-
+ assertEquals(1, results.size());
+
// annotated tag test
results = lucene.search("I663208919f297836a9c16bf458e4a43ffaca4c12", 1, 10, model.name);
assertEquals(1, results.size());
- assertEquals("[v1.3.0.201202151440-r]", results.get(0).tags.toString());
+ assertEquals("[v1.3.0.201202151440-r]", results.get(0).tags.toString());
}
-
+
@Test
public void testMultiSearch() throws Exception {
List<String> list = new ArrayList<String>();
@@ -157,14 +157,14 @@ public class LuceneExecutorTest {
List<SearchResult> results = lucene.search("test", 1, 10, list);
assertEquals(10, results.size());
}
-
+
@Test
public void testDeleteBlobFromIndex() throws Exception {
// start with a fresh reindex of entire repository
Repository repository = GitBlitSuite.getHelloworldRepository();
RepositoryModel model = newRepositoryModel(repository);
lucene.reindex(model, repository);
-
+
// now delete a blob
assertTrue(lucene.deleteBlob(model.name, "refs/heads/master", "java.java"));
assertFalse(lucene.deleteBlob(model.name, "refs/heads/master", "java.java"));
diff --git a/src/test/java/com/gitblit/tests/ModelUtilsTest.java b/src/test/java/com/gitblit/tests/ModelUtilsTest.java
index 95743bba..9dd29b64 100644
--- a/src/test/java/com/gitblit/tests/ModelUtilsTest.java
+++ b/src/test/java/com/gitblit/tests/ModelUtilsTest.java
@@ -60,10 +60,10 @@ public class ModelUtilsTest {
username = "James";
assertEquals(Constants.DEFAULT_USER_REPOSITORY_PREFIX+username.toLowerCase(), ModelUtils.getPersonalPath(username));
-
+
ModelUtils.setUserRepoPrefix("usr/");
username = "noMan";
- assertEquals("usr/"+username.toLowerCase(), ModelUtils.getPersonalPath(username));
+ assertEquals("usr/"+username.toLowerCase(), ModelUtils.getPersonalPath(username));
}
diff --git a/src/test/java/com/gitblit/tests/PermissionsTest.java b/src/test/java/com/gitblit/tests/PermissionsTest.java
index 12225e42..942811d5 100644
--- a/src/test/java/com/gitblit/tests/PermissionsTest.java
+++ b/src/test/java/com/gitblit/tests/PermissionsTest.java
@@ -29,7 +29,7 @@ import com.gitblit.models.UserModel;
/**
* Comprehensive, brute-force test of all permutations of discrete permissions.
- *
+ *
* @author James Moger
*
*/
@@ -42,45 +42,45 @@ public class PermissionsTest extends Assert {
public void testAdmin() throws Exception {
UserModel user = new UserModel("admin");
user.canAdmin = true;
-
+
for (AccessRestrictionType ar : AccessRestrictionType.values()) {
RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
repository.authorizationControl = AuthorizationControl.NAMED;
repository.accessRestriction = ar;
-
+
assertTrue("admin CAN NOT view!", user.canView(repository));
assertTrue("admin CAN NOT clone!", user.canClone(repository));
assertTrue("admin CAN NOT push!", user.canPush(repository));
-
+
assertTrue("admin CAN NOT create ref!", user.canCreateRef(repository));
assertTrue("admin CAN NOT delete ref!", user.canDeleteRef(repository));
assertTrue("admin CAN NOT rewind ref!", user.canRewindRef(repository));
-
+
assertEquals("admin has wrong permission!", AccessPermission.REWIND, user.getRepositoryPermission(repository).permission);
assertTrue("admin CAN NOT fork!", user.canFork(repository));
-
+
assertTrue("admin CAN NOT delete!", user.canDelete(repository));
assertTrue("admin CAN NOT edit!", user.canEdit(repository));
}
}
-
+
/**
- * Anonymous access rights/permissions
+ * Anonymous access rights/permissions
*/
@Test
public void testAnonymous_NONE() throws Exception {
RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
repository.authorizationControl = AuthorizationControl.NAMED;
repository.accessRestriction = AccessRestrictionType.NONE;
-
+
UserModel user = UserModel.ANONYMOUS;
-
+
// all permissions, except fork
assertTrue("anonymous CAN NOT view!", user.canView(repository));
assertTrue("anonymous CAN NOT clone!", user.canClone(repository));
assertTrue("anonymous CAN NOT push!", user.canPush(repository));
-
+
assertTrue("anonymous CAN NOT create ref!", user.canCreateRef(repository));
assertTrue("anonymous CAN NOT delete ref!", user.canDeleteRef(repository));
assertTrue("anonymous CAN NOT rewind ref!", user.canRewindRef(repository));
@@ -91,11 +91,11 @@ public class PermissionsTest extends Assert {
assertFalse("anonymous CAN fork!", user.canFork(repository));
repository.allowForks = true;
assertFalse("anonymous CAN fork!", user.canFork(repository));
-
+
assertFalse("anonymous CAN delete!", user.canDelete(repository));
assertFalse("anonymous CAN edit!", user.canEdit(repository));
}
-
+
@Test
public void testAnonymous_PUSH() throws Exception {
RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
@@ -107,11 +107,11 @@ public class PermissionsTest extends Assert {
assertTrue("anonymous CAN NOT view!", user.canView(repository));
assertTrue("anonymous CAN NOT clone!", user.canClone(repository));
assertFalse("anonymous CAN push!", user.canPush(repository));
-
+
assertFalse("anonymous CAN create ref!", user.canCreateRef(repository));
assertFalse("anonymous CAN delete ref!", user.canDeleteRef(repository));
assertFalse("anonymous CAN rewind ref!", user.canRewindRef(repository));
-
+
assertEquals("anonymous has wrong permission!", AccessPermission.CLONE, user.getRepositoryPermission(repository).permission);
repository.allowForks = false;
@@ -119,7 +119,7 @@ public class PermissionsTest extends Assert {
repository.allowForks = true;
assertFalse("anonymous CAN fork!", user.canFork(repository));
}
-
+
@Test
public void testAnonymous_CLONE() throws Exception {
RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
@@ -131,7 +131,7 @@ public class PermissionsTest extends Assert {
assertTrue("anonymous CAN NOT view!", user.canView(repository));
assertFalse("anonymous CAN clone!", user.canClone(repository));
assertFalse("anonymous CAN push!", user.canPush(repository));
-
+
assertFalse("anonymous CAN create ref!", user.canCreateRef(repository));
assertFalse("anonymous CAN delete ref!", user.canDeleteRef(repository));
assertFalse("anonymous CAN rewind ref!", user.canRewindRef(repository));
@@ -143,19 +143,19 @@ public class PermissionsTest extends Assert {
repository.allowForks = true;
assertFalse("anonymous CAN fork!", user.canFork(repository));
}
-
+
@Test
public void testAnonymous_VIEW() throws Exception {
RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
repository.authorizationControl = AuthorizationControl.NAMED;
repository.accessRestriction = AccessRestrictionType.VIEW;
-
+
UserModel user = UserModel.ANONYMOUS;
assertFalse("anonymous CAN view!", user.canView(repository));
assertFalse("anonymous CAN clone!", user.canClone(repository));
assertFalse("anonymous CAN push!", user.canPush(repository));
-
+
assertFalse("anonymous CAN create ref!", user.canCreateRef(repository));
assertFalse("anonymous CAN delete ref!", user.canDeleteRef(repository));
assertFalse("anonymous CAN rewind ref!", user.canRewindRef(repository));
@@ -167,23 +167,23 @@ public class PermissionsTest extends Assert {
repository.allowForks = true;
assertFalse("anonymous CAN fork!", user.canFork(repository));
}
-
+
/**
- * Authenticated access rights/permissions
+ * Authenticated access rights/permissions
*/
@Test
public void testAuthenticated_NONE() throws Exception {
RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
repository.authorizationControl = AuthorizationControl.AUTHENTICATED;
repository.accessRestriction = AccessRestrictionType.NONE;
-
+
UserModel user = new UserModel("test");
-
+
// all permissions, except fork
assertTrue("authenticated CAN NOT view!", user.canView(repository));
assertTrue("authenticated CAN NOT clone!", user.canClone(repository));
assertTrue("authenticated CAN NOT push!", user.canPush(repository));
-
+
assertTrue("authenticated CAN NOT create ref!", user.canCreateRef(repository));
assertTrue("authenticated CAN NOT delete ref!", user.canDeleteRef(repository));
assertTrue("authenticated CAN NOT rewind ref!", user.canRewindRef(repository));
@@ -197,7 +197,7 @@ public class PermissionsTest extends Assert {
assertFalse("authenticated CAN fork!", user.canFork(repository));
user.canFork = true;
assertTrue("authenticated CAN NOT fork!", user.canFork(repository));
-
+
assertFalse("authenticated CAN delete!", user.canDelete(repository));
assertFalse("authenticated CAN edit!", user.canEdit(repository));
}
@@ -207,13 +207,13 @@ public class PermissionsTest extends Assert {
RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
repository.authorizationControl = AuthorizationControl.AUTHENTICATED;
repository.accessRestriction = AccessRestrictionType.PUSH;
-
+
UserModel user = new UserModel("test");
assertTrue("authenticated CAN NOT view!", user.canView(repository));
assertTrue("authenticated CAN NOT clone!", user.canClone(repository));
assertTrue("authenticated CAN NOT push!", user.canPush(repository));
-
+
assertTrue("authenticated CAN NOT create ref!", user.canCreateRef(repository));
assertTrue("authenticated CAN NOT delete ref!", user.canDeleteRef(repository));
assertTrue("authenticated CAN NOT rewind ref!", user.canRewindRef(repository));
@@ -228,19 +228,19 @@ public class PermissionsTest extends Assert {
user.canFork = true;
assertTrue("authenticated CAN NOT fork!", user.canFork(repository));
}
-
+
@Test
public void testAuthenticated_CLONE() throws Exception {
RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
repository.authorizationControl = AuthorizationControl.AUTHENTICATED;
repository.accessRestriction = AccessRestrictionType.CLONE;
-
+
UserModel user = new UserModel("test");
assertTrue("authenticated CAN NOT view!", user.canView(repository));
assertTrue("authenticated CAN NOT clone!", user.canClone(repository));
assertTrue("authenticated CAN NOT push!", user.canPush(repository));
-
+
assertTrue("authenticated CAN NOT create ref!", user.canCreateRef(repository));
assertTrue("authenticated CAN NOT delete ref!", user.canDeleteRef(repository));
assertTrue("authenticated CAN NOT rewind ref!", user.canRewindRef(repository));
@@ -255,19 +255,19 @@ public class PermissionsTest extends Assert {
user.canFork = true;
assertTrue("authenticated CAN NOT fork!", user.canFork(repository));
}
-
+
@Test
public void testAuthenticated_VIEW() throws Exception {
RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
repository.authorizationControl = AuthorizationControl.AUTHENTICATED;
repository.accessRestriction = AccessRestrictionType.VIEW;
-
+
UserModel user = new UserModel("test");
assertTrue("authenticated CAN NOT view!", user.canView(repository));
assertTrue("authenticated CAN NOT clone!", user.canClone(repository));
assertTrue("authenticated CAN NOT push!", user.canPush(repository));
-
+
assertTrue("authenticated CAN NOT create ref!", user.canCreateRef(repository));
assertTrue("authenticated CAN NOT delete ref!", user.canDeleteRef(repository));
assertTrue("authenticated CAN NOT rewind ref!", user.canRewindRef(repository));
@@ -282,7 +282,7 @@ public class PermissionsTest extends Assert {
user.canFork = true;
assertTrue("authenticated CAN NOT fork!", user.canFork(repository));
}
-
+
/**
* NONE_NONE = NO access restriction, NO access permission
*/
@@ -293,15 +293,15 @@ public class PermissionsTest extends Assert {
repository.accessRestriction = AccessRestrictionType.NONE;
UserModel user = new UserModel("test");
-
+
assertTrue("named CAN NOT view!", user.canView(repository));
assertTrue("named CAN NOT clone!", user.canClone(repository));
assertTrue("named CAN NOT push!", user.canPush(repository));
-
+
assertTrue("named CAN NOT create ref!", user.canCreateRef(repository));
assertTrue("named CAN NOT delete ref!", user.canDeleteRef(repository));
assertTrue("named CAN NOT rewind ref!", user.canRewindRef(repository));
-
+
assertEquals("named has wrong permission!", AccessPermission.REWIND, user.getRepositoryPermission(repository).permission);
repository.allowForks = false;
@@ -311,11 +311,11 @@ public class PermissionsTest extends Assert {
assertFalse("named CAN fork!", user.canFork(repository));
repository.allowForks = true;
assertTrue("named CAN NOT fork!", user.canFork(repository));
-
+
assertFalse("named CAN delete!", user.canDelete(repository));
assertFalse("named CAN edit!", user.canEdit(repository));
}
-
+
/**
* PUSH_NONE = PUSH access restriction, NO access permission
*/
@@ -324,13 +324,13 @@ public class PermissionsTest extends Assert {
RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
repository.authorizationControl = AuthorizationControl.NAMED;
repository.accessRestriction = AccessRestrictionType.PUSH;
-
+
UserModel user = new UserModel("test");
-
+
assertTrue("named CAN NOT view!", user.canView(repository));
assertTrue("named CAN NOT clone!", user.canClone(repository));
assertFalse("named CAN push!", user.canPush(repository));
-
+
assertFalse("named CAN create ref!", user.canCreateRef(repository));
assertFalse("named CAN delete ref!", user.canDeleteRef(repository));
assertFalse("named CAN rewind ref!", user.canRewindRef(repository));
@@ -345,7 +345,7 @@ public class PermissionsTest extends Assert {
repository.allowForks = true;
assertTrue("named CAN NOT fork!", user.canFork(repository));
}
-
+
/**
* CLONE_NONE = CLONE access restriction, NO access permission
*/
@@ -354,13 +354,13 @@ public class PermissionsTest extends Assert {
RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
repository.authorizationControl = AuthorizationControl.NAMED;
repository.accessRestriction = AccessRestrictionType.CLONE;
-
+
UserModel user = new UserModel("test");
-
+
assertTrue("named CAN NOT view!", user.canView(repository));
assertFalse("named CAN clone!", user.canClone(repository));
assertFalse("named CAN push!", user.canPush(repository));
-
+
assertFalse("named CAN create ref!", user.canCreateRef(repository));
assertFalse("named CAN delete ref!", user.canDeleteRef(repository));
assertFalse("named CAN rewind ref!", user.canRewindRef(repository));
@@ -375,7 +375,7 @@ public class PermissionsTest extends Assert {
repository.allowForks = true;
assertFalse("named CAN NOT fork!", user.canFork(repository));
}
-
+
/**
* VIEW_NONE = VIEW access restriction, NO access permission
*/
@@ -384,17 +384,17 @@ public class PermissionsTest extends Assert {
RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
repository.authorizationControl = AuthorizationControl.NAMED;
repository.accessRestriction = AccessRestrictionType.VIEW;
-
+
UserModel user = new UserModel("test");
-
+
assertFalse("named CAN view!", user.canView(repository));
assertFalse("named CAN clone!", user.canClone(repository));
assertFalse("named CAN push!", user.canPush(repository));
-
+
assertFalse("named CAN create ref!", user.canCreateRef(repository));
assertFalse("named CAN delete ref!", user.canDeleteRef(repository));
assertFalse("named CAN rewind ref!", user.canRewindRef(repository));
-
+
assertEquals("named has wrong permission!", AccessPermission.NONE, user.getRepositoryPermission(repository).permission);
repository.allowForks = false;
@@ -406,7 +406,7 @@ public class PermissionsTest extends Assert {
assertFalse("named CAN NOT fork!", user.canFork(repository));
}
-
+
/**
* NONE_VIEW = NO access restriction, VIEW access permission.
* (not useful scenario)
@@ -419,11 +419,11 @@ public class PermissionsTest extends Assert {
UserModel user = new UserModel("test");
user.setRepositoryPermission(repository.name, AccessPermission.VIEW);
-
+
assertTrue("named CAN NOT view!", user.canView(repository));
assertTrue("named CAN NOT clone!", user.canClone(repository));
assertTrue("named CAN NOT push!", user.canPush(repository));
-
+
assertTrue("named CAN NOT create ref!", user.canCreateRef(repository));
assertTrue("named CAN NOT delete ref!", user.canDeleteRef(repository));
assertTrue("named CAN NOT rewind ref!", user.canRewindRef(repository));
@@ -438,7 +438,7 @@ public class PermissionsTest extends Assert {
repository.allowForks = true;
assertTrue("named CAN NOT fork!", user.canFork(repository));
}
-
+
/**
* PUSH_VIEW = PUSH access restriction, VIEW access permission
*/
@@ -447,14 +447,14 @@ public class PermissionsTest extends Assert {
RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
repository.authorizationControl = AuthorizationControl.NAMED;
repository.accessRestriction = AccessRestrictionType.PUSH;
-
+
UserModel user = new UserModel("test");
user.setRepositoryPermission(repository.name, AccessPermission.VIEW);
-
+
assertTrue("named CAN NOT view!", user.canView(repository));
assertTrue("named CAN NOT clone!", user.canClone(repository));
assertFalse("named CAN push!", user.canPush(repository));
-
+
assertFalse("named CAN create ref!", user.canCreateRef(repository));
assertFalse("named CAN delete ref!", user.canDeleteRef(repository));
assertFalse("named CAN rewind ref!", user.canRewindRef(repository));
@@ -469,7 +469,7 @@ public class PermissionsTest extends Assert {
repository.allowForks = true;
assertTrue("named CAN NOT fork!", user.canFork(repository));
}
-
+
/**
* CLONE_VIEW = CLONE access restriction, VIEW access permission
*/
@@ -478,14 +478,14 @@ public class PermissionsTest extends Assert {
RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
repository.authorizationControl = AuthorizationControl.NAMED;
repository.accessRestriction = AccessRestrictionType.CLONE;
-
+
UserModel user = new UserModel("test");
user.setRepositoryPermission(repository.name, AccessPermission.VIEW);
assertTrue("named CAN NOT view!", user.canView(repository));
assertFalse("named CAN clone!", user.canClone(repository));
assertFalse("named CAN push!", user.canPush(repository));
-
+
assertFalse("named CAN create ref!", user.canCreateRef(repository));
assertFalse("named CAN delete ref!", user.canDeleteRef(repository));
assertFalse("named CAN rewind ref!", user.canRewindRef(repository));
@@ -500,7 +500,7 @@ public class PermissionsTest extends Assert {
repository.allowForks = true;
assertFalse("named CAN NOT fork!", user.canFork(repository));
}
-
+
/**
* VIEW_VIEW = VIEW access restriction, VIEW access permission
*/
@@ -509,18 +509,18 @@ public class PermissionsTest extends Assert {
RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
repository.authorizationControl = AuthorizationControl.NAMED;
repository.accessRestriction = AccessRestrictionType.VIEW;
-
+
UserModel user = new UserModel("test");
user.setRepositoryPermission(repository.name, AccessPermission.VIEW);
assertTrue("named CAN NOT view!", user.canView(repository));
assertFalse("named CAN clone!", user.canClone(repository));
assertFalse("named CAN push!", user.canPush(repository));
-
+
assertFalse("named CAN create ref!", user.canCreateRef(repository));
assertFalse("named CAN delete ref!", user.canDeleteRef(repository));
assertFalse("named CAN rewind ref!", user.canRewindRef(repository));
-
+
assertEquals("named has wrong permission!", AccessPermission.VIEW, user.getRepositoryPermission(repository).permission);
repository.allowForks = false;
@@ -531,7 +531,7 @@ public class PermissionsTest extends Assert {
repository.allowForks = true;
assertFalse("named CAN NOT fork!", user.canFork(repository));
}
-
+
/**
* NONE_CLONE = NO access restriction, CLONE access permission.
* (not useful scenario)
@@ -544,15 +544,15 @@ public class PermissionsTest extends Assert {
UserModel user = new UserModel("test");
user.setRepositoryPermission(repository.name, AccessPermission.CLONE);
-
+
assertTrue("named CAN NOT view!", user.canView(repository));
assertTrue("named CAN NOT clone!", user.canClone(repository));
assertTrue("named CAN NOT push!", user.canPush(repository));
-
+
assertTrue("named CAN NOT create ref!", user.canCreateRef(repository));
assertTrue("named CAN NOT delete ref!", user.canDeleteRef(repository));
assertTrue("named CAN NOT rewind ref!", user.canRewindRef(repository));
-
+
assertEquals("named has wrong permission!", AccessPermission.REWIND, user.getRepositoryPermission(repository).permission);
repository.allowForks = false;
@@ -563,7 +563,7 @@ public class PermissionsTest extends Assert {
repository.allowForks = true;
assertTrue("named CAN NOT fork!", user.canFork(repository));
}
-
+
/**
* PUSH_CLONE = PUSH access restriction, CLONE access permission
*/
@@ -572,14 +572,14 @@ public class PermissionsTest extends Assert {
RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
repository.authorizationControl = AuthorizationControl.NAMED;
repository.accessRestriction = AccessRestrictionType.PUSH;
-
+
UserModel user = new UserModel("test");
user.setRepositoryPermission(repository.name, AccessPermission.CLONE);
-
+
assertTrue("named CAN NOT view!", user.canView(repository));
assertTrue("named CAN NOT clone!", user.canClone(repository));
assertFalse("named CAN push!", user.canPush(repository));
-
+
assertFalse("named CAN create ref!", user.canCreateRef(repository));
assertFalse("named CAN delete ref!", user.canDeleteRef(repository));
assertFalse("named CAN rewind ref!", user.canRewindRef(repository));
@@ -594,7 +594,7 @@ public class PermissionsTest extends Assert {
repository.allowForks = true;
assertTrue("named CAN NOT fork!", user.canFork(repository));
}
-
+
/**
* CLONE_CLONE = CLONE access restriction, CLONE access permission
*/
@@ -603,14 +603,14 @@ public class PermissionsTest extends Assert {
RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
repository.authorizationControl = AuthorizationControl.NAMED;
repository.accessRestriction = AccessRestrictionType.CLONE;
-
+
UserModel user = new UserModel("test");
user.setRepositoryPermission(repository.name, AccessPermission.CLONE);
assertTrue("named CAN NOT view!", user.canView(repository));
assertTrue("named CAN NOT clone!", user.canClone(repository));
assertFalse("named CAN push!", user.canPush(repository));
-
+
assertFalse("named CAN create ref!", user.canCreateRef(repository));
assertFalse("named CAN delete ref!", user.canDeleteRef(repository));
assertFalse("named CAN rewind ref!", user.canRewindRef(repository));
@@ -625,7 +625,7 @@ public class PermissionsTest extends Assert {
repository.allowForks = true;
assertTrue("named CAN NOT fork!", user.canFork(repository));
}
-
+
/**
* VIEW_CLONE = VIEW access restriction, CLONE access permission
*/
@@ -634,18 +634,18 @@ public class PermissionsTest extends Assert {
RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
repository.authorizationControl = AuthorizationControl.NAMED;
repository.accessRestriction = AccessRestrictionType.VIEW;
-
+
UserModel user = new UserModel("test");
user.setRepositoryPermission(repository.name, AccessPermission.CLONE);
assertTrue("named CAN NOT view!", user.canView(repository));
assertTrue("named CAN NOT clone!", user.canClone(repository));
assertFalse("named CAN push!", user.canPush(repository));
-
+
assertFalse("named CAN create ref!", user.canCreateRef(repository));
assertFalse("named CAN delete ref!", user.canDeleteRef(repository));
assertFalse("named CAN rewind ref!", user.canRewindRef(repository));
-
+
assertEquals("named has wrong permission!", AccessPermission.CLONE, user.getRepositoryPermission(repository).permission);
repository.allowForks = false;
@@ -655,7 +655,7 @@ public class PermissionsTest extends Assert {
assertFalse("named CAN fork!", user.canFork(repository));
repository.allowForks = true;
assertTrue("named CAN NOT fork!", user.canFork(repository));
- }
+ }
/**
* NONE_PUSH = NO access restriction, PUSH access permission.
@@ -669,15 +669,15 @@ public class PermissionsTest extends Assert {
UserModel user = new UserModel("test");
user.setRepositoryPermission(repository.name, AccessPermission.PUSH);
-
+
assertTrue("named CAN NOT view!", user.canView(repository));
assertTrue("named CAN NOT clone!", user.canClone(repository));
assertTrue("named CAN NOT push!", user.canPush(repository));
-
+
assertTrue("named CAN NOT create ref!", user.canCreateRef(repository));
assertTrue("named CAN NOT delete ref!", user.canDeleteRef(repository));
assertTrue("named CAN NOT rewind ref!", user.canRewindRef(repository));
-
+
assertEquals("named has wrong permission!", AccessPermission.REWIND, user.getRepositoryPermission(repository).permission);
repository.allowForks = false;
@@ -688,7 +688,7 @@ public class PermissionsTest extends Assert {
repository.allowForks = true;
assertTrue("named CAN NOT fork!", user.canFork(repository));
}
-
+
/**
* PUSH_PUSH = PUSH access restriction, PUSH access permission
*/
@@ -697,14 +697,14 @@ public class PermissionsTest extends Assert {
RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
repository.authorizationControl = AuthorizationControl.NAMED;
repository.accessRestriction = AccessRestrictionType.PUSH;
-
+
UserModel user = new UserModel("test");
user.setRepositoryPermission(repository.name, AccessPermission.PUSH);
-
+
assertTrue("named CAN NOT view!", user.canView(repository));
assertTrue("named CAN NOT clone!", user.canClone(repository));
assertTrue("named CAN NOT push!", user.canPush(repository));
-
+
assertFalse("named CAN create ref!", user.canCreateRef(repository));
assertFalse("named CAN delete ref!", user.canDeleteRef(repository));
assertFalse("named CAN rewind ref!", user.canRewindRef(repository));
@@ -719,7 +719,7 @@ public class PermissionsTest extends Assert {
repository.allowForks = true;
assertTrue("named CAN NOT fork!", user.canFork(repository));
}
-
+
/**
* CLONE_PUSH = CLONE access restriction, PUSH access permission
*/
@@ -728,14 +728,14 @@ public class PermissionsTest extends Assert {
RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
repository.authorizationControl = AuthorizationControl.NAMED;
repository.accessRestriction = AccessRestrictionType.CLONE;
-
+
UserModel user = new UserModel("test");
user.setRepositoryPermission(repository.name, AccessPermission.PUSH);
assertTrue("named CAN NOT view!", user.canView(repository));
assertTrue("named CAN NOT clone!", user.canClone(repository));
assertTrue("named CAN NOT push!", user.canPush(repository));
-
+
assertFalse("named CAN create ref!", user.canCreateRef(repository));
assertFalse("named CAN delete red!", user.canDeleteRef(repository));
assertFalse("named CAN rewind ref!", user.canRewindRef(repository));
@@ -750,7 +750,7 @@ public class PermissionsTest extends Assert {
repository.allowForks = true;
assertTrue("named CAN NOT fork!", user.canFork(repository));
}
-
+
/**
* VIEW_PUSH = VIEW access restriction, PUSH access permission
*/
@@ -759,18 +759,18 @@ public class PermissionsTest extends Assert {
RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
repository.authorizationControl = AuthorizationControl.NAMED;
repository.accessRestriction = AccessRestrictionType.VIEW;
-
+
UserModel user = new UserModel("test");
user.setRepositoryPermission(repository.name, AccessPermission.PUSH);
assertTrue("named CAN NOT view!", user.canView(repository));
assertTrue("named CAN NOT clone!", user.canClone(repository));
assertTrue("named CAN not push!", user.canPush(repository));
-
+
assertFalse("named CAN create ref!", user.canCreateRef(repository));
assertFalse("named CAN delete ref!", user.canDeleteRef(repository));
assertFalse("named CAN rewind ref!", user.canRewindRef(repository));
-
+
assertEquals("named has wrong permission!", AccessPermission.PUSH, user.getRepositoryPermission(repository).permission);
repository.allowForks = false;
@@ -794,15 +794,15 @@ public class PermissionsTest extends Assert {
UserModel user = new UserModel("test");
user.setRepositoryPermission(repository.name, AccessPermission.CREATE);
-
+
assertTrue("named CAN NOT view!", user.canView(repository));
assertTrue("named CAN NOT clone!", user.canClone(repository));
assertTrue("named CAN NOT push!", user.canPush(repository));
-
+
assertTrue("named CAN NOT create ref!", user.canCreateRef(repository));
assertTrue("named CAN NOT delete ref!", user.canDeleteRef(repository));
assertTrue("named CAN NOT rewind ref!", user.canRewindRef(repository));
-
+
assertEquals("named has wrong permission!", AccessPermission.REWIND, user.getRepositoryPermission(repository).permission);
repository.allowForks = false;
@@ -813,7 +813,7 @@ public class PermissionsTest extends Assert {
repository.allowForks = true;
assertTrue("named CAN NOT fork!", user.canFork(repository));
}
-
+
/**
* PUSH_CREATE = PUSH access restriction, CREATE access permission
*/
@@ -822,14 +822,14 @@ public class PermissionsTest extends Assert {
RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
repository.authorizationControl = AuthorizationControl.NAMED;
repository.accessRestriction = AccessRestrictionType.PUSH;
-
+
UserModel user = new UserModel("test");
user.setRepositoryPermission(repository.name, AccessPermission.CREATE);
-
+
assertTrue("named CAN NOT view!", user.canView(repository));
assertTrue("named CAN NOT clone!", user.canClone(repository));
assertTrue("named CAN NOT push!", user.canPush(repository));
-
+
assertTrue("named CAN NOT create ref!", user.canCreateRef(repository));
assertFalse("named CAN delete ref!", user.canDeleteRef(repository));
assertFalse("named CAN rewind ref!", user.canRewindRef(repository));
@@ -844,7 +844,7 @@ public class PermissionsTest extends Assert {
repository.allowForks = true;
assertTrue("named CAN NOT fork!", user.canFork(repository));
}
-
+
/**
* CLONE_CREATE = CLONE access restriction, CREATE access permission
*/
@@ -853,14 +853,14 @@ public class PermissionsTest extends Assert {
RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
repository.authorizationControl = AuthorizationControl.NAMED;
repository.accessRestriction = AccessRestrictionType.CLONE;
-
+
UserModel user = new UserModel("test");
user.setRepositoryPermission(repository.name, AccessPermission.CREATE);
assertTrue("named CAN NOT view!", user.canView(repository));
assertTrue("named CAN NOT clone!", user.canClone(repository));
assertTrue("named CAN NOT push!", user.canPush(repository));
-
+
assertTrue("named CAN NOT create ref!", user.canCreateRef(repository));
assertFalse("named CAN delete red!", user.canDeleteRef(repository));
assertFalse("named CAN rewind ref!", user.canRewindRef(repository));
@@ -875,7 +875,7 @@ public class PermissionsTest extends Assert {
repository.allowForks = true;
assertTrue("named CAN NOT fork!", user.canFork(repository));
}
-
+
/**
* VIEW_CREATE = VIEW access restriction, CREATE access permission
*/
@@ -884,18 +884,18 @@ public class PermissionsTest extends Assert {
RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
repository.authorizationControl = AuthorizationControl.NAMED;
repository.accessRestriction = AccessRestrictionType.VIEW;
-
+
UserModel user = new UserModel("test");
user.setRepositoryPermission(repository.name, AccessPermission.CREATE);
assertTrue("named CAN NOT view!", user.canView(repository));
assertTrue("named CAN NOT clone!", user.canClone(repository));
assertTrue("named CAN not push!", user.canPush(repository));
-
+
assertTrue("named CAN NOT create ref!", user.canCreateRef(repository));
assertFalse("named CAN delete ref!", user.canDeleteRef(repository));
assertFalse("named CAN rewind ref!", user.canRewindRef(repository));
-
+
assertEquals("named has wrong permission!", AccessPermission.CREATE, user.getRepositoryPermission(repository).permission);
repository.allowForks = false;
@@ -919,15 +919,15 @@ public class PermissionsTest extends Assert {
UserModel user = new UserModel("test");
user.setRepositoryPermission(repository.name, AccessPermission.DELETE);
-
+
assertTrue("named CAN NOT view!", user.canView(repository));
assertTrue("named CAN NOT clone!", user.canClone(repository));
assertTrue("named CAN NOT push!", user.canPush(repository));
-
+
assertTrue("named CAN NOT create ref!", user.canCreateRef(repository));
assertTrue("named CAN NOT delete ref!", user.canDeleteRef(repository));
assertTrue("named CAN NOT rewind ref!", user.canRewindRef(repository));
-
+
assertEquals("named has wrong permission!", AccessPermission.REWIND, user.getRepositoryPermission(repository).permission);
repository.allowForks = false;
@@ -938,7 +938,7 @@ public class PermissionsTest extends Assert {
repository.allowForks = true;
assertTrue("named CAN NOT fork!", user.canFork(repository));
}
-
+
/**
* PUSH_DELETE = PUSH access restriction, DELETE access permission
*/
@@ -947,14 +947,14 @@ public class PermissionsTest extends Assert {
RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
repository.authorizationControl = AuthorizationControl.NAMED;
repository.accessRestriction = AccessRestrictionType.PUSH;
-
+
UserModel user = new UserModel("test");
user.setRepositoryPermission(repository.name, AccessPermission.DELETE);
-
+
assertTrue("named CAN NOT view!", user.canView(repository));
assertTrue("named CAN NOT clone!", user.canClone(repository));
assertTrue("named CAN NOT push!", user.canPush(repository));
-
+
assertTrue("named CAN NOT create ref!", user.canCreateRef(repository));
assertTrue("named CAN NOT delete ref!", user.canDeleteRef(repository));
assertFalse("named CAN rewind ref!", user.canRewindRef(repository));
@@ -969,7 +969,7 @@ public class PermissionsTest extends Assert {
repository.allowForks = true;
assertTrue("named CAN NOT fork!", user.canFork(repository));
}
-
+
/**
* CLONE_DELETE = CLONE access restriction, DELETE access permission
*/
@@ -978,14 +978,14 @@ public class PermissionsTest extends Assert {
RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
repository.authorizationControl = AuthorizationControl.NAMED;
repository.accessRestriction = AccessRestrictionType.CLONE;
-
+
UserModel user = new UserModel("test");
user.setRepositoryPermission(repository.name, AccessPermission.DELETE);
assertTrue("named CAN NOT view!", user.canView(repository));
assertTrue("named CAN NOT clone!", user.canClone(repository));
assertTrue("named CAN NOT push!", user.canPush(repository));
-
+
assertTrue("named CAN NOT create ref!", user.canCreateRef(repository));
assertTrue("named CAN NOT delete red!", user.canDeleteRef(repository));
assertFalse("named CAN rewind ref!", user.canRewindRef(repository));
@@ -1000,7 +1000,7 @@ public class PermissionsTest extends Assert {
repository.allowForks = true;
assertTrue("named CAN NOT fork!", user.canFork(repository));
}
-
+
/**
* VIEW_DELETE = VIEW access restriction, DELETE access permission
*/
@@ -1009,18 +1009,18 @@ public class PermissionsTest extends Assert {
RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
repository.authorizationControl = AuthorizationControl.NAMED;
repository.accessRestriction = AccessRestrictionType.VIEW;
-
+
UserModel user = new UserModel("test");
user.setRepositoryPermission(repository.name, AccessPermission.DELETE);
assertTrue("named CAN NOT view!", user.canView(repository));
assertTrue("named CAN NOT clone!", user.canClone(repository));
assertTrue("named CAN not push!", user.canPush(repository));
-
+
assertTrue("named CAN NOT create ref!", user.canCreateRef(repository));
assertTrue("named CAN NOT delete ref!", user.canDeleteRef(repository));
assertFalse("named CAN rewind ref!", user.canRewindRef(repository));
-
+
assertEquals("named has wrong permission!", AccessPermission.DELETE, user.getRepositoryPermission(repository).permission);
repository.allowForks = false;
@@ -1031,7 +1031,7 @@ public class PermissionsTest extends Assert {
repository.allowForks = true;
assertTrue("named CAN NOT fork!", user.canFork(repository));
}
-
+
/**
* NONE_REWIND = NO access restriction, REWIND access permission.
* (not useful scenario)
@@ -1044,15 +1044,15 @@ public class PermissionsTest extends Assert {
UserModel user = new UserModel("test");
user.setRepositoryPermission(repository.name, AccessPermission.REWIND);
-
+
assertTrue("named CAN NOT view!", user.canView(repository));
assertTrue("named CAN NOT clone!", user.canClone(repository));
assertTrue("named CAN NOT push!", user.canPush(repository));
-
+
assertTrue("named CAN NOT create ref!", user.canCreateRef(repository));
assertTrue("named CAN NOT delete ref!", user.canDeleteRef(repository));
assertTrue("named CAN NOT rewind ref!", user.canRewindRef(repository));
-
+
assertEquals("named has wrong permission!", AccessPermission.REWIND, user.getRepositoryPermission(repository).permission);
repository.allowForks = false;
@@ -1063,7 +1063,7 @@ public class PermissionsTest extends Assert {
repository.allowForks = true;
assertTrue("named CAN NOT fork!", user.canFork(repository));
}
-
+
/**
* PUSH_REWIND = PUSH access restriction, REWIND access permission
*/
@@ -1072,14 +1072,14 @@ public class PermissionsTest extends Assert {
RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
repository.authorizationControl = AuthorizationControl.NAMED;
repository.accessRestriction = AccessRestrictionType.PUSH;
-
+
UserModel user = new UserModel("test");
user.setRepositoryPermission(repository.name, AccessPermission.REWIND);
-
+
assertTrue("named CAN NOT view!", user.canView(repository));
assertTrue("named CAN NOT clone!", user.canClone(repository));
assertTrue("named CAN NOT push!", user.canPush(repository));
-
+
assertTrue("named CAN NOT create ref!", user.canCreateRef(repository));
assertTrue("named CAN NOT delete ref!", user.canDeleteRef(repository));
assertTrue("named CAN NOT rewind ref!", user.canRewindRef(repository));
@@ -1094,7 +1094,7 @@ public class PermissionsTest extends Assert {
repository.allowForks = true;
assertTrue("named CAN NOT fork!", user.canFork(repository));
}
-
+
/**
* CLONE_REWIND = CLONE access restriction, REWIND access permission
*/
@@ -1103,14 +1103,14 @@ public class PermissionsTest extends Assert {
RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
repository.authorizationControl = AuthorizationControl.NAMED;
repository.accessRestriction = AccessRestrictionType.CLONE;
-
+
UserModel user = new UserModel("test");
user.setRepositoryPermission(repository.name, AccessPermission.REWIND);
assertTrue("named CAN NOT view!", user.canView(repository));
assertTrue("named CAN NOT clone!", user.canClone(repository));
assertTrue("named CAN NOT push!", user.canPush(repository));
-
+
assertTrue("named CAN NOT create ref!", user.canCreateRef(repository));
assertTrue("named CAN NOT delete ref!", user.canDeleteRef(repository));
assertTrue("named CAN NOT rewind ref!", user.canRewindRef(repository));
@@ -1125,7 +1125,7 @@ public class PermissionsTest extends Assert {
repository.allowForks = true;
assertTrue("named CAN NOT fork!", user.canFork(repository));
}
-
+
/**
* VIEW_REWIND = VIEW access restriction, REWIND access permission
*/
@@ -1134,18 +1134,18 @@ public class PermissionsTest extends Assert {
RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
repository.authorizationControl = AuthorizationControl.NAMED;
repository.accessRestriction = AccessRestrictionType.VIEW;
-
+
UserModel user = new UserModel("test");
user.setRepositoryPermission(repository.name, AccessPermission.REWIND);
assertTrue("named CAN NOT view!", user.canView(repository));
assertTrue("named CAN NOT clone!", user.canClone(repository));
assertTrue("named CAN NOT push!", user.canPush(repository));
-
+
assertTrue("named CAN NOT create ref!", user.canCreateRef(repository));
assertTrue("named CAN NOT delete ref!", user.canDeleteRef(repository));
assertTrue("named CAN NOT rewind ref!", user.canRewindRef(repository));
-
+
assertEquals("named has wrong permission!", AccessPermission.REWIND, user.getRepositoryPermission(repository).permission);
repository.allowForks = false;
@@ -1156,7 +1156,7 @@ public class PermissionsTest extends Assert {
repository.allowForks = true;
assertTrue("named CAN NOT fork!", user.canFork(repository));
}
-
+
/**
* NONE_NONE = NO access restriction, NO access permission
*/
@@ -1167,19 +1167,19 @@ public class PermissionsTest extends Assert {
repository.accessRestriction = AccessRestrictionType.NONE;
TeamModel team = new TeamModel("test");
-
+
assertTrue("team CAN NOT view!", team.canView(repository));
assertTrue("team CAN NOT clone!", team.canClone(repository));
assertTrue("team CAN NOT push!", team.canPush(repository));
-
+
assertTrue("team CAN NOT create ref!", team.canCreateRef(repository));
assertTrue("team CAN NOT delete ref!", team.canDeleteRef(repository));
assertTrue("team CAN NOT rewind ref!", team.canRewindRef(repository));
-
+
assertEquals("team has wrong permission!", AccessPermission.REWIND, team.getRepositoryPermission(repository).permission);
}
-
+
/**
* PUSH_NONE = PUSH access restriction, NO access permission
*/
@@ -1190,15 +1190,15 @@ public class PermissionsTest extends Assert {
repository.accessRestriction = AccessRestrictionType.PUSH;
TeamModel team = new TeamModel("test");
-
+
assertTrue("team CAN NOT view!", team.canView(repository));
assertTrue("team CAN NOT clone!", team.canClone(repository));
assertFalse("team CAN push!", team.canPush(repository));
-
+
assertFalse("team CAN create ref!", team.canCreateRef(repository));
assertFalse("team CAN delete ref!", team.canDeleteRef(repository));
assertFalse("team CAN rewind ref!", team.canRewindRef(repository));
-
+
assertEquals("team has wrong permission!", AccessPermission.CLONE, team.getRepositoryPermission(repository).permission);
}
@@ -1213,15 +1213,15 @@ public class PermissionsTest extends Assert {
repository.accessRestriction = AccessRestrictionType.CLONE;
TeamModel team = new TeamModel("test");
-
+
assertTrue("team CAN NOT view!", team.canView(repository));
assertFalse("team CAN clone!", team.canClone(repository));
assertFalse("team CAN push!", team.canPush(repository));
-
+
assertFalse("team CAN create ref!", team.canCreateRef(repository));
assertFalse("team CAN delete ref!", team.canDeleteRef(repository));
assertFalse("team CAN rewind ref!", team.canRewindRef(repository));
-
+
assertEquals("team has wrong permission!", AccessPermission.VIEW, team.getRepositoryPermission(repository).permission);
}
@@ -1235,18 +1235,18 @@ public class PermissionsTest extends Assert {
repository.accessRestriction = AccessRestrictionType.VIEW;
TeamModel team = new TeamModel("test");
-
+
assertFalse("team CAN view!", team.canView(repository));
assertFalse("team CAN clone!", team.canClone(repository));
assertFalse("team CAN push!", team.canPush(repository));
-
+
assertFalse("team CAN create ref!", team.canCreateRef(repository));
assertFalse("team CAN delete ref!", team.canDeleteRef(repository));
assertFalse("team CAN rewind ref!", team.canRewindRef(repository));
-
+
assertEquals("team has wrong permission!", AccessPermission.NONE, team.getRepositoryPermission(repository).permission);
}
-
+
/**
* NONE_PUSH = NO access restriction, PUSH access permission
* (not useful scenario)
@@ -1259,18 +1259,18 @@ public class PermissionsTest extends Assert {
TeamModel team = new TeamModel("test");
team.setRepositoryPermission(repository.name, AccessPermission.PUSH);
-
+
assertTrue("team CAN NOT view!", team.canView(repository));
assertTrue("team CAN NOT clone!", team.canClone(repository));
assertTrue("team CAN NOT push!", team.canPush(repository));
-
+
assertTrue("team CAN NOT create ref!", team.canCreateRef(repository));
assertTrue("team CAN NOT delete ref!", team.canDeleteRef(repository));
assertTrue("team CAN NOT rewind ref!", team.canRewindRef(repository));
-
+
assertEquals("team has wrong permission!", AccessPermission.REWIND, team.getRepositoryPermission(repository).permission);
}
-
+
/**
* PUSH_PUSH = PUSH access restriction, PUSH access permission
*/
@@ -1282,18 +1282,18 @@ public class PermissionsTest extends Assert {
TeamModel team = new TeamModel("test");
team.setRepositoryPermission(repository.name, AccessPermission.PUSH);
-
+
assertTrue("team CAN NOT view!", team.canView(repository));
assertTrue("team CAN NOT clone!", team.canClone(repository));
assertTrue("team CAN NOT push!", team.canPush(repository));
-
+
assertFalse("team CAN create ref!", team.canCreateRef(repository));
assertFalse("team CAN delete ref!", team.canDeleteRef(repository));
assertFalse("team CAN rewind ref!", team.canRewindRef(repository));
-
+
assertEquals("team has wrong permission!", AccessPermission.PUSH, team.getRepositoryPermission(repository).permission);
}
-
+
/**
* CLONE_PUSH = CLONE access restriction, PUSH access permission
*/
@@ -1305,18 +1305,18 @@ public class PermissionsTest extends Assert {
TeamModel team = new TeamModel("test");
team.setRepositoryPermission(repository.name, AccessPermission.PUSH);
-
+
assertTrue("team CAN NOT view!", team.canView(repository));
assertTrue("team CAN NOT clone!", team.canClone(repository));
assertTrue("team CAN NOT push!", team.canPush(repository));
-
+
assertFalse("team CAN create ref!", team.canCreateRef(repository));
assertFalse("team CAN delete ref!", team.canDeleteRef(repository));
assertFalse("team CAN rewind ref!", team.canRewindRef(repository));
-
+
assertEquals("team has wrong permission!", AccessPermission.PUSH, team.getRepositoryPermission(repository).permission);
}
-
+
/**
* VIEW_PUSH = VIEW access restriction, PUSH access permission
*/
@@ -1328,18 +1328,18 @@ public class PermissionsTest extends Assert {
TeamModel team = new TeamModel("test");
team.setRepositoryPermission(repository.name, AccessPermission.PUSH);
-
+
assertTrue("team CAN NOT view!", team.canView(repository));
assertTrue("team CAN NOT clone!", team.canClone(repository));
assertTrue("team CAN NOT push!", team.canPush(repository));
-
+
assertFalse("team CAN create ref!", team.canCreateRef(repository));
assertFalse("team CAN delete ref!", team.canDeleteRef(repository));
assertFalse("team CAN rewind ref!", team.canRewindRef(repository));
assertEquals("team has wrong permission!", AccessPermission.PUSH, team.getRepositoryPermission(repository).permission);
}
-
+
/**
* NONE_CREATE = NO access restriction, CREATE access permission
* (not useful scenario)
@@ -1352,18 +1352,18 @@ public class PermissionsTest extends Assert {
TeamModel team = new TeamModel("test");
team.setRepositoryPermission(repository.name, AccessPermission.CREATE);
-
+
assertTrue("team CAN NOT view!", team.canView(repository));
assertTrue("team CAN NOT clone!", team.canClone(repository));
assertTrue("team CAN NOT push!", team.canPush(repository));
-
+
assertTrue("team CAN NOT create ref!", team.canCreateRef(repository));
assertTrue("team CAN NOT delete ref!", team.canDeleteRef(repository));
assertTrue("team CAN NOT rewind ref!", team.canRewindRef(repository));
assertEquals("team has wrong permission!", AccessPermission.REWIND, team.getRepositoryPermission(repository).permission);
}
-
+
/**
* PUSH_CREATE = PUSH access restriction, CREATE access permission
*/
@@ -1375,18 +1375,18 @@ public class PermissionsTest extends Assert {
TeamModel team = new TeamModel("test");
team.setRepositoryPermission(repository.name, AccessPermission.CREATE);
-
+
assertTrue("team CAN NOT view!", team.canView(repository));
assertTrue("team CAN NOT clone!", team.canClone(repository));
assertTrue("team CAN NOT push!", team.canPush(repository));
-
+
assertTrue("team CAN NOT create ref!", team.canCreateRef(repository));
assertFalse("team CAN delete ref!", team.canDeleteRef(repository));
assertFalse("team CAN rewind ref!", team.canRewindRef(repository));
assertEquals("team has wrong permission!", AccessPermission.CREATE, team.getRepositoryPermission(repository).permission);
}
-
+
/**
* CLONE_CREATE = CLONE access restriction, CREATE access permission
*/
@@ -1398,18 +1398,18 @@ public class PermissionsTest extends Assert {
TeamModel team = new TeamModel("test");
team.setRepositoryPermission(repository.name, AccessPermission.CREATE);
-
+
assertTrue("team CAN NOT view!", team.canView(repository));
assertTrue("team CAN NOT clone!", team.canClone(repository));
assertTrue("team CAN NOT push!", team.canPush(repository));
-
+
assertTrue("team CAN NOT create ref!", team.canCreateRef(repository));
assertFalse("team CAN delete ref!", team.canDeleteRef(repository));
assertFalse("team CAN rewind ref!", team.canRewindRef(repository));
assertEquals("team has wrong permission!", AccessPermission.CREATE, team.getRepositoryPermission(repository).permission);
}
-
+
/**
* VIEW_CREATE = VIEW access restriction, CREATE access permission
*/
@@ -1421,11 +1421,11 @@ public class PermissionsTest extends Assert {
TeamModel team = new TeamModel("test");
team.setRepositoryPermission(repository.name, AccessPermission.CREATE);
-
+
assertTrue("team CAN NOT view!", team.canView(repository));
assertTrue("team CAN NOT clone!", team.canClone(repository));
assertTrue("team CAN NOT push!", team.canPush(repository));
-
+
assertTrue("team CAN NOT create ref!", team.canCreateRef(repository));
assertFalse("team CAN delete ref!", team.canDeleteRef(repository));
assertFalse("team CAN rewind ref!", team.canRewindRef(repository));
@@ -1445,18 +1445,18 @@ public class PermissionsTest extends Assert {
TeamModel team = new TeamModel("test");
team.setRepositoryPermission(repository.name, AccessPermission.DELETE);
-
+
assertTrue("team CAN NOT view!", team.canView(repository));
assertTrue("team CAN NOT clone!", team.canClone(repository));
assertTrue("team CAN NOT push!", team.canPush(repository));
-
+
assertTrue("team CAN NOT create ref!", team.canCreateRef(repository));
assertTrue("team CAN NOT delete ref!", team.canDeleteRef(repository));
assertTrue("team CAN NOT rewind ref!", team.canRewindRef(repository));
assertEquals("team has wrong permission!", AccessPermission.REWIND, team.getRepositoryPermission(repository).permission);
}
-
+
/**
* PUSH_DELETE = PUSH access restriction, DELETE access permission
*/
@@ -1468,18 +1468,18 @@ public class PermissionsTest extends Assert {
TeamModel team = new TeamModel("test");
team.setRepositoryPermission(repository.name, AccessPermission.DELETE);
-
+
assertTrue("team CAN NOT view!", team.canView(repository));
assertTrue("team CAN NOT clone!", team.canClone(repository));
assertTrue("team CAN NOT push!", team.canPush(repository));
-
+
assertTrue("team CAN NOT create ref!", team.canCreateRef(repository));
assertTrue("team CAN NOT delete ref!", team.canDeleteRef(repository));
assertFalse("team CAN rewind ref!", team.canRewindRef(repository));
assertEquals("team has wrong permission!", AccessPermission.DELETE, team.getRepositoryPermission(repository).permission);
}
-
+
/**
* CLONE_DELETE = CLONE access restriction, DELETE access permission
*/
@@ -1491,18 +1491,18 @@ public class PermissionsTest extends Assert {
TeamModel team = new TeamModel("test");
team.setRepositoryPermission(repository.name, AccessPermission.DELETE);
-
+
assertTrue("team CAN NOT view!", team.canView(repository));
assertTrue("team CAN NOT clone!", team.canClone(repository));
assertTrue("team CAN NOT push!", team.canPush(repository));
-
+
assertTrue("team CAN NOT create ref!", team.canCreateRef(repository));
assertTrue("team CAN NOT delete ref!", team.canDeleteRef(repository));
assertFalse("team CAN rewind ref!", team.canRewindRef(repository));
-
+
assertEquals("team has wrong permission!", AccessPermission.DELETE, team.getRepositoryPermission(repository).permission);
}
-
+
/**
* VIEW_DELETE = VIEW access restriction, DELETE access permission
*/
@@ -1514,18 +1514,18 @@ public class PermissionsTest extends Assert {
TeamModel team = new TeamModel("test");
team.setRepositoryPermission(repository.name, AccessPermission.DELETE);
-
+
assertTrue("team CAN NOT view!", team.canView(repository));
assertTrue("team CAN NOT clone!", team.canClone(repository));
assertTrue("team CAN NOT push!", team.canPush(repository));
-
+
assertTrue("team CAN NOT create ref!", team.canCreateRef(repository));
assertTrue("team CAN NOT delete ref!", team.canDeleteRef(repository));
assertFalse("team CAN rewind ref!", team.canRewindRef(repository));
assertEquals("team has wrong permission!", AccessPermission.DELETE, team.getRepositoryPermission(repository).permission);
}
-
+
/**
* NONE_REWIND = NO access restriction, REWIND access permission
* (not useful scenario)
@@ -1538,18 +1538,18 @@ public class PermissionsTest extends Assert {
TeamModel team = new TeamModel("test");
team.setRepositoryPermission(repository.name, AccessPermission.REWIND);
-
+
assertTrue("team CAN NOT view!", team.canView(repository));
assertTrue("team CAN NOT clone!", team.canClone(repository));
assertTrue("team CAN NOT push!", team.canPush(repository));
-
+
assertTrue("team CAN NOT create ref!", team.canCreateRef(repository));
assertTrue("team CAN NOT delete ref!", team.canDeleteRef(repository));
assertTrue("team CAN NOT rewind ref!", team.canRewindRef(repository));
assertEquals("team has wrong permission!", AccessPermission.REWIND, team.getRepositoryPermission(repository).permission);
}
-
+
/**
* PUSH_REWIND = PUSH access restriction, REWIND access permission
*/
@@ -1561,18 +1561,18 @@ public class PermissionsTest extends Assert {
TeamModel team = new TeamModel("test");
team.setRepositoryPermission(repository.name, AccessPermission.REWIND);
-
+
assertTrue("team CAN NOT view!", team.canView(repository));
assertTrue("team CAN NOT clone!", team.canClone(repository));
assertTrue("team CAN NOT push!", team.canPush(repository));
-
+
assertTrue("team CAN NOT create ref!", team.canCreateRef(repository));
assertTrue("team CAN NOT delete ref!", team.canDeleteRef(repository));
assertTrue("team CAN NOT rewind ref!", team.canRewindRef(repository));
assertEquals("team has wrong permission!", AccessPermission.REWIND, team.getRepositoryPermission(repository).permission);
}
-
+
/**
* CLONE_REWIND = CLONE access restriction, REWIND access permission
*/
@@ -1584,18 +1584,18 @@ public class PermissionsTest extends Assert {
TeamModel team = new TeamModel("test");
team.setRepositoryPermission(repository.name, AccessPermission.REWIND);
-
+
assertTrue("team CAN NOT view!", team.canView(repository));
assertTrue("team CAN NOT clone!", team.canClone(repository));
assertTrue("team CAN NOT push!", team.canPush(repository));
-
+
assertTrue("team CAN NOT create ref!", team.canCreateRef(repository));
assertTrue("team CAN NOT delete ref!", team.canDeleteRef(repository));
assertTrue("team CAN NOT rewind ref!", team.canRewindRef(repository));
assertEquals("team has wrong permission!", AccessPermission.REWIND, team.getRepositoryPermission(repository).permission);
}
-
+
/**
* VIEW_REWIND = VIEW access restriction, REWIND access permission
*/
@@ -1607,18 +1607,18 @@ public class PermissionsTest extends Assert {
TeamModel team = new TeamModel("test");
team.setRepositoryPermission(repository.name, AccessPermission.REWIND);
-
+
assertTrue("team CAN NOT view!", team.canView(repository));
assertTrue("team CAN NOT clone!", team.canClone(repository));
assertTrue("team CAN NOT push!", team.canPush(repository));
-
+
assertTrue("team CAN NOT create ref!", team.canCreateRef(repository));
assertTrue("team CAN NOT delete ref!", team.canDeleteRef(repository));
assertTrue("team CAN NOT rewind ref!", team.canRewindRef(repository));
assertEquals("team has wrong permission!", AccessPermission.REWIND, team.getRepositoryPermission(repository).permission);
}
-
+
/**
* NONE_CLONE = NO access restriction, CLONE access permission
* (not useful scenario)
@@ -1631,11 +1631,11 @@ public class PermissionsTest extends Assert {
TeamModel team = new TeamModel("test");
team.setRepositoryPermission(repository.name, AccessPermission.CLONE);
-
+
assertTrue("team CAN NOT view!", team.canView(repository));
assertTrue("team CAN NOT clone!", team.canClone(repository));
assertTrue("team CAN NOT push!", team.canPush(repository));
-
+
assertTrue("team CAN NOT create ref!", team.canCreateRef(repository));
assertTrue("team CAN NOT delete ref!", team.canDeleteRef(repository));
assertTrue("team CAN NOT rewind ref!", team.canRewindRef(repository));
@@ -1654,11 +1654,11 @@ public class PermissionsTest extends Assert {
TeamModel team = new TeamModel("test");
team.setRepositoryPermission(repository.name, AccessPermission.CLONE);
-
+
assertTrue("team CAN NOT view!", team.canView(repository));
assertTrue("team CAN NOT clone!", team.canClone(repository));
assertFalse("team CAN push!", team.canPush(repository));
-
+
assertFalse("team CAN create ref!", team.canCreateRef(repository));
assertFalse("team CAN delete ref!", team.canDeleteRef(repository));
assertFalse("team CAN rewind ref!", team.canRewindRef(repository));
@@ -1677,18 +1677,18 @@ public class PermissionsTest extends Assert {
TeamModel team = new TeamModel("test");
team.setRepositoryPermission(repository.name, AccessPermission.CLONE);
-
+
assertTrue("team CAN NOT view!", team.canView(repository));
assertTrue("team CAN NOT clone!", team.canClone(repository));
assertFalse("team CAN push!", team.canPush(repository));
-
+
assertFalse("team CAN create ref!", team.canCreateRef(repository));
assertFalse("team CAN delete ref!", team.canDeleteRef(repository));
assertFalse("team CAN rewind ref!", team.canRewindRef(repository));
assertEquals("team has wrong permission!", AccessPermission.CLONE, team.getRepositoryPermission(repository).permission);
}
-
+
/**
* VIEW_CLONE = VIEW access restriction, CLONE access permission
*/
@@ -1700,11 +1700,11 @@ public class PermissionsTest extends Assert {
TeamModel team = new TeamModel("test");
team.setRepositoryPermission(repository.name, AccessPermission.CLONE);
-
+
assertTrue("team CAN NOT view!", team.canView(repository));
assertTrue("team CAN NOT clone!", team.canClone(repository));
assertFalse("team CAN push!", team.canPush(repository));
-
+
assertFalse("team CAN create ref!", team.canCreateRef(repository));
assertFalse("team CAN delete ref!", team.canDeleteRef(repository));
assertFalse("team CAN rewind ref!", team.canRewindRef(repository));
@@ -1724,11 +1724,11 @@ public class PermissionsTest extends Assert {
TeamModel team = new TeamModel("test");
team.setRepositoryPermission(repository.name, AccessPermission.VIEW);
-
+
assertTrue("team CAN NOT view!", team.canView(repository));
assertTrue("team CAN NOT clone!", team.canClone(repository));
assertTrue("team CAN NOT push!", team.canPush(repository));
-
+
assertTrue("team CAN NOT create ref!", team.canCreateRef(repository));
assertTrue("team CAN NOT delete ref!", team.canDeleteRef(repository));
assertTrue("team CAN NOT rewind ref!", team.canRewindRef(repository));
@@ -1747,18 +1747,18 @@ public class PermissionsTest extends Assert {
TeamModel team = new TeamModel("test");
team.setRepositoryPermission(repository.name, AccessPermission.VIEW);
-
+
assertTrue("team CAN NOT view!", team.canView(repository));
assertTrue("team CAN NOT clone!", team.canClone(repository));
assertFalse("team CAN push!", team.canPush(repository));
-
+
assertFalse("team CAN create ref!", team.canCreateRef(repository));
assertFalse("team CAN delete ref!", team.canDeleteRef(repository));
assertFalse("team CAN rewind ref!", team.canRewindRef(repository));
assertEquals("team has wrong permission!", AccessPermission.CLONE, team.getRepositoryPermission(repository).permission);
}
-
+
/**
* CLONE_VIEW = CLONE access restriction, VIEW access permission
*/
@@ -1770,18 +1770,18 @@ public class PermissionsTest extends Assert {
TeamModel team = new TeamModel("test");
team.setRepositoryPermission(repository.name, AccessPermission.VIEW);
-
+
assertTrue("team CAN NOT view!", team.canView(repository));
assertFalse("team CAN clone!", team.canClone(repository));
assertFalse("team CAN push!", team.canPush(repository));
-
+
assertFalse("team CAN create ref!", team.canCreateRef(repository));
assertFalse("team CAN delete ref!", team.canDeleteRef(repository));
assertFalse("team CAN rewind ref!", team.canRewindRef(repository));
assertEquals("team has wrong permission!", AccessPermission.VIEW, team.getRepositoryPermission(repository).permission);
}
-
+
/**
* VIEW_VIEW = VIEW access restriction, VIEW access permission
*/
@@ -1793,18 +1793,18 @@ public class PermissionsTest extends Assert {
TeamModel team = new TeamModel("test");
team.setRepositoryPermission(repository.name, AccessPermission.VIEW);
-
+
assertTrue("team CAN NOT view!", team.canView(repository));
assertFalse("team CAN clone!", team.canClone(repository));
assertFalse("team CAN push!", team.canPush(repository));
-
+
assertFalse("team CAN create ref!", team.canCreateRef(repository));
assertFalse("team CAN delete ref!", team.canDeleteRef(repository));
assertFalse("team CAN rewind ref!", team.canRewindRef(repository));
assertEquals("team has wrong permission!", AccessPermission.VIEW, team.getRepositoryPermission(repository).permission);
}
-
+
/**
* NONE_NONE = NO access restriction, NO access permission
*/
@@ -1817,18 +1817,18 @@ public class PermissionsTest extends Assert {
TeamModel team = new TeamModel("test");
UserModel user = new UserModel("test");
user.teams.add(team);
-
+
assertTrue("team member CAN NOT view!", user.canView(repository));
assertTrue("team member CAN NOT clone!", user.canClone(repository));
assertTrue("team member CAN NOT push!", user.canPush(repository));
-
+
assertTrue("team member CAN NOT create ref!", user.canCreateRef(repository));
assertTrue("team member CAN NOT delete ref!", user.canDeleteRef(repository));
assertTrue("team member CAN NOT rewind ref!", user.canRewindRef(repository));
assertEquals("team member has wrong permission!", AccessPermission.REWIND, user.getRepositoryPermission(repository).permission);
}
-
+
/**
* PUSH_NONE = PUSH access restriction, NO access permission
*/
@@ -1841,11 +1841,11 @@ public class PermissionsTest extends Assert {
TeamModel team = new TeamModel("test");
UserModel user = new UserModel("test");
user.teams.add(team);
-
+
assertTrue("team member CAN NOT view!", user.canView(repository));
assertTrue("team member CAN NOT clone!", user.canClone(repository));
assertFalse("team member CAN push!", user.canPush(repository));
-
+
assertFalse("team member CAN create ref!", user.canCreateRef(repository));
assertFalse("team member CAN delete ref!", user.canDeleteRef(repository));
assertFalse("team member CAN rewind ref!", user.canRewindRef(repository));
@@ -1865,11 +1865,11 @@ public class PermissionsTest extends Assert {
TeamModel team = new TeamModel("test");
UserModel user = new UserModel("test");
user.teams.add(team);
-
+
assertTrue("team member CAN NOT view!", user.canView(repository));
assertFalse("team member CAN clone!", user.canClone(repository));
assertFalse("team member CAN push!", user.canPush(repository));
-
+
assertFalse("team member CAN create ref!", user.canCreateRef(repository));
assertFalse("team member CAN delete ref!", user.canDeleteRef(repository));
assertFalse("team member CAN rewind ref!", user.canRewindRef(repository));
@@ -1889,18 +1889,18 @@ public class PermissionsTest extends Assert {
TeamModel team = new TeamModel("test");
UserModel user = new UserModel("test");
user.teams.add(team);
-
+
assertFalse("team member CAN view!", user.canView(repository));
assertFalse("team member CAN clone!", user.canClone(repository));
assertFalse("team member CAN push!", user.canPush(repository));
-
+
assertFalse("team member CAN create ref!", user.canCreateRef(repository));
assertFalse("team member CAN delete ref!", user.canDeleteRef(repository));
assertFalse("team member CAN rewind ref!", user.canRewindRef(repository));
assertEquals("team member has wrong permission!", AccessPermission.NONE, user.getRepositoryPermission(repository).permission);
}
-
+
/**
* NONE_PUSH = NO access restriction, PUSH access permission
* (not useful scenario)
@@ -1915,18 +1915,18 @@ public class PermissionsTest extends Assert {
team.setRepositoryPermission(repository.name, AccessPermission.PUSH);
UserModel user = new UserModel("test");
user.teams.add(team);
-
+
assertTrue("team member CAN NOT view!", user.canView(repository));
assertTrue("team member CAN NOT clone!", user.canClone(repository));
assertTrue("team member CAN NOT push!", user.canPush(repository));
-
+
assertTrue("team member CAN NOT create ref!", user.canCreateRef(repository));
assertTrue("team member CAN NOT delete ref!", user.canDeleteRef(repository));
assertTrue("team member CAN NOT rewind ref!", user.canRewindRef(repository));
assertEquals("team member has wrong permission!", AccessPermission.REWIND, user.getRepositoryPermission(repository).permission);
}
-
+
/**
* PUSH_PUSH = PUSH access restriction, PUSH access permission
*/
@@ -1944,14 +1944,14 @@ public class PermissionsTest extends Assert {
assertTrue("team member CAN NOT view!", user.canView(repository));
assertTrue("team member CAN NOT clone!", user.canClone(repository));
assertTrue("team member CAN NOT push!", user.canPush(repository));
-
+
assertFalse("team member CAN create ref!", user.canCreateRef(repository));
assertFalse("team member CAN delete ref!", user.canDeleteRef(repository));
assertFalse("team member CAN rewind ref!", user.canRewindRef(repository));
assertEquals("team member has wrong permission!", AccessPermission.PUSH, user.getRepositoryPermission(repository).permission);
}
-
+
/**
* CLONE_PUSH = CLONE access restriction, PUSH access permission
*/
@@ -1969,14 +1969,14 @@ public class PermissionsTest extends Assert {
assertTrue("team member CAN NOT view!", user.canView(repository));
assertTrue("team member CAN NOT clone!", user.canClone(repository));
assertTrue("team member CAN NOT push!", user.canPush(repository));
-
+
assertFalse("team member CAN create ref!", user.canCreateRef(repository));
assertFalse("team member CAN delete ref!", user.canDeleteRef(repository));
assertFalse("team member CAN rewind ref!", user.canRewindRef(repository));
assertEquals("team member has wrong permission!", AccessPermission.PUSH, user.getRepositoryPermission(repository).permission);
}
-
+
/**
* VIEW_PUSH = VIEW access restriction, PUSH access permission
*/
@@ -1994,14 +1994,14 @@ public class PermissionsTest extends Assert {
assertTrue("team member CAN NOT view!", user.canView(repository));
assertTrue("team member CAN NOT clone!", user.canClone(repository));
assertTrue("team member CAN NOT push!", user.canPush(repository));
-
+
assertFalse("team member CAN create ref!", user.canCreateRef(repository));
assertFalse("team member CAN delete ref!", user.canDeleteRef(repository));
assertFalse("team member CAN rewind ref!", user.canRewindRef(repository));
assertEquals("team member has wrong permission!", AccessPermission.PUSH, user.getRepositoryPermission(repository).permission);
}
-
+
/**
* NONE_CREATE = NO access restriction, CREATE access permission
* (not useful scenario)
@@ -2016,18 +2016,18 @@ public class PermissionsTest extends Assert {
team.setRepositoryPermission(repository.name, AccessPermission.CREATE);
UserModel user = new UserModel("test");
user.teams.add(team);
-
+
assertTrue("team member CAN NOT view!", user.canView(repository));
assertTrue("team member CAN NOT clone!", user.canClone(repository));
assertTrue("team member CAN NOT push!", user.canPush(repository));
-
+
assertTrue("team member CAN NOT create ref!", user.canCreateRef(repository));
assertTrue("team member CAN NOT delete ref!", user.canDeleteRef(repository));
assertTrue("team member CAN NOT rewind ref!", user.canRewindRef(repository));
assertEquals("team member has wrong permission!", AccessPermission.REWIND, user.getRepositoryPermission(repository).permission);
}
-
+
/**
* PUSH_CREATE = PUSH access restriction, CREATE access permission
*/
@@ -2045,14 +2045,14 @@ public class PermissionsTest extends Assert {
assertTrue("team member CAN NOT view!", user.canView(repository));
assertTrue("team member CAN NOT clone!", user.canClone(repository));
assertTrue("team member CAN NOT push!", user.canPush(repository));
-
+
assertTrue("team member CAN NOT create ref!", user.canCreateRef(repository));
assertFalse("team member CAN delete ref!", user.canDeleteRef(repository));
assertFalse("team member CAN rewind ref!", user.canRewindRef(repository));
assertEquals("team member has wrong permission!", AccessPermission.CREATE, user.getRepositoryPermission(repository).permission);
}
-
+
/**
* CLONE_CREATE = CLONE access restriction, CREATE access permission
*/
@@ -2070,14 +2070,14 @@ public class PermissionsTest extends Assert {
assertTrue("team member CAN NOT view!", user.canView(repository));
assertTrue("team member CAN NOT clone!", user.canClone(repository));
assertTrue("team member CAN NOT push!", user.canPush(repository));
-
+
assertTrue("team member CAN NOT create ref!", user.canCreateRef(repository));
assertFalse("team member CAN delete ref!", user.canDeleteRef(repository));
assertFalse("team member CAN rewind ref!", user.canRewindRef(repository));
assertEquals("team member has wrong permission!", AccessPermission.CREATE, user.getRepositoryPermission(repository).permission);
}
-
+
/**
* VIEW_CREATE = VIEW access restriction, CREATE access permission
*/
@@ -2095,7 +2095,7 @@ public class PermissionsTest extends Assert {
assertTrue("team member CAN NOT view!", user.canView(repository));
assertTrue("team member CAN NOT clone!", user.canClone(repository));
assertTrue("team member CAN NOT push!", user.canPush(repository));
-
+
assertTrue("team member CAN NOT create ref!", user.canCreateRef(repository));
assertFalse("team member CAN delete ref!", user.canDeleteRef(repository));
assertFalse("team member CAN rewind ref!", user.canRewindRef(repository));
@@ -2117,18 +2117,18 @@ public class PermissionsTest extends Assert {
team.setRepositoryPermission(repository.name, AccessPermission.DELETE);
UserModel user = new UserModel("test");
user.teams.add(team);
-
+
assertTrue("team member CAN NOT view!", user.canView(repository));
assertTrue("team member CAN NOT clone!", user.canClone(repository));
assertTrue("team member CAN NOT push!", user.canPush(repository));
-
+
assertTrue("team member CAN NOT create ref!", user.canCreateRef(repository));
assertTrue("team member CAN NOT delete ref!", user.canDeleteRef(repository));
assertTrue("team member CAN NOT rewind ref!", user.canRewindRef(repository));
assertEquals("team member has wrong permission!", AccessPermission.REWIND, user.getRepositoryPermission(repository).permission);
}
-
+
/**
* PUSH_DELETE = PUSH access restriction, DELETE access permission
*/
@@ -2146,14 +2146,14 @@ public class PermissionsTest extends Assert {
assertTrue("team member CAN NOT view!", user.canView(repository));
assertTrue("team member CAN NOT clone!", user.canClone(repository));
assertTrue("team member CAN NOT push!", user.canPush(repository));
-
+
assertTrue("team member CAN NOT create ref!", user.canCreateRef(repository));
assertTrue("team member CAN NOT delete ref!", user.canDeleteRef(repository));
assertFalse("team member CAN rewind ref!", user.canRewindRef(repository));
assertEquals("team member has wrong permission!", AccessPermission.DELETE, user.getRepositoryPermission(repository).permission);
}
-
+
/**
* CLONE_DELETE = CLONE access restriction, DELETE access permission
*/
@@ -2171,14 +2171,14 @@ public class PermissionsTest extends Assert {
assertTrue("team member CAN NOT view!", user.canView(repository));
assertTrue("team member CAN NOT clone!", user.canClone(repository));
assertTrue("team member CAN NOT push!", user.canPush(repository));
-
+
assertTrue("team member CAN NOT create ref!", user.canCreateRef(repository));
assertTrue("team member CAN NOT delete ref!", user.canDeleteRef(repository));
assertFalse("team member CAN rewind ref!", user.canRewindRef(repository));
assertEquals("team member has wrong permission!", AccessPermission.DELETE, user.getRepositoryPermission(repository).permission);
}
-
+
/**
* VIEW_DELETE = VIEW access restriction, DELETE access permission
*/
@@ -2196,7 +2196,7 @@ public class PermissionsTest extends Assert {
assertTrue("team member CAN NOT view!", user.canView(repository));
assertTrue("team member CAN NOT clone!", user.canClone(repository));
assertTrue("team member CAN NOT push!", user.canPush(repository));
-
+
assertTrue("team member CAN NOT create ref!", user.canCreateRef(repository));
assertTrue("team member CAN NOT delete ref!", user.canDeleteRef(repository));
assertFalse("team member CAN rewind ref!", user.canRewindRef(repository));
@@ -2218,18 +2218,18 @@ public class PermissionsTest extends Assert {
team.setRepositoryPermission(repository.name, AccessPermission.REWIND);
UserModel user = new UserModel("test");
user.teams.add(team);
-
+
assertTrue("team member CAN NOT view!", user.canView(repository));
assertTrue("team member CAN NOT clone!", user.canClone(repository));
assertTrue("team member CAN NOT push!", user.canPush(repository));
-
+
assertTrue("team member CAN NOT create ref!", user.canCreateRef(repository));
assertTrue("team member CAN NOT delete ref!", user.canDeleteRef(repository));
assertTrue("team member CAN NOT rewind ref!", user.canRewindRef(repository));
assertEquals("team member has wrong permission!", AccessPermission.REWIND, user.getRepositoryPermission(repository).permission);
}
-
+
/**
* PUSH_REWIND = PUSH access restriction, REWIND access permission
*/
@@ -2247,14 +2247,14 @@ public class PermissionsTest extends Assert {
assertTrue("team member CAN NOT view!", user.canView(repository));
assertTrue("team member CAN NOT clone!", user.canClone(repository));
assertTrue("team member CAN NOT push!", user.canPush(repository));
-
+
assertTrue("team member CAN NOT create ref!", user.canCreateRef(repository));
assertTrue("team member CAN NOT delete ref!", user.canDeleteRef(repository));
assertTrue("team member CAN NOT rewind ref!", user.canRewindRef(repository));
assertEquals("team member has wrong permission!", AccessPermission.REWIND, user.getRepositoryPermission(repository).permission);
}
-
+
/**
* CLONE_REWIND = CLONE access restriction, REWIND access permission
*/
@@ -2272,14 +2272,14 @@ public class PermissionsTest extends Assert {
assertTrue("team member CAN NOT view!", user.canView(repository));
assertTrue("team member CAN NOT clone!", user.canClone(repository));
assertTrue("team member CAN NOT push!", user.canPush(repository));
-
+
assertTrue("team member CAN NOT create ref!", user.canCreateRef(repository));
assertTrue("team member CAN NOT delete ref!", user.canDeleteRef(repository));
assertTrue("team member CAN NOT rewind ref!", user.canRewindRef(repository));
assertEquals("team member has wrong permission!", AccessPermission.REWIND, user.getRepositoryPermission(repository).permission);
}
-
+
/**
* VIEW_REWIND = VIEW access restriction, REWIND access permission
*/
@@ -2297,14 +2297,14 @@ public class PermissionsTest extends Assert {
assertTrue("team member CAN NOT view!", user.canView(repository));
assertTrue("team member CAN NOT clone!", user.canClone(repository));
assertTrue("team member CAN NOT push!", user.canPush(repository));
-
+
assertTrue("team member CAN NOT create ref!", user.canCreateRef(repository));
assertTrue("team member CAN NOT delete ref!", user.canDeleteRef(repository));
assertTrue("team member CAN NOT rewind ref!", user.canRewindRef(repository));
assertEquals("team member has wrong permission!", AccessPermission.REWIND, user.getRepositoryPermission(repository).permission);
}
-
+
/**
* NONE_CLONE = NO access restriction, CLONE access permission
* (not useful scenario)
@@ -2323,7 +2323,7 @@ public class PermissionsTest extends Assert {
assertTrue("team member CAN NOT view!", user.canView(repository));
assertTrue("team member CAN NOT clone!", user.canClone(repository));
assertTrue("team member CAN NOT push!", user.canPush(repository));
-
+
assertTrue("team member CAN NOT create ref!", user.canCreateRef(repository));
assertTrue("team member CAN NOT delete ref!", user.canDeleteRef(repository));
assertTrue("team member CAN NOT rewind ref!", user.canRewindRef(repository));
@@ -2348,7 +2348,7 @@ public class PermissionsTest extends Assert {
assertTrue("team member CAN NOT view!", user.canView(repository));
assertTrue("team member CAN NOT clone!", user.canClone(repository));
assertFalse("team member CAN push!", user.canPush(repository));
-
+
assertFalse("team member CAN create ref!", user.canCreateRef(repository));
assertFalse("team member CAN delete ref!", user.canDeleteRef(repository));
assertFalse("team member CAN rewind ref!", user.canRewindRef(repository));
@@ -2373,14 +2373,14 @@ public class PermissionsTest extends Assert {
assertTrue("team member CAN NOT view!", user.canView(repository));
assertTrue("team member CAN NOT clone!", user.canClone(repository));
assertFalse("team member CAN push!", user.canPush(repository));
-
+
assertFalse("team member CAN create ref!", user.canCreateRef(repository));
assertFalse("team member CAN delete ref!", user.canDeleteRef(repository));
assertFalse("team member CAN rewind ref!", user.canRewindRef(repository));
assertEquals("team member has wrong permission!", AccessPermission.CLONE, user.getRepositoryPermission(repository).permission);
}
-
+
/**
* VIEW_CLONE = VIEW access restriction, CLONE access permission
*/
@@ -2398,7 +2398,7 @@ public class PermissionsTest extends Assert {
assertTrue("team member CAN NOT view!", user.canView(repository));
assertTrue("team member CAN NOT clone!", user.canClone(repository));
assertFalse("team member CAN push!", user.canPush(repository));
-
+
assertFalse("team member CAN create ref!", user.canCreateRef(repository));
assertFalse("team member CAN delete ref!", user.canDeleteRef(repository));
assertFalse("team member CAN rewind ref!", user.canRewindRef(repository));
@@ -2424,7 +2424,7 @@ public class PermissionsTest extends Assert {
assertTrue("team member CAN NOT view!", user.canView(repository));
assertTrue("team member CAN NOT clone!", user.canClone(repository));
assertTrue("team member CAN NOT push!", user.canPush(repository));
-
+
assertTrue("team member CAN NOT create ref!", user.canCreateRef(repository));
assertTrue("team member CAN NOT delete ref!", user.canDeleteRef(repository));
assertTrue("team member CAN NOT rewind ref!", user.canRewindRef(repository));
@@ -2449,14 +2449,14 @@ public class PermissionsTest extends Assert {
assertTrue("team member CAN NOT view!", user.canView(repository));
assertTrue("team member CAN NOT clone!", user.canClone(repository));
assertFalse("team member CAN push!", user.canPush(repository));
-
+
assertFalse("team member CAN create ref!", user.canCreateRef(repository));
assertFalse("team member CAN delete ref!", user.canDeleteRef(repository));
assertFalse("team member CAN rewind ref!", user.canRewindRef(repository));
assertEquals("team member has wrong permission!", AccessPermission.CLONE, user.getRepositoryPermission(repository).permission);
}
-
+
/**
* CLONE_VIEW = CLONE access restriction, VIEW access permission
*/
@@ -2474,14 +2474,14 @@ public class PermissionsTest extends Assert {
assertTrue("team member CAN NOT view!", user.canView(repository));
assertFalse("team member CAN clone!", user.canClone(repository));
assertFalse("team member CAN push!", user.canPush(repository));
-
+
assertFalse("team member CAN create ref!", user.canCreateRef(repository));
assertFalse("team member CAN delete ref!", user.canDeleteRef(repository));
assertFalse("team member CAN rewind ref!", user.canRewindRef(repository));
assertEquals("team member has wrong permission!", AccessPermission.VIEW, user.getRepositoryPermission(repository).permission);
}
-
+
/**
* VIEW_VIEW = VIEW access restriction, VIEW access permission
*/
@@ -2499,14 +2499,14 @@ public class PermissionsTest extends Assert {
assertTrue("team member CAN NOT view!", user.canView(repository));
assertFalse("team member CAN clone!", user.canClone(repository));
assertFalse("team member CAN push!", user.canPush(repository));
-
+
assertFalse("team member CAN create ref!", user.canCreateRef(repository));
assertFalse("team member CAN delete ref!", user.canDeleteRef(repository));
assertFalse("team member CAN rewind ref!", user.canRewindRef(repository));
assertEquals("team member has wrong permission!", AccessPermission.VIEW, user.getRepositoryPermission(repository).permission);
}
-
+
@Test
public void testOwner() throws Exception {
RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
@@ -2520,7 +2520,7 @@ public class PermissionsTest extends Assert {
assertTrue("owner CAN NOT view!", user.canView(repository));
assertTrue("owner CAN NOT clone!", user.canClone(repository));
assertTrue("owner CAN NOT push!", user.canPush(repository));
-
+
assertTrue("owner CAN NOT create ref!", user.canCreateRef(repository));
assertTrue("owner CAN NOT delete ref!", user.canDeleteRef(repository));
assertTrue("owner CAN NOT rewind ref!", user.canRewindRef(repository));
@@ -2528,11 +2528,11 @@ public class PermissionsTest extends Assert {
assertEquals("owner has wrong permission!", AccessPermission.REWIND, user.getRepositoryPermission(repository).permission);
assertTrue("owner CAN NOT fork!", user.canFork(repository));
-
+
assertFalse("owner CAN NOT delete!", user.canDelete(repository));
assertTrue("owner CAN NOT edit!", user.canEdit(repository));
}
-
+
@Test
public void testMultipleOwners() throws Exception {
RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
@@ -2549,7 +2549,7 @@ public class PermissionsTest extends Assert {
assertTrue("owner CAN NOT view!", user.canView(repository));
assertTrue("owner CAN NOT clone!", user.canClone(repository));
assertTrue("owner CAN NOT push!", user.canPush(repository));
-
+
assertTrue("owner CAN NOT create ref!", user.canCreateRef(repository));
assertTrue("owner CAN NOT delete ref!", user.canDeleteRef(repository));
assertTrue("owner CAN NOT rewind ref!", user.canRewindRef(repository));
@@ -2557,16 +2557,16 @@ public class PermissionsTest extends Assert {
assertEquals("owner has wrong permission!", AccessPermission.REWIND, user.getRepositoryPermission(repository).permission);
assertTrue("owner CAN NOT fork!", user.canFork(repository));
-
+
assertFalse("owner CAN NOT delete!", user.canDelete(repository));
assertTrue("owner CAN NOT edit!", user.canEdit(repository));
-
+
// second owner
assertFalse("user SHOULD NOT HAVE a repository permission!", user2.hasRepositoryPermission(repository.name));
assertTrue("owner CAN NOT view!", user2.canView(repository));
assertTrue("owner CAN NOT clone!", user2.canClone(repository));
assertTrue("owner CAN NOT push!", user2.canPush(repository));
-
+
assertTrue("owner CAN NOT create ref!", user2.canCreateRef(repository));
assertTrue("owner CAN NOT delete ref!", user2.canDeleteRef(repository));
assertTrue("owner CAN NOT rewind ref!", user2.canRewindRef(repository));
@@ -2574,14 +2574,14 @@ public class PermissionsTest extends Assert {
assertEquals("owner has wrong permission!", AccessPermission.REWIND, user2.getRepositoryPermission(repository).permission);
assertTrue("owner CAN NOT fork!", user2.canFork(repository));
-
+
assertFalse("owner CAN NOT delete!", user2.canDelete(repository));
assertTrue("owner CAN NOT edit!", user2.canEdit(repository));
-
+
assertTrue(repository.isOwner(user.username));
- assertTrue(repository.isOwner(user2.username));
+ assertTrue(repository.isOwner(user2.username));
}
-
+
@Test
public void testOwnerPersonalRepository() throws Exception {
RepositoryModel repository = new RepositoryModel("~test/myrepo.git", null, null, new Date());
@@ -2595,7 +2595,7 @@ public class PermissionsTest extends Assert {
assertTrue("user CAN NOT view!", user.canView(repository));
assertTrue("user CAN NOT clone!", user.canClone(repository));
assertTrue("user CAN NOT push!", user.canPush(repository));
-
+
assertTrue("user CAN NOT create ref!", user.canCreateRef(repository));
assertTrue("user CAN NOT delete ref!", user.canDeleteRef(repository));
assertTrue("user CAN NOT rewind ref!", user.canRewindRef(repository));
@@ -2603,7 +2603,7 @@ public class PermissionsTest extends Assert {
assertEquals("user has wrong permission!", AccessPermission.REWIND, user.getRepositoryPermission(repository).permission);
assertFalse("user CAN fork!", user.canFork(repository));
-
+
assertTrue("user CAN NOT delete!", user.canDelete(repository));
assertTrue("user CAN NOT edit!", user.canEdit(repository));
}
@@ -2621,7 +2621,7 @@ public class PermissionsTest extends Assert {
assertFalse("user CAN view!", user.canView(repository));
assertFalse("user CAN clone!", user.canClone(repository));
assertFalse("user CAN push!", user.canPush(repository));
-
+
assertFalse("user CAN create ref!", user.canCreateRef(repository));
assertFalse("user CAN delete ref!", user.canDeleteRef(repository));
assertFalse("user CAN rewind ref!", user.canRewindRef(repository));
@@ -2629,11 +2629,11 @@ public class PermissionsTest extends Assert {
assertEquals("user has wrong permission!", AccessPermission.NONE, user.getRepositoryPermission(repository).permission);
assertFalse("user CAN fork!", user.canFork(repository));
-
+
assertFalse("user CAN delete!", user.canDelete(repository));
assertFalse("user CAN edit!", user.canEdit(repository));
}
-
+
@Test
public void testRegexMatching() throws Exception {
RepositoryModel repository = new RepositoryModel("ubercool/_my-r/e~po.git", null, null, new Date());
@@ -2647,7 +2647,7 @@ public class PermissionsTest extends Assert {
assertTrue("user CAN NOT view!", user.canView(repository));
assertTrue("user CAN NOT clone!", user.canClone(repository));
assertFalse("user CAN push!", user.canPush(repository));
-
+
assertFalse("user CAN create ref!", user.canCreateRef(repository));
assertFalse("user CAN delete ref!", user.canDeleteRef(repository));
assertFalse("user CAN rewind ref!", user.canRewindRef(repository));
@@ -2655,14 +2655,14 @@ public class PermissionsTest extends Assert {
assertEquals("user has wrong permission!", AccessPermission.CLONE, user.getRepositoryPermission(repository).permission);
assertFalse("user CAN fork!", user.canFork(repository));
-
+
assertFalse("user CAN delete!", user.canDelete(repository));
assertFalse("user CAN edit!", user.canEdit(repository));
}
@Test
public void testRegexIncludeCommonExcludePersonal() throws Exception {
-
+
UserModel user = new UserModel("test");
user.setRepositoryPermission("[^~].*", AccessPermission.CLONE);
@@ -2670,12 +2670,12 @@ public class PermissionsTest extends Assert {
RepositoryModel common = new RepositoryModel("ubercool/_my-r/e~po.git", null, null, new Date());
common.authorizationControl = AuthorizationControl.NAMED;
common.accessRestriction = AccessRestrictionType.VIEW;
-
+
assertTrue("user DOES NOT HAVE a repository permission!", user.hasRepositoryPermission(common.name));
assertTrue("user CAN NOT view!", user.canView(common));
assertTrue("user CAN NOT clone!", user.canClone(common));
assertFalse("user CAN push!", user.canPush(common));
-
+
assertFalse("user CAN create ref!", user.canCreateRef(common));
assertFalse("user CAN delete ref!", user.canDeleteRef(common));
assertFalse("user CAN rewind ref!", user.canRewindRef(common));
@@ -2683,7 +2683,7 @@ public class PermissionsTest extends Assert {
assertEquals("user has wrong permission!", AccessPermission.CLONE, user.getRepositoryPermission(common).permission);
assertFalse("user CAN fork!", user.canFork(common));
-
+
assertFalse("user CAN delete!", user.canDelete(common));
assertFalse("user CAN edit!", user.canEdit(common));
@@ -2691,12 +2691,12 @@ public class PermissionsTest extends Assert {
RepositoryModel personal = new RepositoryModel("~ubercool/_my-r/e~po.git", null, null, new Date());
personal.authorizationControl = AuthorizationControl.NAMED;
personal.accessRestriction = AccessRestrictionType.VIEW;
-
+
assertFalse("user HAS a repository permission!", user.hasRepositoryPermission(personal.name));
assertFalse("user CAN NOT view!", user.canView(personal));
assertFalse("user CAN NOT clone!", user.canClone(personal));
assertFalse("user CAN push!", user.canPush(personal));
-
+
assertFalse("user CAN create ref!", user.canCreateRef(personal));
assertFalse("user CAN delete ref!", user.canDeleteRef(personal));
assertFalse("user CAN rewind ref!", user.canRewindRef(personal));
@@ -2704,11 +2704,11 @@ public class PermissionsTest extends Assert {
assertEquals("user has wrong permission!", AccessPermission.NONE, user.getRepositoryPermission(personal).permission);
assertFalse("user CAN fork!", user.canFork(personal));
-
+
assertFalse("user CAN delete!", user.canDelete(personal));
assertFalse("user CAN edit!", user.canEdit(personal));
}
-
+
@Test
public void testRegexMatching2() throws Exception {
RepositoryModel personal = new RepositoryModel("~ubercool/_my-r/e~po.git", null, null, new Date());
@@ -2720,13 +2720,13 @@ public class PermissionsTest extends Assert {
user.setRepositoryPermission("[^~].*", AccessPermission.CLONE);
// permitall ~ubercool repositories
user.setRepositoryPermission("~ubercool/.*", AccessPermission.CLONE);
-
+
// personal
assertTrue("user DOES NOT HAVE a repository permission!", user.hasRepositoryPermission(personal.name));
assertTrue("user CAN NOT view!", user.canView(personal));
assertTrue("user CAN NOT clone!", user.canClone(personal));
assertFalse("user CAN push!", user.canPush(personal));
-
+
assertFalse("user CAN create ref!", user.canCreateRef(personal));
assertFalse("user CAN delete ref!", user.canDeleteRef(personal));
assertFalse("user CAN rewind ref!", user.canRewindRef(personal));
@@ -2734,11 +2734,11 @@ public class PermissionsTest extends Assert {
assertEquals("user has wrong permission!", AccessPermission.CLONE, user.getRepositoryPermission(personal).permission);
assertFalse("user CAN fork!", user.canFork(personal));
-
+
assertFalse("user CAN delete!", user.canDelete(personal));
assertFalse("user CAN edit!", user.canEdit(personal));
}
-
+
@Test
public void testRegexOrder() throws Exception {
RepositoryModel personal = new RepositoryModel("~ubercool/_my-r/e~po.git", null, null, new Date());
@@ -2748,13 +2748,13 @@ public class PermissionsTest extends Assert {
UserModel user = new UserModel("test");
user.setRepositoryPermission(".*", AccessPermission.PUSH);
user.setRepositoryPermission("~ubercool/.*", AccessPermission.CLONE);
-
- // has PUSH access because first match is PUSH permission
+
+ // has PUSH access because first match is PUSH permission
assertTrue("user HAS a repository permission!", user.hasRepositoryPermission(personal.name));
assertTrue("user CAN NOT view!", user.canView(personal));
assertTrue("user CAN NOT clone!", user.canClone(personal));
assertTrue("user CAN NOT push!", user.canPush(personal));
-
+
assertFalse("user CAN create ref!", user.canCreateRef(personal));
assertFalse("user CAN delete ref!", user.canDeleteRef(personal));
assertFalse("user CAN rewind ref!", user.canRewindRef(personal));
@@ -2762,20 +2762,20 @@ public class PermissionsTest extends Assert {
assertEquals("user has wrong permission!", AccessPermission.PUSH, user.getRepositoryPermission(personal).permission);
assertFalse("user CAN fork!", user.canFork(personal));
-
+
assertFalse("user CAN delete!", user.canDelete(personal));
assertFalse("user CAN edit!", user.canEdit(personal));
-
+
user.permissions.clear();
user.setRepositoryPermission("~ubercool/.*", AccessPermission.CLONE);
user.setRepositoryPermission(".*", AccessPermission.PUSH);
-
+
// has CLONE access because first match is CLONE permission
assertTrue("user HAS a repository permission!", user.hasRepositoryPermission(personal.name));
assertTrue("user CAN NOT view!", user.canView(personal));
assertTrue("user CAN NOT clone!", user.canClone(personal));
assertFalse("user CAN push!", user.canPush(personal));
-
+
assertFalse("user CAN create ref!", user.canCreateRef(personal));
assertFalse("user CAN delete ref!", user.canDeleteRef(personal));
assertFalse("user CAN rewind ref!", user.canRewindRef(personal));
@@ -2783,11 +2783,11 @@ public class PermissionsTest extends Assert {
assertEquals("user has wrong permission!", AccessPermission.CLONE, user.getRepositoryPermission(personal).permission);
assertFalse("user CAN fork!", user.canFork(personal));
-
+
assertFalse("user CAN delete!", user.canDelete(personal));
assertFalse("user CAN edit!", user.canEdit(personal));
}
-
+
@Test
public void testExclusion() throws Exception {
RepositoryModel personal = new RepositoryModel("~ubercool/_my-r/e~po.git", null, null, new Date());
@@ -2797,13 +2797,13 @@ public class PermissionsTest extends Assert {
UserModel user = new UserModel("test");
user.setRepositoryPermission("~ubercool/.*", AccessPermission.EXCLUDE);
user.setRepositoryPermission(".*", AccessPermission.PUSH);
-
+
// has EXCLUDE access because first match is EXCLUDE permission
assertTrue("user DOES NOT HAVE a repository permission!", user.hasRepositoryPermission(personal.name));
assertFalse("user CAN NOT view!", user.canView(personal));
assertFalse("user CAN NOT clone!", user.canClone(personal));
assertFalse("user CAN push!", user.canPush(personal));
-
+
assertFalse("user CAN create ref!", user.canCreateRef(personal));
assertFalse("user CAN delete ref!", user.canDeleteRef(personal));
assertFalse("user CAN rewind ref!", user.canRewindRef(personal));
@@ -2811,7 +2811,7 @@ public class PermissionsTest extends Assert {
assertEquals("user has wrong permission!", AccessPermission.EXCLUDE, user.getRepositoryPermission(personal).permission);
assertFalse("user CAN fork!", user.canFork(personal));
-
+
assertFalse("user CAN delete!", user.canDelete(personal));
assertFalse("user CAN edit!", user.canEdit(personal));
}
@@ -2824,7 +2824,7 @@ public class PermissionsTest extends Assert {
user.teams.add(team);
assertTrue("User did not inherit admin privileges", user.canAdmin());
}
-
+
@Test
public void testForkTeamInheritance() throws Exception {
UserModel user = new UserModel("test");
@@ -2854,13 +2854,13 @@ public class PermissionsTest extends Assert {
assertEquals("user has wrong permission!", AccessPermission.REWIND, user.getRepositoryPermission(repo).permission);
assertEquals("team has wrong permission!", AccessPermission.REWIND, team.getRepositoryPermission(repo).permission);
-
+
// freeze repo
repo.isFrozen = true;
assertEquals("user has wrong permission!", AccessPermission.CLONE, user.getRepositoryPermission(repo).permission);
assertEquals("team has wrong permission!", AccessPermission.CLONE, team.getRepositoryPermission(repo).permission);
}
-
+
@Test
public void testIsBare() throws Exception {
RepositoryModel repo = new RepositoryModel("somerepo.git", null, null, new Date());
@@ -2872,7 +2872,7 @@ public class PermissionsTest extends Assert {
assertEquals("user has wrong permission!", AccessPermission.REWIND, user.getRepositoryPermission(repo).permission);
assertEquals("team has wrong permission!", AccessPermission.REWIND, team.getRepositoryPermission(repo).permission);
-
+
// set repo to have a working copy, pushes prohibited
repo.isBare = false;
assertEquals("user has wrong permission!", AccessPermission.CLONE, user.getRepositoryPermission(repo).permission);
diff --git a/src/test/java/com/gitblit/tests/RedmineUserServiceTest.java b/src/test/java/com/gitblit/tests/RedmineUserServiceTest.java
index 12fa73ff..7e04a915 100644
--- a/src/test/java/com/gitblit/tests/RedmineUserServiceTest.java
+++ b/src/test/java/com/gitblit/tests/RedmineUserServiceTest.java
@@ -50,7 +50,7 @@ public class RedmineUserServiceTest {
assertNotNull(userModel.cookie);
assertThat(userModel.canAdmin, is(false));
}
-
+
@Test
public void testLocalAccount() {
RedmineUserService redmineUserService = new RedmineUserService();
@@ -62,8 +62,8 @@ public class RedmineUserServiceTest {
redmineUserService.deleteUser(localAccount.username);
assertTrue("Failed to add local account",
redmineUserService.updateUserModel(localAccount));
- assertEquals("Accounts are not equal!",
- localAccount,
+ assertEquals("Accounts are not equal!",
+ localAccount,
redmineUserService.authenticate(localAccount.username, "gimmesomesugar".toCharArray()));
assertTrue("Failed to delete local account!",
redmineUserService.deleteUser(localAccount.username));
diff --git a/src/test/java/com/gitblit/tests/RepositoryModelTest.java b/src/test/java/com/gitblit/tests/RepositoryModelTest.java
index 1fe3fbd0..56c1ebbc 100644
--- a/src/test/java/com/gitblit/tests/RepositoryModelTest.java
+++ b/src/test/java/com/gitblit/tests/RepositoryModelTest.java
@@ -31,37 +31,37 @@ import com.gitblit.GitBlit;
import com.gitblit.models.RepositoryModel;
public class RepositoryModelTest {
-
+
private static boolean wasStarted = false;
-
+
@BeforeClass
public static void startGitBlit() throws Exception {
wasStarted = GitBlitSuite.startGitblit() == false;
}
-
+
@AfterClass
public static void stopGitBlit() throws Exception {
if (wasStarted == false)
GitBlitSuite.stopGitblit();
}
-
+
@Before
public void initializeConfiguration() throws Exception{
Repository r = GitBlitSuite.getHelloworldRepository();
StoredConfig config = r.getConfig();
-
+
config.unsetSection(Constants.CONFIG_GITBLIT, Constants.CONFIG_CUSTOM_FIELDS);
config.setString(Constants.CONFIG_GITBLIT, Constants.CONFIG_CUSTOM_FIELDS, "commitMessageRegEx", "\\d");
config.setString(Constants.CONFIG_GITBLIT, Constants.CONFIG_CUSTOM_FIELDS, "anotherProperty", "Hello");
-
+
config.save();
}
-
+
@After
public void teardownConfiguration() throws Exception {
Repository r = GitBlitSuite.getHelloworldRepository();
StoredConfig config = r.getConfig();
-
+
config.unsetSection(Constants.CONFIG_GITBLIT, Constants.CONFIG_CUSTOM_FIELDS);
config.save();
}
@@ -70,25 +70,25 @@ public class RepositoryModelTest {
public void testGetCustomProperty() throws Exception {
RepositoryModel model = GitBlit.self().getRepositoryModel(
GitBlitSuite.getHelloworldRepository().getDirectory().getName());
-
+
assertEquals("\\d", model.customFields.get("commitMessageRegEx"));
assertEquals("Hello", model.customFields.get("anotherProperty"));
}
-
+
@Test
public void testSetCustomProperty() throws Exception {
RepositoryModel model = GitBlit.self().getRepositoryModel(
GitBlitSuite.getHelloworldRepository().getDirectory().getName());
-
+
assertEquals("\\d", model.customFields.get("commitMessageRegEx"));
assertEquals("Hello", model.customFields.get("anotherProperty"));
-
+
assertEquals("Hello", model.customFields.put("anotherProperty", "GoodBye"));
GitBlit.self().updateRepositoryModel(model.name, model, false);
-
+
model = GitBlit.self().getRepositoryModel(
GitBlitSuite.getHelloworldRepository().getDirectory().getName());
-
+
assertEquals("\\d", model.customFields.get("commitMessageRegEx"));
assertEquals("GoodBye", model.customFields.get("anotherProperty"));
}
diff --git a/src/test/java/com/gitblit/tests/RpcTests.java b/src/test/java/com/gitblit/tests/RpcTests.java
index 2f0cffe2..f816ff63 100644
--- a/src/test/java/com/gitblit/tests/RpcTests.java
+++ b/src/test/java/com/gitblit/tests/RpcTests.java
@@ -54,9 +54,9 @@ import com.gitblit.utils.RpcUtils;
/**
* Tests all the rpc client utility methods, the rpc filter and rpc servlet.
- *
+ *
* @author James Moger
- *
+ *
*/
public class RpcTests {
@@ -103,7 +103,7 @@ public class RpcTests {
list = RpcUtils.getUsers(url, "admin", "admin".toCharArray());
assertTrue("User list is empty!", list.size() > 0);
}
-
+
@Test
public void testGetUser() throws IOException {
UserModel user = null;
@@ -215,7 +215,7 @@ public class RpcTests {
assertTrue("Failed to update repository!", RpcUtils.updateRepository(retrievedRepository.name, retrievedRepository,
url, account, password.toCharArray()));
retrievedRepository = findRepository(retrievedRepository.name);
-
+
// memberships
UserModel testMember = new UserModel("justadded");
assertTrue(RpcUtils.createUser(testMember, url, account, password.toCharArray()));
@@ -272,7 +272,7 @@ public class RpcTests {
public void testTeamAdministration() throws IOException {
List<TeamModel> teams = RpcUtils.getTeams(url, account, password.toCharArray());
assertEquals(1, teams.size());
-
+
// Create the A-Team
TeamModel aTeam = new TeamModel("A-Team");
aTeam.users.add("admin");
@@ -302,7 +302,7 @@ public class RpcTests {
}
}
assertNotNull(helloworld);
-
+
// Confirm that we have added the team
List<String> helloworldTeams = RpcUtils.getRepositoryTeams(helloworld, url, account,
password.toCharArray());
@@ -319,7 +319,7 @@ public class RpcTests {
helloworldTeams = RpcUtils.getRepositoryTeams(helloworld, url, account,
password.toCharArray());
assertEquals(0, helloworldTeams.size());
-
+
// delete the A-Team
assertTrue(RpcUtils.deleteTeam(aTeam, url, account, password.toCharArray()));
diff --git a/src/test/java/com/gitblit/tests/StringUtilsTest.java b/src/test/java/com/gitblit/tests/StringUtilsTest.java
index bcf3a99c..bec5c542 100644
--- a/src/test/java/com/gitblit/tests/StringUtilsTest.java
+++ b/src/test/java/com/gitblit/tests/StringUtilsTest.java
@@ -150,7 +150,7 @@ public class StringUtilsTest {
assertFalse(StringUtils.fuzzyMatch("123", "12345"));
assertFalse(StringUtils.fuzzyMatch("AbCdEfHIJ", "abc*hhh"));
}
-
+
@Test
public void testGetRepositoryPath() throws Exception {
assertEquals("gitblit/gitblit.git", StringUtils.extractRepositoryPath("git://github.com/gitblit/gitblit.git", new String [] { ".*?://github.com/(.*)" }));
diff --git a/src/test/java/com/gitblit/tests/SyndicationUtilsTest.java b/src/test/java/com/gitblit/tests/SyndicationUtilsTest.java
index 75fbd7ca..66d0c3a9 100644
--- a/src/test/java/com/gitblit/tests/SyndicationUtilsTest.java
+++ b/src/test/java/com/gitblit/tests/SyndicationUtilsTest.java
@@ -54,7 +54,7 @@ public class SyndicationUtilsTest {
entries.add(entry);
}
ByteArrayOutputStream os = new ByteArrayOutputStream();
- SyndicationUtils.toRSS("http://localhost", "", "Title", "Description",
+ SyndicationUtils.toRSS("http://localhost", "", "Title", "Description",
entries, os);
String feed = os.toString();
os.close();
diff --git a/src/test/java/com/gitblit/tests/X509UtilsTest.java b/src/test/java/com/gitblit/tests/X509UtilsTest.java
index 5d17e18d..668626ba 100644
--- a/src/test/java/com/gitblit/tests/X509UtilsTest.java
+++ b/src/test/java/com/gitblit/tests/X509UtilsTest.java
@@ -39,18 +39,19 @@ import com.gitblit.utils.X509Utils.X509Metadata;
/**
* Unit tests for X509 certificate generation.
- *
+ *
* @author James Moger
- *
+ *
*/
public class X509UtilsTest extends Assert {
-
+
// passwords are case-sensitive and may be length-limited
// based on the JCE policy files
String caPassword = "aBcDeFg";
File folder = new File(System.getProperty("user.dir"), "x509test");
-
+
X509Log log = new X509Log() {
+ @Override
public void log(String message) {
System.out.println(message);
}
@@ -62,69 +63,69 @@ public class X509UtilsTest extends Assert {
X509Metadata goMetadata = new X509Metadata("localhost", caPassword);
X509Utils.prepareX509Infrastructure(goMetadata, folder, log);
}
-
+
@After
public void cleanUp() throws Exception {
if (folder.exists()) {
FileUtils.delete(folder, FileUtils.RECURSIVE);
}
}
-
+
@Test
- public void testNewCA() throws Exception {
+ public void testNewCA() throws Exception {
File storeFile = new File(folder, X509Utils.CA_KEY_STORE);
X509Utils.getPrivateKey(X509Utils.CA_ALIAS, storeFile, caPassword);
X509Certificate cert = X509Utils.getCertificate(X509Utils.CA_ALIAS, storeFile, caPassword);
assertEquals("O=Gitblit,OU=Gitblit,CN=Gitblit Certificate Authority", cert.getIssuerDN().getName());
- }
+ }
@Test
- public void testCertificateUserMapping() throws Exception {
+ public void testCertificateUserMapping() throws Exception {
File storeFile = new File(folder, X509Utils.CA_KEY_STORE);
PrivateKey caPrivateKey = X509Utils.getPrivateKey(X509Utils.CA_ALIAS, storeFile, caPassword);
X509Certificate caCert = X509Utils.getCertificate(X509Utils.CA_ALIAS, storeFile, caPassword);
-
+
X509Metadata userMetadata = new X509Metadata("james", "james");
userMetadata.serverHostname = "www.myserver.com";
userMetadata.userDisplayname = "James Moger";
userMetadata.passwordHint = "your name";
userMetadata.oids.put("C", "US");
-
+
X509Certificate cert1 = X509Utils.newClientCertificate(userMetadata, caPrivateKey, caCert, storeFile.getParentFile());
UserModel userModel1 = HttpUtils.getUserModelFromCertificate(cert1);
assertEquals(userMetadata.commonName, userModel1.username);
assertEquals(userMetadata.emailAddress, userModel1.emailAddress);
assertEquals("C=US,O=Gitblit,OU=Gitblit,CN=james", cert1.getSubjectDN().getName());
-
-
+
+
X509Certificate cert2 = X509Utils.newClientCertificate(userMetadata, caPrivateKey, caCert, storeFile.getParentFile());
UserModel userModel2 = HttpUtils.getUserModelFromCertificate(cert2);
assertEquals(userMetadata.commonName, userModel2.username);
assertEquals(userMetadata.emailAddress, userModel2.emailAddress);
assertEquals("C=US,O=Gitblit,OU=Gitblit,CN=james", cert2.getSubjectDN().getName());
-
+
assertNotSame("Serial numbers are the same!", cert1.getSerialNumber().longValue(), cert2.getSerialNumber().longValue());
}
-
+
@Test
public void testUserBundle() throws Exception {
File storeFile = new File(folder, X509Utils.CA_KEY_STORE);
-
+
X509Metadata userMetadata = new X509Metadata("james", "james");
- userMetadata.serverHostname = "www.myserver.com";
+ userMetadata.serverHostname = "www.myserver.com";
userMetadata.userDisplayname = "James Moger";
userMetadata.passwordHint = "your name";
File zip = X509Utils.newClientBundle(userMetadata, storeFile, caPassword, log);
assertTrue(zip.exists());
-
+
List<String> expected = Arrays.asList(
userMetadata.commonName + ".pem",
userMetadata.commonName + ".p12",
userMetadata.commonName + ".cer",
"ca.cer",
"README.TXT");
-
+
ZipInputStream zis = new ZipInputStream(new FileInputStream(zip));
ZipEntry entry = null;
while ((entry = zis.getNextEntry()) != null) {
@@ -132,49 +133,49 @@ public class X509UtilsTest extends Assert {
}
zis.close();
}
-
+
@Test
- public void testCertificateRevocation() throws Exception {
+ public void testCertificateRevocation() throws Exception {
File storeFile = new File(folder, X509Utils.CA_KEY_STORE);
PrivateKey caPrivateKey = X509Utils.getPrivateKey(X509Utils.CA_ALIAS, storeFile, caPassword);
X509Certificate caCert = X509Utils.getCertificate(X509Utils.CA_ALIAS, storeFile, caPassword);
-
+
X509Metadata userMetadata = new X509Metadata("james", "james");
userMetadata.serverHostname = "www.myserver.com";
userMetadata.userDisplayname = "James Moger";
userMetadata.passwordHint = "your name";
-
+
// generate a new client certificate
X509Certificate cert1 = X509Utils.newClientCertificate(userMetadata, caPrivateKey, caCert, storeFile.getParentFile());
-
+
// confirm this certificate IS NOT revoked
File caRevocationList = new File(folder, X509Utils.CA_REVOCATION_LIST);
assertFalse(X509Utils.isRevoked(cert1, caRevocationList));
-
+
// revoke certificate and then confirm it IS revoked
X509Utils.revoke(cert1, RevocationReason.ACompromise, caRevocationList, storeFile, caPassword, log);
assertTrue(X509Utils.isRevoked(cert1, caRevocationList));
-
+
// generate a second certificate
X509Certificate cert2 = X509Utils.newClientCertificate(userMetadata, caPrivateKey, caCert, storeFile.getParentFile());
-
+
// confirm second certificate IS NOT revoked
assertTrue(X509Utils.isRevoked(cert1, caRevocationList));
assertFalse(X509Utils.isRevoked(cert2, caRevocationList));
-
+
// revoke second certificate and then confirm it IS revoked
X509Utils.revoke(cert2, RevocationReason.ACompromise, caRevocationList, caPrivateKey, log);
assertTrue(X509Utils.isRevoked(cert1, caRevocationList));
assertTrue(X509Utils.isRevoked(cert2, caRevocationList));
-
+
// generate a third certificate
X509Certificate cert3 = X509Utils.newClientCertificate(userMetadata, caPrivateKey, caCert, storeFile.getParentFile());
-
+
// confirm third certificate IS NOT revoked
assertTrue(X509Utils.isRevoked(cert1, caRevocationList));
assertTrue(X509Utils.isRevoked(cert2, caRevocationList));
assertFalse(X509Utils.isRevoked(cert3, caRevocationList));
-
+
// revoke third certificate and then confirm it IS revoked
X509Utils.revoke(cert3, RevocationReason.ACompromise, caRevocationList, caPrivateKey, log);
assertTrue(X509Utils.isRevoked(cert1, caRevocationList));
diff --git a/src/test/java/com/gitblit/tests/mock/MemorySettings.java b/src/test/java/com/gitblit/tests/mock/MemorySettings.java
index 1b3e2382..5b8e60a9 100644
--- a/src/test/java/com/gitblit/tests/mock/MemorySettings.java
+++ b/src/test/java/com/gitblit/tests/mock/MemorySettings.java
@@ -22,9 +22,9 @@ import java.util.Properties;
import com.gitblit.IStoredSettings;
public class MemorySettings extends IStoredSettings {
-
+
private Map<String, Object> backingMap;
-
+
public MemorySettings(Map<String, Object> backingMap) {
super(MemorySettings.class);
this.backingMap = backingMap;
@@ -34,10 +34,10 @@ public class MemorySettings extends IStoredSettings {
protected Properties read() {
Properties props = new Properties();
props.putAll(backingMap);
-
+
return props;
}
-
+
public void put(Object key, Object value) {
backingMap.put(key.toString(), value);
}