summaryrefslogtreecommitdiffstats
path: root/src/test/java/com/gitblit/tests/RedmineUserServiceTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/com/gitblit/tests/RedmineUserServiceTest.java')
-rw-r--r--src/test/java/com/gitblit/tests/RedmineUserServiceTest.java66
1 files changed, 0 insertions, 66 deletions
diff --git a/src/test/java/com/gitblit/tests/RedmineUserServiceTest.java b/src/test/java/com/gitblit/tests/RedmineUserServiceTest.java
deleted file mode 100644
index 3c6769f0..00000000
--- a/src/test/java/com/gitblit/tests/RedmineUserServiceTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package com.gitblit.tests;
-
-import static org.hamcrest.CoreMatchers.is;
-
-import org.junit.Test;
-
-import com.gitblit.RedmineUserService;
-import com.gitblit.models.UserModel;
-import com.gitblit.tests.mock.MockRuntimeManager;
-import com.gitblit.utils.StringUtils;
-
-public class RedmineUserServiceTest extends GitblitUnitTest {
-
- private static final String JSON = "{\"user\":{\"created_on\":\"2011-03-28T00:41:29Z\",\"lastname\":\"foo\","
- + "\"last_login_on\":\"2012-09-06T23:59:26Z\",\"firstname\":\"baz\","
- + "\"id\":4,\"login\":\"RedmineUserId\",\"mail\":\"baz@example.com\"}}";
-
- private static final String NOT_ADMIN_JSON = "{\"user\":{\"lastname\":\"foo\","
- + "\"last_login_on\":\"2012-09-08T13:59:01Z\",\"created_on\":\"2009-03-17T14:25:50Z\","
- + "\"mail\":\"baz@example.com\",\"id\":5,\"firstname\":\"baz\"}}";
-
- @Test
- public void testAuthenticate() throws Exception {
- RedmineUserService redmineUserService = new RedmineUserService();
- redmineUserService.setup(new MockRuntimeManager());
- redmineUserService.setTestingCurrentUserAsJson(JSON);
- UserModel userModel = redmineUserService.authenticate("RedmineAdminId", "RedmineAPIKey".toCharArray());
- assertThat(userModel.getName(), is("redmineadminid"));
- assertThat(userModel.getDisplayName(), is("baz foo"));
- assertThat(userModel.emailAddress, is("baz@example.com"));
- assertNotNull(userModel.cookie);
- assertThat(userModel.canAdmin, is(true));
- }
-
- @Test
- public void testAuthenticateNotAdminUser() throws Exception {
- RedmineUserService redmineUserService = new RedmineUserService();
- redmineUserService.setup(new MockRuntimeManager());
- redmineUserService.setTestingCurrentUserAsJson(NOT_ADMIN_JSON);
- UserModel userModel = redmineUserService.authenticate("RedmineUserId", "RedmineAPIKey".toCharArray());
- assertThat(userModel.getName(), is("redmineuserid"));
- assertThat(userModel.getDisplayName(), is("baz foo"));
- assertThat(userModel.emailAddress, is("baz@example.com"));
- assertNotNull(userModel.cookie);
- assertThat(userModel.canAdmin, is(false));
- }
-
- @Test
- public void testLocalAccount() {
- RedmineUserService redmineUserService = new RedmineUserService();
- redmineUserService.setup(new MockRuntimeManager());
-
- 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));
- }
-
-}