use of org.apereo.cas.mock.MockService in project cas by apereo.
the class SessionMonitorTests method addTicketsToRegistry.
private static void addTicketsToRegistry(final TicketRegistry registry, final int tgtCount, final int stCount) {
final TicketGrantingTicketImpl[] ticket = { null };
IntStream.range(0, tgtCount).forEach(i -> {
ticket[0] = new TicketGrantingTicketImpl(GENERATOR.getNewTicketId("TGT"), CoreAuthenticationTestUtils.getAuthentication(), TEST_EXP_POLICY);
registry.addTicket(ticket[0]);
});
if (ticket[0] != null) {
IntStream.range(0, stCount).forEach(i -> registry.addTicket(ticket[0].grantServiceTicket(GENERATOR.getNewTicketId("ST"), new MockService("junit"), TEST_EXP_POLICY, false, true)));
}
}
use of org.apereo.cas.mock.MockService in project cas by apereo.
the class TicketGrantingTicketImplTests method verifyWebApplicationServices.
@Test
public void verifyWebApplicationServices() {
final MockService testService = new MockService(TGT_ID);
final TicketGrantingTicket t = new TicketGrantingTicketImpl(TGT_ID, null, null, CoreAuthenticationTestUtils.getAuthentication(), new NeverExpiresExpirationPolicy());
t.grantServiceTicket(ID_GENERATOR.getNewTicketId(ServiceTicket.PREFIX), testService, new NeverExpiresExpirationPolicy(), false, true);
Map<String, Service> services = t.getServices();
assertEquals(1, services.size());
final String ticketId = services.keySet().iterator().next();
assertEquals(testService, services.get(ticketId));
t.removeAllServices();
services = t.getServices();
assertEquals(0, services.size());
}
use of org.apereo.cas.mock.MockService in project cas by apereo.
the class SessionMonitorJpaTests method addTicketsToRegistry.
private static void addTicketsToRegistry(final TicketRegistry registry, final int tgtCount, final int stCount) {
TicketGrantingTicketImpl ticket = null;
for (int i = 0; i < tgtCount; i++) {
ticket = new TicketGrantingTicketImpl(GENERATOR.getNewTicketId("TGT"), CoreAuthenticationTestUtils.getAuthentication(), TEST_EXP_POLICY);
registry.addTicket(ticket);
}
if (ticket != null) {
for (int i = 0; i < stCount; i++) {
registry.addTicket(ticket.grantServiceTicket(GENERATOR.getNewTicketId("ST"), new MockService("junit"), TEST_EXP_POLICY, false, true));
}
}
}
use of org.apereo.cas.mock.MockService in project cas by apereo.
the class RegexRegisteredServiceTests method verifyMatches.
@Test
public void verifyMatches() throws Exception {
final Service testService;
if (serviceToMatch == null) {
testService = null;
} else {
testService = new MockService(serviceToMatch);
}
assertEquals(expected, service.matches(testService));
}
use of org.apereo.cas.mock.MockService in project cas by apereo.
the class TicketGrantingTicketImplTests method verifyWebApplicationExpire.
@Test
public void verifyWebApplicationExpire() {
final MockService testService = new MockService(TGT_ID);
final TicketGrantingTicket t = new TicketGrantingTicketImpl(TGT_ID, null, null, CoreAuthenticationTestUtils.getAuthentication(), new NeverExpiresExpirationPolicy());
t.grantServiceTicket(ID_GENERATOR.getNewTicketId(ServiceTicket.PREFIX), testService, new NeverExpiresExpirationPolicy(), false, true);
assertFalse(t.isExpired());
t.markTicketExpired();
assertTrue(t.isExpired());
}
Aggregations