Search in sources :

Example 1 with TicketGrantingTicketImpl

use of org.apereo.cas.ticket.TicketGrantingTicketImpl 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 TicketGrantingTicketImpl

use of org.apereo.cas.ticket.TicketGrantingTicketImpl in project cas by apereo.

the class RememberMeDelegatingExpirationPolicyTests method verifyTicketExpirationWithRememberMe.

@Test
public void verifyTicketExpirationWithRememberMe() {
    final Authentication authentication = CoreAuthenticationTestUtils.getAuthentication(this.principalFactory.createPrincipal("test"), Collections.singletonMap(RememberMeCredential.AUTHENTICATION_ATTRIBUTE_REMEMBER_ME, true));
    final TicketGrantingTicketImpl t = new TicketGrantingTicketImpl("111", authentication, this.p);
    assertFalse(t.isExpired());
    t.grantServiceTicket("55", RegisteredServiceTestUtils.getService(), this.p, false, true);
    assertTrue(t.isExpired());
}
Also used : Authentication(org.apereo.cas.authentication.Authentication) TicketGrantingTicketImpl(org.apereo.cas.ticket.TicketGrantingTicketImpl) Test(org.junit.Test)

Example 3 with TicketGrantingTicketImpl

use of org.apereo.cas.ticket.TicketGrantingTicketImpl in project cas by apereo.

the class TimeoutExpirationPolicyTests method verifyTicketIsExpired.

@Test
public void verifyTicketIsExpired() throws InterruptedException {
    ticket = new TicketGrantingTicketImpl("test", CoreAuthenticationTestUtils.getAuthentication(), new TimeoutExpirationPolicy(-100));
    assertTrue(ticket.isExpired());
}
Also used : TicketGrantingTicketImpl(org.apereo.cas.ticket.TicketGrantingTicketImpl) Test(org.junit.Test)

Example 4 with TicketGrantingTicketImpl

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

Example 5 with TicketGrantingTicketImpl

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

Aggregations

TicketGrantingTicketImpl (org.apereo.cas.ticket.TicketGrantingTicketImpl)28 Test (org.junit.Test)22 NeverExpiresExpirationPolicy (org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy)17 TicketGrantingTicket (org.apereo.cas.ticket.TicketGrantingTicket)12 ServiceTicket (org.apereo.cas.ticket.ServiceTicket)10 Authentication (org.apereo.cas.authentication.Authentication)8 Service (org.apereo.cas.authentication.principal.Service)8 MockServiceTicket (org.apereo.cas.mock.MockServiceTicket)5 MockTicketGrantingTicket (org.apereo.cas.mock.MockTicketGrantingTicket)5 Before (org.junit.Before)5 ProxyGrantingTicket (org.apereo.cas.ticket.proxy.ProxyGrantingTicket)3 MockService (org.apereo.cas.mock.MockService)2 ExpirationPolicy (org.apereo.cas.ticket.ExpirationPolicy)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)2 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)2 ServletExternalContext (org.springframework.webflow.context.servlet.ServletExternalContext)2 MockRequestContext (org.springframework.webflow.test.MockRequestContext)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1