Add Factor Tests for Authentication Providers
Issue gh-17933
This commit is contained in:
+11
@@ -26,6 +26,7 @@ import org.springframework.ldap.core.DirContextOperations;
|
||||
import org.springframework.ldap.support.LdapNameBuilder;
|
||||
import org.springframework.security.authentication.BadCredentialsException;
|
||||
import org.springframework.security.authentication.InternalAuthenticationServiceException;
|
||||
import org.springframework.security.authentication.SecurityAssertions;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
@@ -156,6 +157,16 @@ public class LdapAuthenticationProviderTests {
|
||||
.isSameAs(expectedCause);
|
||||
}
|
||||
|
||||
@Test
|
||||
void authenticateWhenSuccessThenIssuesFactor() {
|
||||
MockAuthenticator authenticator = new MockAuthenticator();
|
||||
MockAuthoritiesPopulator populator = new MockAuthoritiesPopulator();
|
||||
LdapAuthenticationProvider ldapProvider = new LdapAuthenticationProvider(authenticator, populator);
|
||||
UsernamePasswordAuthenticationToken request = new UsernamePasswordAuthenticationToken("ben", "benspassword");
|
||||
Authentication result = ldapProvider.authenticate(request);
|
||||
SecurityAssertions.assertThat(result).hasAuthority("FACTOR_PASSWORD");
|
||||
}
|
||||
|
||||
class MockAuthenticator implements LdapAuthenticator {
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user