use of org.apache.knox.gateway.services.security.token.TokenStateService in project knox by apache.
the class CommonJWTFilterTest method doTestIsStillValid.
private boolean doTestIsStillValid(final Long expiration) throws Exception {
TokenStateService tss = EasyMock.createNiceMock(TokenStateService.class);
EasyMock.expect(tss.getTokenExpiration(anyObject(JWT.class))).andReturn(expiration).anyTimes();
EasyMock.expect(tss.getTokenExpiration(anyObject(String.class))).andReturn(expiration).anyTimes();
EasyMock.replay(tss);
return doTestIsStillValid(tss);
}
use of org.apache.knox.gateway.services.security.token.TokenStateService in project knox by apache.
the class CommonJWTFilterTest method testIsStillValidUnknownToken.
@Test(expected = UnknownTokenException.class)
public void testIsStillValidUnknownToken() throws Exception {
TokenStateService tss = EasyMock.createNiceMock(TokenStateService.class);
final String tokenId = UUID.randomUUID().toString();
EasyMock.expect(tss.getTokenExpiration(anyObject(JWT.class))).andThrow(new UnknownTokenException(tokenId)).anyTimes();
EasyMock.expect(tss.getTokenExpiration(anyObject(String.class))).andThrow(new UnknownTokenException(tokenId)).anyTimes();
EasyMock.replay(tss);
doTestIsStillValid(tss);
}
use of org.apache.knox.gateway.services.security.token.TokenStateService in project knox by apache.
the class TokenStateServiceFactoryTest method shouldReturnAliasBasedTokenStateService.
@Test
public void shouldReturnAliasBasedTokenStateService() throws Exception {
final TokenStateService tokenStateService = (TokenStateService) serviceFactory.create(gatewayServices, ServiceType.TOKEN_STATE_SERVICE, gatewayConfig, options, AliasBasedTokenStateService.class.getName());
assertTrue(tokenStateService instanceof AliasBasedTokenStateService);
assertTrue(isAliasServiceSet(tokenStateService));
}
use of org.apache.knox.gateway.services.security.token.TokenStateService in project knox by apache.
the class TokenStateServiceFactoryTest method shouldReturnAliasBasedTokenStateServiceByDefault.
@Test
public void shouldReturnAliasBasedTokenStateServiceByDefault() throws Exception {
TokenStateService tokenStateService = (TokenStateService) serviceFactory.create(gatewayServices, ServiceType.TOKEN_STATE_SERVICE, gatewayConfig, options, "");
assertTrue(tokenStateService instanceof AliasBasedTokenStateService);
assertTrue(isAliasServiceSet(tokenStateService));
}
use of org.apache.knox.gateway.services.security.token.TokenStateService in project knox by apache.
the class TokenStateServiceFactoryTest method shouldReturnDefaultTokenStateService.
@Test
public void shouldReturnDefaultTokenStateService() throws Exception {
TokenStateService tokenStateService = (TokenStateService) serviceFactory.create(gatewayServices, ServiceType.TOKEN_STATE_SERVICE, gatewayConfig, options, DefaultTokenStateService.class.getName());
assertTrue(tokenStateService instanceof DefaultTokenStateService);
}
Aggregations