@BeforeClass(alwaysRun = true) public void startUp() throws Exception { appMServer = new AutomationContext(AppmTestConstants.APP_MANAGER, TestUserMode.SUPER_TENANT_ADMIN); appCreator = appMServer.getSuperTenant().getTenantUser(AppmTestConstants.TestUsers.APP_CREATOR); adminUser = appMServer.getSuperTenant().getTenantUser(AppmTestConstants.TestUsers.ADMIN); appProvider = appCreator.getUserName(); backEndUrl = appMServer.getContextUrls().getWebAppURLHttps(); appmPublisherRestClient = new APPMPublisherRestClient(backEndUrl); User appCreator = appMServer.getSuperTenant().getTenantUser(AppmTestConstants.TestUsers.APP_CREATOR); appmPublisherRestClient.login(appCreator.getUserName(), appCreator.getPassword()); // Create test web applications creatorDeleteAppTestAppId = createWebApp(creatorDeleteAppTest); adminDeleteAppTestAppId = createWebApp(adminDeleteAppTest); publisherDeleteAppTestAppId = createWebApp(publisherDeleteAppTest); appmPublisherRestClient.logout(); // Promote lifecycle state in to "Unpublished" state appmPublisherRestClient.login(adminUser.getUserName(), adminUser.getPassword()); changeLifeCycleStateIntoUnpublished(creatorDeleteAppTestAppId); changeLifeCycleStateIntoUnpublished(adminDeleteAppTestAppId); changeLifeCycleStateIntoUnpublished(publisherDeleteAppTestAppId); }
@Test(description = TEST_DESCRIPTION) public void testAppPropertyRetrieval() throws Exception { HttpResponse response = appmPublisherRestClient.webAppCreate(appName, context, appVersion, trackingCode); JSONObject responseData = new JSONObject(response.getData()); String uuid = responseData.getString(AppmTestConstants.ID); String appType = AppmTestConstants.WEB_APP; appmPublisherRestClient.publishWebApp(uuid); HttpResponse appPropertyResponse = appmPublisherRestClient.getWebAppProperty(uuid); JSONObject jsonObject = new JSONObject(appPropertyResponse.getData()); // Check App Id String appId = (String) jsonObject.get(AppmTestConstants.ID); assertTrue((appId.equals(uuid) == true), "Unable to Retrieve application id."); // Check App Type String type = (String) jsonObject.get(AppmTestConstants.TYPE); assertTrue((type.equals(appType) == true), "Unable to Retrieve application type."); // Check lifecycleState String lifecycleState = (String) jsonObject.get(AppmTestConstants.LIFE_CYCLE_STATE); assertTrue( (lifecycleState.equalsIgnoreCase(AppmTestConstants.PUBLISHED) == true), "Unable to Retrieve application life cycle."); // Check Path attribute String appPropertyString = userName + "/" + appName + "/" + appVersion + "/" + appType; String path = (String) jsonObject.get("path"); assertTrue(path.endsWith(appPropertyString), "Unable to Retrieve application path."); }
@Test(dataProvider = "validUserModeDataProvider", description = TEST_DESCRIPTION) public void testChangeStateFromCreateToInReviewWithValidUsers( String userName, String password, String uuid) throws Exception { APPMPublisherRestClient publisherRestClient = new APPMPublisherRestClient(backEndUrl); // Login to publisher by a valid user. publisherRestClient.login(userName, password); HttpResponse httpResponse = publisherRestClient.changeState(uuid, AppmTestConstants.LifeCycleStatus.SUBMIT_FOR_REVIEW); JSONObject responseData = new JSONObject(httpResponse.getData()); // Logout from publisher by valid user. publisherRestClient.logout(); int responseCode = httpResponse.getResponseCode(); assertTrue( responseCode == 200, "Excepted status code is 200 for user :"******". But received status " + "code is " + responseCode); assertEquals( responseData.getString(AppmTestConstants.STATUS), "Success", "Changing web app life cycle state " + "from create to review failed for user : "******" who has sufficient privileges to change " + "life cycle status."); }
@Test(dataProvider = "inValidUserModeDataProvider", description = TEST_DESCRIPTION) public void testChangeStateFromInReviewToRejectWithInValidUsers( String userName, String password, String uuid) throws Exception { APPMPublisherRestClient publisherRestClient = new APPMPublisherRestClient(backEndUrl); // Login to publisher by an invalid user. publisherRestClient.login(userName, password); HttpResponse httpResponse = publisherRestClient.changeState(uuid, AppmTestConstants.LifeCycleStatus.REJECT); JSONObject responseData = new JSONObject(httpResponse.getData()); // Logout from publisher by invalid user. publisherRestClient.logout(); int responseCode = httpResponse.getResponseCode(); assertTrue( responseCode == 401, "Excepted status code is 401 for user :"******". But received " + "status code is " + responseCode); assertEquals( responseData.getString(AppmTestConstants.STATUS), "Access Denied", "Changing WebApp life cycle " + "state from in review to reject allowed for user : "******" who has insufficient privileges " + "to change life cycle status."); }
@AfterClass(alwaysRun = true) public void closeDown() throws Exception { // Deleted created web app by AppCreator. appmPublisherRestClient.deleteApp(app1Uuid); appmPublisherRestClient.deleteApp(app2Uuid); appmPublisherRestClient.deleteApp(app3Uuid); // Logout from publisher by AppCreator user. appmPublisherRestClient.logout(); }
@Test(dataProvider = "validUserModeDataProvider", description = TEST_DESCRIPTION) public void testUnpublishedWebAppDeleteWithValidUsers( String username, String password, String appId) throws Exception { APPMPublisherRestClient publisherRestClient = new APPMPublisherRestClient(backEndUrl); publisherRestClient.login(username, password); // delete web application HttpResponse appDeleteResponse = publisherRestClient.deleteApp(appId); publisherRestClient.logout(); JSONObject jsonObject = new JSONObject(appDeleteResponse.getData()); Assert.assertTrue( (Boolean) jsonObject.get("isDeleted"), "Web App delete is not allowed for user :"******" who has sufficient privileges to delete."); }
private String createWebApp(String appPrefix) throws Exception { PolicyGroup defaultPolicyGroup = WebAppUtil.createDefaultPolicy(); HttpResponse response = appmPublisherRestClient.addPolicyGroup(defaultPolicyGroup); String policyId = WebAppUtil.getPolicyId(response); List<WebAppResource> webAppResources = WebAppUtil.createDefaultResources(policyId); WebApp webApp = WebAppUtil.createBasicWebApp( appCreatorUserName, appName + appPrefix, context + appPrefix, appVersion, "http://wso2.com/", webAppResources); appmPublisherRestClient.createWebApp(webApp); return webApp.getAppId(); }
private String createWebAppAndSubmitForReview(String appPrefix) throws Exception { PolicyGroup defaultPolicyGroup = WebAppUtil.createDefaultPolicy(); HttpResponse response = appmPublisherRestClient.addPolicyGroup(defaultPolicyGroup); String policyId = WebAppUtil.getPolicyId(response); List<WebAppResource> webAppResources = WebAppUtil.createDefaultResources(policyId); WebApp webApp = WebAppUtil.createBasicWebApp( appCreatorUserName, appName + appPrefix, context + appPrefix, appVersion, "http://wso2.com/", webAppResources); appmPublisherRestClient.createWebApp(webApp); String appId = webApp.getAppId(); appmPublisherRestClient.changeState(appId, AppmTestConstants.LifeCycleStatus.SUBMIT_FOR_REVIEW); return appId; }
@BeforeClass(alwaysRun = true) public void startUp() throws Exception { AutomationContext appMServer = new AutomationContext(AppmTestConstants.APP_MANAGER, TestUserMode.SUPER_TENANT_ADMIN); backEndUrl = appMServer.getContextUrls().getWebAppURLHttps(); appmPublisherRestClient = new APPMPublisherRestClient(backEndUrl); adminUser = appMServer.getSuperTenant().getTenantAdmin(); userName = adminUser.getUserName(); password = adminUser.getPassword(); appmPublisherRestClient.login(userName, password); }
@BeforeClass(alwaysRun = true) public void startUp() throws Exception { appMServer = new AutomationContext(AppmTestConstants.APP_MANAGER, TestUserMode.SUPER_TENANT_ADMIN); backEndUrl = appMServer.getContextUrls().getWebAppURLHttps(); appmPublisherRestClient = new APPMPublisherRestClient(backEndUrl); User appCreator = appMServer.getSuperTenant().getTenantUser("AppCreator"); appCreatorUserName = appCreator.getUserName(); appCreatorPassword = appCreator.getPassword(); // Login to publisher by AppCreator user. appmPublisherRestClient.login(appCreatorUserName, appCreatorPassword); // Multiple web apps are created for multiple users. app1Uuid = createWebApp("1"); app2Uuid = createWebApp("2"); app3Uuid = createWebApp("3"); }
@AfterClass(alwaysRun = true) public void closeDown() throws Exception { HttpResponse response = appmPublisherRestClient.deleteApp(publisherDeleteAppTestAppId); VerificationUtil.checkDeleteResponse(response); appmPublisherRestClient.logout(); }
private void changeLifeCycleStateIntoUnpublished(String appId) throws Exception { appmPublisherRestClient.changeState(appId, AppmTestConstants.LifeCycleStatus.SUBMIT_FOR_REVIEW); appmPublisherRestClient.changeState(appId, AppmTestConstants.LifeCycleStatus.APPROVE); appmPublisherRestClient.changeState(appId, AppmTestConstants.LifeCycleStatus.PUBLISH); appmPublisherRestClient.changeState(appId, AppmTestConstants.LifeCycleStatus.UNPUBLISH); }
@AfterClass(alwaysRun = true) public void closeDown() throws Exception { appmPublisherRestClient.logout(); }