use of org.apereo.cas.authentication.AuthenticationResult in project cas by apereo.
the class TicketOrCredentialPrincipalResolverTests method verifyResolverServiceTicket.
@Test
public void verifyResolverServiceTicket() throws Exception {
final Credential c = CoreAuthenticationTestUtils.getCredentialsWithSameUsernameAndPassword();
final AuthenticationResult ctx = CoreAuthenticationTestUtils.getAuthenticationResult(getAuthenticationSystemSupport(), c);
final TicketGrantingTicket ticketId = getCentralAuthenticationService().createTicketGrantingTicket(ctx);
final ServiceTicket st = getCentralAuthenticationService().grantServiceTicket(ticketId.getId(), CoreAuthenticationTestUtils.getService(), ctx);
final TicketOrCredentialPrincipalResolver res = new TicketOrCredentialPrincipalResolver(getCentralAuthenticationService());
final JoinPoint jp = mock(JoinPoint.class);
when(jp.getArgs()).thenReturn(new Object[] { st.getId() });
final String result = res.resolveFrom(jp, null);
assertNotNull(result);
assertEquals(result, c.getId());
}
use of org.apereo.cas.authentication.AuthenticationResult in project cas by apereo.
the class CentralAuthenticationServiceImplWithMockitoTests method getAuthenticationContext.
private AuthenticationResult getAuthenticationContext() {
final AuthenticationResult ctx = mock(AuthenticationResult.class);
when(ctx.getAuthentication()).thenReturn(this.authentication);
return ctx;
}
use of org.apereo.cas.authentication.AuthenticationResult in project cas by apereo.
the class CentralAuthenticationServiceImplTests method checkGrantingOfServiceTicketUsingDefaultTicketIdGen.
@Test
public void checkGrantingOfServiceTicketUsingDefaultTicketIdGen() throws Exception {
final Service mockService = mock(Service.class);
when(mockService.getId()).thenReturn("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.AuthenticationResult in project cas by apereo.
the class CentralAuthenticationServiceImplTests method disallowNullCredentialsWhenCreatingTicketGrantingTicket.
@Test
public void disallowNullCredentialsWhenCreatingTicketGrantingTicket() throws Exception {
final AuthenticationResult ctx = CoreAuthenticationTestUtils.getAuthenticationResult(getAuthenticationSystemSupport(), new Credential[] { null });
this.thrown.expect(RuntimeException.class);
getCentralAuthenticationService().createTicketGrantingTicket(ctx);
}
use of org.apereo.cas.authentication.AuthenticationResult in project cas by apereo.
the class AuthenticationViaFormActionTests method verifyRenewWithServiceAndDifferentCredentials.
@Test
public void verifyRenewWithServiceAndDifferentCredentials() throws Exception {
final Credential c = CoreAuthenticationTestUtils.getCredentialsWithSameUsernameAndPassword();
final AuthenticationResult ctx = CoreAuthenticationTestUtils.getAuthenticationResult(getAuthenticationSystemSupport(), RegisteredServiceTestUtils.getService(TEST), c);
final TicketGrantingTicket ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(ctx);
final MockHttpServletRequest request = new MockHttpServletRequest();
final MockRequestContext context = new MockRequestContext();
WebUtils.putTicketGrantingTicketInScopes(context, ticketGrantingTicket);
request.addParameter(CasProtocolConstants.PARAMETER_RENEW, "true");
request.addParameter(CasProtocolConstants.PARAMETER_SERVICE, RegisteredServiceTestUtils.getService(TEST).getId());
final Credential c2 = CoreAuthenticationTestUtils.getCredentialsWithSameUsernameAndPassword();
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, new MockHttpServletResponse()));
putCredentialInRequestScope(context, c2);
assertEquals(CasWebflowConstants.TRANSITION_ID_SUCCESS, this.action.execute(context).getId());
}
Aggregations