use of org.springframework.security.authentication.AnonymousAuthenticationProvider in project spring-security by spring-projects.
the class AnonymousAuthenticationProviderTests method testDetectsAnInvalidKey.
// ~ Methods
// ========================================================================================================
@Test
public void testDetectsAnInvalidKey() throws Exception {
AnonymousAuthenticationProvider aap = new AnonymousAuthenticationProvider("qwerty");
AnonymousAuthenticationToken token = new AnonymousAuthenticationToken("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.AnonymousAuthenticationProvider in project spring-security by spring-projects.
the class AnonymousAuthenticationProviderTests method testSupports.
@Test
public void testSupports() {
AnonymousAuthenticationProvider aap = new AnonymousAuthenticationProvider("qwerty");
assertThat(aap.supports(AnonymousAuthenticationToken.class)).isTrue();
assertThat(aap.supports(TestingAuthenticationToken.class)).isFalse();
}
Aggregations