diff options
author | mallowlabs <mallowlabs@gmail.com> | 2012-09-08 21:40:53 +0900 |
---|---|---|
committer | mallowlabs <mallowlabs@gmail.com> | 2012-09-08 21:40:53 +0900 |
commit | 98ba4e116e79dfda72810b1e5135a4d9b1ddab6e (patch) | |
tree | ae8b2c8993d7d547dd08b28088519cb365465102 /tests | |
parent | 13a3f5bc3e2d25fc76850f86070dc34efe60d77a (diff) | |
download | gitblit-98ba4e116e79dfda72810b1e5135a4d9b1ddab6e.tar.gz gitblit-98ba4e116e79dfda72810b1e5135a4d9b1ddab6e.zip |
Added RedmineUserService
Diffstat (limited to 'tests')
-rw-r--r-- | tests/com/gitblit/tests/RedmineUserServiceTest.java | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/com/gitblit/tests/RedmineUserServiceTest.java b/tests/com/gitblit/tests/RedmineUserServiceTest.java new file mode 100644 index 00000000..a6a8a5eb --- /dev/null +++ b/tests/com/gitblit/tests/RedmineUserServiceTest.java @@ -0,0 +1,41 @@ +package com.gitblit.tests;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertThat;
+
+import java.util.HashMap;
+
+import org.junit.Test;
+
+import com.gitblit.RedmineUserService;
+import com.gitblit.models.UserModel;
+import com.gitblit.tests.mock.MemorySettings;
+
+public class RedmineUserServiceTest {
+
+ 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\"}}";
+
+ @Test
+ public void testAuthenticate() throws Exception {
+ RedmineUserService redmineUserService = new RedmineUserService();
+ 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.getDisplayName(), is("baz foo"));
+ assertThat(userModel.emailAddress, is("baz@example.com"));
+ }
+
+ @Test
+ public void testAuthenticateWithWronId() throws Exception {
+ RedmineUserService redmineUserService = new RedmineUserService();
+ redmineUserService.setup(new MemorySettings(new HashMap<String, Object>()));
+ redmineUserService.setTestingCurrentUserAsJson(JSON);
+ UserModel userModel = redmineUserService.authenticate("WrongRedmineUserId", "RedmineAPIKey".toCharArray());
+ assertNull(userModel);
+ }
+
+}
|