use of org.springframework.webflow.test.MockRequestControlContext in project cas by apereo.
the class AccountManagementWebflowConfigurerTests 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_VIEW_ACCOUNT_SIGNUP));
assertTrue(flow.containsState(CasWebflowConstants.STATE_ID_SUBMIT_ACCOUNT_REGISTRATION));
assertTrue(flow.containsState(CasWebflowConstants.STATE_ID_SENT_ACCOUNT_SIGNUP_INFO));
assertTrue(flow.containsState(CasWebflowConstants.STATE_ID_ACCOUNT_REGISTRATION_SUBFLOW));
val subflow = (SubflowState) flow.getState(CasWebflowConstants.STATE_ID_ACCOUNT_REGISTRATION_SUBFLOW);
assertNotNull(subflow);
val regFlow = (Flow) loginFlowDefinitionRegistry.getFlowDefinition(AccountManagementWebflowConfigurer.FLOW_ID_ACCOUNT_REGISTRATION);
val context = new MockRequestControlContext(regFlow);
val request = new MockHttpServletRequest();
val response = new MockHttpServletResponse();
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));
RequestContextHolder.setRequestContext(context);
ExternalContextHolder.setExternalContext(context.getExternalContext());
val completeState = (ViewState) regFlow.getState(CasWebflowConstants.STATE_ID_COMPLETE_ACCOUNT_REGISTRATION);
completeState.enter(context);
assertNotNull(WebUtils.getPasswordPolicyPattern(context));
assertEquals(2, AccountRegistrationUtils.getAccountRegistrationSecurityQuestionsCount(context));
}
use of org.springframework.webflow.test.MockRequestControlContext in project cas by apereo.
the class DefaultLoginWebflowConfigurerTests method verifyWebflowConfigError.
@Test
public void verifyWebflowConfigError() {
val flow = (Flow) this.loginFlowDefinitionRegistry.getFlowDefinition(CasWebflowConfigurer.FLOW_ID_LOGIN);
val stopState = (EndState) flow.getState(CasWebflowConstants.STATE_ID_VIEW_WEBFLOW_CONFIG_ERROR);
val context = new MockRequestControlContext(flow);
val request = new MockHttpServletRequest();
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, new MockHttpServletResponse()));
context.getFlashScope().put(CasWebflowConstants.ATTRIBUTE_ERROR_ROOT_CAUSE_EXCEPTION, new RuntimeException());
assertDoesNotThrow(new Executable() {
@Override
public void execute() throws Throwable {
stopState.enter(context);
}
});
}
use of org.springframework.webflow.test.MockRequestControlContext 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.test.MockRequestControlContext 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"));
}
Aggregations