Search in sources :

Example 1 with MockService

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)));
    }
}
Also used : MockService(org.apereo.cas.mock.MockService) TicketGrantingTicketImpl(org.apereo.cas.ticket.TicketGrantingTicketImpl)

Example 2 with MockService

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());
}
Also used : NeverExpiresExpirationPolicy(org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy) MockService(org.apereo.cas.mock.MockService) MockService(org.apereo.cas.mock.MockService) Service(org.apereo.cas.authentication.principal.Service) Test(org.junit.Test)

Example 3 with MockService

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));
        }
    }
}
Also used : MockService(org.apereo.cas.mock.MockService) TicketGrantingTicketImpl(org.apereo.cas.ticket.TicketGrantingTicketImpl)

Example 4 with MockService

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));
}
Also used : Service(org.apereo.cas.authentication.principal.Service) MockService(org.apereo.cas.mock.MockService) MockService(org.apereo.cas.mock.MockService) Test(org.junit.Test)

Example 5 with MockService

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());
}
Also used : NeverExpiresExpirationPolicy(org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy) MockService(org.apereo.cas.mock.MockService) Test(org.junit.Test)

Aggregations

MockService (org.apereo.cas.mock.MockService)5 Test (org.junit.Test)3 Service (org.apereo.cas.authentication.principal.Service)2 TicketGrantingTicketImpl (org.apereo.cas.ticket.TicketGrantingTicketImpl)2 NeverExpiresExpirationPolicy (org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy)2