use of org.springframework.webflow.test.MockParameterMap in project cas by apereo.
the class DefaultCasWebflowAuthenticationExceptionHandlerTests method setup.
@BeforeEach
public void setup() {
val errors = new LinkedHashSet<Class<? extends Throwable>>();
errors.add(UnauthorizedServiceForPrincipalException.class);
errors.add(UnauthorizedAuthenticationException.class);
val catalog = new DefaultCasWebflowExceptionCatalog();
catalog.registerExceptions(errors);
val request = new MockHttpServletRequest();
val response = new MockHttpServletResponse();
this.context = mock(RequestContext.class);
when(context.getMessageContext()).thenReturn(mock(MessageContext.class));
when(context.getFlowScope()).thenReturn(new LocalAttributeMap<>());
when(context.getRequestParameters()).thenReturn(new MockParameterMap());
when(context.getFlashScope()).thenReturn(new LocalAttributeMap<>());
when(context.getExternalContext()).thenReturn(new ServletExternalContext(new MockServletContext(), request, response));
this.handler = new DefaultCasWebflowAuthenticationExceptionHandler(catalog, MessageBundleProperties.DEFAULT_BUNDLE_PREFIX_AUTHN_FAILURE);
}
use of org.springframework.webflow.test.MockParameterMap in project cas by apereo.
the class DefaultCasWebflowAbstractTicketExceptionHandlerTests method setup.
@BeforeEach
public void setup() {
val errors = new LinkedHashSet<Class<? extends Throwable>>();
errors.add(InvalidTicketException.class);
errors.add(InvalidProxyGrantingTicketForServiceTicketException.class);
errors.add(UnauthorizedServiceTicketValidationException.class);
val catalog = new DefaultCasWebflowExceptionCatalog();
catalog.registerExceptions(errors);
val request = new MockHttpServletRequest();
val response = new MockHttpServletResponse();
this.context = mock(RequestContext.class);
when(context.getMessageContext()).thenReturn(mock(MessageContext.class));
when(context.getFlowScope()).thenReturn(new LocalAttributeMap<>());
when(context.getRequestParameters()).thenReturn(new MockParameterMap());
when(context.getFlashScope()).thenReturn(new LocalAttributeMap<>());
when(context.getExternalContext()).thenReturn(new ServletExternalContext(new MockServletContext(), request, response));
this.handler = new DefaultCasWebflowAbstractTicketExceptionHandler(catalog, MessageBundleProperties.DEFAULT_BUNDLE_PREFIX_AUTHN_FAILURE);
}
use of org.springframework.webflow.test.MockParameterMap in project cas by apereo.
the class DelegatedClientAuthenticationDynamicDiscoveryExecutionActionTests method verifyOperationWithoutClient.
@Test
public void verifyOperationWithoutClient() throws Exception {
val context = mock(RequestContext.class);
when(context.getMessageContext()).thenReturn(mock(MessageContext.class));
when(context.getFlowScope()).thenReturn(new LocalAttributeMap<>());
when(context.getRequestParameters()).thenReturn(new MockParameterMap());
when(context.getRequestScope()).thenReturn(new LocalAttributeMap<>());
val request = new MockHttpServletRequest();
request.addParameter("username", "cas@test.org");
val response = new MockHttpServletResponse();
when(context.getExternalContext()).thenReturn(new ServletExternalContext(new org.springframework.mock.web.MockServletContext(), request, response));
val result = delegatedAuthenticationDiscoveryAction.execute(context);
assertNotNull(result);
assertEquals(CasWebflowConstants.TRANSITION_ID_ERROR, result.getId());
}
use of org.springframework.webflow.test.MockParameterMap in project cas by apereo.
the class FinalizeAccountRegistrationActionTests method setup.
@BeforeEach
public void setup() {
this.context = mock(RequestContext.class);
when(context.getMessageContext()).thenReturn(mock(MessageContext.class));
when(context.getFlowScope()).thenReturn(new LocalAttributeMap<>());
when(context.getRequestParameters()).thenReturn(new MockParameterMap());
when(context.getConversationScope()).thenReturn(new LocalAttributeMap<>());
when(context.getRequestParameters()).thenReturn(new MockParameterMap());
RequestContextHolder.setRequestContext(context);
ExternalContextHolder.setExternalContext(context.getExternalContext());
}
use of org.springframework.webflow.test.MockParameterMap in project cas by apereo.
the class SubmitAccountRegistrationActionTests method verifyFailingOperation.
@Test
public void verifyFailingOperation() throws Exception {
val request = new MockHttpServletRequest();
val response = new MockHttpServletResponse();
val context = mock(RequestContext.class);
when(context.getMessageContext()).thenReturn(mock(MessageContext.class));
when(context.getFlashScope()).thenReturn(new LocalAttributeMap<>());
when(context.getFlowScope()).thenReturn(new LocalAttributeMap<>());
when(context.getRequestParameters()).thenReturn(new MockParameterMap());
when(context.getExternalContext()).thenReturn(new ServletExternalContext(new MockServletContext(), request, response));
RequestContextHolder.setRequestContext(context);
ExternalContextHolder.setExternalContext(context.getExternalContext());
val results = submitAccountRegistrationAction.execute(context);
assertEquals(CasWebflowConstants.TRANSITION_ID_ERROR, results.getId());
}
Aggregations