use of org.apereo.cas.ticket.ServiceTicket in project cas by apereo.
the class AbstractServiceValidateControllerTests method getModelAndViewUponServiceValidationWithSecurePgtUrl.
/*
Helper methods.
*/
protected ModelAndView getModelAndViewUponServiceValidationWithSecurePgtUrl() throws Exception {
final AuthenticationResult ctx = CoreAuthenticationTestUtils.getAuthenticationResult(getAuthenticationSystemSupport(), SERVICE);
final TicketGrantingTicket tId = getCentralAuthenticationService().createTicketGrantingTicket(ctx);
final ServiceTicket sId = getCentralAuthenticationService().grantServiceTicket(tId.getId(), SERVICE, ctx);
final MockHttpServletRequest request = new MockHttpServletRequest();
request.addParameter(CasProtocolConstants.PARAMETER_SERVICE, SERVICE.getId());
request.addParameter(CasProtocolConstants.PARAMETER_TICKET, sId.getId());
request.addParameter(CasProtocolConstants.PARAMETER_PROXY_GRANTING_TICKET_URL, GITHUB_URL);
return this.serviceValidateController.handleRequestInternal(request, new MockHttpServletResponse());
}
use of org.apereo.cas.ticket.ServiceTicket in project cas by apereo.
the class AbstractServiceValidateControllerTests method verifyValidServiceTicketAndBadFormat.
@Test
public void verifyValidServiceTicketAndBadFormat() throws Exception {
final Service svc = RegisteredServiceTestUtils.getService("proxyService");
final AuthenticationResult ctx = CoreAuthenticationTestUtils.getAuthenticationResult(getAuthenticationSystemSupport(), svc);
final TicketGrantingTicket tId = getCentralAuthenticationService().createTicketGrantingTicket(ctx);
final ServiceTicket sId = getCentralAuthenticationService().grantServiceTicket(tId.getId(), svc, ctx);
final MockHttpServletRequest request = new MockHttpServletRequest();
request.addParameter(CasProtocolConstants.PARAMETER_SERVICE, svc.getId());
request.addParameter(CasProtocolConstants.PARAMETER_TICKET, sId.getId());
request.addParameter(CasProtocolConstants.PARAMETER_FORMAT, "NOTHING");
final ModelAndView modelAndView = this.serviceValidateController.handleRequestInternal(request, new MockHttpServletResponse());
assertTrue(modelAndView.getView().toString().contains("Success"));
}
use of org.apereo.cas.ticket.ServiceTicket in project cas by apereo.
the class AbstractServiceValidateControllerTests method verifyValidServiceTicketWithDifferentEncoding.
/*
CAS10 Proxying Tests.
*/
@Test
public void verifyValidServiceTicketWithDifferentEncoding() throws Exception {
final Service svc = RegisteredServiceTestUtils.getService("http://www.jasig.org?param=hello+world");
final AuthenticationResult ctx = CoreAuthenticationTestUtils.getAuthenticationResult(getAuthenticationSystemSupport(), svc);
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(CasProtocolConstants.PARAMETER_SERVICE, RegisteredServiceTestUtils.getService(reqSvc).getId());
request.addParameter(CasProtocolConstants.PARAMETER_TICKET, sId.getId());
this.serviceValidateController.setProxyHandler(new Cas10ProxyHandler());
assertTrue(this.serviceValidateController.handleRequestInternal(request, new MockHttpServletResponse()).getView().toString().contains(SUCCESS));
}
use of org.apereo.cas.ticket.ServiceTicket in project cas by apereo.
the class AbstractServiceValidateControllerTests method verifyInvalidServiceTicket.
@Test
public void verifyInvalidServiceTicket() throws Exception {
final AuthenticationResult ctx = CoreAuthenticationTestUtils.getAuthenticationResult(getAuthenticationSystemSupport(), SERVICE);
final TicketGrantingTicket tId = getCentralAuthenticationService().createTicketGrantingTicket(ctx);
final ServiceTicket sId = getCentralAuthenticationService().grantServiceTicket(tId.getId(), SERVICE, ctx);
getCentralAuthenticationService().destroyTicketGrantingTicket(tId.getId());
final MockHttpServletRequest request = new MockHttpServletRequest();
request.addParameter(CasProtocolConstants.PARAMETER_SERVICE, SERVICE.getId());
request.addParameter(CasProtocolConstants.PARAMETER_TICKET, sId.getId());
assertFalse(this.serviceValidateController.handleRequestInternal(request, new MockHttpServletResponse()).getView().toString().contains(SUCCESS));
}
use of org.apereo.cas.ticket.ServiceTicket in project cas by apereo.
the class AbstractServiceValidateControllerTests method verifyValidServiceTicketAndFormatAsJson.
@Test
public void verifyValidServiceTicketAndFormatAsJson() throws Exception {
final Service svc = RegisteredServiceTestUtils.getService("proxyService");
final AuthenticationResult ctx = CoreAuthenticationTestUtils.getAuthenticationResult(getAuthenticationSystemSupport(), svc);
final TicketGrantingTicket tId = getCentralAuthenticationService().createTicketGrantingTicket(ctx);
final ServiceTicket sId = getCentralAuthenticationService().grantServiceTicket(tId.getId(), svc, ctx);
final MockHttpServletRequest request = new MockHttpServletRequest();
request.addParameter(CasProtocolConstants.PARAMETER_SERVICE, svc.getId());
request.addParameter(CasProtocolConstants.PARAMETER_TICKET, sId.getId());
request.addParameter(CasProtocolConstants.PARAMETER_FORMAT, ValidationResponseType.JSON.name());
final ModelAndView modelAndView = this.serviceValidateController.handleRequestInternal(request, new MockHttpServletResponse());
assertTrue(modelAndView.getView().toString().contains("Json"));
}
Aggregations