diff --git a/core/src/test/java/org/acegisecurity/providers/dao/DaoAuthenticationProviderTests.java b/core/src/test/java/org/acegisecurity/providers/dao/DaoAuthenticationProviderTests.java index 3f818b2960..d9c00f850d 100644 --- a/core/src/test/java/org/acegisecurity/providers/dao/DaoAuthenticationProviderTests.java +++ b/core/src/test/java/org/acegisecurity/providers/dao/DaoAuthenticationProviderTests.java @@ -66,6 +66,8 @@ public class DaoAuthenticationProviderTests extends TestCase { DaoAuthenticationProvider provider = new DaoAuthenticationProvider(); provider.setAuthenticationDao(new MockAuthenticationDaoUserMarissa()); provider.setUserCache(new MockUserCache()); + provider.setApplicationContext(new ClassPathXmlApplicationContext( + "net/sf/acegisecurity/util/filtertest-valid.xml")); try { provider.authenticate(token); @@ -89,6 +91,16 @@ public class DaoAuthenticationProviderTests extends TestCase { } catch (AccountExpiredException expected) { assertTrue(true); } + + provider.setApplicationContext(new ClassPathXmlApplicationContext( + "net/sf/acegisecurity/util/filtertest-valid.xml")); + + try { + provider.authenticate(token); + fail("Should have thrown AccountExpiredException"); + } catch (AccountExpiredException expected) { + assertTrue(true); + } } public void testAuthenticateFailsIfCredentialsExpired() { @@ -105,6 +117,16 @@ public class DaoAuthenticationProviderTests extends TestCase { } catch (CredentialsExpiredException expected) { assertTrue(true); } + + provider.setApplicationContext(new ClassPathXmlApplicationContext( + "net/sf/acegisecurity/util/filtertest-valid.xml")); + + try { + provider.authenticate(token); + fail("Should have thrown CredentialsExpiredException"); + } catch (CredentialsExpiredException expected) { + assertTrue(true); + } } public void testAuthenticateFailsIfUserDisabled() { @@ -121,6 +143,16 @@ public class DaoAuthenticationProviderTests extends TestCase { } catch (DisabledException expected) { assertTrue(true); } + + provider.setApplicationContext(new ClassPathXmlApplicationContext( + "net/sf/acegisecurity/util/filtertest-valid.xml")); + + try { + provider.authenticate(token); + fail("Should have thrown DisabledException"); + } catch (DisabledException expected) { + assertTrue(true); + } } public void testAuthenticateFailsWhenAuthenticationDaoHasBackendFailure() { diff --git a/core/src/test/java/org/acegisecurity/providers/dao/PasswordDaoAuthenticationProviderTests.java b/core/src/test/java/org/acegisecurity/providers/dao/PasswordDaoAuthenticationProviderTests.java index 18a71cca8b..e0b33b84e3 100644 --- a/core/src/test/java/org/acegisecurity/providers/dao/PasswordDaoAuthenticationProviderTests.java +++ b/core/src/test/java/org/acegisecurity/providers/dao/PasswordDaoAuthenticationProviderTests.java @@ -31,6 +31,8 @@ import net.sf.acegisecurity.providers.UsernamePasswordAuthenticationToken; import net.sf.acegisecurity.providers.dao.cache.EhCacheBasedUserCache; import net.sf.acegisecurity.providers.dao.cache.NullUserCache; +import org.springframework.context.support.ClassPathXmlApplicationContext; + import org.springframework.dao.DataAccessException; import org.springframework.dao.DataRetrievalFailureException; @@ -84,6 +86,16 @@ public class PasswordDaoAuthenticationProviderTests extends TestCase { } catch (AccountExpiredException expected) { assertTrue(true); } + + provider.setApplicationContext(new ClassPathXmlApplicationContext( + "net/sf/acegisecurity/util/filtertest-valid.xml")); + + try { + provider.authenticate(token); + fail("Should have thrown AccountExpiredException"); + } catch (AccountExpiredException expected) { + assertTrue(true); + } } public void testAuthenticateFailsIfCredentialsExpired() { @@ -100,6 +112,16 @@ public class PasswordDaoAuthenticationProviderTests extends TestCase { } catch (CredentialsExpiredException expected) { assertTrue(true); } + + provider.setApplicationContext(new ClassPathXmlApplicationContext( + "net/sf/acegisecurity/util/filtertest-valid.xml")); + + try { + provider.authenticate(token); + fail("Should have thrown CredentialsExpiredException"); + } catch (CredentialsExpiredException expected) { + assertTrue(true); + } } public void testAuthenticateFailsIfUserDisabled() {