use of org.apereo.cas.mock.MockTicketGrantingTicket in project cas by apereo.
the class DynamoDbTicketRegistryTests method verifyAccessTokenCanBeAdded.
@RepeatedTest(2)
public void verifyAccessTokenCanBeAdded() throws Exception {
val code = createOAuthCode();
val jwtBuilder = new JwtBuilder(CipherExecutor.noOpOfSerializableToString(), servicesManager, RegisteredServiceCipherExecutor.noOp());
val token = new OAuth20DefaultAccessTokenFactory(neverExpiresExpirationPolicyBuilder(), jwtBuilder, servicesManager).create(RegisteredServiceTestUtils.getService(), RegisteredServiceTestUtils.getAuthentication(), new MockTicketGrantingTicket("casuser"), CollectionUtils.wrapSet("1", "2"), code.getId(), "clientId1234567", new HashMap<>(), OAuth20ResponseTypes.CODE, OAuth20GrantTypes.AUTHORIZATION_CODE);
newTicketRegistry.addTicket(token);
assertSame(1, newTicketRegistry.deleteTicket(token.getId()), "Wrong ticket count");
assertNull(newTicketRegistry.getTicket(token.getId()));
}
use of org.apereo.cas.mock.MockTicketGrantingTicket in project cas by apereo.
the class EhCacheHealthIndicatorTests method verifyObserve.
@Test
public void verifyObserve() {
var status = monitor.health();
assertEquals(Status.UP, status.getStatus());
/*
* Fill cache 95% full, which is
* above 10% free WARN threshold
*/
IntStream.range(0, 95).forEach(Unchecked.intConsumer(i -> this.ticketRegistry.addTicket(new MockServiceTicket("ST-" + i, RegisteredServiceTestUtils.getService(), new MockTicketGrantingTicket("test")))));
status = monitor.health();
assertEquals(Status.OUT_OF_SERVICE, status.getStatus());
/*
* Exceed the capacity and force evictions
* which should report WARN status
*/
IntStream.range(95, 110).forEach(Unchecked.intConsumer(i -> {
val st = new MockServiceTicket("ST-" + i, RegisteredServiceTestUtils.getService(), new MockTicketGrantingTicket("test"));
this.ticketRegistry.addTicket(st);
}));
status = monitor.health();
assertEquals("WARN", status.getStatus().getCode());
}
use of org.apereo.cas.mock.MockTicketGrantingTicket in project cas by apereo.
the class MemcachedTicketRegistryTests method verifyOAuthCodeIsAddedToMemcached.
@RepeatedTest(2)
public void verifyOAuthCodeIsAddedToMemcached() throws Exception {
val factory = new OAuth20DefaultOAuthCodeFactory(neverExpiresExpirationPolicyBuilder(), servicesManager);
val code = factory.create(RegisteredServiceTestUtils.getService(), CoreAuthenticationTestUtils.getAuthentication(), new MockTicketGrantingTicket("casuser"), CollectionUtils.wrapList("openid"), "code-challenge", "plain", "clientId123456", new HashMap<>(), OAuth20ResponseTypes.CODE, OAuth20GrantTypes.AUTHORIZATION_CODE);
this.newTicketRegistry.addTicket(code);
val ticket = this.newTicketRegistry.getTicket(code.getId(), OAuth20Code.class);
assertNotNull(ticket);
}
use of org.apereo.cas.mock.MockTicketGrantingTicket in project cas by apereo.
the class CasKryoTranscoderTests method internalProxyTest.
private void internalProxyTest() {
val expectedTGT = new MockTicketGrantingTicket(USERNAME);
expectedTGT.grantServiceTicket(ST_ID, null, null, false, true);
val result = transcoder.encode(expectedTGT);
assertEquals(expectedTGT, transcoder.decode(result));
assertEquals(expectedTGT, transcoder.decode(result));
}
use of org.apereo.cas.mock.MockTicketGrantingTicket in project cas by apereo.
the class CasKryoTranscoderTests method verifyEncodeDecodeNonRegisteredClass.
@Test
public void verifyEncodeDecodeNonRegisteredClass() {
val tgt = new MockTicketGrantingTicket(USERNAME);
val expectedST = new MockServiceTicket(ST_ID, RegisteredServiceTestUtils.getService(), tgt);
val step = new UnregisteredServiceTicketExpirationPolicy(1, 600);
expectedST.setExpirationPolicy(step);
try {
transcoder.encode(expectedST);
throw new AssertionError("Unregistered class is not allowed by Kryo");
} catch (final KryoException e) {
LOGGER.trace(e.getMessage(), e);
} catch (final Exception e) {
throw new AssertionError("Not resetting Kryo between de-serializations with unregistered class.");
}
}
Aggregations