mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-06-29 15:22:15 +00:00
Expand test coverage.
This commit is contained in:
parent
9176aa0efb
commit
d6207106c0
@ -66,6 +66,8 @@ public class DaoAuthenticationProviderTests extends TestCase {
|
|||||||
DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
|
DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
|
||||||
provider.setAuthenticationDao(new MockAuthenticationDaoUserMarissa());
|
provider.setAuthenticationDao(new MockAuthenticationDaoUserMarissa());
|
||||||
provider.setUserCache(new MockUserCache());
|
provider.setUserCache(new MockUserCache());
|
||||||
|
provider.setApplicationContext(new ClassPathXmlApplicationContext(
|
||||||
|
"net/sf/acegisecurity/util/filtertest-valid.xml"));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
provider.authenticate(token);
|
provider.authenticate(token);
|
||||||
@ -89,6 +91,16 @@ public class DaoAuthenticationProviderTests extends TestCase {
|
|||||||
} catch (AccountExpiredException expected) {
|
} catch (AccountExpiredException expected) {
|
||||||
assertTrue(true);
|
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() {
|
public void testAuthenticateFailsIfCredentialsExpired() {
|
||||||
@ -105,6 +117,16 @@ public class DaoAuthenticationProviderTests extends TestCase {
|
|||||||
} catch (CredentialsExpiredException expected) {
|
} catch (CredentialsExpiredException expected) {
|
||||||
assertTrue(true);
|
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() {
|
public void testAuthenticateFailsIfUserDisabled() {
|
||||||
@ -121,6 +143,16 @@ public class DaoAuthenticationProviderTests extends TestCase {
|
|||||||
} catch (DisabledException expected) {
|
} catch (DisabledException expected) {
|
||||||
assertTrue(true);
|
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() {
|
public void testAuthenticateFailsWhenAuthenticationDaoHasBackendFailure() {
|
||||||
|
@ -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.EhCacheBasedUserCache;
|
||||||
import net.sf.acegisecurity.providers.dao.cache.NullUserCache;
|
import net.sf.acegisecurity.providers.dao.cache.NullUserCache;
|
||||||
|
|
||||||
|
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||||
|
|
||||||
import org.springframework.dao.DataAccessException;
|
import org.springframework.dao.DataAccessException;
|
||||||
import org.springframework.dao.DataRetrievalFailureException;
|
import org.springframework.dao.DataRetrievalFailureException;
|
||||||
|
|
||||||
@ -84,6 +86,16 @@ public class PasswordDaoAuthenticationProviderTests extends TestCase {
|
|||||||
} catch (AccountExpiredException expected) {
|
} catch (AccountExpiredException expected) {
|
||||||
assertTrue(true);
|
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() {
|
public void testAuthenticateFailsIfCredentialsExpired() {
|
||||||
@ -100,6 +112,16 @@ public class PasswordDaoAuthenticationProviderTests extends TestCase {
|
|||||||
} catch (CredentialsExpiredException expected) {
|
} catch (CredentialsExpiredException expected) {
|
||||||
assertTrue(true);
|
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() {
|
public void testAuthenticateFailsIfUserDisabled() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user