use of org.apereo.cas.ticket.TicketGrantingTicket in project cas by apereo.
the class CentralAuthenticationServiceImplWithMockitoTests method createMockTicketGrantingTicket.
private TicketGrantingTicket createMockTicketGrantingTicket(final String id, final ServiceTicket svcTicket, final boolean isExpired, final TicketGrantingTicket root, final List<Authentication> chainedAuthnList) {
final TicketGrantingTicket tgtMock = mock(TicketGrantingTicket.class);
when(tgtMock.isExpired()).thenReturn(isExpired);
when(tgtMock.getId()).thenReturn(id);
final String svcId = svcTicket.getService().getId();
when(tgtMock.grantServiceTicket(anyString(), argThat(new VerifyServiceByIdMatcher(svcId)), any(ExpirationPolicy.class), anyBoolean(), anyBoolean())).thenReturn(svcTicket);
when(tgtMock.getRoot()).thenReturn(root);
when(tgtMock.getChainedAuthentications()).thenReturn(chainedAuthnList);
when(tgtMock.getAuthentication()).thenReturn(this.authentication);
when(svcTicket.getTicketGrantingTicket()).thenReturn(tgtMock);
return tgtMock;
}
use of org.apereo.cas.ticket.TicketGrantingTicket in project cas by apereo.
the class MultifactorAuthenticationTests method verifyAllowsAccessToNormalSecurityServiceWithOTP.
@Test
public void verifyAllowsAccessToNormalSecurityServiceWithOTP() {
final AuthenticationResult ctx = processAuthenticationAttempt(NORMAL_SERVICE, new OneTimePasswordCredential(ALICE, PASSWORD_31415));
final TicketGrantingTicket tgt = cas.createTicketGrantingTicket(ctx);
assertNotNull(tgt);
final ServiceTicket st = cas.grantServiceTicket(tgt.getId(), NORMAL_SERVICE, ctx);
assertNotNull(st);
}
use of org.apereo.cas.ticket.TicketGrantingTicket in project cas by apereo.
the class MultifactorAuthenticationTests method verifyDeniesAccessToHighSecurityServiceWithPassword.
@Test
public void verifyDeniesAccessToHighSecurityServiceWithPassword() {
final AuthenticationResult ctx = processAuthenticationAttempt(HIGH_SERVICE, newUserPassCredentials(ALICE, ALICE));
this.thrown.expect(UnsatisfiedAuthenticationPolicyException.class);
final TicketGrantingTicket tgt = cas.createTicketGrantingTicket(ctx);
assertNotNull(tgt);
cas.grantServiceTicket(tgt.getId(), HIGH_SERVICE, ctx);
}
use of org.apereo.cas.ticket.TicketGrantingTicket in project cas by apereo.
the class MultifactorAuthenticationTests method verifyAllowsAccessToNormalSecurityServiceWithPassword.
@Test
public void verifyAllowsAccessToNormalSecurityServiceWithPassword() {
final AuthenticationResult ctx = processAuthenticationAttempt(NORMAL_SERVICE, newUserPassCredentials(ALICE, ALICE));
final TicketGrantingTicket tgt = cas.createTicketGrantingTicket(ctx);
assertNotNull(tgt);
final ServiceTicket st = cas.grantServiceTicket(tgt.getId(), NORMAL_SERVICE, ctx);
assertNotNull(st);
}
use of org.apereo.cas.ticket.TicketGrantingTicket in project cas by apereo.
the class SendTicketGrantingTicketActionSsoTests method verifySsoSessionCookieOnRenewAsParameter.
@Test
public void verifySsoSessionCookieOnRenewAsParameter() throws Exception {
final MockHttpServletResponse response = new MockHttpServletResponse();
final MockHttpServletRequest request = new MockHttpServletRequest();
request.addParameter(CasProtocolConstants.PARAMETER_RENEW, "true");
request.setRemoteAddr(LOCALHOST_IP);
request.setLocalAddr(LOCALHOST_IP);
request.addHeader(HttpRequestUtils.USER_AGENT_HEADER, "test");
ClientInfoHolder.setClientInfo(new ClientInfo(request));
final TicketGrantingTicket tgt = mock(TicketGrantingTicket.class);
when(tgt.getId()).thenReturn(TEST_STRING);
request.setCookies(new Cookie("TGT", "test5"));
WebUtils.putTicketGrantingTicketInScopes(this.context, tgt);
this.context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));
assertEquals(SUCCESS, action.execute(this.context).getId());
assertEquals(0, response.getCookies().length);
}
Aggregations