SEC-427: Fix. Added NullAuthoritiesPopulator and extra constructor.
This commit is contained in:
@@ -47,7 +47,6 @@ public class LdapAuthenticationProviderTests extends TestCase {
|
||||
}
|
||||
|
||||
public LdapAuthenticationProviderTests() {
|
||||
super();
|
||||
}
|
||||
|
||||
//~ Methods ========================================================================================================
|
||||
@@ -86,8 +85,7 @@ public class LdapAuthenticationProviderTests extends TestCase {
|
||||
}
|
||||
|
||||
public void testEmptyPasswordIsRejected() {
|
||||
LdapAuthenticationProvider ldapProvider = new LdapAuthenticationProvider(new MockAuthenticator(),
|
||||
new MockAuthoritiesPopulator());
|
||||
LdapAuthenticationProvider ldapProvider = new LdapAuthenticationProvider(new MockAuthenticator());
|
||||
try {
|
||||
ldapProvider.retrieveUser("jen", new UsernamePasswordAuthenticationToken("jen", ""));
|
||||
fail("Expected BadCredentialsException for empty password");
|
||||
@@ -116,6 +114,14 @@ public class LdapAuthenticationProviderTests extends TestCase {
|
||||
ldapProvider.additionalAuthenticationChecks(user, authRequest);
|
||||
}
|
||||
|
||||
public void testUseWithNullAuthoritiesPopulatorReturnsCorrectRole() {
|
||||
LdapAuthenticationProvider ldapProvider = new LdapAuthenticationProvider(new MockAuthenticator());
|
||||
UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken("bob", "bobspassword");
|
||||
UserDetails user = ldapProvider.retrieveUser("bob", authRequest);
|
||||
assertEquals(1, user.getAuthorities().length);
|
||||
assertEquals("ROLE_FROM_ENTRY", user.getAuthorities()[0].getAuthority());
|
||||
}
|
||||
|
||||
//~ Inner Classes ==================================================================================================
|
||||
|
||||
class MockAuthenticator implements LdapAuthenticator {
|
||||
|
||||
Reference in New Issue
Block a user