use of org.apereo.cas.authentication.AuthenticationResult in project cas by apereo.
the class CentralAuthenticationServiceImplTests method verifyGrantServiceTicketWithInvalidTicketGrantingTicket.
@Test
public void verifyGrantServiceTicketWithInvalidTicketGrantingTicket() {
final AuthenticationResult ctx = CoreAuthenticationTestUtils.getAuthenticationResult(getAuthenticationSystemSupport());
final TicketGrantingTicket ticketId = getCentralAuthenticationService().createTicketGrantingTicket(ctx);
getCentralAuthenticationService().destroyTicketGrantingTicket(ticketId.getId());
this.thrown.expect(AbstractTicketException.class);
getCentralAuthenticationService().grantServiceTicket(ticketId.getId(), getService(), ctx);
}
use of org.apereo.cas.authentication.AuthenticationResult in project cas by apereo.
the class CentralAuthenticationServiceImplTests method verifyBadCredentialsOnTicketGrantingTicketCreation.
@Test
public void verifyBadCredentialsOnTicketGrantingTicketCreation() {
this.thrown.expect(AuthenticationException.class);
final AuthenticationResult ctx = CoreAuthenticationTestUtils.getAuthenticationResult(getAuthenticationSystemSupport(), CoreAuthenticationTestUtils.getCredentialsWithDifferentUsernameAndPassword());
getCentralAuthenticationService().createTicketGrantingTicket(ctx);
}
use of org.apereo.cas.authentication.AuthenticationResult in project cas by apereo.
the class CentralAuthenticationServiceImplTests method verifyGrantServiceTicketWithNoCredsAndSsoFalse.
@Test
public void verifyGrantServiceTicketWithNoCredsAndSsoFalse() {
final Service svc = getService("TestSsoFalse");
final AuthenticationResult ctx = CoreAuthenticationTestUtils.getAuthenticationResult(getAuthenticationSystemSupport(), svc);
final TicketGrantingTicket ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(ctx);
assertNotNull(getCentralAuthenticationService().grantServiceTicket(ticketGrantingTicket.getId(), svc, ctx));
}
use of org.apereo.cas.authentication.AuthenticationResult in project cas by apereo.
the class CentralAuthenticationServiceImplTests method verifyValidateServiceTicketReturnOnlyAllowedAttribute.
@Test
public void verifyValidateServiceTicketReturnOnlyAllowedAttribute() {
final Service service = getService("eduPersonTestInvalid");
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();
final Map<String, Object> attributes = auth.getPrincipal().getAttributes();
assertEquals(1, attributes.size());
assertEquals("adopters", attributes.get("groupMembership"));
}
use of org.apereo.cas.authentication.AuthenticationResult in project cas by apereo.
the class CentralAuthenticationServiceImplTests method verifyValidateServiceTicketWithoutUsernameAttribute.
@Test
public void verifyValidateServiceTicketWithoutUsernameAttribute() {
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());
}
Aggregations