Search in sources :

Example 11 with Event

use of org.springframework.webflow.execution.Event in project cas by apereo.

the class InitialFlowSetupActionTests method verifyNoServiceFound.

@Test
public void verifyNoServiceFound() throws Exception {
    final MockRequestContext context = new MockRequestContext();
    context.setExternalContext(new ServletExternalContext(new MockServletContext(), new MockHttpServletRequest(), new MockHttpServletResponse()));
    final Event event = this.action.execute(context);
    assertNull(WebUtils.getService(context));
    assertEquals("success", event.getId());
}
Also used : ServletExternalContext(org.springframework.webflow.context.servlet.ServletExternalContext) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) Event(org.springframework.webflow.execution.Event) MockRequestContext(org.springframework.webflow.test.MockRequestContext) MockServletContext(org.springframework.mock.web.MockServletContext) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Example 12 with Event

use of org.springframework.webflow.execution.Event in project cas by apereo.

the class LogoutActionTests method verifyLogoutRequestFront.

@SuppressWarnings("unchecked")
@Test
public void verifyLogoutRequestFront() throws Exception {
    final Cookie cookie = new Cookie(COOKIE_TGC_ID, "test");
    this.request.setCookies(cookie);
    final LogoutRequest logoutRequest = new DefaultLogoutRequest(StringUtils.EMPTY, null, null);
    WebUtils.putLogoutRequests(this.requestContext, Arrays.asList(logoutRequest));
    final LogoutProperties properties = new LogoutProperties();
    this.logoutAction = new LogoutAction(getWebApplicationServiceFactory(), this.serviceManager, properties);
    final Event event = this.logoutAction.doExecute(this.requestContext);
    assertEquals(LogoutAction.FRONT_EVENT, event.getId());
    final List<LogoutRequest> logoutRequests = WebUtils.getLogoutRequests(this.requestContext);
    assertEquals(1, logoutRequests.size());
    assertEquals(logoutRequest, logoutRequests.get(0));
}
Also used : Cookie(javax.servlet.http.Cookie) LogoutProperties(org.apereo.cas.configuration.model.core.logout.LogoutProperties) DefaultLogoutRequest(org.apereo.cas.logout.DefaultLogoutRequest) Event(org.springframework.webflow.execution.Event) LogoutRequest(org.apereo.cas.logout.LogoutRequest) DefaultLogoutRequest(org.apereo.cas.logout.DefaultLogoutRequest) Test(org.junit.Test)

Example 13 with Event

use of org.springframework.webflow.execution.Event in project cas by apereo.

the class LogoutActionTests method verifyLogoutNoCookie.

@Test
public void verifyLogoutNoCookie() throws Exception {
    final LogoutProperties properties = new LogoutProperties();
    this.logoutAction = new LogoutAction(getWebApplicationServiceFactory(), this.serviceManager, properties);
    final Event event = this.logoutAction.doExecute(this.requestContext);
    assertEquals(LogoutAction.FINISH_EVENT, event.getId());
}
Also used : LogoutProperties(org.apereo.cas.configuration.model.core.logout.LogoutProperties) Event(org.springframework.webflow.execution.Event) Test(org.junit.Test)

Example 14 with Event

use of org.springframework.webflow.execution.Event in project cas by apereo.

the class LogoutActionTests method verifyLogoutForServiceWithFollowRedirectsAndMatchingService.

@Test
public void verifyLogoutForServiceWithFollowRedirectsAndMatchingService() throws Exception {
    this.request.addParameter("service", TEST_SERVICE_ID);
    final RegexRegisteredService impl = new RegexRegisteredService();
    impl.setServiceId(TEST_SERVICE_ID);
    impl.setName(TEST_SERVICE_ID);
    this.serviceManager.save(impl);
    final LogoutProperties properties = new LogoutProperties();
    properties.setFollowServiceRedirects(true);
    this.logoutAction = new LogoutAction(getWebApplicationServiceFactory(), this.serviceManager, properties);
    final Event event = this.logoutAction.doExecute(this.requestContext);
    assertEquals(LogoutAction.FINISH_EVENT, event.getId());
    assertEquals(TEST_SERVICE_ID, this.requestContext.getFlowScope().get("logoutRedirectUrl"));
}
Also used : LogoutProperties(org.apereo.cas.configuration.model.core.logout.LogoutProperties) Event(org.springframework.webflow.execution.Event) RegexRegisteredService(org.apereo.cas.services.RegexRegisteredService) Test(org.junit.Test)

Example 15 with Event

use of org.springframework.webflow.execution.Event in project cas by apereo.

the class LogoutActionTests method verifyLogoutRequestBack.

@Test
public void verifyLogoutRequestBack() throws Exception {
    final Cookie cookie = new Cookie(COOKIE_TGC_ID, "test");
    this.request.setCookies(cookie);
    final LogoutRequest logoutRequest = new DefaultLogoutRequest(StringUtils.EMPTY, null, null);
    logoutRequest.setStatus(LogoutRequestStatus.SUCCESS);
    WebUtils.putLogoutRequests(this.requestContext, Arrays.asList(logoutRequest));
    final LogoutProperties properties = new LogoutProperties();
    this.logoutAction = new LogoutAction(getWebApplicationServiceFactory(), this.serviceManager, properties);
    final Event event = this.logoutAction.doExecute(this.requestContext);
    assertEquals(LogoutAction.FINISH_EVENT, event.getId());
}
Also used : Cookie(javax.servlet.http.Cookie) LogoutProperties(org.apereo.cas.configuration.model.core.logout.LogoutProperties) DefaultLogoutRequest(org.apereo.cas.logout.DefaultLogoutRequest) Event(org.springframework.webflow.execution.Event) LogoutRequest(org.apereo.cas.logout.LogoutRequest) DefaultLogoutRequest(org.apereo.cas.logout.DefaultLogoutRequest) Test(org.junit.Test)

Aggregations

Event (org.springframework.webflow.execution.Event)56 Test (org.junit.Test)26 MockRequestContext (org.springframework.webflow.test.MockRequestContext)20 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)15 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)15 Authentication (org.apereo.cas.authentication.Authentication)13 AuthenticationException (org.apereo.cas.authentication.AuthenticationException)13 ServletExternalContext (org.springframework.webflow.context.servlet.ServletExternalContext)13 RegisteredService (org.apereo.cas.services.RegisteredService)12 MultifactorAuthenticationProvider (org.apereo.cas.services.MultifactorAuthenticationProvider)11 MockServletContext (org.springframework.mock.web.MockServletContext)11 HttpServletRequest (javax.servlet.http.HttpServletRequest)9 CentralAuthenticationService (org.apereo.cas.CentralAuthenticationService)8 LogoutProperties (org.apereo.cas.configuration.model.core.logout.LogoutProperties)8 WebUtils (org.apereo.cas.web.support.WebUtils)8 EventFactorySupport (org.springframework.webflow.action.EventFactorySupport)8 RequestContext (org.springframework.webflow.execution.RequestContext)8 Logger (org.slf4j.Logger)7 LoggerFactory (org.slf4j.LoggerFactory)7 Map (java.util.Map)6