use of org.apereo.cas.ticket.TicketGrantingTicket in project cas by apereo.
the class SendTicketGrantingTicketActionTests method verifyTgtToSet.
@Test
public void verifyTgtToSet() throws Exception {
final MockHttpServletRequest request = new MockHttpServletRequest();
request.setRemoteAddr(LOCALHOST_IP);
request.setLocalAddr(LOCALHOST_IP);
ClientInfoHolder.setClientInfo(new ClientInfo(request));
final MockHttpServletResponse response = new MockHttpServletResponse();
request.addHeader("User-Agent", "Test");
final TicketGrantingTicket tgt = mock(TicketGrantingTicket.class);
when(tgt.getId()).thenReturn(TEST_STRING);
WebUtils.putTicketGrantingTicketInScopes(this.context, tgt);
this.context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));
assertEquals(SUCCESS, this.action.execute(this.context).getId());
request.setCookies(response.getCookies());
assertEquals(tgt.getId(), this.ticketGrantingTicketCookieGenerator.retrieveCookieValue(request));
}
use of org.apereo.cas.ticket.TicketGrantingTicket in project cas by apereo.
the class SendTicketGrantingTicketActionTests method verifySsoSessionCookieOnServiceSsoDisallowed.
@Test
public void verifySsoSessionCookieOnServiceSsoDisallowed() throws Exception {
final MockHttpServletResponse response = new MockHttpServletResponse();
final MockHttpServletRequest request = new MockHttpServletRequest();
final WebApplicationService svc = mock(WebApplicationService.class);
when(svc.getId()).thenReturn("TestSsoFalse");
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));
this.context.getFlowScope().put("service", svc);
final SendTicketGrantingTicketAction action = new SendTicketGrantingTicketAction(centralAuthenticationService, servicesManager, ticketGrantingTicketCookieGenerator, false);
assertEquals(SUCCESS, action.execute(this.context).getId());
assertEquals(0, response.getCookies().length);
}
use of org.apereo.cas.ticket.TicketGrantingTicket in project cas by apereo.
the class TicketGrantingTicketCheckActionTests method verifyValidTicket.
@Test
public void verifyValidTicket() throws Exception {
final MockRequestContext ctx = new MockRequestContext();
final AuthenticationResult ctxAuthN = CoreAuthenticationTestUtils.getAuthenticationResult(getAuthenticationSystemSupport());
final TicketGrantingTicket tgt = this.getCentralAuthenticationService().createTicketGrantingTicket(ctxAuthN);
WebUtils.putTicketGrantingTicketInScopes(ctx, tgt);
final TicketGrantingTicketCheckAction action = new TicketGrantingTicketCheckAction(this.getCentralAuthenticationService());
final Event event = action.doExecute(ctx);
assertEquals(event.getId(), TicketGrantingTicketCheckAction.VALID);
}
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.getGrantingTicket()).thenReturn(tgtMock);
return tgtMock;
}
use of org.apereo.cas.ticket.TicketGrantingTicket in project cas by apereo.
the class MultifactorAuthenticationTests method verifyAllowsAccessToNormalSecurityServiceWithPassword.
@Test
public void verifyAllowsAccessToNormalSecurityServiceWithPassword() throws Exception {
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);
}
Aggregations