use of org.apereo.cas.ticket.ServiceTicket in project cas by apereo.
the class AbstractTicketRegistryTests method verifyDeleteTicketWithPGT.
@Test
public void verifyDeleteTicketWithPGT() {
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");
final ServiceTicket st1 = tgt.grantServiceTicket(ST_1_ID, service, new NeverExpiresExpirationPolicy(), false, true);
this.ticketRegistry.addTicket(st1);
this.ticketRegistry.updateTicket(tgt);
assertNotNull(this.ticketRegistry.getTicket(TGT_ID, TicketGrantingTicket.class));
assertNotNull(this.ticketRegistry.getTicket(ST_1_ID, ServiceTicket.class));
final ProxyGrantingTicket pgt = st1.grantProxyGrantingTicket(PGT_1_ID, a, new NeverExpiresExpirationPolicy());
this.ticketRegistry.addTicket(pgt);
this.ticketRegistry.updateTicket(tgt);
this.ticketRegistry.updateTicket(st1);
assertEquals(pgt.getTicketGrantingTicket(), tgt);
assertNotNull(this.ticketRegistry.getTicket(PGT_1_ID, ProxyGrantingTicket.class));
assertEquals(a, pgt.getAuthentication());
assertNotNull(this.ticketRegistry.getTicket(ST_1_ID, ServiceTicket.class));
assertTrue(this.ticketRegistry.deleteTicket(tgt.getId()) > 0);
assertNull(this.ticketRegistry.getTicket(TGT_ID, TicketGrantingTicket.class));
assertNull(this.ticketRegistry.getTicket(ST_1_ID, ServiceTicket.class));
assertNull(this.ticketRegistry.getTicket(PGT_1_ID, ProxyGrantingTicket.class));
}
use of org.apereo.cas.ticket.ServiceTicket 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.ServiceTicket 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);
}
use of org.apereo.cas.ticket.ServiceTicket 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.getTicketGrantingTicket(), returned.getTicketGrantingTicket());
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.getTicketGrantingTicket(), sreturned.getTicketGrantingTicket());
assertEquals(s.getId(), sreturned.getId());
assertEquals(s.isExpired(), sreturned.isExpired());
assertEquals(s.getService(), sreturned.getService());
assertEquals(s.isFromNewLogin(), sreturned.isFromNewLogin());
}
use of org.apereo.cas.ticket.ServiceTicket in project cas by apereo.
the class CasKryoTranscoderTests method verifyEncodeDecode.
@Test
public void verifyEncodeDecode() {
final TicketGrantingTicket tgt = new MockTicketGrantingTicket(USERNAME);
final ServiceTicket expectedST = new MockServiceTicket(ST_ID, RegisteredServiceTestUtils.getService(), tgt);
assertEquals(expectedST, transcoder.decode(transcoder.encode(expectedST)));
final TicketGrantingTicket expectedTGT = new MockTicketGrantingTicket(USERNAME);
expectedTGT.grantServiceTicket(ST_ID, null, null, false, true);
final CachedData result = transcoder.encode(expectedTGT);
assertEquals(expectedTGT, transcoder.decode(result));
assertEquals(expectedTGT, transcoder.decode(result));
internalProxyTest("http://localhost");
internalProxyTest("https://localhost:8080/path/file.html?p1=v1&p2=v2#fragment");
}
Aggregations