use of org.apereo.cas.ticket.TicketGrantingTicketImpl in project cas by apereo.
the class AbstractTicketRegistryTests method verifyGetTicketsFromRegistryEqualToTicketsAdded.
@Test
public void verifyGetTicketsFromRegistryEqualToTicketsAdded() {
final Collection<Ticket> tickets = new ArrayList<>();
for (int i = 0; i < TICKETS_IN_REGISTRY; i++) {
final TicketGrantingTicket ticketGrantingTicket = new TicketGrantingTicketImpl(TicketGrantingTicket.PREFIX + i, CoreAuthenticationTestUtils.getAuthentication(), new NeverExpiresExpirationPolicy());
final ServiceTicket st = ticketGrantingTicket.grantServiceTicket("ST" + i, RegisteredServiceTestUtils.getService(), new NeverExpiresExpirationPolicy(), false, true);
tickets.add(ticketGrantingTicket);
tickets.add(st);
this.ticketRegistry.addTicket(ticketGrantingTicket);
this.ticketRegistry.addTicket(st);
}
try {
final Collection<Ticket> ticketRegistryTickets = this.ticketRegistry.getTickets();
assertEquals("The size of the registry is not the same as the collection.", tickets.size(), ticketRegistryTickets.size());
tickets.stream().filter(ticket -> !ticketRegistryTickets.contains(ticket)).forEach(ticket -> fail("Ticket was added to registry but was not found in retrieval of collection of all tickets."));
} catch (final Exception e) {
fail(EXCEPTION_CAUGHT_NONE_EXPECTED);
}
}
use of org.apereo.cas.ticket.TicketGrantingTicketImpl in project cas by apereo.
the class CentralAuthenticationServiceImplTests method verifyDestroyRemoteRegistry.
/**
* This test checks that the TGT destruction happens properly for a remote registry.
* It previously failed when the deletion happens before the ticket was marked expired because an update was necessary for that.
*/
@Test
public void verifyDestroyRemoteRegistry() throws AbstractTicketException, AuthenticationException {
final MockOnlyOneTicketRegistry registry = new MockOnlyOneTicketRegistry();
final TicketGrantingTicketImpl tgt = new TicketGrantingTicketImpl("TGT-1", mock(Authentication.class), mock(ExpirationPolicy.class));
final MockExpireUpdateTicketLogoutManager logoutManager = new MockExpireUpdateTicketLogoutManager(registry);
registry.addTicket(tgt);
final DefaultCentralAuthenticationService cas = new DefaultCentralAuthenticationService(registry, null, null, logoutManager, null, null, null, null);
cas.setApplicationEventPublisher(mock(ApplicationEventPublisher.class));
cas.destroyTicketGrantingTicket(tgt.getId());
}
use of org.apereo.cas.ticket.TicketGrantingTicketImpl 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