use of org.apereo.cas.validation.Assertion in project cas by apereo.
the class CentralAuthenticationServiceImplTests method verifyValidateServiceTicketReturnAllAttributes.
@Test
public void verifyValidateServiceTicketReturnAllAttributes() throws Exception {
final Service service = getService("eduPersonTest");
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(4, auth.getPrincipal().getAttributes().size());
}
use of org.apereo.cas.validation.Assertion in project cas by apereo.
the class CentralAuthenticationServiceImplTests method verifyValidateServiceTicketWithoutUsernameAttribute.
@Test
public void verifyValidateServiceTicketWithoutUsernameAttribute() throws Exception {
final UsernamePasswordCredential cred = CoreAuthenticationTestUtils.getCredentialsWithSameUsernameAndPassword();
final AuthenticationResult ctx = CoreAuthenticationTestUtils.getAuthenticationResult(getAuthenticationSystemSupport(), getService());
final TicketGrantingTicket ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(ctx);
final ServiceTicket serviceTicket = getCentralAuthenticationService().grantServiceTicket(ticketGrantingTicket.getId(), getService(), ctx);
final Assertion assertion = getCentralAuthenticationService().validateServiceTicket(serviceTicket.getId(), getService());
final Authentication auth = assertion.getPrimaryAuthentication();
assertEquals(auth.getPrincipal().getId(), cred.getUsername());
}
use of org.apereo.cas.validation.Assertion in project cas by apereo.
the class CentralAuthenticationServiceImplTests method verifyValidateServiceTicketWithUsernameAttribute.
@Test
public void verifyValidateServiceTicketWithUsernameAttribute() throws Exception {
final Service svc = getService("eduPersonTest");
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);
assertEquals("developer", assertion.getPrimaryAuthentication().getPrincipal().getId());
}
Aggregations