use of org.wso2.carbon.apimgt.api.model.KeyManager in project carbon-apimgt by wso2.
the class ApplicationUtilsTestCase method testCreateTokenRequestWhenAccessTokenIsNull.
@Test
public void testCreateTokenRequestWhenAccessTokenIsNull() throws APIManagementException {
PowerMockito.mockStatic(KeyManagerHolder.class);
OAuthApplicationInfo oAuthApplicationInfo = new OAuthApplicationInfo();
ApplicationUtils.createAccessTokenRequest(keyManager, oAuthApplicationInfo, null);
Mockito.verify(keyManager, Mockito.times(1)).buildAccessTokenRequestFromOAuthApp(Matchers.any(OAuthApplicationInfo.class), Matchers.any(AccessTokenRequest.class));
}
use of org.wso2.carbon.apimgt.api.model.KeyManager in project carbon-apimgt by wso2.
the class ApplicationUtilsTestCase method testCreateTokenRequestWhenKeyManagerNull.
@Test
public void testCreateTokenRequestWhenKeyManagerNull() throws APIManagementException {
PowerMockito.mockStatic(KeyManagerHolder.class);
AccessTokenRequest accessTokenRequest = new AccessTokenRequest();
OAuthApplicationInfo oAuthApplicationInfo = new OAuthApplicationInfo();
AccessTokenRequest result = ApplicationUtils.createAccessTokenRequest(null, oAuthApplicationInfo, accessTokenRequest);
Assert.assertNull(result);
Mockito.verify(keyManager, Mockito.times(0)).buildAccessTokenRequestFromOAuthApp(Matchers.any(OAuthApplicationInfo.class), Matchers.any(AccessTokenRequest.class));
}
use of org.wso2.carbon.apimgt.api.model.KeyManager in project carbon-apimgt by wso2.
the class ApplicationUtilsTestCase method testPopulateTokenRequestWhenKeyManagerNull.
@Test
public void testPopulateTokenRequestWhenKeyManagerNull() throws APIManagementException {
PowerMockito.mockStatic(KeyManagerHolder.class);
AccessTokenRequest accessTokenRequest = new AccessTokenRequest();
ApplicationUtils.populateTokenRequest(null, "", accessTokenRequest);
Mockito.verify(keyManager, Mockito.times(0)).buildAccessTokenRequestFromJSON(Matchers.anyString(), Matchers.any(AccessTokenRequest.class));
}
use of org.wso2.carbon.apimgt.api.model.KeyManager in project carbon-apimgt by wso2.
the class ApplicationUtilsTestCase method testCreateTokenRequestWhenAccessTokenNotNull.
@Test
public void testCreateTokenRequestWhenAccessTokenNotNull() throws APIManagementException {
PowerMockito.mockStatic(KeyManagerHolder.class);
AccessTokenRequest accessTokenRequest = new AccessTokenRequest();
OAuthApplicationInfo oAuthApplicationInfo = new OAuthApplicationInfo();
ApplicationUtils.createAccessTokenRequest(keyManager, oAuthApplicationInfo, accessTokenRequest);
Mockito.verify(keyManager, Mockito.times(1)).buildAccessTokenRequestFromOAuthApp(Matchers.any(OAuthApplicationInfo.class), Matchers.any(AccessTokenRequest.class));
}
use of org.wso2.carbon.apimgt.api.model.KeyManager in project carbon-apimgt by wso2.
the class ApplicationRegistrationWSWorkflowExecutorTest method init.
@Before
public void init() throws Exception {
ServiceReferenceHolder serviceReferenceHolder = TestUtils.getServiceReferenceHolder();
ConfigurationContextService configurationContextService = Mockito.mock(ConfigurationContextService.class);
configurationContext = Mockito.mock(ConfigurationContext.class);
PowerMockito.when(serviceReferenceHolder.getContextService()).thenReturn(configurationContextService);
PowerMockito.when(configurationContextService.getClientConfigContext()).thenReturn(configurationContext);
serviceClient = Mockito.mock(ServiceClient.class);
PowerMockito.whenNew(ServiceClient.class).withAnyArguments().thenReturn(serviceClient);
applicationRegistrationWSWorkflowExecutor = new ApplicationRegistrationWSWorkflowExecutor();
apiMgtDAO = TestUtils.getApiMgtDAO();
application = new Application("test", new Subscriber("testUser"));
application.setCallbackUrl(callBaclURL);
application.setTier("Unlimited");
PowerMockito.mockStatic(KeyManagerHolder.class);
keyManager = Mockito.mock(KeyManager.class);
KeyManagerConfiguration keyManagerConfiguration = new KeyManagerConfiguration();
Mockito.when(keyManager.getKeyManagerConfiguration()).thenReturn(keyManagerConfiguration);
PowerMockito.when(KeyManagerHolder.getKeyManagerInstance("carbon.super", "default")).thenReturn(keyManager);
OAuthApplicationInfo oAuthApplicationInfo = new OAuthApplicationInfo();
PowerMockito.when(keyManager.createApplication((OAuthAppRequest) Mockito.anyObject())).thenReturn(oAuthApplicationInfo);
OAuthAppRequest oAuthAppRequest = new OAuthAppRequest();
oAuthAppRequest.setOAuthApplicationInfo(oAuthApplicationInfo);
workflowDTO = new ApplicationRegistrationWorkflowDTO();
workflowDTO.setWorkflowReference("1");
workflowDTO.setApplication(application);
workflowDTO.setCallbackUrl(callBaclURL);
workflowDTO.setTenantDomain("carbon.super");
workflowDTO.setUserName("testUser");
workflowDTO.setExternalWorkflowReference("testUser");
workflowDTO.setKeyType("PRODUCTION");
workflowDTO.setAppInfoDTO(oAuthAppRequest);
KeyManagerConfigurationDTO kmConfigDTO = new KeyManagerConfigurationDTO();
kmConfigDTO.setOrganization("carbon.super");
kmConfigDTO.setName("default");
PowerMockito.when(apiMgtDAO.getKeyManagerConfigurationByUUID("default")).thenReturn(kmConfigDTO);
}
Aggregations