use of org.apereo.cas.ticket.TicketGrantingTicket in project cas by apereo.
the class CentralAuthenticationServiceImplTests method verifyGrantServiceTicketWithNoCredsAndSsoFalseAndSsoFalse.
@Test
public void verifyGrantServiceTicketWithNoCredsAndSsoFalseAndSsoFalse() {
final Service svc = getService("TestSsoFalse");
final AuthenticationResult ctx = mock(AuthenticationResult.class);
when(ctx.getAuthentication()).thenReturn(CoreAuthenticationTestUtils.getAuthentication());
when(ctx.isCredentialProvided()).thenReturn(true);
final TicketGrantingTicket ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(ctx);
final Service service = getService("eduPersonTest");
getCentralAuthenticationService().grantServiceTicket(ticketGrantingTicket.getId(), service, ctx);
this.thrown.expect(UnauthorizedSsoServiceException.class);
when(ctx.isCredentialProvided()).thenReturn(false);
getCentralAuthenticationService().grantServiceTicket(ticketGrantingTicket.getId(), svc, ctx);
}
use of org.apereo.cas.ticket.TicketGrantingTicket in project cas by apereo.
the class CentralAuthenticationServiceImplTests method verifyValidateServiceTicketNoAttributesReturned.
@Test
public void verifyValidateServiceTicketNoAttributesReturned() {
final Service service = getService();
final AuthenticationResult ctx = CoreAuthenticationTestUtils.getAuthenticationResult(getAuthenticationSystemSupport(), service);
final TicketGrantingTicket ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(ctx);
final ServiceTicket serviceTicket = getCentralAuthenticationService().grantServiceTicket(ticketGrantingTicket.getId(), service, ctx);
final Assertion assertion = getCentralAuthenticationService().validateServiceTicket(serviceTicket.getId(), service);
final Authentication auth = assertion.getPrimaryAuthentication();
assertEquals(0, auth.getPrincipal().getAttributes().size());
}
use of org.apereo.cas.ticket.TicketGrantingTicket in project cas by apereo.
the class CentralAuthenticationServiceImplTests method verifyValidateServiceTicketWithInvalidServiceTicket.
@Test
public void verifyValidateServiceTicketWithInvalidServiceTicket() {
final AuthenticationResult ctx = CoreAuthenticationTestUtils.getAuthenticationResult(getAuthenticationSystemSupport(), getService());
final TicketGrantingTicket ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(ctx);
final ServiceTicket serviceTicket = getCentralAuthenticationService().grantServiceTicket(ticketGrantingTicket.getId(), getService(), ctx);
getCentralAuthenticationService().destroyTicketGrantingTicket(ticketGrantingTicket.getId());
this.thrown.expect(AbstractTicketException.class);
getCentralAuthenticationService().validateServiceTicket(serviceTicket.getId(), getService());
}
use of org.apereo.cas.ticket.TicketGrantingTicket in project cas by apereo.
the class CentralAuthenticationServiceImplTests method verifyValidateServiceTicketWithDefaultUsernameAttribute.
@Test
public void verifyValidateServiceTicketWithDefaultUsernameAttribute() {
final Service svc = getService("testDefault");
final UsernamePasswordCredential cred = CoreAuthenticationTestUtils.getCredentialsWithSameUsernameAndPassword();
final AuthenticationResult ctx = CoreAuthenticationTestUtils.getAuthenticationResult(getAuthenticationSystemSupport(), svc);
final TicketGrantingTicket ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(ctx);
final ServiceTicket serviceTicket = getCentralAuthenticationService().grantServiceTicket(ticketGrantingTicket.getId(), svc, ctx);
final Assertion assertion = getCentralAuthenticationService().validateServiceTicket(serviceTicket.getId(), svc);
final Authentication auth = assertion.getPrimaryAuthentication();
assertEquals(auth.getPrincipal().getId(), cred.getUsername());
}
use of org.apereo.cas.ticket.TicketGrantingTicket in project cas by apereo.
the class CentralAuthenticationServiceImplTests method verifyGrantingOfServiceTicketUsingDefaultTicketIdGen.
@Test
public void verifyGrantingOfServiceTicketUsingDefaultTicketIdGen() {
final Service mockService = RegisteredServiceTestUtils.getService("testDefault");
final AuthenticationResult ctx = CoreAuthenticationTestUtils.getAuthenticationResult(getAuthenticationSystemSupport(), mockService);
final TicketGrantingTicket ticketId = getCentralAuthenticationService().createTicketGrantingTicket(ctx);
final ServiceTicket serviceTicketId = getCentralAuthenticationService().grantServiceTicket(ticketId.getId(), mockService, ctx);
assertNotNull(serviceTicketId);
}
Aggregations