use of org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy 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.support.NeverExpiresExpirationPolicy in project cas by apereo.
the class CasKryoTranscoderTests method verifyEncodeDecodeTGTImpl.
@Test
public void verifyEncodeDecodeTGTImpl() {
final Credential userPassCredential = new UsernamePasswordCredential(USERNAME, PASSWORD);
final AuthenticationBuilder bldr = new DefaultAuthenticationBuilder(new DefaultPrincipalFactory().createPrincipal("user", new HashMap<>(this.principalAttributes)));
bldr.setAttributes(new HashMap<>(this.principalAttributes));
bldr.setAuthenticationDate(ZonedDateTime.now());
bldr.addCredential(new BasicCredentialMetaData(userPassCredential));
bldr.addFailure("error", new AccountNotFoundException());
bldr.addSuccess("authn", new DefaultAuthenticationHandlerExecutionResult(new AcceptUsersAuthenticationHandler(""), new BasicCredentialMetaData(userPassCredential)));
final TicketGrantingTicket expectedTGT = new TicketGrantingTicketImpl(TGT_ID, RegisteredServiceTestUtils.getService(), null, bldr.build(), new NeverExpiresExpirationPolicy());
final ServiceTicket ticket = expectedTGT.grantServiceTicket(ST_ID, RegisteredServiceTestUtils.getService(), new NeverExpiresExpirationPolicy(), false, true);
CachedData result = transcoder.encode(expectedTGT);
final TicketGrantingTicket resultTicket = (TicketGrantingTicket) transcoder.decode(result);
assertEquals(expectedTGT, resultTicket);
result = transcoder.encode(ticket);
ServiceTicket resultStTicket = (ServiceTicket) transcoder.decode(result);
assertEquals(ticket, resultStTicket);
resultStTicket = (ServiceTicket) transcoder.decode(result);
assertEquals(ticket, resultStTicket);
}
use of org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy in project cas by apereo.
the class AddTicketMessageQueueCommandTests method verifyAddTicket.
@Test
public void verifyAddTicket() {
TicketGrantingTicket ticket = new TicketGrantingTicketImpl("TGT", CoreAuthenticationTestUtils.getAuthentication(), new NeverExpiresExpirationPolicy());
ticketRegistry.addTicket(ticket);
final AddTicketMessageQueueCommand cmd = new AddTicketMessageQueueCommand(new StringBean(), ticket);
cmd.execute(ticketRegistry);
ticket = ticketRegistry.getTicket(ticket.getId(), ticket.getClass());
assertNotNull(ticket);
assertEquals("TGT", ticket.getId());
}
use of org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy in project cas by apereo.
the class UpdateTicketMessageQueueCommandTests method verifyUpdateTicket.
@Test
public void verifyUpdateTicket() {
TicketGrantingTicket ticket = new TicketGrantingTicketImpl("TGT", CoreAuthenticationTestUtils.getAuthentication(), new NeverExpiresExpirationPolicy());
final UpdateTicketMessageQueueCommand cmd = new UpdateTicketMessageQueueCommand(new StringBean(), ticket);
cmd.execute(ticketRegistry);
ticket = ticketRegistry.getTicket(ticket.getId(), ticket.getClass());
assertNotNull(ticket);
assertEquals("TGT", ticket.getId());
}
Aggregations