Search in sources :

Example 6 with TicketGrantingTicketImpl

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

Example 7 with TicketGrantingTicketImpl

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

the class AbstractTicketRegistryTests method verifyGetExistingTicket.

@Test
public void verifyGetExistingTicket() {
    try {
        this.ticketRegistry.addTicket(new TicketGrantingTicketImpl(TicketGrantingTicket.PREFIX, CoreAuthenticationTestUtils.getAuthentication(), new NeverExpiresExpirationPolicy()));
        this.ticketRegistry.getTicket(TicketGrantingTicket.PREFIX);
    } catch (final Exception e) {
        fail(CAUGHT_AN_EXCEPTION_BUT_WAS_NOT_EXPECTED + e.getMessage());
    }
}
Also used : NeverExpiresExpirationPolicy(org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy) TicketGrantingTicketImpl(org.apereo.cas.ticket.TicketGrantingTicketImpl) Test(org.junit.Test)

Example 8 with TicketGrantingTicketImpl

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

the class AbstractTicketRegistryTests method verifyGetExistingTicketWithImproperClass.

@Test
public void verifyGetExistingTicketWithImproperClass() {
    try {
        this.ticketRegistry.addTicket(new TicketGrantingTicketImpl(TicketGrantingTicket.PREFIX, CoreAuthenticationTestUtils.getAuthentication(), new NeverExpiresExpirationPolicy()));
        this.ticketRegistry.getTicket(TicketGrantingTicket.PREFIX, ServiceTicket.class);
    } catch (final ClassCastException e) {
        return;
    }
    fail("ClassCastException expected.");
}
Also used : NeverExpiresExpirationPolicy(org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy) TicketGrantingTicketImpl(org.apereo.cas.ticket.TicketGrantingTicketImpl) Test(org.junit.Test)

Example 9 with TicketGrantingTicketImpl

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

the class AbstractTicketRegistryTests method verifyDeleteNullTicket.

@Test
public void verifyDeleteNullTicket() {
    try {
        this.ticketRegistry.addTicket(new TicketGrantingTicketImpl(TicketGrantingTicket.PREFIX, CoreAuthenticationTestUtils.getAuthentication(), new NeverExpiresExpirationPolicy()));
        assertFalse("Ticket was deleted.", this.ticketRegistry.deleteTicket(null) == 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 TicketGrantingTicketImpl

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

the class MultiTimeUseOrTimeoutExpirationPolicyTests method setUp.

@Before
public void setUp() throws Exception {
    this.expirationPolicy = new MultiTimeUseOrTimeoutExpirationPolicy(NUMBER_OF_USES, TIMEOUT_SECONDS);
    this.ticket = new TicketGrantingTicketImpl("test", CoreAuthenticationTestUtils.getAuthentication(), this.expirationPolicy);
}
Also used : TicketGrantingTicketImpl(org.apereo.cas.ticket.TicketGrantingTicketImpl) Before(org.junit.Before)

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