Expand test coverage.

This commit is contained in:
Ben Alex 2005-01-04 20:20:21 +00:00
parent 9176aa0efb
commit d6207106c0
2 changed files with 54 additions and 0 deletions

View File

@ -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() {

View File

@ -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() {