use of org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy in project cas by apereo.
the class MemCacheTicketRegistryTests method verifyDeleteTicketWithPGT.
@Test
public void verifyDeleteTicketWithPGT() {
final Authentication a = CoreAuthenticationTestUtils.getAuthentication();
this.registry.addTicket(new TicketGrantingTicketImpl(TGT_ID, a, new NeverExpiresExpirationPolicy()));
final TicketGrantingTicket tgt = this.registry.getTicket(TGT_ID, TicketGrantingTicket.class);
final Service service = RegisteredServiceTestUtils.getService("TGT_DELETE_TEST");
final ServiceTicket st1 = tgt.grantServiceTicket(ST_1_ID, service, new NeverExpiresExpirationPolicy(), false, true);
this.registry.addTicket(st1);
this.registry.updateTicket(tgt);
assertNotNull(this.registry.getTicket(TGT_ID, TicketGrantingTicket.class));
assertNotNull(this.registry.getTicket(ST_1_ID, ServiceTicket.class));
final ProxyGrantingTicket pgt = st1.grantProxyGrantingTicket(PGT_1_ID, a, new NeverExpiresExpirationPolicy());
this.registry.addTicket(pgt);
this.registry.updateTicket(tgt);
this.registry.updateTicket(st1);
assertEquals(pgt.getGrantingTicket(), tgt);
assertNotNull(this.registry.getTicket(PGT_1_ID, ProxyGrantingTicket.class));
assertEquals(a, pgt.getAuthentication());
assertNotNull(this.registry.getTicket(ST_1_ID, ServiceTicket.class));
assertTrue(this.registry.deleteTicket(tgt.getId()) > 0);
assertNull(this.registry.getTicket(TGT_ID, TicketGrantingTicket.class));
assertNull(this.registry.getTicket(ST_1_ID, ServiceTicket.class));
assertNull(this.registry.getTicket(PGT_1_ID, ProxyGrantingTicket.class));
}
Aggregations