use of org.wso2.carbon.apimgt.common.gateway.jwtgenerator.AbstractAPIMgtGatewayJWTGenerator in project carbon-apimgt by wso2.
the class APIMgtGatewayJWTGeneratorImplTest method testJWTGeneratorClaimConfig.
@Test
public void testJWTGeneratorClaimConfig() {
APIManagerConfiguration apiManagerConfiguration = Mockito.mock(APIManagerConfiguration.class);
APIManagerConfigurationService apiManagerConfigurationService = Mockito.mock(APIManagerConfigurationService.class);
ServiceReferenceHolder serviceReferenceHolder = Mockito.mock(ServiceReferenceHolder.class);
PowerMockito.mockStatic(ServiceReferenceHolder.class);
PowerMockito.when(ServiceReferenceHolder.getInstance()).thenReturn(serviceReferenceHolder);
Mockito.when(serviceReferenceHolder.getAPIManagerConfigurationService()).thenReturn(apiManagerConfigurationService);
Mockito.when(apiManagerConfigurationService.getAPIManagerConfiguration()).thenReturn(apiManagerConfiguration);
ExtendedJWTConfigurationDto jwtConfigurationDto = Mockito.mock(ExtendedJWTConfigurationDto.class);
Mockito.when(apiManagerConfiguration.getJwtConfigurationDto()).thenReturn(jwtConfigurationDto);
String defaultDialectUri = "http://wso2.org/claims";
// default dialect if not changed
AbstractAPIMgtGatewayJWTGenerator generator = new APIMgtGatewayJWTGeneratorImpl();
// Set jwtConfigurationDto
generator.setJWTConfigurationDto(jwtConfigurationDto);
Assert.assertEquals(generator.getDialectURI(), ClaimsRetriever.DEFAULT_DIALECT_URI);
// Test dialect after changing it through config
String claimDialect = "http://test.com";
Mockito.when(jwtConfigurationDto.getConsumerDialectUri()).thenReturn(claimDialect);
generator = new APIMgtGatewayJWTGeneratorImpl();
generator.setJWTConfigurationDto(jwtConfigurationDto);
Assert.assertEquals(generator.getDialectURI(), claimDialect);
}
Aggregations