Search in sources :

Example 16 with ServletExternalContext

use of org.springframework.webflow.context.servlet.ServletExternalContext in project cas by apereo.

the class X509CertificateCredentialsNonInteractiveActionTests method verifyNoCredentialsResultsInError.

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

Example 17 with ServletExternalContext

use of org.springframework.webflow.context.servlet.ServletExternalContext in project cas by apereo.

the class X509CertificateCredentialsNonInteractiveActionTests method verifyCredentialsResultsInSuccess.

@Test
public void verifyCredentialsResultsInSuccess() throws Exception {
    final MockRequestContext context = new MockRequestContext();
    final MockHttpServletRequest request = new MockHttpServletRequest();
    request.setAttribute("javax.servlet.request.X509Certificate", new X509Certificate[] { VALID_CERTIFICATE });
    context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, new MockHttpServletResponse()));
    assertEquals("success", this.action.execute(context).getId());
}
Also used : MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) ServletExternalContext(org.springframework.webflow.context.servlet.ServletExternalContext) MockRequestContext(org.springframework.webflow.test.MockRequestContext) MockServletContext(org.springframework.mock.web.MockServletContext) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Example 18 with ServletExternalContext

use of org.springframework.webflow.context.servlet.ServletExternalContext in project cas by apereo.

the class PrincipalFromRequestRemoteUserNonInteractiveCredentialsActionTests method verifyRemoteUserDoesntExists.

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

Example 19 with ServletExternalContext

use of org.springframework.webflow.context.servlet.ServletExternalContext in project cas by apereo.

the class PrincipalFromRequestUserPrincipalNonInteractiveCredentialsActionTests method verifyRemoteUserDoesntExists.

@Test
public void verifyRemoteUserDoesntExists() throws Exception {
    final MockRequestContext context = new MockRequestContext();
    context.setExternalContext(new ServletExternalContext(new MockServletContext(), new MockHttpServletRequest(), new MockHttpServletResponse()));
    Assert.assertEquals("error", this.action.execute(context).getId());
}
Also used : ServletExternalContext(org.springframework.webflow.context.servlet.ServletExternalContext) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) MockRequestContext(org.springframework.webflow.test.MockRequestContext) MockServletContext(org.springframework.mock.web.MockServletContext) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Example 20 with ServletExternalContext

use of org.springframework.webflow.context.servlet.ServletExternalContext in project cas by apereo.

the class OpenIdSingleSignOnActionTests method verifySuccessfulServiceTicket.

@Test
public void verifySuccessfulServiceTicket() throws Exception {
    final MockRequestContext context = new MockRequestContext();
    final MockHttpServletRequest request = new MockHttpServletRequest();
    final Authentication authentication = CoreAuthenticationTestUtils.getAuthentication("scootman28");
    final TicketGrantingTicket t = new TicketGrantingTicketImpl("TGT-11", authentication, new NeverExpiresExpirationPolicy());
    this.ticketRegistry.addTicket(t);
    request.setParameter(OpenIdProtocolConstants.OPENID_IDENTITY, "http://openid.aol.com/scootman28");
    request.setParameter(OpenIdProtocolConstants.OPENID_RETURNTO, "http://www.cnn.com");
    final OpenIdService service = new OpenIdServiceFactory("").createService(request);
    context.getFlowScope().put("service", service);
    context.getFlowScope().put("ticketGrantingTicketId", t.getId());
    context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, new MockHttpServletResponse()));
    assertEquals("success", this.action.execute(context).getId());
}
Also used : NeverExpiresExpirationPolicy(org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) Authentication(org.apereo.cas.authentication.Authentication) TicketGrantingTicket(org.apereo.cas.ticket.TicketGrantingTicket) OpenIdService(org.apereo.cas.support.openid.authentication.principal.OpenIdService) ServletExternalContext(org.springframework.webflow.context.servlet.ServletExternalContext) TicketGrantingTicketImpl(org.apereo.cas.ticket.TicketGrantingTicketImpl) MockRequestContext(org.springframework.webflow.test.MockRequestContext) OpenIdServiceFactory(org.apereo.cas.support.openid.authentication.principal.OpenIdServiceFactory) MockServletContext(org.springframework.mock.web.MockServletContext) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Aggregations

ServletExternalContext (org.springframework.webflow.context.servlet.ServletExternalContext)48 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)47 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)47 Test (org.junit.Test)44 MockServletContext (org.springframework.mock.web.MockServletContext)43 MockRequestContext (org.springframework.webflow.test.MockRequestContext)40 Event (org.springframework.webflow.execution.Event)13 TicketGrantingTicket (org.apereo.cas.ticket.TicketGrantingTicket)11 Credential (org.apereo.cas.authentication.Credential)7 EventFactorySupport (org.springframework.webflow.action.EventFactorySupport)7 Cookie (javax.servlet.http.Cookie)4 AuthenticationResult (org.apereo.cas.authentication.AuthenticationResult)4 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)4 Service (org.apereo.cas.authentication.principal.Service)3 SamlMetadataUIInfo (org.apereo.cas.support.saml.mdui.SamlMetadataUIInfo)3 CentralAuthenticationService (org.apereo.cas.CentralAuthenticationService)2 Authentication (org.apereo.cas.authentication.Authentication)2 OpenIdService (org.apereo.cas.support.openid.authentication.principal.OpenIdService)2 OpenIdServiceFactory (org.apereo.cas.support.openid.authentication.principal.OpenIdServiceFactory)2 TicketGrantingTicketImpl (org.apereo.cas.ticket.TicketGrantingTicketImpl)2