use of org.apereo.cas.ticket.ServiceTicket in project cas by apereo.
the class DefaultServiceTicketFactoryTests method verifyCustomExpirationPolicy.
@Test
public void verifyCustomExpirationPolicy() {
val svc = RegisteredServiceTestUtils.getRegisteredService("customExpirationPolicy", RegexRegisteredService.class);
svc.setServiceTicketExpirationPolicy(new DefaultRegisteredServiceServiceTicketExpirationPolicy(10, "666"));
servicesManager.save(svc);
val factory = (ServiceTicketFactory) this.ticketFactory.get(ServiceTicket.class);
val serviceTicket = factory.create(new MockTicketGrantingTicket("casuser"), RegisteredServiceTestUtils.getService("customExpirationPolicy"), true, ServiceTicket.class);
assertNotNull(serviceTicket);
assertEquals(666, serviceTicket.getExpirationPolicy().getTimeToLive());
}
use of org.apereo.cas.ticket.ServiceTicket in project cas by apereo.
the class DefaultServiceTicketFactoryTests method verifyDefaultExpirationPolicy.
@Test
public void verifyDefaultExpirationPolicy() {
val svc = RegisteredServiceTestUtils.getRegisteredService("defaultExpirationPolicy", RegexRegisteredService.class);
servicesManager.save(svc);
val factory = (ServiceTicketFactory) this.ticketFactory.get(ServiceTicket.class);
val serviceTicket = factory.create(new MockTicketGrantingTicket("casuser"), RegisteredServiceTestUtils.getService("defaultExpirationPolicy"), true, ServiceTicket.class);
assertNotNull(serviceTicket);
assertEquals(10, serviceTicket.getExpirationPolicy().getTimeToLive());
}
use of org.apereo.cas.ticket.ServiceTicket in project cas by apereo.
the class DistributedTicketRegistryTests method verifyProxiedInstancesEqual.
@Test
public void verifyProxiedInstancesEqual() throws Exception {
val t = new TicketGrantingTicketImpl(TGT_ID, CoreAuthenticationTestUtils.getAuthentication(), NeverExpiresExpirationPolicy.INSTANCE);
this.ticketRegistry.addTicket(t);
val 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());
val s = t.grantServiceTicket("stest", RegisteredServiceTestUtils.getService(), NeverExpiresExpirationPolicy.INSTANCE, false, true);
this.ticketRegistry.addTicket(s);
val 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(((RenewableServiceTicket) s).isFromNewLogin(), ((RenewableServiceTicket) sreturned).isFromNewLogin());
}
Aggregations