Search in sources :

Example 81 with TicketGrantingTicket

use of org.apereo.cas.ticket.TicketGrantingTicket in project cas by apereo.

the class HazelcastTicketRegistryReplicationTests method basicOperationsAndClustering.

@Test
public void basicOperationsAndClustering() throws Exception {
    final TicketGrantingTicket tgt = newTestTgt();
    this.hzTicketRegistry1.addTicket(tgt);
    assertNotNull(this.hzTicketRegistry1.getTicket(tgt.getId()));
    assertNotNull(this.hzTicketRegistry2.getTicket(tgt.getId()));
    assertEquals(1, this.hzTicketRegistry2.deleteTicket(tgt.getId()));
    assertEquals(0, this.hzTicketRegistry1.deleteTicket(tgt.getId()));
    assertNull(this.hzTicketRegistry1.getTicket(tgt.getId()));
    assertNull(this.hzTicketRegistry2.getTicket(tgt.getId()));
    final ServiceTicket st = newTestSt(tgt);
    this.hzTicketRegistry2.addTicket(st);
    assertNotNull(this.hzTicketRegistry1.getTicket("ST-TEST"));
    assertNotNull(this.hzTicketRegistry2.getTicket("ST-TEST"));
    assertEquals(1, this.hzTicketRegistry1.deleteTicket("ST-TEST"));
    assertNull(this.hzTicketRegistry1.getTicket("ST-TEST"));
    assertNull(this.hzTicketRegistry2.getTicket("ST-TEST"));
}
Also used : TicketGrantingTicket(org.apereo.cas.ticket.TicketGrantingTicket) MockTicketGrantingTicket(org.apereo.cas.mock.MockTicketGrantingTicket) MockServiceTicket(org.apereo.cas.mock.MockServiceTicket) ServiceTicket(org.apereo.cas.ticket.ServiceTicket) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 82 with TicketGrantingTicket

use of org.apereo.cas.ticket.TicketGrantingTicket in project cas by apereo.

the class JpaTicketRegistryTests method verifyTicketDeletionInBulk.

@Test
public void verifyTicketDeletionInBulk() {
    final TicketGrantingTicket newTgt = newTGT();
    addTicketInTransaction(newTgt);
    final TicketGrantingTicket tgtFromDb = (TicketGrantingTicket) getTicketInTransaction(newTgt.getId());
    final ServiceTicket newSt = grantServiceTicketInTransaction(tgtFromDb);
    final ServiceTicket stFromDb = (ServiceTicket) getTicketInTransaction(newSt.getId());
    final ProxyGrantingTicket newPgt = grantProxyGrantingTicketInTransaction(stFromDb);
    final ProxyGrantingTicket pgtFromDb = (ProxyGrantingTicket) getTicketInTransaction(newPgt.getId());
    final ProxyTicket newPt = grantProxyTicketInTransaction(pgtFromDb);
    getTicketInTransaction(newPt.getId());
    deleteTicketsInTransaction();
}
Also used : TicketGrantingTicket(org.apereo.cas.ticket.TicketGrantingTicket) ServiceTicket(org.apereo.cas.ticket.ServiceTicket) ProxyGrantingTicket(org.apereo.cas.ticket.proxy.ProxyGrantingTicket) ProxyTicket(org.apereo.cas.ticket.proxy.ProxyTicket) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Example 83 with TicketGrantingTicket

use of org.apereo.cas.ticket.TicketGrantingTicket in project cas by apereo.

the class CentralAuthenticationServiceImplWithMockitoTests method createRootTicketGrantingTicket.

private TicketGrantingTicket createRootTicketGrantingTicket() {
    final TicketGrantingTicket tgtRootMock = mock(TicketGrantingTicket.class);
    when(tgtRootMock.isExpired()).thenReturn(false);
    when(tgtRootMock.getAuthentication()).thenReturn(this.authentication);
    return tgtRootMock;
}
Also used : TicketGrantingTicket(org.apereo.cas.ticket.TicketGrantingTicket)

Example 84 with TicketGrantingTicket

use of org.apereo.cas.ticket.TicketGrantingTicket 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);
}
Also used : TicketGrantingTicket(org.apereo.cas.ticket.TicketGrantingTicket) AbstractWebApplicationService(org.apereo.cas.authentication.principal.AbstractWebApplicationService) Service(org.apereo.cas.authentication.principal.Service) ServiceTicket(org.apereo.cas.ticket.ServiceTicket) AuthenticationResult(org.apereo.cas.authentication.AuthenticationResult) Test(org.junit.Test)

Example 85 with TicketGrantingTicket

use of org.apereo.cas.ticket.TicketGrantingTicket in project cas by apereo.

the class SendTicketGrantingTicketActionTests method verifySsoSessionCookieOnRenewAsParameter.

@Test
public void verifySsoSessionCookieOnRenewAsParameter() throws Exception {
    final MockHttpServletResponse response = new MockHttpServletResponse();
    final MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter(CasProtocolConstants.PARAMETER_RENEW, "true");
    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));
    final SendTicketGrantingTicketAction action = new SendTicketGrantingTicketAction(centralAuthenticationService, servicesManager, ticketGrantingTicketCookieGenerator, false);
    assertEquals(SUCCESS, action.execute(this.context).getId());
    assertEquals(0, response.getCookies().length);
}
Also used : Cookie(javax.servlet.http.Cookie) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) TicketGrantingTicket(org.apereo.cas.ticket.TicketGrantingTicket) ServletExternalContext(org.springframework.webflow.context.servlet.ServletExternalContext) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) MockServletContext(org.springframework.mock.web.MockServletContext) Test(org.junit.Test)

Aggregations

TicketGrantingTicket (org.apereo.cas.ticket.TicketGrantingTicket)155 Test (org.junit.Test)119 AuthenticationResult (org.apereo.cas.authentication.AuthenticationResult)69 ServiceTicket (org.apereo.cas.ticket.ServiceTicket)67 Service (org.apereo.cas.authentication.principal.Service)43 MockTicketGrantingTicket (org.apereo.cas.mock.MockTicketGrantingTicket)35 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)32 Credential (org.apereo.cas.authentication.Credential)26 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)26 Authentication (org.apereo.cas.authentication.Authentication)24 UsernamePasswordCredential (org.apereo.cas.authentication.UsernamePasswordCredential)23 TicketGrantingTicketImpl (org.apereo.cas.ticket.TicketGrantingTicketImpl)21 NeverExpiresExpirationPolicy (org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy)20 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)18 AbstractWebApplicationService (org.apereo.cas.authentication.principal.AbstractWebApplicationService)16 MockServiceTicket (org.apereo.cas.mock.MockServiceTicket)16 ServletExternalContext (org.springframework.webflow.context.servlet.ServletExternalContext)14 Assertion (org.apereo.cas.validation.Assertion)13 CachedData (net.spy.memcached.CachedData)12 MockServletContext (org.springframework.mock.web.MockServletContext)12