From 27ae9095639bb228a1b7ff86a3ebe4264abf05be Mon Sep 17 00:00:00 2001
From: mschaefers <mschaefers@scoop-gmbh.de>
Date: Thu, 29 Nov 2012 12:33:09 -0500
Subject: [PATCH] feature: when using LdapUserService one can configure Gitblit to fetch all users from ldap that can possibly login. This allows to see newly generated LDAP users instantly in Gitblit. By now an LDAP user had to log in once to appear in GitBlit.
---
tests/com/gitblit/tests/RedmineUserServiceTest.java | 19 +++++++++++++++----
1 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/tests/com/gitblit/tests/RedmineUserServiceTest.java b/tests/com/gitblit/tests/RedmineUserServiceTest.java
index a6a8a5e..30a8fb2 100644
--- a/tests/com/gitblit/tests/RedmineUserServiceTest.java
+++ b/tests/com/gitblit/tests/RedmineUserServiceTest.java
@@ -1,6 +1,7 @@
package com.gitblit.tests;
import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
@@ -18,6 +19,10 @@
+ "\"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();
@@ -27,15 +32,21 @@
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(true));
}
@Test
- public void testAuthenticateWithWronId() throws Exception {
+ public void testAuthenticateNotAdminUser() 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);
+ redmineUserService.setTestingCurrentUserAsJson(NOT_ADMIN_JSON);
+ UserModel userModel = redmineUserService.authenticate("RedmineUserId", "RedmineAPIKey".toCharArray());
+ assertThat(userModel.getName(), is("baz@example.com"));
+ assertThat(userModel.getDisplayName(), is("baz foo"));
+ assertThat(userModel.emailAddress, is("baz@example.com"));
+ assertNotNull(userModel.cookie);
+ assertThat(userModel.canAdmin, is(false));
}
}
--
Gitblit v1.9.1