use of org.springframework.security.authentication.RememberMeAuthenticationToken in project spring-security by spring-projects.
the class RememberMeAuthenticationProviderTests method testDetectsAnInvalidKey.
// ~ Methods
// ========================================================================================================
@Test
public void testDetectsAnInvalidKey() throws Exception {
RememberMeAuthenticationProvider aap = new RememberMeAuthenticationProvider("qwerty");
RememberMeAuthenticationToken token = new RememberMeAuthenticationToken("WRONG_KEY", "Test", AuthorityUtils.createAuthorityList("ROLE_ONE", "ROLE_TWO"));
try {
aap.authenticate(token);
fail("Should have thrown BadCredentialsException");
} catch (BadCredentialsException expected) {
}
}
use of org.springframework.security.authentication.RememberMeAuthenticationToken in project spring-security by spring-projects.
the class RememberMeAuthenticationTokenTests method testGetters.
@Test
public void testGetters() {
RememberMeAuthenticationToken token = new RememberMeAuthenticationToken("key", "Test", ROLES_12);
assertThat(token.getKeyHash()).isEqualTo("key".hashCode());
assertThat(token.getPrincipal()).isEqualTo("Test");
assertThat(token.getCredentials()).isEqualTo("");
assertThat(AuthorityUtils.authorityListToSet(token.getAuthorities())).contains("ROLE_ONE");
assertThat(AuthorityUtils.authorityListToSet(token.getAuthorities())).contains("ROLE_TWO");
assertThat(token.isAuthenticated()).isTrue();
}
use of org.springframework.security.authentication.RememberMeAuthenticationToken in project spring-security by spring-projects.
the class RememberMeAuthenticationTokenTests method testSetAuthenticatedIgnored.
@Test
public void testSetAuthenticatedIgnored() {
RememberMeAuthenticationToken token = new RememberMeAuthenticationToken("key", "Test", ROLES_12);
assertThat(token.isAuthenticated()).isTrue();
token.setAuthenticated(false);
assertThat(!token.isAuthenticated()).isTrue();
}
use of org.springframework.security.authentication.RememberMeAuthenticationToken in project spring-security by spring-projects.
the class RememberMeAuthenticationTokenTests method testNotEqualsDueToAbstractParentEqualsCheck.
@Test
public void testNotEqualsDueToAbstractParentEqualsCheck() {
RememberMeAuthenticationToken token1 = new RememberMeAuthenticationToken("key", "Test", ROLES_12);
RememberMeAuthenticationToken token2 = new RememberMeAuthenticationToken("key", "DIFFERENT_PRINCIPAL", ROLES_12);
assertThat(token1.equals(token2)).isFalse();
}
use of org.springframework.security.authentication.RememberMeAuthenticationToken in project spring-security by spring-projects.
the class RememberMeAuthenticationTokenTests method testNotEqualsDueToKey.
@Test
public void testNotEqualsDueToKey() {
RememberMeAuthenticationToken token1 = new RememberMeAuthenticationToken("key", "Test", ROLES_12);
RememberMeAuthenticationToken token2 = new RememberMeAuthenticationToken("DIFFERENT_KEY", "Test", ROLES_12);
assertThat(token1.equals(token2)).isFalse();
}
Aggregations