use of org.apereo.cas.adaptors.duo.DuoSecurityUserAccount 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