Search in sources :

Example 21 with MockTicketGrantingTicket

use of org.apereo.cas.mock.MockTicketGrantingTicket in project cas by apereo.

the class AbstractTicketRegistryTests method verifyExpiration.

@Test
public void verifyExpiration() {
    final String id = "ST-1234567890ABCDEFGHIJKL-exp1";
    final MockServiceTicket ticket = new MockServiceTicket(id, RegisteredServiceTestUtils.getService(), new MockTicketGrantingTicket("test"));
    ticket.setExpiration(new AlwaysExpiresExpirationPolicy());
    ticketRegistry.addTicket(ticket);
    assertNull(ticketRegistry.getTicket(id, ServiceTicket.class));
}
Also used : MockTicketGrantingTicket(org.apereo.cas.mock.MockTicketGrantingTicket) MockServiceTicket(org.apereo.cas.mock.MockServiceTicket) AlwaysExpiresExpirationPolicy(org.apereo.cas.ticket.support.AlwaysExpiresExpirationPolicy) MockServiceTicket(org.apereo.cas.mock.MockServiceTicket) ServiceTicket(org.apereo.cas.ticket.ServiceTicket) Test(org.junit.Test)

Example 22 with MockTicketGrantingTicket

use of org.apereo.cas.mock.MockTicketGrantingTicket in project cas by apereo.

the class MemCacheTicketRegistryTests method verifyExpiration.

@Test
public void verifyExpiration() throws Exception {
    final String id = "ST-1234567890ABCDEFGHIJKL-exp1";
    final MockServiceTicket ticket = new MockServiceTicket(id, RegisteredServiceTestUtils.getService(), new MockTicketGrantingTicket("test"));
    ticket.setExpiration(new AlwaysExpiresExpirationPolicy());
    registry.addTicket(ticket);
    Thread.sleep(1500);
    assertNull(registry.getTicket(id, ServiceTicket.class));
}
Also used : MockTicketGrantingTicket(org.apereo.cas.mock.MockTicketGrantingTicket) MockServiceTicket(org.apereo.cas.mock.MockServiceTicket) AlwaysExpiresExpirationPolicy(org.apereo.cas.ticket.support.AlwaysExpiresExpirationPolicy) MockServiceTicket(org.apereo.cas.mock.MockServiceTicket) ServiceTicket(org.apereo.cas.ticket.ServiceTicket) Test(org.junit.Test)

Example 23 with MockTicketGrantingTicket

use of org.apereo.cas.mock.MockTicketGrantingTicket in project cas by apereo.

the class MemCacheTicketRegistryTests method verifyWriteGetDelete.

@Test
public void verifyWriteGetDelete() throws Exception {
    final String id = "ST-1234567890ABCDEFGHIJKL123-crud";
    final ServiceTicket ticket = new MockServiceTicket(id, RegisteredServiceTestUtils.getService(), new MockTicketGrantingTicket("test"));
    registry.addTicket(ticket);
    final ServiceTicket ticketFromRegistry = (ServiceTicket) registry.getTicket(id);
    assertNotNull(ticketFromRegistry);
    assertEquals(id, ticketFromRegistry.getId());
    registry.deleteTicket(id);
    assertNull(registry.getTicket(id));
}
Also used : MockTicketGrantingTicket(org.apereo.cas.mock.MockTicketGrantingTicket) MockServiceTicket(org.apereo.cas.mock.MockServiceTicket) MockServiceTicket(org.apereo.cas.mock.MockServiceTicket) ServiceTicket(org.apereo.cas.ticket.ServiceTicket) Test(org.junit.Test)

Example 24 with MockTicketGrantingTicket

use of org.apereo.cas.mock.MockTicketGrantingTicket in project cas by apereo.

the class KryoTranscoderTests method verifyEncodeDecode.

@Test
public void verifyEncodeDecode() throws Exception {
    final TicketGrantingTicket tgt = new MockTicketGrantingTicket(USERNAME);
    final ServiceTicket expectedST = new MockServiceTicket(ST_ID, RegisteredServiceTestUtils.getService(), tgt);
    assertEquals(expectedST, transcoder.decode(transcoder.encode(expectedST)));
    final Credential userPassCredential = new UsernamePasswordCredential(USERNAME, PASSWORD);
    final TicketGrantingTicket expectedTGT = new MockTicketGrantingTicket(USERNAME);
    expectedTGT.grantServiceTicket(ST_ID, null, null, false, true);
    assertEquals(expectedTGT, transcoder.decode(transcoder.encode(expectedTGT)));
    internalProxyTest("http://localhost");
    internalProxyTest("https://localhost:8080/path/file.html?p1=v1&p2=v2#fragment");
}
Also used : MockTicketGrantingTicket(org.apereo.cas.mock.MockTicketGrantingTicket) UsernamePasswordCredential(org.apereo.cas.authentication.UsernamePasswordCredential) Credential(org.apereo.cas.authentication.Credential) HttpBasedServiceCredential(org.apereo.cas.authentication.HttpBasedServiceCredential) TicketGrantingTicket(org.apereo.cas.ticket.TicketGrantingTicket) MockTicketGrantingTicket(org.apereo.cas.mock.MockTicketGrantingTicket) MockServiceTicket(org.apereo.cas.mock.MockServiceTicket) MockServiceTicket(org.apereo.cas.mock.MockServiceTicket) ServiceTicket(org.apereo.cas.ticket.ServiceTicket) UsernamePasswordCredential(org.apereo.cas.authentication.UsernamePasswordCredential) Test(org.junit.Test)

Example 25 with MockTicketGrantingTicket

use of org.apereo.cas.mock.MockTicketGrantingTicket in project cas by apereo.

the class KryoTranscoderTests method verifyEncodeDecodeTGTWithListOrderedMap.

@Test
public void verifyEncodeDecodeTGTWithListOrderedMap() throws Exception {
    final Credential userPassCredential = new UsernamePasswordCredential(USERNAME, PASSWORD);
    @SuppressWarnings("unchecked") final TicketGrantingTicket expectedTGT = new MockTicketGrantingTicket(TGT_ID, userPassCredential, this.principalAttributes);
    expectedTGT.grantServiceTicket(ST_ID, null, null, false, true);
    assertEquals(expectedTGT, transcoder.decode(transcoder.encode(expectedTGT)));
}
Also used : MockTicketGrantingTicket(org.apereo.cas.mock.MockTicketGrantingTicket) UsernamePasswordCredential(org.apereo.cas.authentication.UsernamePasswordCredential) Credential(org.apereo.cas.authentication.Credential) HttpBasedServiceCredential(org.apereo.cas.authentication.HttpBasedServiceCredential) TicketGrantingTicket(org.apereo.cas.ticket.TicketGrantingTicket) MockTicketGrantingTicket(org.apereo.cas.mock.MockTicketGrantingTicket) UsernamePasswordCredential(org.apereo.cas.authentication.UsernamePasswordCredential) Test(org.junit.Test)

Aggregations

MockTicketGrantingTicket (org.apereo.cas.mock.MockTicketGrantingTicket)35 Test (org.junit.Test)30 TicketGrantingTicket (org.apereo.cas.ticket.TicketGrantingTicket)21 Credential (org.apereo.cas.authentication.Credential)16 UsernamePasswordCredential (org.apereo.cas.authentication.UsernamePasswordCredential)16 HashMap (java.util.HashMap)10 CachedData (net.spy.memcached.CachedData)10 HttpBasedServiceCredential (org.apereo.cas.authentication.HttpBasedServiceCredential)9 Authentication (org.apereo.cas.authentication.Authentication)8 MockServiceTicket (org.apereo.cas.mock.MockServiceTicket)8 LinkedHashMap (java.util.LinkedHashMap)6 Principal (org.apereo.cas.authentication.principal.Principal)6 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)6 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)6 ServiceTicket (org.apereo.cas.ticket.ServiceTicket)5 AlwaysExpiresExpirationPolicy (org.apereo.cas.ticket.support.AlwaysExpiresExpirationPolicy)5 Service (org.apereo.cas.authentication.principal.Service)4 WebApplicationServiceFactory (org.apereo.cas.authentication.principal.WebApplicationServiceFactory)4 RegisteredService (org.apereo.cas.services.RegisteredService)4 OAuthRegisteredService (org.apereo.cas.support.oauth.services.OAuthRegisteredService)4