use of org.apereo.cas.authentication.principal.Service 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.authentication.principal.Service 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.authentication.principal.Service 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.authentication.principal.Service 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));
}
use of org.apereo.cas.authentication.principal.Service in project cas by apereo.
the class DefaultCasAttributeEncoderTests method checkNoPublicKeyDefined.
@Test
public void checkNoPublicKeyDefined() {
final Service service = RegisteredServiceTestUtils.getService("testDefault");
final ProtocolAttributeEncoder encoder = new DefaultCasProtocolAttributeEncoder(this.servicesManager, CipherExecutor.noOpOfStringToString());
final Map<String, Object> encoded = encoder.encodeAttributes(this.attributes, this.servicesManager.findServiceBy(service));
assertEquals(this.attributes.size() - 2, encoded.size());
}
Aggregations