Search in sources :

Example 1 with ProxyHandler

use of org.apereo.cas.ticket.proxy.ProxyHandler in project cas by apereo.

the class AbstractServiceValidateControllerTests method verifyValidServiceTicketWithValidPgtAndProxyHandlerFailing.

@Test
public void verifyValidServiceTicketWithValidPgtAndProxyHandlerFailing() 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(SERVICE_PARAM, SERVICE.getId());
    request.addParameter(TICKET_PARAM, sId.getId());
    request.addParameter(PGT_URL_PARAM, GITHUB_URL);
    this.serviceValidateController.setProxyHandler(new ProxyHandler() {

        @Override
        public String handle(final Credential credential, final TicketGrantingTicket proxyGrantingTicketId) {
            return null;
        }

        @Override
        public boolean canHandle(final Credential credential) {
            return true;
        }
    });
    final ModelAndView modelAndView = this.serviceValidateController.handleRequestInternal(request, new MockHttpServletResponse());
    assertFalse(modelAndView.getView().toString().contains(SUCCESS));
    assertNull(modelAndView.getModel().get(PGT_IOU_PARAM));
}
Also used : Credential(org.apereo.cas.authentication.Credential) ProxyHandler(org.apereo.cas.ticket.proxy.ProxyHandler) Cas10ProxyHandler(org.apereo.cas.ticket.proxy.support.Cas10ProxyHandler) Cas20ProxyHandler(org.apereo.cas.ticket.proxy.support.Cas20ProxyHandler) TicketGrantingTicket(org.apereo.cas.ticket.TicketGrantingTicket) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) ModelAndView(org.springframework.web.servlet.ModelAndView) ServiceTicket(org.apereo.cas.ticket.ServiceTicket) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) AuthenticationResult(org.apereo.cas.authentication.AuthenticationResult) Test(org.junit.Test)

Aggregations

AuthenticationResult (org.apereo.cas.authentication.AuthenticationResult)1 Credential (org.apereo.cas.authentication.Credential)1 ServiceTicket (org.apereo.cas.ticket.ServiceTicket)1 TicketGrantingTicket (org.apereo.cas.ticket.TicketGrantingTicket)1 ProxyHandler (org.apereo.cas.ticket.proxy.ProxyHandler)1 Cas10ProxyHandler (org.apereo.cas.ticket.proxy.support.Cas10ProxyHandler)1 Cas20ProxyHandler (org.apereo.cas.ticket.proxy.support.Cas20ProxyHandler)1 Test (org.junit.Test)1 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)1 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1