diff options
author | James Moger <james.moger@gitblit.com> | 2013-01-04 17:23:23 -0500 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2013-01-04 17:23:23 -0500 |
commit | 4e3c152fa7e97200855ba0d2716362dbe7976920 (patch) | |
tree | 6ecaa64074a0ccf4f3943592606eef4f02d6022f /tests | |
parent | 8427e93f25fb79bc39dbd31ce13fab637e7cfdff (diff) | |
download | gitblit-4e3c152fa7e97200855ba0d2716362dbe7976920.tar.gz gitblit-4e3c152fa7e97200855ba0d2716362dbe7976920.zip |
Support local accounts with LdapUserService and RedmineUserService (issue-183)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/com/gitblit/tests/LdapUserServiceTest.java | 16 | ||||
-rw-r--r-- | tests/com/gitblit/tests/RedmineUserServiceTest.java | 24 |
2 files changed, 38 insertions, 2 deletions
diff --git a/tests/com/gitblit/tests/LdapUserServiceTest.java b/tests/com/gitblit/tests/LdapUserServiceTest.java index ffe82640..a928f4a5 100644 --- a/tests/com/gitblit/tests/LdapUserServiceTest.java +++ b/tests/com/gitblit/tests/LdapUserServiceTest.java @@ -31,6 +31,7 @@ import org.junit.Test; import com.gitblit.LdapUserService; import com.gitblit.models.UserModel; import com.gitblit.tests.mock.MemorySettings; +import com.gitblit.utils.StringUtils; import com.unboundid.ldap.listener.InMemoryDirectoryServer; import com.unboundid.ldap.listener.InMemoryDirectoryServerConfig; import com.unboundid.ldap.listener.InMemoryListenerConfig; @@ -154,5 +155,20 @@ public class LdapUserServiceTest { UserModel userOneModel = ldapUserService.authenticate("*)(userPassword=userOnePassword", "userOnePassword".toCharArray()); assertNull(userOneModel); } + + @Test + public void testLocalAccount() { + UserModel localAccount = new UserModel("bruce"); + localAccount.displayName = "Bruce Campbell"; + localAccount.password = StringUtils.MD5_TYPE + StringUtils.getMD5("gimmesomesugar"); + ldapUserService.deleteUser(localAccount.username); + assertTrue("Failed to add local account", + ldapUserService.updateUserModel(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/tests/com/gitblit/tests/RedmineUserServiceTest.java b/tests/com/gitblit/tests/RedmineUserServiceTest.java index 30a8fb20..0e12542d 100644 --- a/tests/com/gitblit/tests/RedmineUserServiceTest.java +++ b/tests/com/gitblit/tests/RedmineUserServiceTest.java @@ -1,9 +1,10 @@ package com.gitblit.tests;
import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
import java.util.HashMap;
@@ -12,6 +13,7 @@ import org.junit.Test; import com.gitblit.RedmineUserService;
import com.gitblit.models.UserModel;
import com.gitblit.tests.mock.MemorySettings;
+import com.gitblit.utils.StringUtils;
public class RedmineUserServiceTest {
@@ -29,7 +31,7 @@ public class RedmineUserServiceTest { redmineUserService.setup(new MemorySettings(new HashMap<String, Object>()));
redmineUserService.setTestingCurrentUserAsJson(JSON);
UserModel userModel = redmineUserService.authenticate("RedmineUserId", "RedmineAPIKey".toCharArray());
- assertThat(userModel.getName(), is("RedmineUserId"));
+ assertThat(userModel.getName(), is("redmineuserid"));
assertThat(userModel.getDisplayName(), is("baz foo"));
assertThat(userModel.emailAddress, is("baz@example.com"));
assertNotNull(userModel.cookie);
@@ -48,5 +50,23 @@ public class RedmineUserServiceTest { assertNotNull(userModel.cookie);
assertThat(userModel.canAdmin, is(false));
}
+
+ @Test
+ public void testLocalAccount() {
+ RedmineUserService redmineUserService = new RedmineUserService();
+ redmineUserService.setup(new MemorySettings(new HashMap<String, Object>()));
+
+ UserModel localAccount = new UserModel("bruce");
+ localAccount.displayName = "Bruce Campbell";
+ localAccount.password = StringUtils.MD5_TYPE + StringUtils.getMD5("gimmesomesugar");
+ redmineUserService.deleteUser(localAccount.username);
+ assertTrue("Failed to add local account",
+ redmineUserService.updateUserModel(localAccount));
+ assertEquals("Accounts are not equal!",
+ localAccount,
+ redmineUserService.authenticate(localAccount.username, "gimmesomesugar".toCharArray()));
+ assertTrue("Failed to delete local account!",
+ redmineUserService.deleteUser(localAccount.username));
+ }
}
|