Search in sources :

Example 21 with TicketGrantingTicketImpl

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

the class AbstractTicketRegistryTests method verifyDeleteExistingTicket.

@Test
public void verifyDeleteExistingTicket() {
    try {
        this.ticketRegistry.addTicket(new TicketGrantingTicketImpl(TicketGrantingTicket.PREFIX, CoreAuthenticationTestUtils.getAuthentication(), new NeverExpiresExpirationPolicy()));
        assertSame(1, this.ticketRegistry.deleteTicket(TicketGrantingTicket.PREFIX));
    } catch (final Exception e) {
        fail(CAUGHT_AN_EXCEPTION_BUT_WAS_NOT_EXPECTED + e.getMessage());
    }
}
Also used : NeverExpiresExpirationPolicy(org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy) TicketGrantingTicketImpl(org.apereo.cas.ticket.TicketGrantingTicketImpl) Test(org.junit.Test)

Example 22 with TicketGrantingTicketImpl

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

the class DistributedTicketRegistryTests method verifyProxiedInstancesEqual.

@Test
public void verifyProxiedInstancesEqual() {
    final TicketGrantingTicket t = new TicketGrantingTicketImpl(TGT_ID, CoreAuthenticationTestUtils.getAuthentication(), new NeverExpiresExpirationPolicy());
    this.ticketRegistry.addTicket(t);
    final TicketGrantingTicket returned = (TicketGrantingTicket) this.ticketRegistry.getTicket(TGT_ID);
    assertEquals(t, returned);
    assertEquals(returned, t);
    assertEquals(t.getCreationTime(), returned.getCreationTime());
    assertEquals(t.getAuthentication(), returned.getAuthentication());
    assertEquals(t.getCountOfUses(), returned.getCountOfUses());
    assertEquals(t.getGrantingTicket(), returned.getGrantingTicket());
    assertEquals(t.getId(), returned.getId());
    assertEquals(t.getChainedAuthentications(), returned.getChainedAuthentications());
    assertEquals(t.isExpired(), returned.isExpired());
    assertEquals(t.isRoot(), returned.isRoot());
    final ServiceTicket s = t.grantServiceTicket("stest", RegisteredServiceTestUtils.getService(), new NeverExpiresExpirationPolicy(), false, true);
    this.ticketRegistry.addTicket(s);
    final ServiceTicket sreturned = (ServiceTicket) this.ticketRegistry.getTicket("stest");
    assertEquals(s, sreturned);
    assertEquals(sreturned, s);
    assertEquals(s.getCreationTime(), sreturned.getCreationTime());
    assertEquals(s.getCountOfUses(), sreturned.getCountOfUses());
    assertEquals(s.getGrantingTicket(), sreturned.getGrantingTicket());
    assertEquals(s.getId(), sreturned.getId());
    assertEquals(s.isExpired(), sreturned.isExpired());
    assertEquals(s.getService(), sreturned.getService());
    assertEquals(s.isFromNewLogin(), sreturned.isFromNewLogin());
}
Also used : NeverExpiresExpirationPolicy(org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy) TicketGrantingTicket(org.apereo.cas.ticket.TicketGrantingTicket) TicketGrantingTicketImpl(org.apereo.cas.ticket.TicketGrantingTicketImpl) ServiceTicket(org.apereo.cas.ticket.ServiceTicket) Test(org.junit.Test)

Example 23 with TicketGrantingTicketImpl

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

the class DistributedTicketRegistryTests method verifyUpdateOfRegistry.

@Test
public void verifyUpdateOfRegistry() throws AbstractTicketException {
    final TicketGrantingTicket t = new TicketGrantingTicketImpl(TGT_ID, CoreAuthenticationTestUtils.getAuthentication(), new NeverExpiresExpirationPolicy());
    this.ticketRegistry.addTicket(t);
    final TicketGrantingTicket returned = (TicketGrantingTicket) this.ticketRegistry.getTicket(TGT_ID);
    final ServiceTicket s = returned.grantServiceTicket("test2", RegisteredServiceTestUtils.getService(), new NeverExpiresExpirationPolicy(), false, true);
    this.ticketRegistry.addTicket(s);
    final ServiceTicket s2 = (ServiceTicket) this.ticketRegistry.getTicket("test2");
    assertNotNull(s2.grantProxyGrantingTicket("ff", CoreAuthenticationTestUtils.getAuthentication(), new NeverExpiresExpirationPolicy()));
    assertTrue(s2.isValidFor(RegisteredServiceTestUtils.getService()));
    assertTrue(this.wasTicketUpdated);
    returned.markTicketExpired();
    assertTrue(t.isExpired());
}
Also used : NeverExpiresExpirationPolicy(org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy) TicketGrantingTicket(org.apereo.cas.ticket.TicketGrantingTicket) TicketGrantingTicketImpl(org.apereo.cas.ticket.TicketGrantingTicketImpl) ServiceTicket(org.apereo.cas.ticket.ServiceTicket) Test(org.junit.Test)

Example 24 with TicketGrantingTicketImpl

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

the class DistributedTicketRegistryTests method verifyDeleteTicketWithPGT.

@Test
public void verifyDeleteTicketWithPGT() {
    final Authentication a = CoreAuthenticationTestUtils.getAuthentication();
    this.ticketRegistry.addTicket(new TicketGrantingTicketImpl(TGT_NAME, a, new NeverExpiresExpirationPolicy()));
    final TicketGrantingTicket tgt = this.ticketRegistry.getTicket(TGT_NAME, TicketGrantingTicket.class);
    final Service service = CoreAuthenticationTestUtils.getService("TGT_DELETE_TEST");
    final ServiceTicket st1 = tgt.grantServiceTicket("ST1", service, new NeverExpiresExpirationPolicy(), true, true);
    this.ticketRegistry.addTicket(st1);
    assertNotNull(this.ticketRegistry.getTicket(TGT_NAME, TicketGrantingTicket.class));
    assertNotNull(this.ticketRegistry.getTicket("ST1", ServiceTicket.class));
    final ProxyGrantingTicket pgt = st1.grantProxyGrantingTicket("PGT-1", a, new NeverExpiresExpirationPolicy());
    assertEquals(a, pgt.getAuthentication());
    this.ticketRegistry.addTicket(pgt);
    assertSame(3, this.ticketRegistry.deleteTicket(tgt.getId()));
    assertNull(this.ticketRegistry.getTicket(TGT_NAME, TicketGrantingTicket.class));
    assertNull(this.ticketRegistry.getTicket("ST1", ServiceTicket.class));
    assertNull(this.ticketRegistry.getTicket("PGT-1", ProxyGrantingTicket.class));
}
Also used : NeverExpiresExpirationPolicy(org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy) Authentication(org.apereo.cas.authentication.Authentication) TicketGrantingTicket(org.apereo.cas.ticket.TicketGrantingTicket) Service(org.apereo.cas.authentication.principal.Service) TicketGrantingTicketImpl(org.apereo.cas.ticket.TicketGrantingTicketImpl) ServiceTicket(org.apereo.cas.ticket.ServiceTicket) ProxyGrantingTicket(org.apereo.cas.ticket.proxy.ProxyGrantingTicket) Test(org.junit.Test)

Example 25 with TicketGrantingTicketImpl

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

the class RememberMeDelegatingExpirationPolicyTests method verifyTicketExpirationWithoutRememberMe.

@Test
public void verifyTicketExpirationWithoutRememberMe() {
    final Authentication authentication = CoreAuthenticationTestUtils.getAuthentication();
    final TicketGrantingTicketImpl t = new TicketGrantingTicketImpl("111", authentication, this.p);
    assertFalse(t.isExpired());
    t.grantServiceTicket("55", RegisteredServiceTestUtils.getService(), this.p, false, true);
    assertFalse(t.isExpired());
}
Also used : Authentication(org.apereo.cas.authentication.Authentication) TicketGrantingTicketImpl(org.apereo.cas.ticket.TicketGrantingTicketImpl) Test(org.junit.Test)

Aggregations

TicketGrantingTicketImpl (org.apereo.cas.ticket.TicketGrantingTicketImpl)28 Test (org.junit.Test)22 NeverExpiresExpirationPolicy (org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy)17 TicketGrantingTicket (org.apereo.cas.ticket.TicketGrantingTicket)12 ServiceTicket (org.apereo.cas.ticket.ServiceTicket)10 Authentication (org.apereo.cas.authentication.Authentication)8 Service (org.apereo.cas.authentication.principal.Service)8 MockServiceTicket (org.apereo.cas.mock.MockServiceTicket)5 MockTicketGrantingTicket (org.apereo.cas.mock.MockTicketGrantingTicket)5 Before (org.junit.Before)5 ProxyGrantingTicket (org.apereo.cas.ticket.proxy.ProxyGrantingTicket)3 MockService (org.apereo.cas.mock.MockService)2 ExpirationPolicy (org.apereo.cas.ticket.ExpirationPolicy)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)2 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)2 ServletExternalContext (org.springframework.webflow.context.servlet.ServletExternalContext)2 MockRequestContext (org.springframework.webflow.test.MockRequestContext)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1