use of org.apereo.cas.authentication.AuthenticationResult in project cas by apereo.
the class CentralAuthenticationServiceImplTests method verifyGrantServiceTicketWithDifferentCredentials.
@Test
public void verifyGrantServiceTicketWithDifferentCredentials() {
final AuthenticationResult ctx = CoreAuthenticationTestUtils.getAuthenticationResult(getAuthenticationSystemSupport(), CoreAuthenticationTestUtils.getCredentialsWithSameUsernameAndPassword("testA"));
final TicketGrantingTicket ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(ctx);
final AuthenticationResult ctx2 = CoreAuthenticationTestUtils.getAuthenticationResult(getAuthenticationSystemSupport(), CoreAuthenticationTestUtils.getCredentialsWithSameUsernameAndPassword("testB"));
this.thrown.expect(MixedPrincipalException.class);
getCentralAuthenticationService().grantServiceTicket(ticketGrantingTicket.getId(), getService(), ctx2);
}
use of org.apereo.cas.authentication.AuthenticationResult in project cas by apereo.
the class CentralAuthenticationServiceImplTests method verifyDisallowNullCredentialsArrayWhenCreatingTicketGrantingTicket.
@Test
public void verifyDisallowNullCredentialsArrayWhenCreatingTicketGrantingTicket() {
final AuthenticationResult ctx = CoreAuthenticationTestUtils.getAuthenticationResult(getAuthenticationSystemSupport(), new Credential[] { null, null });
this.thrown.expect(RuntimeException.class);
getCentralAuthenticationService().createTicketGrantingTicket(ctx);
}
use of org.apereo.cas.authentication.AuthenticationResult in project cas by apereo.
the class CentralAuthenticationServiceImplTests method verifyValidateServiceTicketReturnAllAttributes.
@Test
public void verifyValidateServiceTicketReturnAllAttributes() {
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(3, auth.getPrincipal().getAttributes().size());
}
use of org.apereo.cas.authentication.AuthenticationResult in project cas by apereo.
the class CentralAuthenticationServiceImplTests method verifyValidateServiceTicketAnonymous.
@Test
public void verifyValidateServiceTicketAnonymous() {
final Service service = getService("testAnonymous");
final UsernamePasswordCredential cred = CoreAuthenticationTestUtils.getCredentialsWithSameUsernameAndPassword();
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();
assertNotEquals(cred.getUsername(), auth.getPrincipal().getId());
}
use of org.apereo.cas.authentication.AuthenticationResult in project cas by apereo.
the class CentralAuthenticationServiceImplTests method verifyDestroyTicketGrantingTicketWithInvalidTicket.
@Test
public void verifyDestroyTicketGrantingTicketWithInvalidTicket() {
final AuthenticationResult ctx = CoreAuthenticationTestUtils.getAuthenticationResult(getAuthenticationSystemSupport());
final TicketGrantingTicket ticketId = getCentralAuthenticationService().createTicketGrantingTicket(ctx);
final ServiceTicket serviceTicketId = getCentralAuthenticationService().grantServiceTicket(ticketId.getId(), getService(), ctx);
this.thrown.expect(ClassCastException.class);
getCentralAuthenticationService().destroyTicketGrantingTicket(serviceTicketId.getId());
}
Aggregations