Search in sources :

Example 1 with Cas10ProxyHandler

use of org.apereo.cas.ticket.proxy.support.Cas10ProxyHandler in project cas by apereo.

the class AbstractServiceValidateControllerTests method verifyValidServiceTicketWithInvalidPgt.

@Test
public void verifyValidServiceTicketWithInvalidPgt() throws Exception {
    final AuthenticationResult ctx = CoreAuthenticationTestUtils.getAuthenticationResult(getAuthenticationSystemSupport(), SERVICE);
    this.serviceValidateController.setProxyHandler(new Cas10ProxyHandler());
    final TicketGrantingTicket tId = getCentralAuthenticationService().createTicketGrantingTicket(ctx);
    final ServiceTicket sId = getCentralAuthenticationService().grantServiceTicket(tId.getId(), SERVICE, ctx);
    final MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter(SERVICE_PARAM, SERVICE.getId());
    request.addParameter(TICKET_PARAM, sId.getId());
    request.addParameter(PGT_URL_PARAM, "duh");
    final ModelAndView modelAndView = this.serviceValidateController.handleRequestInternal(request, new MockHttpServletResponse());
    assertTrue(modelAndView.getView().toString().contains(SUCCESS));
    assertNull(modelAndView.getModel().get(PGT_IOU_PARAM));
}
Also used : TicketGrantingTicket(org.apereo.cas.ticket.TicketGrantingTicket) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) ModelAndView(org.springframework.web.servlet.ModelAndView) Cas10ProxyHandler(org.apereo.cas.ticket.proxy.support.Cas10ProxyHandler) ServiceTicket(org.apereo.cas.ticket.ServiceTicket) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) AuthenticationResult(org.apereo.cas.authentication.AuthenticationResult) Test(org.junit.Test)

Example 2 with Cas10ProxyHandler

use of org.apereo.cas.ticket.proxy.support.Cas10ProxyHandler in project cas by apereo.

the class AbstractServiceValidateControllerTests method verifyValidServiceTicketWithDifferentEncodingAndIgnoringCase.

@Test
public void verifyValidServiceTicketWithDifferentEncodingAndIgnoringCase() throws Exception {
    final String origSvc = "http://www.jasig.org?param=hello+world";
    final Service svc = CoreAuthenticationTestUtils.getService(origSvc);
    final AuthenticationResult ctx = CoreAuthenticationTestUtils.getAuthenticationResult(getAuthenticationSystemSupport(), svc);
    this.serviceValidateController.setProxyHandler(new Cas10ProxyHandler());
    final TicketGrantingTicket tId = getCentralAuthenticationService().createTicketGrantingTicket(ctx);
    final ServiceTicket sId = getCentralAuthenticationService().grantServiceTicket(tId.getId(), svc, ctx);
    final String reqSvc = "http://WWW.JASIG.ORG?PARAM=hello%20world";
    final MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter(SERVICE_PARAM, CoreAuthenticationTestUtils.getService(reqSvc).getId());
    request.addParameter(TICKET_PARAM, sId.getId());
    assertTrue(this.serviceValidateController.handleRequestInternal(request, new MockHttpServletResponse()).getView().toString().contains(SUCCESS));
}
Also used : TicketGrantingTicket(org.apereo.cas.ticket.TicketGrantingTicket) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) Service(org.apereo.cas.authentication.principal.Service) Cas10ProxyHandler(org.apereo.cas.ticket.proxy.support.Cas10ProxyHandler) ServiceTicket(org.apereo.cas.ticket.ServiceTicket) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) AuthenticationResult(org.apereo.cas.authentication.AuthenticationResult) Test(org.junit.Test)

Example 3 with Cas10ProxyHandler

use of org.apereo.cas.ticket.proxy.support.Cas10ProxyHandler in project cas by apereo.

the class AbstractServiceValidateControllerTests method verifyValidServiceTicketWithDifferentEncoding.

@Test
public void verifyValidServiceTicketWithDifferentEncoding() throws Exception {
    final Service svc = CoreAuthenticationTestUtils.getService("http://www.jasig.org?param=hello+world");
    final AuthenticationResult ctx = CoreAuthenticationTestUtils.getAuthenticationResult(getAuthenticationSystemSupport(), svc);
    this.serviceValidateController.setProxyHandler(new Cas10ProxyHandler());
    final TicketGrantingTicket tId = getCentralAuthenticationService().createTicketGrantingTicket(ctx);
    final ServiceTicket sId = getCentralAuthenticationService().grantServiceTicket(tId.getId(), svc, ctx);
    final String reqSvc = "http://www.jasig.org?param=hello%20world";
    final MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter(SERVICE_PARAM, CoreAuthenticationTestUtils.getService(reqSvc).getId());
    request.addParameter(TICKET_PARAM, sId.getId());
    assertTrue(this.serviceValidateController.handleRequestInternal(request, new MockHttpServletResponse()).getView().toString().contains(SUCCESS));
}
Also used : TicketGrantingTicket(org.apereo.cas.ticket.TicketGrantingTicket) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) Service(org.apereo.cas.authentication.principal.Service) Cas10ProxyHandler(org.apereo.cas.ticket.proxy.support.Cas10ProxyHandler) ServiceTicket(org.apereo.cas.ticket.ServiceTicket) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) AuthenticationResult(org.apereo.cas.authentication.AuthenticationResult) Test(org.junit.Test)

Example 4 with Cas10ProxyHandler

use of org.apereo.cas.ticket.proxy.support.Cas10ProxyHandler in project cas by apereo.

the class AbstractServiceValidateControllerTests method verifyValidServiceTicketWithSecurePgtUrl.

@Test
public void verifyValidServiceTicketWithSecurePgtUrl() throws Exception {
    this.serviceValidateController.setProxyHandler(new Cas10ProxyHandler());
    final ModelAndView modelAndView = getModelAndViewUponServiceValidationWithSecurePgtUrl();
    assertTrue(modelAndView.getView().toString().contains(SUCCESS));
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) Cas10ProxyHandler(org.apereo.cas.ticket.proxy.support.Cas10ProxyHandler) Test(org.junit.Test)

Example 5 with Cas10ProxyHandler

use of org.apereo.cas.ticket.proxy.support.Cas10ProxyHandler in project cas by apereo.

the class AbstractServiceValidateControllerTests method verifyValidServiceTicketWithValidPgtNoProxyHandling.

@Test
public void verifyValidServiceTicketWithValidPgtNoProxyHandling() throws Exception {
    final AuthenticationResult ctx = CoreAuthenticationTestUtils.getAuthenticationResult(getAuthenticationSystemSupport(), SERVICE);
    this.serviceValidateController.setProxyHandler(new Cas10ProxyHandler());
    final TicketGrantingTicket tId = getCentralAuthenticationService().createTicketGrantingTicket(ctx);
    final ServiceTicket sId = getCentralAuthenticationService().grantServiceTicket(tId.getId(), SERVICE, ctx);
    final MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter(SERVICE_PARAM, SERVICE.getId());
    request.addParameter(TICKET_PARAM, sId.getId());
    request.addParameter(PGT_URL_PARAM, GITHUB_URL);
    assertTrue(this.serviceValidateController.handleRequestInternal(request, new MockHttpServletResponse()).getView().toString().contains(SUCCESS));
}
Also used : TicketGrantingTicket(org.apereo.cas.ticket.TicketGrantingTicket) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) Cas10ProxyHandler(org.apereo.cas.ticket.proxy.support.Cas10ProxyHandler) ServiceTicket(org.apereo.cas.ticket.ServiceTicket) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) AuthenticationResult(org.apereo.cas.authentication.AuthenticationResult) Test(org.junit.Test)

Aggregations

Cas10ProxyHandler (org.apereo.cas.ticket.proxy.support.Cas10ProxyHandler)5 Test (org.junit.Test)5 AuthenticationResult (org.apereo.cas.authentication.AuthenticationResult)4 ServiceTicket (org.apereo.cas.ticket.ServiceTicket)4 TicketGrantingTicket (org.apereo.cas.ticket.TicketGrantingTicket)4 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)4 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)4 Service (org.apereo.cas.authentication.principal.Service)2 ModelAndView (org.springframework.web.servlet.ModelAndView)2