@BeforeClass(alwaysRun = true) public void setEnvironment() throws Exception { String synapseConfFile; super.init(userMode); gatewaySessionCookie = createSession(gatewayContext); if (gatewayContext.getContextTenant().getDomain().equals("carbon.super")) { gatewayUrl = gatewayUrls.getWebAppURLNhttp(); synapseConfFile = "url-mapping-synapse.xml"; } else { gatewayUrl = gatewayUrls.getWebAppURLNhttp() + "t/" + gatewayContext.getContextTenant().getDomain() + "/"; synapseConfFile = "url-mapping-synapse-tenant.xml"; } loadSynapseConfigurationFromClasspath( "artifacts" + File.separator + "AM" + File.separator + "synapseconfigs" + File.separator + "rest" + File.separator + synapseConfFile, gatewayContext, gatewaySessionCookie); }
@BeforeClass(alwaysRun = true) public void setEnvironment() throws Exception { super.init(userMode); gatewaySessionCookie = createSession(gatewayContextMgt); // Initialize publisher and store. apiPublisher = new APIPublisherRestClient(getPublisherURLHttp()); apiStore = new APIStoreRestClient(getStoreURLHttp()); provider = user.getUserName(); // Load the back-end dummy API if (TestUserMode.SUPER_TENANT_ADMIN == userMode) { loadSynapseConfigurationFromClasspath( "artifacts" + File.separator + "AM" + File.separator + "synapseconfigs" + File.separator + "rest" + File.separator + "dummy_api.xml", gatewayContextMgt, gatewaySessionCookie); } }
@AfterClass(alwaysRun = true) public void destroy() throws Exception { super.cleanUp( gatewayContext.getContextTenant().getTenantAdmin().getUserName(), gatewayContext.getContextTenant().getContextUser().getPassword(), storeUrls.getWebAppURLHttp(), publisherUrls.getWebAppURLHttp()); }
@BeforeClass(alwaysRun = true) public void setEnvironment() throws Exception { super.init(userMode); apiPublisher = new APIPublisherRestClient(getPublisherURLHttp()); apiStore = new APIStoreRestClient(getStoreURLHttp()); providerName = user.getUserName(); apiPublisher.login(user.getUserName(), user.getPassword()); apiStore.login(user.getUserName(), user.getPassword()); }
@BeforeClass(alwaysRun = true) public void setEnvironment() throws Exception { super.init(); String publisherURLHttp = publisherUrls.getWebAppURLHttp(); String storeURLHttp = storeUrls.getWebAppURLHttp(); apiStore = new APIStoreRestClient(storeURLHttp); apiPublisher = new APIPublisherRestClient(publisherURLHttp); apiPublisher.login( publisherContext.getContextTenant().getContextUser().getUserName(), publisherContext.getContextTenant().getContextUser().getPassword()); apiStore.login( storeContext.getContextTenant().getContextUser().getUserName(), storeContext.getContextTenant().getContextUser().getPassword()); }
@BeforeClass(alwaysRun = true) public void setEnvironment() throws Exception { super.init(userMode); String publisherURLHttp = publisherUrls.getWebAppURLHttp(); String storeURLHttp = storeUrls.getWebAppURLHttp(); apiStore = new APIStoreRestClient(storeURLHttp); APIPublisherRestClient apiPublisher = new APIPublisherRestClient(publisherURLHttp); String APIName = "APIGetAllSubscriptionsTestAPI"; String APIContext = "getAllSubscriptionsTestAPI"; String tags = "youtube, video, media"; String url = "http://gdata.youtube.com/feeds/api/standardfeeds"; String description = "This is test API create by API manager integration test"; String providerName = "admin"; String APIVersion = "1.0.0"; apiPublisher.login( publisherContext.getContextTenant().getContextUser().getUserName(), publisherContext.getContextTenant().getContextUser().getPassword()); APIRequest apiRequest = new APIRequest(APIName, APIContext, new URL(url)); apiRequest.setTags(tags); apiRequest.setDescription(description); apiRequest.setVersion(APIVersion); apiRequest.setVisibility("restricted"); apiRequest.setRoles("admin"); apiRequest.setTiersCollection(SILVER); apiRequest.setTier(SILVER); apiPublisher.addAPI(apiRequest); APILifeCycleStateRequest updateRequest = new APILifeCycleStateRequest(APIName, providerName, APILifeCycleState.PUBLISHED); apiPublisher.changeAPILifeCycleStatus(updateRequest); apiStore.login( storeContext.getContextTenant().getContextUser().getUserName(), storeContext.getContextTenant().getContextUser().getPassword()); for (int i = 0; i < numberOfApplications; i++) { String applicationName = applicationNamePrefix + i; apiStore.addApplication( applicationName, APIMIntegrationConstants.APPLICATION_TIER.DEFAULT_APP_POLICY_FIFTY_REQ_PER_MIN, "", "this-is-test"); SubscriptionRequest subscriptionRequest = new SubscriptionRequest( APIName, storeContext.getContextTenant().getContextUser().getUserName()); subscriptionRequest.setApplicationName(applicationName); subscriptionRequest.setTier(SILVER); apiStore.subscribe(subscriptionRequest); APPKeyRequestGenerator generateAppKeyRequest = new APPKeyRequestGenerator(applicationName); String responseString = apiStore.generateApplicationKey(generateAppKeyRequest).getData(); JSONObject response = new JSONObject(responseString); String error = response.getString("error"); if ("true".equals(error)) { throw new Exception("Unable to generate the tokens. Hence unable to execute the test case"); } } Thread.sleep(60000); }
@AfterClass(alwaysRun = true) public void destroy() throws Exception { super.cleanUp(); }