use of org.apereo.cas.authentication.AuthenticationResult in project cas by apereo.
the class CentralAuthenticationServiceImplTests method verifyDestroyTicketGrantingTicketWithValidTicket.
@Test
public void verifyDestroyTicketGrantingTicketWithValidTicket() {
final AuthenticationResult ctx = CoreAuthenticationTestUtils.getAuthenticationResult(getAuthenticationSystemSupport());
final TicketGrantingTicket ticketId = getCentralAuthenticationService().createTicketGrantingTicket(ctx);
getCentralAuthenticationService().destroyTicketGrantingTicket(ticketId.getId());
}
use of org.apereo.cas.authentication.AuthenticationResult in project cas by apereo.
the class CentralAuthenticationServiceImplTests method verifyGoodCredentialsOnTicketGrantingTicketCreation.
@Test
public void verifyGoodCredentialsOnTicketGrantingTicketCreation() {
try {
final AuthenticationResult ctx = CoreAuthenticationTestUtils.getAuthenticationResult(getAuthenticationSystemSupport());
assertNotNull(getCentralAuthenticationService().createTicketGrantingTicket(ctx));
} catch (final AbstractTicketException e) {
throw new AssertionError("Exception expected", e);
}
}
use of org.apereo.cas.authentication.AuthenticationResult in project cas by apereo.
the class CentralAuthenticationServiceImplTests method verifyDelegateTicketGrantingTicketWithBadServiceTicket.
@Test
public void verifyDelegateTicketGrantingTicketWithBadServiceTicket() {
final AuthenticationResult ctx = CoreAuthenticationTestUtils.getAuthenticationResult(getAuthenticationSystemSupport(), getService());
final TicketGrantingTicket ticketId = getCentralAuthenticationService().createTicketGrantingTicket(ctx);
final ServiceTicket serviceTicketId = getCentralAuthenticationService().grantServiceTicket(ticketId.getId(), getService(), ctx);
getCentralAuthenticationService().destroyTicketGrantingTicket(ticketId.getId());
final AuthenticationResult ctx2 = CoreAuthenticationTestUtils.getAuthenticationResult(getAuthenticationSystemSupport(), RegisteredServiceTestUtils.getHttpBasedServiceCredentials());
this.thrown.expect(AbstractTicketException.class);
getCentralAuthenticationService().createProxyGrantingTicket(serviceTicketId.getId(), ctx2);
}
use of org.apereo.cas.authentication.AuthenticationResult in project cas by apereo.
the class CentralAuthenticationServiceImplTests method verifyGrantServiceTicketFailsAuthzRule.
@Test
public void verifyGrantServiceTicketFailsAuthzRule() {
final AuthenticationResult ctx = CoreAuthenticationTestUtils.getAuthenticationResult(getAuthenticationSystemSupport(), getService("TestServiceAttributeForAuthzFails"));
this.thrown.expect(PrincipalException.class);
final TicketGrantingTicket ticketId = getCentralAuthenticationService().createTicketGrantingTicket(ctx);
getCentralAuthenticationService().grantServiceTicket(ticketId.getId(), getService("TestServiceAttributeForAuthzFails"), ctx);
}
use of org.apereo.cas.authentication.AuthenticationResult in project cas by apereo.
the class CentralAuthenticationServiceImplTests method verifyValidateServiceTicketWithInvalidUsernameAttribute.
@Test
public void verifyValidateServiceTicketWithInvalidUsernameAttribute() {
final Service svc = getService("eduPersonTestInvalid");
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();
/*
* The attribute specified for this service does not resolve.
* Therefore, we expect the default to be returned.
*/
assertEquals(auth.getPrincipal().getId(), cred.getUsername());
}
Aggregations