Search in sources :

Example 71 with AuthenticationResult

use of org.apereo.cas.authentication.AuthenticationResult in project cas by apereo.

the class AbstractServiceValidateControllerTests method verifyValidServiceTicket.

@Test
public void verifyValidServiceTicket() 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());
    final ModelAndView mv = this.serviceValidateController.handleRequestInternal(request, new MockHttpServletResponse());
    assertTrue(mv.getView().toString().contains(SUCCESS));
}
Also used : 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)

Example 72 with AuthenticationResult

use of org.apereo.cas.authentication.AuthenticationResult in project cas by apereo.

the class AbstractServiceValidateControllerTests method getHttpServletRequest.

private HttpServletRequest getHttpServletRequest() throws Exception {
    final AuthenticationResult ctx = CoreAuthenticationTestUtils.getAuthenticationResult(getAuthenticationSystemSupport(), SERVICE);
    final TicketGrantingTicket tId = getCentralAuthenticationService().createTicketGrantingTicket(ctx);
    getCentralAuthenticationService().grantServiceTicket(tId.getId(), SERVICE, ctx);
    final ServiceTicket sId2 = getCentralAuthenticationService().grantServiceTicket(tId.getId(), SERVICE, null);
    final MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter(SERVICE_PARAM, SERVICE.getId());
    request.addParameter(TICKET_PARAM, sId2.getId());
    request.addParameter("renew", "true");
    return request;
}
Also used : TicketGrantingTicket(org.apereo.cas.ticket.TicketGrantingTicket) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) ServiceTicket(org.apereo.cas.ticket.ServiceTicket) AuthenticationResult(org.apereo.cas.authentication.AuthenticationResult)

Aggregations

AuthenticationResult (org.apereo.cas.authentication.AuthenticationResult)72 TicketGrantingTicket (org.apereo.cas.ticket.TicketGrantingTicket)57 Test (org.junit.Test)57 ServiceTicket (org.apereo.cas.ticket.ServiceTicket)44 Service (org.apereo.cas.authentication.principal.Service)29 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)17 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)15 AbstractWebApplicationService (org.apereo.cas.authentication.principal.AbstractWebApplicationService)14 Authentication (org.apereo.cas.authentication.Authentication)11 Credential (org.apereo.cas.authentication.Credential)10 Assertion (org.apereo.cas.validation.Assertion)10 ModelAndView (org.springframework.web.servlet.ModelAndView)7 CentralAuthenticationService (org.apereo.cas.CentralAuthenticationService)6 UsernamePasswordCredential (org.apereo.cas.authentication.UsernamePasswordCredential)6 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)6 AuthenticationException (org.apereo.cas.authentication.AuthenticationException)5 Cas10ProxyHandler (org.apereo.cas.ticket.proxy.support.Cas10ProxyHandler)5 OneTimePasswordCredential (org.apereo.cas.authentication.OneTimePasswordCredential)4 RegisteredService (org.apereo.cas.services.RegisteredService)4 AbstractTicketException (org.apereo.cas.ticket.AbstractTicketException)4