use of org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy in project cas by apereo.
the class TicketGrantingTicketImplTests method verifyCheckCreationTime.
@Test
public void verifyCheckCreationTime() {
final Authentication authentication = CoreAuthenticationTestUtils.getAuthentication();
final List<Authentication> principals = new ArrayList<>();
principals.add(authentication);
final ZonedDateTime startTime = ZonedDateTime.now(ZoneOffset.UTC).minusNanos(100);
final TicketGrantingTicket t = new TicketGrantingTicketImpl(TGT_ID, null, null, authentication, new NeverExpiresExpirationPolicy());
final ZonedDateTime finishTime = ZonedDateTime.now(ZoneOffset.UTC).plusNanos(100);
assertTrue(startTime.isBefore(t.getCreationTime()) && finishTime.isAfter(t.getCreationTime()));
}
use of org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy in project cas by apereo.
the class TicketGrantingTicketImplTests method verifyGetAuthentication.
@Test
public void verifyGetAuthentication() {
final Authentication authentication = CoreAuthenticationTestUtils.getAuthentication();
final TicketGrantingTicket t = new TicketGrantingTicketImpl(TGT_ID, null, null, authentication, new NeverExpiresExpirationPolicy());
assertEquals(t.getAuthentication(), authentication);
assertEquals(t.getId(), t.toString());
}
use of org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy in project cas by apereo.
the class AbstractTicketRegistryTests method verifyGetExistingTicketWithProperClass.
@Test
public void verifyGetExistingTicketWithProperClass() {
try {
this.ticketRegistry.addTicket(new TicketGrantingTicketImpl(TicketGrantingTicket.PREFIX, CoreAuthenticationTestUtils.getAuthentication(), new NeverExpiresExpirationPolicy()));
this.ticketRegistry.getTicket(TicketGrantingTicket.PREFIX, TicketGrantingTicket.class);
} catch (final Exception e) {
fail(EXCEPTION_CAUGHT_NONE_EXPECTED);
}
}
use of org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy in project cas by apereo.
the class AbstractTicketRegistryTests method verifyDeleteNonExistingTicket.
@Test
public void verifyDeleteNonExistingTicket() {
try {
this.ticketRegistry.addTicket(new TicketGrantingTicketImpl(TicketGrantingTicket.PREFIX, CoreAuthenticationTestUtils.getAuthentication(), new NeverExpiresExpirationPolicy()));
assertSame(0, this.ticketRegistry.deleteTicket(TicketGrantingTicket.PREFIX + "1"));
} catch (final Exception e) {
fail(EXCEPTION_CAUGHT_NONE_EXPECTED);
}
}
use of org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy in project cas by apereo.
the class AbstractTicketRegistryTests method verifyDeleteTicketWithChildren.
@Test
public void verifyDeleteTicketWithChildren() {
try {
this.ticketRegistry.addTicket(new TicketGrantingTicketImpl(TicketGrantingTicket.PREFIX + "1", CoreAuthenticationTestUtils.getAuthentication(), new NeverExpiresExpirationPolicy()));
final TicketGrantingTicket tgt = this.ticketRegistry.getTicket(TicketGrantingTicket.PREFIX + "1", TicketGrantingTicket.class);
final Service service = RegisteredServiceTestUtils.getService("TGT_DELETE_TEST");
final ServiceTicket st1 = tgt.grantServiceTicket("ST11", service, new NeverExpiresExpirationPolicy(), false, false);
final ServiceTicket st2 = tgt.grantServiceTicket("ST21", service, new NeverExpiresExpirationPolicy(), false, false);
final ServiceTicket st3 = tgt.grantServiceTicket("ST31", service, new NeverExpiresExpirationPolicy(), false, false);
this.ticketRegistry.addTicket(st1);
this.ticketRegistry.addTicket(st2);
this.ticketRegistry.addTicket(st3);
assertNotNull(this.ticketRegistry.getTicket(TicketGrantingTicket.PREFIX + "1", TicketGrantingTicket.class));
assertNotNull(this.ticketRegistry.getTicket("ST11", ServiceTicket.class));
assertNotNull(this.ticketRegistry.getTicket("ST21", ServiceTicket.class));
assertNotNull(this.ticketRegistry.getTicket("ST31", ServiceTicket.class));
this.ticketRegistry.updateTicket(tgt);
assertSame(4, this.ticketRegistry.deleteTicket(tgt.getId()));
assertNull(this.ticketRegistry.getTicket(TicketGrantingTicket.PREFIX + "1", TicketGrantingTicket.class));
assertNull(this.ticketRegistry.getTicket("ST11", ServiceTicket.class));
assertNull(this.ticketRegistry.getTicket("ST21", ServiceTicket.class));
assertNull(this.ticketRegistry.getTicket("ST31", ServiceTicket.class));
} catch (final Exception e) {
fail(CAUGHT_AN_EXCEPTION_BUT_WAS_NOT_EXPECTED + e.getMessage());
}
}
Aggregations