Search in sources :

Example 21 with NeverExpiresExpirationPolicy

use of org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy in project cas by apereo.

the class TicketGrantingTicketImplTests method verifyDoubleGrantSameServiceTicketKeepMostRecentSession.

@Test
public void verifyDoubleGrantSameServiceTicketKeepMostRecentSession() {
    final TicketGrantingTicket t = new TicketGrantingTicketImpl(TGT_ID, null, null, CoreAuthenticationTestUtils.getAuthentication(), new NeverExpiresExpirationPolicy());
    t.grantServiceTicket(ID_GENERATOR.getNewTicketId(ServiceTicket.PREFIX), RegisteredServiceTestUtils.getService(), new NeverExpiresExpirationPolicy(), false, true);
    t.grantServiceTicket(ID_GENERATOR.getNewTicketId(ServiceTicket.PREFIX), RegisteredServiceTestUtils.getService(), new NeverExpiresExpirationPolicy(), false, true);
    assertEquals(1, t.getServices().size());
}
Also used : NeverExpiresExpirationPolicy(org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy) Test(org.junit.Test)

Example 22 with NeverExpiresExpirationPolicy

use of org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy in project cas by apereo.

the class TicketGrantingTicketImplTests method verifyEquals.

@Test
public void verifyEquals() {
    final TicketGrantingTicket t = new TicketGrantingTicketImpl(TGT_ID, null, null, CoreAuthenticationTestUtils.getAuthentication(), new NeverExpiresExpirationPolicy());
    assertNotNull(t);
    assertFalse(t.equals(new Object()));
    assertTrue(t.equals(t));
}
Also used : NeverExpiresExpirationPolicy(org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy) Test(org.junit.Test)

Example 23 with NeverExpiresExpirationPolicy

use of org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy in project cas by apereo.

the class TicketGrantingTicketImplTests method verifyIsRootFalse.

@Test
public void verifyIsRootFalse() {
    final TicketGrantingTicketImpl t1 = new TicketGrantingTicketImpl(TGT_ID, null, null, CoreAuthenticationTestUtils.getAuthentication(), new NeverExpiresExpirationPolicy());
    final TicketGrantingTicket t = new TicketGrantingTicketImpl(TGT_ID, CoreAuthenticationTestUtils.getService("gantor"), t1, CoreAuthenticationTestUtils.getAuthentication(), new NeverExpiresExpirationPolicy());
    assertFalse(t.isRoot());
}
Also used : NeverExpiresExpirationPolicy(org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy) Test(org.junit.Test)

Example 24 with NeverExpiresExpirationPolicy

use of org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy in project cas by apereo.

the class TicketGrantingTicketImplTests method verifyWebApplicationServices.

@Test
public void verifyWebApplicationServices() {
    final MockService testService = new MockService(TGT_ID);
    final TicketGrantingTicket t = new TicketGrantingTicketImpl(TGT_ID, null, null, CoreAuthenticationTestUtils.getAuthentication(), new NeverExpiresExpirationPolicy());
    t.grantServiceTicket(ID_GENERATOR.getNewTicketId(ServiceTicket.PREFIX), testService, new NeverExpiresExpirationPolicy(), false, true);
    Map<String, Service> services = t.getServices();
    assertEquals(1, services.size());
    final String ticketId = services.keySet().iterator().next();
    assertEquals(testService, services.get(ticketId));
    t.removeAllServices();
    services = t.getServices();
    assertEquals(0, services.size());
}
Also used : NeverExpiresExpirationPolicy(org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy) MockService(org.apereo.cas.mock.MockService) MockService(org.apereo.cas.mock.MockService) Service(org.apereo.cas.authentication.principal.Service) Test(org.junit.Test)

Example 25 with NeverExpiresExpirationPolicy

use of org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy in project cas by apereo.

the class HazelcastTicketRegistryReplicationTests method verifyDeleteTicketWithPGT.

@Test
public void verifyDeleteTicketWithPGT() {
    final Authentication a = CoreAuthenticationTestUtils.getAuthentication();
    this.hzTicketRegistry1.addTicket(new TicketGrantingTicketImpl(TGT_ID, a, new NeverExpiresExpirationPolicy()));
    final TicketGrantingTicket tgt = this.hzTicketRegistry1.getTicket(TGT_ID, TicketGrantingTicket.class);
    final Service service = RegisteredServiceTestUtils.getService("TGT_DELETE_TEST");
    final ServiceTicket st1 = tgt.grantServiceTicket(ST_ID_1, service, new NeverExpiresExpirationPolicy(), false, true);
    this.hzTicketRegistry1.addTicket(st1);
    assertNotNull(this.hzTicketRegistry1.getTicket(TGT_ID, TicketGrantingTicket.class));
    assertNotNull(this.hzTicketRegistry1.getTicket(ST_ID_1, ServiceTicket.class));
    final ProxyGrantingTicket pgt = st1.grantProxyGrantingTicket(PGT_ID_1, a, new NeverExpiresExpirationPolicy());
    assertEquals(a, pgt.getAuthentication());
    this.hzTicketRegistry1.addTicket(pgt);
    this.hzTicketRegistry1.updateTicket(tgt);
    assertSame(3, this.hzTicketRegistry1.deleteTicket(tgt.getId()));
    assertNull(this.hzTicketRegistry1.getTicket(TGT_ID, TicketGrantingTicket.class));
    assertNull(this.hzTicketRegistry1.getTicket(ST_ID_1, ServiceTicket.class));
    assertNull(this.hzTicketRegistry1.getTicket(PGT_ID_1, ProxyGrantingTicket.class));
}
Also used : NeverExpiresExpirationPolicy(org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy) Authentication(org.apereo.cas.authentication.Authentication) TicketGrantingTicket(org.apereo.cas.ticket.TicketGrantingTicket) MockTicketGrantingTicket(org.apereo.cas.mock.MockTicketGrantingTicket) Service(org.apereo.cas.authentication.principal.Service) TicketGrantingTicketImpl(org.apereo.cas.ticket.TicketGrantingTicketImpl) MockServiceTicket(org.apereo.cas.mock.MockServiceTicket) ServiceTicket(org.apereo.cas.ticket.ServiceTicket) ProxyGrantingTicket(org.apereo.cas.ticket.proxy.ProxyGrantingTicket) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

NeverExpiresExpirationPolicy (org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy)51 Test (org.junit.Test)50 TicketGrantingTicketImpl (org.apereo.cas.ticket.TicketGrantingTicketImpl)17 Authentication (org.apereo.cas.authentication.Authentication)11 TicketGrantingTicket (org.apereo.cas.ticket.TicketGrantingTicket)11 Service (org.apereo.cas.authentication.principal.Service)10 ServiceTicket (org.apereo.cas.ticket.ServiceTicket)10 MockServiceTicket (org.apereo.cas.mock.MockServiceTicket)5 MockTicketGrantingTicket (org.apereo.cas.mock.MockTicketGrantingTicket)5 ProxyGrantingTicket (org.apereo.cas.ticket.proxy.ProxyGrantingTicket)5 ArrayList (java.util.ArrayList)4 MultiTimeUseOrTimeoutExpirationPolicy (org.apereo.cas.ticket.support.MultiTimeUseOrTimeoutExpirationPolicy)4 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)3 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)3 MockService (org.apereo.cas.mock.MockService)2 ProxyGrantingTicketImpl (org.apereo.cas.ticket.ProxyGrantingTicketImpl)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 ZonedDateTime (java.time.ZonedDateTime)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1