Search in sources :

Example 1 with NeverExpiresExpirationPolicy

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

the class TicketGrantingTicketImplTests method verifyServiceTicketAsFromNotInitialCredentials.

@Test
public void verifyServiceTicketAsFromNotInitialCredentials() {
    final TicketGrantingTicket t = new TicketGrantingTicketImpl(TGT_ID, null, null, CoreAuthenticationTestUtils.getAuthentication(), new NeverExpiresExpirationPolicy());
    t.grantServiceTicket(ID_GENERATOR.getNewTicketId(ServiceTicket.PREFIX), RegisteredServiceTestUtils.getService(), new NeverExpiresExpirationPolicy(), false, true);
    final ServiceTicket s = t.grantServiceTicket(ID_GENERATOR.getNewTicketId(ServiceTicket.PREFIX), RegisteredServiceTestUtils.getService(), new NeverExpiresExpirationPolicy(), false, true);
    assertFalse(s.isFromNewLogin());
}
Also used : NeverExpiresExpirationPolicy(org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy) Test(org.junit.Test)

Example 2 with NeverExpiresExpirationPolicy

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

the class TicketGrantingTicketImplTests method verifyDoubleGrantSimilarServiceTicketKeepMostRecentSession.

@Test
public void verifyDoubleGrantSimilarServiceTicketKeepMostRecentSession() {
    final TicketGrantingTicket t = new TicketGrantingTicketImpl(TGT_ID, null, null, CoreAuthenticationTestUtils.getAuthentication(), new NeverExpiresExpirationPolicy());
    t.grantServiceTicket(ID_GENERATOR.getNewTicketId(ServiceTicket.PREFIX), RegisteredServiceTestUtils.getService("http://host.com?test"), new NeverExpiresExpirationPolicy(), false, true);
    t.grantServiceTicket(ID_GENERATOR.getNewTicketId(ServiceTicket.PREFIX), RegisteredServiceTestUtils.getService("http://host.com;JSESSIONID=xxx"), new NeverExpiresExpirationPolicy(), false, true);
    assertEquals(1, t.getServices().size());
}
Also used : NeverExpiresExpirationPolicy(org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy) Test(org.junit.Test)

Example 3 with NeverExpiresExpirationPolicy

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

the class TicketGrantingTicketImplTests method verifyProperRootIsReturned.

@Test
public void verifyProperRootIsReturned() {
    final TicketGrantingTicketImpl t1 = new TicketGrantingTicketImpl(TGT_ID, null, null, CoreAuthenticationTestUtils.getAuthentication(), new NeverExpiresExpirationPolicy());
    final TicketGrantingTicket t2 = new TicketGrantingTicketImpl(TGT_ID, CoreAuthenticationTestUtils.getService("gantor"), t1, CoreAuthenticationTestUtils.getAuthentication(), new NeverExpiresExpirationPolicy());
    final TicketGrantingTicket t3 = new TicketGrantingTicketImpl(TGT_ID, CoreAuthenticationTestUtils.getService("gantor"), t2, CoreAuthenticationTestUtils.getAuthentication(), new NeverExpiresExpirationPolicy());
    assertSame(t1, t3.getRoot());
}
Also used : NeverExpiresExpirationPolicy(org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy) Test(org.junit.Test)

Example 4 with NeverExpiresExpirationPolicy

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

the class TicketGrantingTicketImplTests method verifySerializeToJson.

@Test
public void verifySerializeToJson() throws IOException {
    final Authentication authenticationWritten = CoreAuthenticationTestUtils.getAuthentication();
    final NeverExpiresExpirationPolicy expirationPolicyWritten = new NeverExpiresExpirationPolicy();
    final TicketGrantingTicket tgtWritten = new TicketGrantingTicketImpl(TGT_ID, null, null, authenticationWritten, expirationPolicyWritten);
    mapper.writeValue(TGT_JSON_FILE, tgtWritten);
    final TicketGrantingTicketImpl tgtRead = mapper.readValue(TGT_JSON_FILE, TicketGrantingTicketImpl.class);
    assertEquals(tgtWritten, tgtRead);
    assertEquals(authenticationWritten, tgtRead.getAuthentication());
}
Also used : NeverExpiresExpirationPolicy(org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy) Authentication(org.apereo.cas.authentication.Authentication) Test(org.junit.Test)

Example 5 with NeverExpiresExpirationPolicy

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

the class TicketGrantingTicketImplTests method verifyGetChainedPrincipalsWithOne.

@Test
public void verifyGetChainedPrincipalsWithOne() {
    final Authentication authentication = CoreAuthenticationTestUtils.getAuthentication();
    final List<Authentication> principals = new ArrayList<>();
    principals.add(authentication);
    final TicketGrantingTicket t = new TicketGrantingTicketImpl(TGT_ID, null, null, authentication, new NeverExpiresExpirationPolicy());
    assertEquals(principals, t.getChainedAuthentications());
}
Also used : NeverExpiresExpirationPolicy(org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy) Authentication(org.apereo.cas.authentication.Authentication) ArrayList(java.util.ArrayList) 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