use of org.apereo.cas.ticket.ServiceTicket 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.ServiceTicket 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.ServiceTicket 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.ServiceTicket 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);
}
use of org.apereo.cas.ticket.ServiceTicket in project cas by apereo.
the class CentralAuthenticationServiceImplWithMockitoTests method verifyChainedAuthenticationsOnValidation.
@Test
public void verifyChainedAuthenticationsOnValidation() {
final Service svc = RegisteredServiceTestUtils.getService(SVC2_ID);
final ServiceTicket st = this.cas.grantServiceTicket(TGT2_ID, svc, getAuthenticationContext());
assertNotNull(st);
final Assertion assertion = this.cas.validateServiceTicket(st.getId(), svc);
assertNotNull(assertion);
assertEquals(assertion.getService(), svc);
assertEquals(PRINCIPAL, assertion.getPrimaryAuthentication().getPrincipal().getId());
assertSame(2, assertion.getChainedAuthentications().size());
IntStream.range(0, assertion.getChainedAuthentications().size()).forEach(i -> assertEquals(assertion.getChainedAuthentications().get(i), authentication));
}
Aggregations