Enforce the setting of a LdapUserDetailsMapper on authenticators (rather than a general mapper) to make sure the correct type is returned and that the username is set before it is returned.
This commit is contained in:
@@ -37,6 +37,7 @@ public class FilterBasedLdapUserSearchTests extends AbstractLdapServerTestCase {
|
||||
locator.setDerefLinkFlag(false);
|
||||
|
||||
LdapUserDetails bob = locator.searchForUser("bob");
|
||||
assertEquals("bob", bob.getUsername());
|
||||
// name is wrong with embedded apacheDS
|
||||
// assertEquals("uid=bob,ou=people,dc=acegisecurity,dc=org", bob.getDn());
|
||||
}
|
||||
@@ -48,6 +49,7 @@ public class FilterBasedLdapUserSearchTests extends AbstractLdapServerTestCase {
|
||||
locator.setSearchSubtree(true);
|
||||
|
||||
LdapUserDetails ben = locator.searchForUser("Ben Alex");
|
||||
assertEquals("Ben Alex", ben.getUsername());
|
||||
// assertEquals("uid=ben,ou=people,dc=acegisecurity,dc=org", ben.getDn());
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ public class BindAuthenticatorTests extends AbstractLdapServerTestCase {
|
||||
public void testAuthenticationWithCorrectPasswordSucceeds() {
|
||||
authenticator.setUserDnPatterns(new String[] {"uid={0},ou=people"});
|
||||
LdapUserDetails user = authenticator.authenticate("bob","bobspassword");
|
||||
assertEquals("bob", user.getUsername());
|
||||
}
|
||||
|
||||
public void testAuthenticationWithWrongPasswordFails() {
|
||||
|
||||
@@ -65,7 +65,10 @@ public class PasswordComparisonAuthenticatorTests extends AbstractLdapServerTest
|
||||
}
|
||||
*/
|
||||
public void testLocalPasswordComparisonSucceedsWithCorrectPassword() {
|
||||
authenticator.authenticate("Bob", "bobspassword");
|
||||
LdapUserDetails user = authenticator.authenticate("Bob", "bobspassword");
|
||||
// check username is retrieved.
|
||||
assertEquals("Bob", user.getUsername());
|
||||
assertEquals("bobspassword", user.getPassword());
|
||||
}
|
||||
|
||||
public void testMultipleDnPatternsWorkOk() {
|
||||
@@ -88,7 +91,7 @@ public class PasswordComparisonAuthenticatorTests extends AbstractLdapServerTest
|
||||
|
||||
public void testAllAttributesAreRetrivedByDefault() {
|
||||
LdapUserDetails user = authenticator.authenticate("Bob", "bobspassword");
|
||||
System.out.println(user.getAttributes().toString());
|
||||
//System.out.println(user.getAttributes().toString());
|
||||
assertEquals("User should have 5 attributes", 5, user.getAttributes().size());
|
||||
|
||||
}
|
||||
@@ -107,7 +110,7 @@ public class PasswordComparisonAuthenticatorTests extends AbstractLdapServerTest
|
||||
mapper.setPasswordAttributeName("uid");
|
||||
authenticator.setPasswordAttributeName("uid");
|
||||
authenticator.setUserDetailsMapper(mapper);
|
||||
authenticator.authenticate("bob", "bob");
|
||||
LdapUserDetails bob = authenticator.authenticate("bob", "bob");
|
||||
}
|
||||
/*
|
||||
public void testLdapCompareWithDifferentPasswordAttributeSucceeds() {
|
||||
|
||||
Reference in New Issue
Block a user