Search in sources :

Example 26 with MockTicketGrantingTicket

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

the class KryoTranscoderTests method verifyEncodeDecodeTGTWithSingletonMap.

@Test
public void verifyEncodeDecodeTGTWithSingletonMap() throws Exception {
    final Map<String, Object> newAttributes = Collections.singletonMap(NICKNAME_KEY, NICKNAME_VALUE);
    final Credential userPassCredential = new UsernamePasswordCredential(USERNAME, PASSWORD);
    final TicketGrantingTicket expectedTGT = new MockTicketGrantingTicket(TGT_ID, userPassCredential, newAttributes);
    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)

Example 27 with MockTicketGrantingTicket

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

the class AbstractCasEventRepositoryTests method getCasEvent.

private CasEvent getCasEvent() {
    final TicketGrantingTicket ticket = new MockTicketGrantingTicket("casuser");
    final CasTicketGrantingTicketCreatedEvent event = new CasTicketGrantingTicketCreatedEvent(this, ticket);
    final CasEvent dto = new CasEvent();
    dto.setType(event.getClass().getCanonicalName());
    dto.putTimestamp(event.getTimestamp());
    dto.setCreationTime(event.getTicketGrantingTicket().getCreationTime().toString());
    dto.putId(event.getTicketGrantingTicket().getId());
    dto.setPrincipalId(event.getTicketGrantingTicket().getAuthentication().getPrincipal().getId());
    return dto;
}
Also used : MockTicketGrantingTicket(org.apereo.cas.mock.MockTicketGrantingTicket) CasTicketGrantingTicketCreatedEvent(org.apereo.cas.support.events.ticket.CasTicketGrantingTicketCreatedEvent) MockTicketGrantingTicket(org.apereo.cas.mock.MockTicketGrantingTicket) TicketGrantingTicket(org.apereo.cas.ticket.TicketGrantingTicket) CasEvent(org.apereo.cas.support.events.dao.CasEvent)

Example 28 with MockTicketGrantingTicket

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

the class CasKryoTranscoderTests method internalProxyTest.

private void internalProxyTest(final String proxyUrl) {
    final TicketGrantingTicket expectedTGT = new MockTicketGrantingTicket(USERNAME);
    expectedTGT.grantServiceTicket(ST_ID, null, null, false, true);
    final CachedData result = transcoder.encode(expectedTGT);
    assertEquals(expectedTGT, transcoder.decode(result));
    assertEquals(expectedTGT, transcoder.decode(result));
}
Also used : MockTicketGrantingTicket(org.apereo.cas.mock.MockTicketGrantingTicket) CachedData(net.spy.memcached.CachedData) TicketGrantingTicket(org.apereo.cas.ticket.TicketGrantingTicket) MockTicketGrantingTicket(org.apereo.cas.mock.MockTicketGrantingTicket)

Example 29 with MockTicketGrantingTicket

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

the class CasKryoTranscoderTests method verifyEncodeDecodeTGTWithSingleton.

@Test
public void verifyEncodeDecodeTGTWithSingleton() {
    final Map<String, Object> newAttributes = new HashMap<>();
    newAttributes.put(NICKNAME_KEY, Collections.singleton(NICKNAME_VALUE));
    final Credential userPassCredential = new UsernamePasswordCredential(USERNAME, PASSWORD);
    final TicketGrantingTicket expectedTGT = new MockTicketGrantingTicket(TGT_ID, userPassCredential, newAttributes);
    expectedTGT.grantServiceTicket(ST_ID, null, null, false, true);
    final CachedData result = transcoder.encode(expectedTGT);
    assertEquals(expectedTGT, transcoder.decode(result));
    assertEquals(expectedTGT, transcoder.decode(result));
}
Also used : MockTicketGrantingTicket(org.apereo.cas.mock.MockTicketGrantingTicket) UsernamePasswordCredential(org.apereo.cas.authentication.UsernamePasswordCredential) Credential(org.apereo.cas.authentication.Credential) CachedData(net.spy.memcached.CachedData) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) TicketGrantingTicket(org.apereo.cas.ticket.TicketGrantingTicket) MockTicketGrantingTicket(org.apereo.cas.mock.MockTicketGrantingTicket) UsernamePasswordCredential(org.apereo.cas.authentication.UsernamePasswordCredential) Test(org.junit.Test)

Example 30 with MockTicketGrantingTicket

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

the class CasKryoTranscoderTests method verifyEncodeDecode.

@Test
public void verifyEncodeDecode() {
    final TicketGrantingTicket tgt = new MockTicketGrantingTicket(USERNAME);
    final ServiceTicket expectedST = new MockServiceTicket(ST_ID, RegisteredServiceTestUtils.getService(), tgt);
    assertEquals(expectedST, transcoder.decode(transcoder.encode(expectedST)));
    final TicketGrantingTicket expectedTGT = new MockTicketGrantingTicket(USERNAME);
    expectedTGT.grantServiceTicket(ST_ID, null, null, false, true);
    final CachedData result = transcoder.encode(expectedTGT);
    assertEquals(expectedTGT, transcoder.decode(result));
    assertEquals(expectedTGT, transcoder.decode(result));
    internalProxyTest("http://localhost");
    internalProxyTest("https://localhost:8080/path/file.html?p1=v1&p2=v2#fragment");
}
Also used : MockTicketGrantingTicket(org.apereo.cas.mock.MockTicketGrantingTicket) CachedData(net.spy.memcached.CachedData) 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) 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