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");
}
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));
}
Aggregations