Search in sources :

Example 1 with InMemoryPasswordlessTokenRepository

use of org.apereo.cas.impl.token.InMemoryPasswordlessTokenRepository in project cas by apereo.

the class PasswordlessTokenAuthenticationHandlerTests method verifyAction.

@Test
public void verifyAction() throws Exception {
    val repository = new InMemoryPasswordlessTokenRepository(60);
    repository.saveToken("casuser", "123456");
    val h = new PasswordlessTokenAuthenticationHandler(null, mock(ServicesManager.class), PrincipalFactoryUtils.newPrincipalFactory(), 0, repository);
    val c = new OneTimePasswordCredential("casuser", "123456");
    assertNotNull(h.authenticate(c));
    assertThrows(FailedLoginException.class, () -> h.authenticate(new OneTimePasswordCredential("1", "2")));
    assertTrue(h.supports(c));
    assertTrue(h.supports(c.getCredentialClass()));
    assertFalse(h.supports(new UsernamePasswordCredential()));
}
Also used : lombok.val(lombok.val) ServicesManager(org.apereo.cas.services.ServicesManager) OneTimePasswordCredential(org.apereo.cas.authentication.credential.OneTimePasswordCredential) InMemoryPasswordlessTokenRepository(org.apereo.cas.impl.token.InMemoryPasswordlessTokenRepository) UsernamePasswordCredential(org.apereo.cas.authentication.credential.UsernamePasswordCredential) Test(org.junit.jupiter.api.Test)

Aggregations

lombok.val (lombok.val)1 OneTimePasswordCredential (org.apereo.cas.authentication.credential.OneTimePasswordCredential)1 UsernamePasswordCredential (org.apereo.cas.authentication.credential.UsernamePasswordCredential)1 InMemoryPasswordlessTokenRepository (org.apereo.cas.impl.token.InMemoryPasswordlessTokenRepository)1 ServicesManager (org.apereo.cas.services.ServicesManager)1 Test (org.junit.jupiter.api.Test)1