use of org.apereo.cas.ticket.DefaultTicketDefinition in project cas by apereo.
the class HazelcastTicketRegistryTests method verifyBadTicketInCatalog.
@RepeatedTest(1)
public void verifyBadTicketInCatalog() {
val ticket = new MockTicketGrantingTicket("casuser");
val instance = mock(HazelcastInstance.class);
when(instance.getMap(anyString())).thenThrow(new RuntimeException());
val catalog = mock(TicketCatalog.class);
val defn = new DefaultTicketDefinition(ticket.getClass(), ticket.getPrefix(), 0);
defn.getProperties().setStorageName("Tickets");
when(catalog.find(any(Ticket.class))).thenReturn(defn);
val registry = new HazelcastTicketRegistry(instance, catalog, 0);
assertDoesNotThrow(new Executable() {
@Override
public void execute() throws Exception {
registry.addTicket(ticket);
}
});
assertNull(registry.getTicket(ticket.getId()));
}
use of org.apereo.cas.ticket.DefaultTicketDefinition in project cas by apereo.
the class MongoDbTicketRegistryTests method verifyBadTicketInCatalog.
@RepeatedTest(1)
public void verifyBadTicketInCatalog() throws Exception {
val ticket = new MockTicketGrantingTicket("casuser");
val catalog = mock(TicketCatalog.class);
val defn = new DefaultTicketDefinition(ticket.getClass(), ticket.getPrefix(), 0);
when(catalog.find(any(Ticket.class))).thenReturn(null);
val mgr = mock(TicketSerializationManager.class);
when(mgr.serializeTicket(any())).thenReturn("{}");
val registry = new MongoDbTicketRegistry(catalog, mongoDbTicketRegistryTemplate, mgr);
registry.addTicket(ticket);
assertNull(registry.updateTicket(ticket));
when(catalog.find(any(Ticket.class))).thenReturn(defn);
defn.getProperties().setStorageName(null);
registry.addTicket(ticket);
assertNull(registry.updateTicket(ticket));
when(catalog.find(any(Ticket.class))).thenThrow(new RuntimeException());
defn.getProperties().setStorageName(null);
registry.addTicket(ticket);
assertNull(registry.updateTicket(ticket));
when(catalog.find(anyString())).thenThrow(new RuntimeException());
assertNull(registry.getTicket(ticket.getId()));
}
Aggregations