use of org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy in project cas by apereo.
the class AbstractTicketRegistryTests method verifyGetTicketsFromRegistryEqualToTicketsAdded.
@Test
public void verifyGetTicketsFromRegistryEqualToTicketsAdded() {
Assume.assumeTrue(isIterableRegistry());
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 -> {
throw new AssertionError("Ticket " + ticket + " was not found in retrieval of collection of all tickets.");
});
} catch (final Exception e) {
throw new AssertionError(EXCEPTION_CAUGHT_NONE_EXPECTED + e.getMessage(), e);
}
}
use of org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy in project cas by apereo.
the class AbstractTicketRegistryTests method verifyAddAndUpdateTicket.
@Test
public void verifyAddAndUpdateTicket() {
try {
TicketGrantingTicket tgt = new TicketGrantingTicketImpl(TicketGrantingTicket.PREFIX, CoreAuthenticationTestUtils.getAuthentication(), new NeverExpiresExpirationPolicy());
this.ticketRegistry.addTicket(tgt);
tgt = this.ticketRegistry.getTicket(tgt.getId(), TicketGrantingTicket.class);
assertNotNull(tgt);
assertTrue(tgt.getServices().isEmpty());
tgt.grantServiceTicket("ST1", RegisteredServiceTestUtils.getService("TGT_UPDATE_TEST"), new NeverExpiresExpirationPolicy(), false, false);
this.ticketRegistry.updateTicket(tgt);
tgt = this.ticketRegistry.getTicket(tgt.getId(), TicketGrantingTicket.class);
assertEquals(Collections.singleton("ST1"), tgt.getServices().keySet());
} catch (final Exception e) {
throw new AssertionError(CAUGHT_AN_EXCEPTION_BUT_WAS_NOT_EXPECTED + e.getMessage(), e);
}
}
use of org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy 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));
assertNull(this.ticketRegistry.getTicket(TicketGrantingTicket.PREFIX));
} catch (final Exception e) {
throw new AssertionError(CAUGHT_AN_EXCEPTION_BUT_WAS_NOT_EXPECTED + e.getMessage(), e);
}
}
use of org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy in project cas by apereo.
the class AbstractTicketRegistryTests method verifyWriteGetDelete.
@Test
public void verifyWriteGetDelete() {
final Ticket ticket = new TicketGrantingTicketImpl(TicketGrantingTicket.PREFIX, CoreAuthenticationTestUtils.getAuthentication(), new NeverExpiresExpirationPolicy());
ticketRegistry.addTicket(ticket);
final Ticket ticketFromRegistry = ticketRegistry.getTicket(TicketGrantingTicket.PREFIX);
assertNotNull(ticketFromRegistry);
assertEquals(TicketGrantingTicket.PREFIX, ticketFromRegistry.getId());
ticketRegistry.deleteTicket(TicketGrantingTicket.PREFIX);
assertNull(ticketRegistry.getTicket(TicketGrantingTicket.PREFIX));
}
use of org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy in project cas by apereo.
the class AbstractTicketRegistryTests method verifyDeleteTicketsWithMultiplePGTs.
@Test
public void verifyDeleteTicketsWithMultiplePGTs() {
final Authentication a = CoreAuthenticationTestUtils.getAuthentication();
this.ticketRegistry.addTicket(new TicketGrantingTicketImpl(TGT_ID, a, new NeverExpiresExpirationPolicy()));
final TicketGrantingTicket tgt = this.ticketRegistry.getTicket(TGT_ID, TicketGrantingTicket.class);
final Service service = RegisteredServiceTestUtils.getService("TGT_DELETE_TEST");
IntStream.range(1, 5).forEach(i -> {
final ServiceTicket st = tgt.grantServiceTicket(ST_1_ID + "-" + i, service, new NeverExpiresExpirationPolicy(), false, true);
this.ticketRegistry.addTicket(st);
this.ticketRegistry.updateTicket(tgt);
final ProxyGrantingTicket pgt = st.grantProxyGrantingTicket(PGT_1_ID + "-" + i, a, new NeverExpiresExpirationPolicy());
this.ticketRegistry.addTicket(pgt);
this.ticketRegistry.updateTicket(tgt);
this.ticketRegistry.updateTicket(st);
});
final int c = this.ticketRegistry.deleteTicket(TGT_ID);
assertEquals(6, c);
}
Aggregations