use of org.apereo.cas.ticket.TicketGrantingTicket in project cas by apereo.
the class CentralAuthenticationServiceImplTests method verifyGrantServiceTicketWithNoCredsAndSsoFalseAndSsoFalse.
@Test
public void verifyGrantServiceTicketWithNoCredsAndSsoFalseAndSsoFalse() throws Exception {
final Service svc = getService("TestSsoFalse");
final AuthenticationResult ctx = CoreAuthenticationTestUtils.getAuthenticationResult(getAuthenticationSystemSupport(), svc);
final TicketGrantingTicket ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(ctx);
final Service service = getService("eduPersonTest");
getCentralAuthenticationService().grantServiceTicket(ticketGrantingTicket.getId(), service, ctx);
this.thrown.expect(UnauthorizedSsoServiceException.class);
this.thrown.expectMessage("service.not.authorized.sso");
getCentralAuthenticationService().grantServiceTicket(ticketGrantingTicket.getId(), svc, ctx);
}
use of org.apereo.cas.ticket.TicketGrantingTicket in project cas by apereo.
the class CentralAuthenticationServiceImplTests method verifyDestroyTicketGrantingTicketWithValidTicket.
@Test
public void verifyDestroyTicketGrantingTicketWithValidTicket() throws Exception {
final AuthenticationResult ctx = CoreAuthenticationTestUtils.getAuthenticationResult(getAuthenticationSystemSupport());
final TicketGrantingTicket ticketId = getCentralAuthenticationService().createTicketGrantingTicket(ctx);
getCentralAuthenticationService().destroyTicketGrantingTicket(ticketId.getId());
}
use of org.apereo.cas.ticket.TicketGrantingTicket in project cas by apereo.
the class CentralAuthenticationServiceImplTests method verifyGrantServiceTicketFailsAuthzRule.
@Test
public void verifyGrantServiceTicketFailsAuthzRule() throws Exception {
final AuthenticationResult ctx = CoreAuthenticationTestUtils.getAuthenticationResult(getAuthenticationSystemSupport(), getService("TestServiceAttributeForAuthzFails"));
this.thrown.expect(PrincipalException.class);
this.thrown.expectMessage("screen.service.error.message");
final TicketGrantingTicket ticketId = getCentralAuthenticationService().createTicketGrantingTicket(ctx);
getCentralAuthenticationService().grantServiceTicket(ticketId.getId(), getService("TestServiceAttributeForAuthzFails"), ctx);
}
use of org.apereo.cas.ticket.TicketGrantingTicket in project cas by apereo.
the class AuthenticationViaFormActionTests method verifyRenewWithServiceAndSameCredentials.
@Test
public void verifyRenewWithServiceAndSameCredentials() throws Exception {
final Credential c = CoreAuthenticationTestUtils.getCredentialsWithSameUsernameAndPassword();
final Service service = RegisteredServiceTestUtils.getService(RegisteredServiceTestUtils.CONST_TEST_URL);
final AuthenticationResult ctx = CoreAuthenticationTestUtils.getAuthenticationResult(getAuthenticationSystemSupport(), service, c);
final TicketGrantingTicket ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(ctx);
final MockHttpServletRequest request = new MockHttpServletRequest();
final MockRequestContext context = new MockRequestContext();
WebUtils.putTicketGrantingTicketInScopes(context, ticketGrantingTicket);
request.addParameter(CasProtocolConstants.PARAMETER_RENEW, "true");
request.addParameter(CasProtocolConstants.PARAMETER_SERVICE, RegisteredServiceTestUtils.getService(RegisteredServiceTestUtils.CONST_TEST_URL).getId());
putCredentialInRequestScope(context, CoreAuthenticationTestUtils.getCredentialsWithSameUsernameAndPassword());
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, new MockHttpServletResponse()));
context.getFlowScope().put(CasProtocolConstants.PARAMETER_SERVICE, RegisteredServiceTestUtils.getService());
final Event ev = this.action.execute(context);
assertEquals(CasWebflowConstants.STATE_ID_SUCCESS, ev.getId());
}
use of org.apereo.cas.ticket.TicketGrantingTicket in project cas by apereo.
the class GenerateServiceTicketActionTests method verifyTicketGrantingTicketNotTgtButGateway.
@Test
public void verifyTicketGrantingTicketNotTgtButGateway() throws Exception {
final MockRequestContext context = new MockRequestContext();
context.getFlowScope().put(SERVICE_PARAM, RegisteredServiceTestUtils.getService());
final MockHttpServletRequest request = new MockHttpServletRequest();
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, new MockHttpServletResponse()));
request.addParameter(CasProtocolConstants.PARAMETER_SERVICE, SERVICE_PARAM);
request.addParameter(CasProtocolConstants.PARAMETER_GATEWAY, "true");
final TicketGrantingTicket tgt = mock(TicketGrantingTicket.class);
when(tgt.getId()).thenReturn("bleh");
WebUtils.putTicketGrantingTicketInScopes(context, tgt);
assertEquals(CasWebflowConstants.STATE_ID_GATEWAY, this.action.execute(context).getId());
}
Aggregations