@BeforeClass(alwaysRun = true) public void initialize() throws APIManagerIntegrationTestException, XPathExpressionException, RemoteException, ResourceAdminServiceExceptionException, MalformedURLException { super.init(); apiEndPointUrl = getGatewayURLHttp() + API_END_POINT_POSTFIX_URL; providerName = user.getUserName(); apiCreationRequestBean = new APICreationRequestBean( API_NAME, API_CONTEXT, API_VERSION_1_0_0, providerName, new URL(apiEndPointUrl)); apiCreationRequestBean.setTags(API_TAGS); apiCreationRequestBean.setDescription(API_DESCRIPTION); String publisherURLHttp = getPublisherURLHttp(); String storeURLHttp = getStoreURLHttp(); apiPublisherClientUser1 = new APIPublisherRestClient(publisherURLHttp); APIStoreRestClient apiStoreClientUser1 = new APIStoreRestClient(storeURLHttp); // Login to API Publisher with admin apiPublisherClientUser1.login(user.getUserName(), user.getPassword()); // Login to API Store with admin apiStoreClientUser1.login(user.getUserName(), user.getPassword()); apiIdentifier = new APIIdentifier(providerName, API_NAME, API_VERSION_1_0_0); String artifactsLocation = TestConfigurationProvider.getResourceLocation() + File.separator + "artifacts" + File.separator + "AM" + File.separator + "lifecycletest" + File.separator + "tiers.xml"; resourceAdminServiceClient = new ResourceAdminServiceClient( publisherContext.getContextUrls().getBackEndUrl(), createSession(publisherContext)); originalTiersXML = resourceAdminServiceClient.getTextContent(TIER_XML_REG_CONFIG_LOCATION); newTiersXML = readFile(artifactsLocation); }
@Test( groups = {"wso2.am"}, description = "test availability of tiers in Permission Page after change tiers XML", dependsOnMethods = "testAvailabilityOfTiersInAPIManagePageBeforeChangeTiersXML") public void testAvailabilityOfTiersInPermissionPageAfterChangeTiersXML() throws RemoteException, ResourceAdminServiceExceptionException, APIManagerIntegrationTestException { // Changing the Tier XML resourceAdminServiceClient.updateTextContent(TIER_XML_REG_CONFIG_LOCATION, newTiersXML); HttpResponse tierPermissionPageHttpResponse = apiPublisherClientUser1.getTierPermissionsPage(); assertEquals( tierPermissionPageHttpResponse.getResponseCode(), HTTP_RESPONSE_CODE_OK, "Response code mismatched when invoke to get Tier Permission Page"); assertTrue( tierPermissionPageHttpResponse.getData().contains(TIER_PERMISSION_PAGE_TIER_GOLD), "default tier Gold is not available in Tier Permission page before add new tear in tiers.xml"); assertTrue( tierPermissionPageHttpResponse.getData().contains(TIER_PERMISSION_PAGE_TIER_PLATINUM), "new tier Platinum is not available in Tier Permission page before add new tear in tiers.xml"); }
@AfterClass(alwaysRun = true) public void cleanUpArtifacts() throws Exception { deleteAPI(apiIdentifier, apiPublisherClientUser1); // restore the original tiers.xml content. resourceAdminServiceClient.updateTextContent(TIER_XML_REG_CONFIG_LOCATION, originalTiersXML); }