Search in sources :

Example 6 with NeverExpiresExpirationPolicy

use of org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy in project cas by apereo.

the class TicketGrantingTicketImplTests method verifyCheckCreationTime.

@Test
public void verifyCheckCreationTime() {
    final Authentication authentication = CoreAuthenticationTestUtils.getAuthentication();
    final List<Authentication> principals = new ArrayList<>();
    principals.add(authentication);
    final ZonedDateTime startTime = ZonedDateTime.now(ZoneOffset.UTC).minusNanos(100);
    final TicketGrantingTicket t = new TicketGrantingTicketImpl(TGT_ID, null, null, authentication, new NeverExpiresExpirationPolicy());
    final ZonedDateTime finishTime = ZonedDateTime.now(ZoneOffset.UTC).plusNanos(100);
    assertTrue(startTime.isBefore(t.getCreationTime()) && finishTime.isAfter(t.getCreationTime()));
}
Also used : NeverExpiresExpirationPolicy(org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy) ZonedDateTime(java.time.ZonedDateTime) Authentication(org.apereo.cas.authentication.Authentication) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 7 with NeverExpiresExpirationPolicy

use of org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy in project cas by apereo.

the class TicketGrantingTicketImplTests method verifyGetAuthentication.

@Test
public void verifyGetAuthentication() {
    final Authentication authentication = CoreAuthenticationTestUtils.getAuthentication();
    final TicketGrantingTicket t = new TicketGrantingTicketImpl(TGT_ID, null, null, authentication, new NeverExpiresExpirationPolicy());
    assertEquals(t.getAuthentication(), authentication);
    assertEquals(t.getId(), t.toString());
}
Also used : NeverExpiresExpirationPolicy(org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy) Authentication(org.apereo.cas.authentication.Authentication) Test(org.junit.Test)

Example 8 with NeverExpiresExpirationPolicy

use of org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy 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 9 with NeverExpiresExpirationPolicy

use of org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy 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)

Example 10 with NeverExpiresExpirationPolicy

use of org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy in project cas by apereo.

the class AbstractTicketRegistryTests method verifyDeleteTicketWithChildren.

@Test
public void verifyDeleteTicketWithChildren() {
    try {
        this.ticketRegistry.addTicket(new TicketGrantingTicketImpl(TicketGrantingTicket.PREFIX + "1", CoreAuthenticationTestUtils.getAuthentication(), new NeverExpiresExpirationPolicy()));
        final TicketGrantingTicket tgt = this.ticketRegistry.getTicket(TicketGrantingTicket.PREFIX + "1", TicketGrantingTicket.class);
        final Service service = RegisteredServiceTestUtils.getService("TGT_DELETE_TEST");
        final ServiceTicket st1 = tgt.grantServiceTicket("ST11", service, new NeverExpiresExpirationPolicy(), false, false);
        final ServiceTicket st2 = tgt.grantServiceTicket("ST21", service, new NeverExpiresExpirationPolicy(), false, false);
        final ServiceTicket st3 = tgt.grantServiceTicket("ST31", service, new NeverExpiresExpirationPolicy(), false, false);
        this.ticketRegistry.addTicket(st1);
        this.ticketRegistry.addTicket(st2);
        this.ticketRegistry.addTicket(st3);
        assertNotNull(this.ticketRegistry.getTicket(TicketGrantingTicket.PREFIX + "1", TicketGrantingTicket.class));
        assertNotNull(this.ticketRegistry.getTicket("ST11", ServiceTicket.class));
        assertNotNull(this.ticketRegistry.getTicket("ST21", ServiceTicket.class));
        assertNotNull(this.ticketRegistry.getTicket("ST31", ServiceTicket.class));
        this.ticketRegistry.updateTicket(tgt);
        assertSame(4, this.ticketRegistry.deleteTicket(tgt.getId()));
        assertNull(this.ticketRegistry.getTicket(TicketGrantingTicket.PREFIX + "1", TicketGrantingTicket.class));
        assertNull(this.ticketRegistry.getTicket("ST11", ServiceTicket.class));
        assertNull(this.ticketRegistry.getTicket("ST21", ServiceTicket.class));
        assertNull(this.ticketRegistry.getTicket("ST31", ServiceTicket.class));
    } catch (final Exception e) {
        fail(CAUGHT_AN_EXCEPTION_BUT_WAS_NOT_EXPECTED + e.getMessage());
    }
}
Also used : NeverExpiresExpirationPolicy(org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy) TicketGrantingTicket(org.apereo.cas.ticket.TicketGrantingTicket) Service(org.apereo.cas.authentication.principal.Service) TicketGrantingTicketImpl(org.apereo.cas.ticket.TicketGrantingTicketImpl) ServiceTicket(org.apereo.cas.ticket.ServiceTicket) Test(org.junit.Test)

Aggregations

NeverExpiresExpirationPolicy (org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy)51 Test (org.junit.Test)50 TicketGrantingTicketImpl (org.apereo.cas.ticket.TicketGrantingTicketImpl)17 Authentication (org.apereo.cas.authentication.Authentication)11 TicketGrantingTicket (org.apereo.cas.ticket.TicketGrantingTicket)11 Service (org.apereo.cas.authentication.principal.Service)10 ServiceTicket (org.apereo.cas.ticket.ServiceTicket)10 MockServiceTicket (org.apereo.cas.mock.MockServiceTicket)5 MockTicketGrantingTicket (org.apereo.cas.mock.MockTicketGrantingTicket)5 ProxyGrantingTicket (org.apereo.cas.ticket.proxy.ProxyGrantingTicket)5 ArrayList (java.util.ArrayList)4 MultiTimeUseOrTimeoutExpirationPolicy (org.apereo.cas.ticket.support.MultiTimeUseOrTimeoutExpirationPolicy)4 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)3 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)3 MockService (org.apereo.cas.mock.MockService)2 ProxyGrantingTicketImpl (org.apereo.cas.ticket.ProxyGrantingTicketImpl)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 ZonedDateTime (java.time.ZonedDateTime)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1