Search in sources :

Example 11 with DuoSecurityMultifactorAuthenticationProperties

use of org.apereo.cas.configuration.model.support.mfa.DuoSecurityMultifactorAuthenticationProperties in project cas by apereo.

the class DuoSecurityAdminApiEndpointTests method setup.

@BeforeEach
public void setup() {
    ApplicationContextProvider.holdApplicationContext(applicationContext);
    val props = new DuoSecurityMultifactorAuthenticationProperties().setDuoApiHost("localhost:8443").setDuoAdminIntegrationKey(UUID.randomUUID().toString()).setDuoAdminSecretKey(UUID.randomUUID().toString());
    val duoService = new BasicDuoSecurityAuthenticationService(props, httpClient, List.of(), Caffeine.newBuilder().build());
    val bean = mock(DuoSecurityMultifactorAuthenticationProvider.class);
    when(bean.getId()).thenReturn(DuoSecurityMultifactorAuthenticationProperties.DEFAULT_IDENTIFIER);
    when(bean.getDuoAuthenticationService()).thenReturn(duoService);
    when(bean.matches(eq(DuoSecurityMultifactorAuthenticationProperties.DEFAULT_IDENTIFIER))).thenReturn(true);
    ApplicationContextProvider.registerBeanIntoApplicationContext(applicationContext, bean, "duoProvider");
}
Also used : lombok.val(lombok.val) BasicDuoSecurityAuthenticationService(org.apereo.cas.adaptors.duo.authn.BasicDuoSecurityAuthenticationService) DuoSecurityMultifactorAuthenticationProperties(org.apereo.cas.configuration.model.support.mfa.DuoSecurityMultifactorAuthenticationProperties) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 12 with DuoSecurityMultifactorAuthenticationProperties

use of org.apereo.cas.configuration.model.support.mfa.DuoSecurityMultifactorAuthenticationProperties in project cas by apereo.

the class DuoSecurityUserAccountStatusEndpointTests method verifyOperation.

@Test
public void verifyOperation() {
    ApplicationContextProvider.holdApplicationContext(applicationContext);
    val account = new DuoSecurityUserAccount("casuser");
    account.setMessage("User is valid");
    account.setStatus(DuoSecurityUserAccountStatus.AUTH);
    val duoService = mock(DuoSecurityAuthenticationService.class);
    when(duoService.ping()).thenReturn(true);
    val props = new DuoSecurityMultifactorAuthenticationProperties().setDuoApiHost("https://api.duosecurity.com");
    when(duoService.getProperties()).thenReturn(props);
    when(duoService.getUserAccount(eq("casuser"))).thenReturn(account);
    val bean = mock(DuoSecurityMultifactorAuthenticationProvider.class);
    when(bean.getId()).thenReturn(DuoSecurityMultifactorAuthenticationProperties.DEFAULT_IDENTIFIER);
    when(bean.getDuoAuthenticationService()).thenReturn(duoService);
    when(bean.matches(eq(DuoSecurityMultifactorAuthenticationProperties.DEFAULT_IDENTIFIER))).thenReturn(true);
    ApplicationContextProvider.registerBeanIntoApplicationContext(applicationContext, bean, "duoProvider");
    val indicator = new DuoSecurityUserAccountStatusEndpoint(casProperties, this.applicationContext);
    val result = indicator.fetchAccountStatus("casuser", DuoSecurityMultifactorAuthenticationProperties.DEFAULT_IDENTIFIER);
    assertNotNull(result);
    assertTrue(result.containsKey(DuoSecurityMultifactorAuthenticationProperties.DEFAULT_IDENTIFIER));
}
Also used : lombok.val(lombok.val) DuoSecurityMultifactorAuthenticationProperties(org.apereo.cas.configuration.model.support.mfa.DuoSecurityMultifactorAuthenticationProperties) DuoSecurityUserAccount(org.apereo.cas.adaptors.duo.DuoSecurityUserAccount) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

lombok.val (lombok.val)12 DuoSecurityMultifactorAuthenticationProperties (org.apereo.cas.configuration.model.support.mfa.DuoSecurityMultifactorAuthenticationProperties)12 Test (org.junit.jupiter.api.Test)9 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)5 HttpClient (org.apereo.cas.util.http.HttpClient)3 MockWebServer (org.apereo.cas.util.MockWebServer)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 Http (com.duosecurity.client.Http)1 AccessDevice (com.duosecurity.model.AccessDevice)1 Application (com.duosecurity.model.Application)1 AuthContext (com.duosecurity.model.AuthContext)1 AuthDevice (com.duosecurity.model.AuthDevice)1 AuthResult (com.duosecurity.model.AuthResult)1 HealthCheckResponse (com.duosecurity.model.HealthCheckResponse)1 Location (com.duosecurity.model.Location)1 Token (com.duosecurity.model.Token)1 User (com.duosecurity.model.User)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1