use of org.apereo.cas.configuration.model.support.mfa.InweboMultifactorAuthenticationProperties in project cas by apereo.
the class BaseActionTests method setUp.
@BeforeEach
public void setUp() {
val applicationContext = new StaticApplicationContext();
applicationContext.refresh();
ApplicationContextProvider.registerBeanIntoApplicationContext(applicationContext, CoreAuthenticationTestUtils.getAuthenticationSystemSupport(), AuthenticationSystemSupport.BEAN_NAME);
requestContext = new MockRequestContext();
request = new MockHttpServletRequest();
val response = new MockHttpServletResponse();
requestContext.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));
setRequestContext(requestContext);
setExternalContext(requestContext.getExternalContext());
((DefaultMessageContext) requestContext.getMessageContext()).setMessageSource(new AbstractMessageSource() {
@Override
protected MessageFormat resolveCode(final String code, final Locale locale) {
return new MessageFormat(StringUtils.EMPTY);
}
});
service = mock(InweboService.class);
val authenticationEventExecutionPlan = new DefaultAuthenticationEventExecutionPlan();
authenticationEventExecutionPlan.registerAuthenticationHandler(new InweboAuthenticationHandler(mock(ServicesManager.class), PrincipalFactoryUtils.newPrincipalFactory(), new InweboMultifactorAuthenticationProperties(), service));
authenticationEventExecutionPlan.registerAuthenticationMetadataPopulator(new InweboAuthenticationDeviceMetadataPopulator());
val authenticationManager = new DefaultAuthenticationManager(authenticationEventExecutionPlan, true, applicationContext);
val authenticationTransactionManager = new DefaultAuthenticationTransactionManager(applicationContext, authenticationManager);
val authenticationSystemSupport = new DefaultAuthenticationSystemSupport(authenticationTransactionManager, new DefaultPrincipalElectionStrategy(), new DefaultAuthenticationResultBuilderFactory(), new DefaultAuthenticationTransactionFactory());
val context = CasWebflowEventResolutionConfigurationContext.builder().authenticationSystemSupport(authenticationSystemSupport).build();
resolver = new InweboMultifactorAuthenticationWebflowEventResolver(context);
setAuthenticationInContext(LOGIN);
}
use of org.apereo.cas.configuration.model.support.mfa.InweboMultifactorAuthenticationProperties in project cas by apereo.
the class InweboAuthenticationHandlerTests method verifyOperation.
@Test
public void verifyOperation() throws Exception {
val inweboService = mock(InweboService.class);
val response = new InweboDeviceNameResponse();
response.setDeviceName("DeviceName");
response.setResult(InweboResult.OK);
when(inweboService.authenticateExtended(anyString(), anyString())).thenReturn(response);
val handler = new InweboAuthenticationHandler(mock(ServicesManager.class), PrincipalFactoryUtils.newPrincipalFactory(), new InweboMultifactorAuthenticationProperties(), inweboService);
val credential = new InweboCredential("token");
credential.setOtp("otp");
val result = handler.authenticate(credential);
assertNotNull(result);
assertNotNull(credential.getDeviceName());
assertTrue(handler.supports(credential));
assertTrue(handler.supports(credential.getCredentialClass()));
}
use of org.apereo.cas.configuration.model.support.mfa.InweboMultifactorAuthenticationProperties in project cas by apereo.
the class InweboAuthenticationHandlerTests method verifyFailsOperation.
@Test
public void verifyFailsOperation() {
val inweboService = mock(InweboService.class);
val response = new InweboDeviceNameResponse();
response.setDeviceName("DeviceName");
response.setResult(InweboResult.OK);
when(inweboService.authenticateExtended(anyString(), anyString())).thenReturn(response);
val handler = new InweboAuthenticationHandler(mock(ServicesManager.class), PrincipalFactoryUtils.newPrincipalFactory(), new InweboMultifactorAuthenticationProperties(), inweboService);
val credential = new InweboCredential("token");
assertThrows(FailedLoginException.class, () -> handler.authenticate(credential));
}
use of org.apereo.cas.configuration.model.support.mfa.InweboMultifactorAuthenticationProperties in project cas by apereo.
the class InweboCheckUserActionTests method setUp.
@BeforeEach
public void setUp() {
super.setUp();
val inwebo = new InweboMultifactorAuthenticationProperties();
inwebo.setSiteAlias(SITE_ALIAS);
val casProperties = new CasConfigurationProperties();
casProperties.getAuthn().getMfa().setInwebo(inwebo);
action = new InweboCheckUserAction(service, casProperties);
}
Aggregations