@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(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."); }
@AfterClass(alwaysRun = true) public void closeDown() throws Exception { HttpResponse response = appmPublisherRestClient.deleteApp(publisherDeleteAppTestAppId); VerificationUtil.checkDeleteResponse(response); appmPublisherRestClient.logout(); }
@AfterClass(alwaysRun = true) public void closeDown() throws Exception { appmPublisherRestClient.logout(); }