SEC-536: Introduced UserDetailsChecker strategy to extract code for checking status of accounts and allowing variation in pre/post authentication checks made by AbstractUserDetailsAuthenticationProvider
This commit is contained in:
@@ -50,14 +50,6 @@ import org.springframework.dao.DataRetrievalFailureException;
|
||||
public class SiteminderAuthenticationProviderTests extends TestCase {
|
||||
//~ Methods ========================================================================================================
|
||||
|
||||
public static void main(String[] args) {
|
||||
junit.textui.TestRunner.run(SiteminderAuthenticationProviderTests.class);
|
||||
}
|
||||
|
||||
public final void setUp() throws Exception {
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
public void testAuthenticateFailsIfAccountExpired() {
|
||||
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("peter", "opal");
|
||||
|
||||
|
||||
@@ -478,11 +478,11 @@ public class AbstractProcessingFilterTests extends TestCase {
|
||||
|
||||
// Setup our test object, to grant access
|
||||
MockAbstractProcessingFilter filter = new MockAbstractProcessingFilter(true);
|
||||
filter.setDefaultTargetUrl("http://monkeymachine.co.uk/");
|
||||
filter.setDefaultTargetUrl("https://monkeymachine.co.uk/");
|
||||
filter.setAlwaysUseDefaultTargetUrl(true);
|
||||
|
||||
executeFilterInContainerSimulator(config, filter, request, response, chain);
|
||||
assertEquals("http://monkeymachine.co.uk/", response.getRedirectedUrl());
|
||||
assertEquals("https://monkeymachine.co.uk/", response.getRedirectedUrl());
|
||||
assertNotNull(SecurityContextHolder.getContext().getAuthentication());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
package org.springframework.security.userdetails.decorator;
|
||||
|
||||
import org.springframework.security.userdetails.MockUserDetailsService;
|
||||
import org.springframework.security.LockedException;
|
||||
import org.springframework.security.DisabledException;
|
||||
import org.springframework.security.CredentialsExpiredException;
|
||||
import org.springframework.security.AccountExpiredException;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author Luke Taylor
|
||||
* @version $Id$
|
||||
*/
|
||||
public class StatusCheckingUserDetailsServiceTests {
|
||||
private StatusCheckingUserDetailsService us = new StatusCheckingUserDetailsService(new MockUserDetailsService());
|
||||
|
||||
@Test
|
||||
public void validAccountIsSuccessfullyLoaded() throws Exception {
|
||||
us.loadUserByUsername("valid");
|
||||
}
|
||||
|
||||
@Test(expected = LockedException.class)
|
||||
public void lockedAccountThrowsLockedException() throws Exception {
|
||||
us.loadUserByUsername("locked");
|
||||
}
|
||||
|
||||
@Test(expected = DisabledException.class)
|
||||
public void disabledAccountThrowsDisabledException() throws Exception {
|
||||
us.loadUserByUsername("disabled");
|
||||
}
|
||||
|
||||
@Test(expected = CredentialsExpiredException.class)
|
||||
public void credentialsExpiredAccountThrowsCredentialsExpiredException() throws Exception {
|
||||
us.loadUserByUsername("credentialsExpired");
|
||||
}
|
||||
|
||||
@Test(expected = AccountExpiredException.class)
|
||||
public void expiredAccountThrowsAccountExpiredException() throws Exception {
|
||||
us.loadUserByUsername("expired");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user