use of org.springframework.webflow.engine.ViewState in project cas by apereo.
the class WebAuthnMultifactorWebflowConfigurerTests method verifyCsrfOperation.
@Test
public void verifyCsrfOperation() {
val webAuthnFlow = (Flow) loginFlowDefinitionRegistry.getFlowDefinition(WebAuthnMultifactorWebflowConfigurer.FLOW_ID_MFA_WEBAUTHN);
val context = new MockRequestControlContext(webAuthnFlow);
val request = new MockHttpServletRequest();
val response = new MockHttpServletResponse();
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));
RequestContextHolder.setRequestContext(context);
ExternalContextHolder.setExternalContext(context.getExternalContext());
WebUtils.putAuthentication(RegisteredServiceTestUtils.getAuthentication(), context);
WebUtils.putMultifactorAuthenticationProviderIdIntoFlowScope(context, webAuthnMultifactorAuthenticationProvider);
val registration = (ViewState) webAuthnFlow.getState(CasWebflowConstants.STATE_ID_WEBAUTHN_VIEW_REGISTRATION);
registration.enter(context);
assertNotNull(context.getFlowScope().get("_csrf"));
}
use of org.springframework.webflow.engine.ViewState in project cas by apereo.
the class DefaultLoginWebflowConfigurerTests method verifyRenderAction.
@Test
public void verifyRenderAction() {
val context = new MockRequestContext();
val request = new MockHttpServletRequest();
val response = new MockHttpServletResponse();
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));
RequestContextHolder.setRequestContext(context);
ExternalContextHolder.setExternalContext(context.getExternalContext());
assertFalse(casWebflowExecutionPlan.getWebflowConfigurers().isEmpty());
val cfg = casWebflowExecutionPlan.getWebflowConfigurers().iterator().next();
assertNotNull(cfg.createRenderAction("ExampleRenderAction"));
val flow = (Flow) this.loginFlowDefinitionRegistry.getFlowDefinition(CasWebflowConfigurer.FLOW_ID_LOGIN);
assertNotNull(flow);
assertNull(cfg.getState(flow, "InvalidStateId", ViewState.class));
assertNull(cfg.createTransitionForState(null, "BadCriteria", "BadTarget", false, Map.of(), (Action) null));
assertNull(cfg.createTransitionForState(null, "BadCriteria", "BadTarget", Map.of(), (Action) null));
assertTrue(cfg.getTransitionExecutionCriteriaChainForTransition(mock(Transition.class)).isEmpty());
assertNull(cfg.createViewState(null, "ViewState", (ViewFactory) null));
assertNull(cfg.createViewState(null, "ViewState", (Expression) null, null));
assertNotNull(cfg.createViewState(flow, CasWebflowConstants.STATE_ID_VIEW_LOGIN_FORM, (ViewFactory) null));
}
use of org.springframework.webflow.engine.ViewState in project cas by apereo.
the class DelegatedAuthenticationWebflowConfigurerTests method verifyOperation.
@Test
public void verifyOperation() {
assertFalse(casWebflowExecutionPlan.getWebflowConfigurers().isEmpty());
val flow = (Flow) this.loginFlowDefinitionRegistry.getFlowDefinition(CasWebflowConfigurer.FLOW_ID_LOGIN);
assertNotNull(flow);
assertTrue(flow.containsState(CasWebflowConstants.STATE_ID_DELEGATED_AUTHENTICATION_CLIENT_RETRY));
assertTrue(flow.containsState(CasWebflowConstants.STATE_ID_DELEGATED_AUTHENTICATION));
val stopState = (ViewState) flow.getState(CasWebflowConstants.STATE_ID_STOP_WEBFLOW);
val context = new MockRequestControlContext(flow);
val request = new MockHttpServletRequest();
request.addParameter("error_description", "fail");
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, new MockHttpServletResponse()));
context.getFlowScope().put(CasWebflowConstants.ATTRIBUTE_ERROR_ROOT_CAUSE_EXCEPTION, new RuntimeException());
stopState.enter(context);
assertTrue(context.getFlowScope().contains("code"));
assertTrue(context.getFlowScope().contains("description"));
}
use of org.springframework.webflow.engine.ViewState in project cas by apereo.
the class AbstractCasWebflowConfigurer method createViewState.
@Override
public ViewState createViewState(final Flow flow, final String id, final ViewFactory viewFactory) {
try {
if (containsFlowState(flow, id)) {
LOGGER.trace("Flow [{}] already contains a definition for state id [{}]", flow.getId(), id);
return getTransitionableState(flow, id, ViewState.class);
}
val viewState = new ViewState(flow, id, viewFactory);
LOGGER.trace("Added view state [{}]", viewState.getId());
return viewState;
} catch (final Exception e) {
LoggingUtils.error(LOGGER, e);
}
return null;
}
use of org.springframework.webflow.engine.ViewState in project cas by apereo.
the class DuoSecurityUniversalPromptMultifactorWebflowConfigurerTests method verifyUniversalPromptFlow.
@Test
public void verifyUniversalPromptFlow() {
val loginFlow = (Flow) loginFlowDefinitionRegistry.getFlowDefinition(CasWebflowConfigurer.FLOW_ID_LOGIN);
assertNotNull(loginFlow.getState(CasWebflowConstants.STATE_ID_DUO_UNIVERSAL_PROMPT_VALIDATE_LOGIN));
assertEquals(CasWebflowConstants.STATE_ID_DUO_UNIVERSAL_PROMPT_VALIDATE_LOGIN, loginFlow.getStartState().getId());
val registry = getMultifactorFlowDefinitionRegistry();
val flow = (Flow) registry.getFlowDefinition(getMultifactorEventId());
val viewState = (ViewState) flow.getState(CasWebflowConstants.STATE_ID_VIEW_LOGIN_FORM_DUO);
assertTrue(viewState.getEntryActionList().get(0).toString().contains(CasWebflowConstants.ACTION_ID_DUO_UNIVERSAL_PROMPT_PREPARE_LOGIN));
}
Aggregations