diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/collection/BreadcrumbTest.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/collection/BreadcrumbTest.java deleted file mode 100755 index 811e36c19..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/collection/BreadcrumbTest.java +++ /dev/null @@ -1,288 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.integration.test.collection; - -import java.util.Properties; -import java.util.Random; - -import org.apache.commons.lang3.RandomStringUtils; -import org.irods.jargon.core.pub.IRODSFileSystem; -import org.irods.jargon.testutils.IRODSTestSetupUtilities; -import org.irods.jargon.testutils.TestingPropertiesHelper; -import org.irods.jargon.testutils.filemanip.ScratchFileUtils; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.Keys; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; - -import com.emc.metalnx.core.domain.exceptions.DataGridException; -import com.emc.metalnx.integration.test.utils.CollectionUtils; -import com.emc.metalnx.integration.test.utils.FileUtils; -import com.emc.metalnx.integration.test.utils.TemplateUtils; -import com.emc.metalnx.integration.test.utils.UserUtils; -import com.emc.metalnx.test.generic.UiTestUtilities; - -import junit.framework.Assert; - -@Deprecated -@Ignore -public class BreadcrumbTest { - - private static WebDriver driver = null; - private static WebDriverWait wait = null; - - private static Properties testingProperties = new Properties(); - private static ScratchFileUtils scratchFileUtils = null; - public static final String IRODS_TEST_SUBDIR_PATH = "ITBreadcrumbTest"; - private static IRODSTestSetupUtilities irodsTestSetupUtilities = null; - private static IRODSFileSystem irodsFileSystem; - - - private static By breadcrumbLocator = By.className("breadcrumb"); - private static By navigationInputLocator = By.id("navigationInput"); - private static String zoneAndHomePath = "/" + UiTestUtilities.IRODS_ZONE + "/home"; - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - org.irods.jargon.testutils.TestingPropertiesHelper testingPropertiesLoader = new TestingPropertiesHelper(); - testingProperties = testingPropertiesLoader.getTestProperties(); - scratchFileUtils = new ScratchFileUtils(testingProperties); - scratchFileUtils.clearAndReinitializeScratchDirectory(IRODS_TEST_SUBDIR_PATH); - irodsTestSetupUtilities = new IRODSTestSetupUtilities(); - irodsTestSetupUtilities.initializeIrodsScratchDirectory(); - irodsTestSetupUtilities.initializeDirectoryForTest(IRODS_TEST_SUBDIR_PATH); - irodsFileSystem = IRODSFileSystem.instance(); - UiTestUtilities.init(); - driver = UiTestUtilities.getDriver(); - wait = new WebDriverWait(driver, 5); - } - - @Before - public void setUp() { - UiTestUtilities.login(); - - } - - /** - * After each test the user created for the test should be removed. - */ - @After - public void tearDown() { - UiTestUtilities.logout(); - - } - - /** - * After all tests are done, the test must quit the driver. This will close - * every window associated with the current driver instance. - */ - - @AfterClass - public static void tearDownAfterClass() { - if (driver != null) { - driver.quit(); - driver = null; - UiTestUtilities.setDriver(null); - irodsFileSystem.closeAndEatExceptions(); - } - } - - /** - * Check if rodsadmin can go to /zone/home - */ - @Test - - public void testGoToHomeCollection() { - CollectionUtils.writeOnEditableBreadCrumb(driver, wait, zoneAndHomePath); - - wait.until(ExpectedConditions.elementToBeClickable(breadcrumbLocator)); - - String path = driver.findElement(navigationInputLocator).getAttribute("value"); - - Assert.assertEquals(zoneAndHomePath, path); - } - - /** - * Check if user gets a message warning the user that the path entered doesn't - * exist - */ - @Test - - public void testNonExistentCollection() { - String randomString = RandomStringUtils.randomAlphanumeric(20); - - CollectionUtils.writeOnEditableBreadCrumb(driver, wait, randomString); - - wait.until(ExpectedConditions.elementToBeClickable(breadcrumbLocator)); - - Assert.assertEquals(randomString + " does not exist or user lacks access permission.", - driver.findElement(By.id("invalidPathErrorMsg")).getText()); - } - - /** - * when user tries to send an empty path input - */ - @Test - public void testBlankPath() { - CollectionUtils.writeOnEditableBreadCrumb(driver, wait, Keys.BACK_SPACE.toString()); - - Assert.assertTrue(driver.findElement(navigationInputLocator).isDisplayed()); - } - - /** - * Try to access a path that the current user doesn't have access to - */ - @Test - @Ignore - public void testPathWithoutPermission() { - String uname = "breadcrumbPermission" + System.currentTimeMillis(); - String pwd = "webdriver"; - - // creating a new user - driver.get(UiTestUtilities.ADD_USERS_URL); - UserUtils.fillInUserGeneralInformation(uname, pwd, UiTestUtilities.RODS_USER_TYPE, driver); - UserUtils.submitUserForm(driver); - - String newUserCollection = zoneAndHomePath + "/" + uname; - CollectionUtils.writeOnEditableBreadCrumb(driver, wait, newUserCollection); - - wait.until(ExpectedConditions.elementToBeClickable(breadcrumbLocator)); - - Assert.assertEquals( - "You do not have permissions to access information in the target collection or for the selected object.", - driver.findElement(By.cssSelector("#tree-view-panel-body > .col-xs-12 > .text-center > span")) - .getText()); - - // removing user - driver.get(UiTestUtilities.USERS_URL); - - By removeButton = By.id("btn_remove_" + uname); - By removeConfirmationButton = By.id("btnConfUserRemoval_Yes"); - - UserUtils.searchUser(driver, uname); - - wait.until(ExpectedConditions.elementToBeClickable(removeButton)); - - driver.findElement(removeButton).click(); - wait.until(ExpectedConditions.elementToBeClickable(removeConfirmationButton)); - driver.findElement(removeConfirmationButton).click(); - } - - /** - * Uploads a file to the rods user and tries to access the file via breadcrumb - * - * @throws DataGridException - * - */ - @Test - @Ignore - public void testFilePath() throws DataGridException { - // Upload test files - FileUtils.uploadToHomeDirAsAdmin(TemplateUtils.TEST_FILES[0]); - - String filePath = zoneAndHomePath + "/" + UiTestUtilities.RODS_USERNAME + "/" + TemplateUtils.TEST_FILES[0]; - - CollectionUtils.writeOnEditableBreadCrumb(driver, wait, filePath); - - wait.until(ExpectedConditions.elementToBeClickable(breadcrumbLocator)); - String path = driver.findElement(navigationInputLocator).getAttribute("value"); - - Assert.assertEquals(filePath, path); - } - - /** - * Creates a collection and tries to access it via breadcrumb - */ - @Test - @Ignore - public void testCollectionPath() { - String collectionName = "breadcrumbCollectionTest" + System.currentTimeMillis(); - CollectionUtils.createCollection(driver, collectionName); - - String collectionPath = zoneAndHomePath + "/" + UiTestUtilities.RODS_USERNAME + "/" + collectionName; - - CollectionUtils.writeOnEditableBreadCrumb(driver, wait, collectionPath); - - wait.until(ExpectedConditions.elementToBeClickable(breadcrumbLocator)); - - String path = driver.findElement(navigationInputLocator).getAttribute("value"); - - Assert.assertEquals(collectionPath, path); - - CollectionUtils.writeOnEditableBreadCrumb(driver, wait, zoneAndHomePath + "/" + UiTestUtilities.RODS_USERNAME); - wait.until(ExpectedConditions.elementToBeClickable(breadcrumbLocator)); - CollectionUtils.removeColl(driver, collectionName); - } - - /** - * Adds "/" at the end of an existent path - */ - @Test - @Ignore - public void testSlashAtTheEndOfPath() { - CollectionUtils.writeOnEditableBreadCrumb(driver, wait, zoneAndHomePath + "/"); - - wait.until(ExpectedConditions.elementToBeClickable(breadcrumbLocator)); - - String path = driver.findElement(navigationInputLocator).getAttribute("value"); - - Assert.assertEquals(zoneAndHomePath, path); - } - - /** - * Adds multiples "/" at the end of an existent path - */ - @Test - @Ignore - public void testMultipleSlashesPath() { - Random random = new Random(); - String zoneAndHomePathPlusSlashes = zoneAndHomePath; - for (int i = 0; i < random.nextInt(20); i++) { - zoneAndHomePathPlusSlashes += "/"; - } - - CollectionUtils.writeOnEditableBreadCrumb(driver, wait, zoneAndHomePathPlusSlashes); - - wait.until(ExpectedConditions.elementToBeClickable(breadcrumbLocator)); - - String path = driver.findElement(navigationInputLocator).getAttribute("value"); - - Assert.assertEquals(zoneAndHomePath, path); - } - - /** - * Adds "\" at the end of an existent path - */ - @Test - @Ignore - public void testInvertedSlash() { - CollectionUtils.writeOnEditableBreadCrumb(driver, wait, zoneAndHomePath + "\\"); - - wait.until(ExpectedConditions.elementToBeClickable(breadcrumbLocator)); - - Assert.assertEquals("The provided path \"" + zoneAndHomePath + "\\\" is not a valid one.", - driver.findElement(By.id("invalidPathErrorMsg")).getText()); - } - -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/collection/EmptyTrashTest.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/collection/EmptyTrashTest.java deleted file mode 100755 index 496017711..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/collection/EmptyTrashTest.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.integration.test.collection; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.NoSuchElementException; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.emc.metalnx.core.domain.exceptions.DataGridException; -import com.emc.metalnx.integration.test.utils.CollectionUtils; -import com.emc.metalnx.integration.test.utils.FileUtils; -import com.emc.metalnx.test.generic.UiTestUtilities; - -@Deprecated -@Ignore -public class EmptyTrashTest { - private static final Logger logger = LoggerFactory.getLogger(EmptyTrashTest.class); - private static WebDriver driver = null; - private static WebDriverWait wait = null; - private static final String[] TEST_FILES = { "emptyTrashTest.png" }; - - @BeforeClass - public static void setUpBeforeClass() { - - } - - @Before - public void setUp() throws Exception { - UiTestUtilities.login(); - } - - /** - * After each test the user created for the test should be removed. - */ - @After - public void tearDown() throws Exception { - UiTestUtilities.logout(); - } - - /** - * After all tests are done, the test must quit the driver. This will close - * every window associated with the current driver instance. - */ - - @AfterClass - public static void tearDownAfterClass() { - if (driver != null) { - driver.quit(); - driver = null; - UiTestUtilities.setDriver(null); - } - } - - /** - * Method used for testing if all items are removed from the trash folder once - * the user clicks on the empty trash button. No results should be shown. - * - * TimeoutException is expected since no items should be shown. - * - * @throws DataGridException - */ - @Test - public void testEmptyTrash() throws DataGridException { - logger.info("Testing if empty trash button works"); - - FileUtils.uploadToHomeDirAsAdmin(TEST_FILES); - FileUtils.removeFilesFromHomeAsAdmin(TEST_FILES); - - driver.get(UiTestUtilities.TRASH_URL); - - CollectionUtils.clickOnEmptyTrash(driver); - CollectionUtils.confirmEmptyTrash(driver); - - Assert.assertEquals(UiTestUtilities.TRASH_URL, driver.getCurrentUrl()); - - // check if a feedback message of success is displayed - wait.until(ExpectedConditions.visibilityOfElementLocated(By.className("alert-success"))); - WebElement successMsg = driver.findElement(By.className("alert-success")); - Assert.assertTrue(successMsg.isDisplayed()); - - // wait for items to be deleted and checking if no results were found - wait.until(ExpectedConditions - .visibilityOfElementLocated(By.cssSelector("table tbody tr td[class='dataTables_empty']"))); - } - - /** - * Method used for testing if the empty trash button shows up when the user is - * in the trash folder. - * - * NoSuchElementException is expected if no results are shown, then the empty - * trash won't show up. - */ - @Test(expected = NoSuchElementException.class) - public void testIfEmptyTrashButtonIsShown() { - logger.info("Testing if empty trash button shows up"); - - driver.get(UiTestUtilities.TRASH_URL); - - // check if there is any item in the trash - driver.findElement(CollectionUtils.COLLS_TABLE); - - // if there is at least one item in the trash, the empty trash button must be - // shown - Assert.assertNotNull(driver.findElement(CollectionUtils.EMPTY_TRASH_BTN)); - } - - /** - * Method used for testing if a confirmation modal is displayed after the user - * clicks on the empty trash button. - * - * @throws DataGridException - */ - @Test - public void testIfAfterClikingOnEmptyTrashButtonAConfirmationShowsUp() throws DataGridException { - logger.info("Testing if empty trash button shows up"); - - String trashTestFile = "emptyTrashTest.png"; - - FileUtils.uploadToHomeDirAsAdmin(trashTestFile); - FileUtils.removeFilesFromHomeAsAdmin(trashTestFile); - - driver.get(UiTestUtilities.TRASH_URL); - - wait.until(ExpectedConditions.elementToBeClickable(CollectionUtils.EMPTY_TRASH_BTN)); - driver.findElement(CollectionUtils.EMPTY_TRASH_BTN).click(); - - // a confirmation modal should be shown after clicking on the empty trash button - Assert.assertNotNull(driver.findElement(CollectionUtils.EMPTY_TRASH_MODAL)); - - String trashPath = String.format("/%s/trash/home/%s", UiTestUtilities.IRODS_ZONE, UiTestUtilities.RODS_USERNAME); - FileUtils.forceRemoveFilesFromDirAsAdmin(trashPath, trashTestFile); - } - - /** - * Method used for testing if the empty trash button is NOT shown in the - * collection management page. - * - * NoSuchElementException is expected since the empty trash button is not - * supposed to be displayed in the collections mgmt. page - */ - @Test(expected = NoSuchElementException.class) - public void testIfEmptyTrashButtonIsNotShownInTheCollPage() { - logger.info("Testing if empty trash button is not shown in the collections mgmt. page"); - - driver.get(UiTestUtilities.COLLECTIONS_URL); - - // if the user is in the collections mgmt. page, the empty trash button must NOT - // be shown - driver.findElement(CollectionUtils.EMPTY_TRASH_BTN); - - // if the test gets to this point, it means the empty trash button is available - Assert.fail(); - } -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/collection/FilePermissionTest.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/collection/FilePermissionTest.java deleted file mode 100755 index dd0e4c1a6..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/collection/FilePermissionTest.java +++ /dev/null @@ -1,247 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.integration.test.collection; - -import static org.junit.Assert.assertTrue; - -import java.util.List; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.Keys; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.Select; -import org.openqa.selenium.support.ui.WebDriverWait; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.emc.metalnx.core.domain.exceptions.DataGridException; -import com.emc.metalnx.integration.test.utils.CollectionUtils; -import com.emc.metalnx.integration.test.utils.FileUtils; -import com.emc.metalnx.integration.test.utils.MetadataUtils; -import com.emc.metalnx.integration.test.utils.UserUtils; -import com.emc.metalnx.test.generic.UiTestUtilities; - -@Deprecated -@Ignore -public class FilePermissionTest { - - private static String uname = "collectionPermission" + System.currentTimeMillis(); - private static String pwd = "webdriver"; - private static String publicColl = String.format("/%s/home/public", UiTestUtilities.IRODS_ZONE); - - private static final By COLLECTION_TABLE_ELEMENT = By.cssSelector("#treeViewTable tbody a:nth-child(1)"); - private static WebDriverWait wait = null; - private static WebDriver driver = null; - private static final Logger logger = LoggerFactory.getLogger(FilePermissionTest.class); - - @BeforeClass - public static void setUpBeforeClass() throws DataGridException { - - FileUtils.uploadToDirAsAdmin(publicColl, MetadataUtils.METADATA_SEARCH_FILES); - UserUtils.createUser(uname, pwd, UiTestUtilities.RODS_USER_TYPE, driver); - } - - @After - public void tearDown() { - UiTestUtilities.logout(); - } - - @AfterClass - public static void tearDownAfterClass() throws DataGridException { - FileUtils.forceRemoveFilesFromDirAsAdmin(publicColl, MetadataUtils.METADATA_SEARCH_FILES); - UserUtils.removeUser(uname, driver); - - if (driver != null) { - driver.quit(); - driver = null; - UiTestUtilities.setDriver(null); - } - } - - /** - * Test method to check if it is possible to access a file in public folder that - * does not belong to the current user without crashing the application. The - * ideal scenario would be to display a message informing that the user does not - * have permission access to that file - */ - @Test - public void testOpenFileFromAnotherUser() { - logger.info("Testing if a 500 error doesn't show on screen"); - By lackOfPermissionLocator = By.cssSelector(".browse-collection-files-content > div > .text-center span"); - - // Code below logs in as rodsuser to try and access a file that does not belong - // to him - CollectionUtils.goToPublicCollection(driver, UiTestUtilities.RODS_USER_TYPE, uname, pwd); - - wait.until(ExpectedConditions.visibilityOfElementLocated(COLLECTION_TABLE_ELEMENT)); - driver.findElement(COLLECTION_TABLE_ELEMENT).click(); - - wait.until(ExpectedConditions.textToBePresentInElementLocated(By.id("directoryPath"), "public")); - wait.until(ExpectedConditions.visibilityOfElementLocated(lackOfPermissionLocator)); - WebElement messageNoPermission = driver.findElement(lackOfPermissionLocator); - assertTrue(messageNoPermission.getText().contains( - "You do not have permissions to access information in the target collection or for the selected object.")); - } - - /** - * Method to test if giving read permission to another user works fine - */ - @Test - public void testGiveReadPermissions() { - logger.info("Testing permission on collections"); - CollectionUtils.goToPublicCollection(driver, UiTestUtilities.RODS_ADMIN_TYPE, null, null); - - // giving permissions - wait.until(ExpectedConditions.presenceOfElementLocated(COLLECTION_TABLE_ELEMENT)); - List files = driver.findElements(COLLECTION_TABLE_ELEMENT); - - /* - * Getting first item in the file list - */ - WebElement file = files.get(0); - String fileName = file.findElement(By.tagName("span")).getText(); - file.click(); - // once in the file location, we use the method below to add a permission - // through - // permission tab - addPermissionToCollection(driver, uname, "READ"); - - // checking if nookmark exists for the newly created user - UserUtils.checkIfBookmarksExist(uname, pwd, new String[] { fileName }, driver); - - } - - /** - * Method to test if giving write permission to another user works fine - */ - @Test - public void testGiveWritePermissions() { - logger.info("Testing permission on collections"); - CollectionUtils.goToPublicCollection(driver, UiTestUtilities.RODS_ADMIN_TYPE, null, null); - - // giving permissions - wait.until(ExpectedConditions.visibilityOfElementLocated(COLLECTION_TABLE_ELEMENT)); - List files = driver.findElements(COLLECTION_TABLE_ELEMENT); - - /* - * Getting second item in the file list - */ - WebElement file = files.get(0); - String fileName = file.findElement(By.tagName("span")).getText(); - file.click(); - // once in the file location, we use the method below to add a permission - // through - // permission tab - addPermissionToCollection(driver, uname, "WRITE"); - - // checking if nookmark exists for the newly created user - UserUtils.checkIfBookmarksExist(uname, pwd, new String[] { fileName }, driver); - - } - - /** - * Method to test if giving ownership to another user works fine - */ - @Test - public void testGiveOwnerPermissions() { - logger.info("Testing permission on collections"); - - WebDriverWait wait = new WebDriverWait(driver, 5); - CollectionUtils.goToPublicCollection(driver, UiTestUtilities.RODS_ADMIN_TYPE, null, null); - - // giving permissions - wait.until(ExpectedConditions.presenceOfElementLocated(COLLECTION_TABLE_ELEMENT)); - List files = driver.findElements(COLLECTION_TABLE_ELEMENT); - - /* - * Getting third item in the file list - */ - WebElement file = files.get(0); - String fileName = file.findElement(By.tagName("span")).getText(); - file.click(); - // once in the file location, we use the method below to add a permission - // through - // permission tab - addPermissionToCollection(driver, uname, "OWN"); - - // checking if nookmark exists for the newly created user - UserUtils.checkIfBookmarksExist(uname, pwd, new String[] { fileName }, driver); - - } - - /** - * This method below is used so that once the driver is in the file's location, - * we navigate through the tabs to add a permission to the current file - */ - private void addPermissionToCollection(WebDriver driver, String uname, String permission) { - - // getting to permissions tab - try { - wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("çççç"))); - } catch (Exception e) { - } - wait.until(ExpectedConditions.elementToBeClickable(By.id("breadcrumbOptionsMenu"))); - driver.findElement(By.id("breadcrumbOptionsMenu")).click(); - wait.until(ExpectedConditions.elementToBeClickable(By.id("permissions"))); - driver.findElement(By.id("permissions")).click(); - wait.until(ExpectedConditions.presenceOfElementLocated(By.id("permissionsTabList"))); - assertTrue(driver.findElement(By.id("permissionsTabList")).isDisplayed()); - - // getting to user permissions tab - wait.until( - ExpectedConditions.elementToBeClickable(By.cssSelector(".nav.nav-tabs a[href=\"#userPermissions\"]"))); - driver.findElement(By.cssSelector(".nav.nav-tabs a[href=\"#userPermissions\"]")).click(); - wait.until(ExpectedConditions.presenceOfElementLocated(By.id("userPermissions"))); - assertTrue(driver.findElement(By.id("userPermissions")).isDisplayed()); - - // open add user permission modal - By inputName = By.cssSelector("#newUserPermissionModal .tt-input"); - driver.findElement(By.cssSelector("#addPermissionButtonDiv > .dropdown-toggle")).click(); - wait.until(ExpectedConditions.elementToBeClickable( - By.cssSelector("#addPermissionButtonDiv a[data-target=\"#newUserPermissionModal\"]"))); - driver.findElement(By.cssSelector("#addPermissionButtonDiv a[data-target=\"#newUserPermissionModal\"]")) - .click(); - wait.until(ExpectedConditions.visibilityOfElementLocated(inputName)); - driver.findElement(inputName).click(); - driver.findElement(inputName).clear(); - for (char letter : uname.toCharArray()) { - driver.findElement(inputName).sendKeys(Character.toString(letter)); - } - driver.findElement(inputName).sendKeys(Keys.ARROW_DOWN); - driver.findElement(inputName).sendKeys(Keys.ENTER); - - // By suggestions = By.cssSelector("#newUserPermissionModal .tt-suggestion"); - // wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(suggestions)); - // wait.until(ExpectedConditions.elementToBeClickable(suggestions)); - - // driver.findElement(suggestions).click(); - // choosing read permission - new Select(driver.findElement(By.id("userPermissionToBeSet"))).selectByValue(permission); - - driver.findElement(By.id("submitUserToBeAddedButton")).click(); - wait.until(ExpectedConditions.textToBePresentInElementLocated(By.id("userPermissionsTable"), uname)); - assertTrue(driver.findElement(By.id("userPermissionsTable")).getText().contains(uname)); - } - -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/collection/HistoryStackTest.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/collection/HistoryStackTest.java deleted file mode 100755 index 5b6eab961..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/collection/HistoryStackTest.java +++ /dev/null @@ -1,314 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.integration.test.collection; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; - -import com.emc.metalnx.integration.test.utils.CollectionUtils; -import com.emc.metalnx.test.generic.UiTestUtilities; - -@Deprecated -@Ignore -public class HistoryStackTest { - private static WebDriver driver = null; - private static WebDriverWait wait = null; - - private static String collectionName1 = "breadcrumbCollectionTestA" + System.currentTimeMillis(); - private static String collectionName2 = "breadcrumbCollectionTestB" + System.currentTimeMillis(); - private static String collectionName3 = "breadcrumbCollectionTestC" + System.currentTimeMillis(); - private static String[] arrayPaths = { CollectionUtils.RODS_COLL_PATH, - String.format("%s/%s", CollectionUtils.RODS_COLL_PATH, collectionName1), - String.format("%s/%s/%s", CollectionUtils.RODS_COLL_PATH, collectionName1, collectionName2), String.format( - "%s/%s/%s/%s", CollectionUtils.RODS_COLL_PATH, collectionName1, collectionName2, collectionName3) }; - - private By backButtonLocator = By.cssSelector("#backBtn"); - private By forwardButtonLocator = By.cssSelector("#forwardBtn"); - private By dropdownHistoryButtonLocator = By.cssSelector("#historyBtn"); - private By dropdownHistoryMenuLocator = By.cssSelector("#directoryPath > .btn-group > .dropdown-menu"); - - private By inactivePathHistory = By - .cssSelector("#directoryPath > .btn-group > ul.dropdown-menu > li:not(.active) a"); - - @BeforeClass - public static void setUpBeforeClass() { - - driver = UiTestUtilities.getDriver(); - wait = new WebDriverWait(driver, 5); - - UiTestUtilities.login(); - createCollectionHistoryTree(driver, wait); - UiTestUtilities.logout(); - } - - @Before - public void setUp() { - UiTestUtilities.login(); - driver.get(UiTestUtilities.COLLECTIONS_URL); - - CollectionUtils.goToCollection(driver, collectionName1); - CollectionUtils.goToCollection(driver, collectionName2); - CollectionUtils.goToCollection(driver, collectionName3); - } - - @After - public void tearDown() { - UiTestUtilities.logout(); - } - - @AfterClass - public static void tearDownAfterClass() { - UiTestUtilities.login(); - driver.get(UiTestUtilities.COLLECTIONS_URL); - wait.until(ExpectedConditions.elementToBeClickable(By.className("breadcrumb"))); - CollectionUtils.writeOnEditableBreadCrumb(driver, wait, CollectionUtils.RODS_COLL_PATH); - wait.until(ExpectedConditions - .visibilityOfElementLocated(By.cssSelector("#directoryPath .breadcrumb > li:last-of-type > span"))); - CollectionUtils.removeColl(driver, collectionName1); - UiTestUtilities.logout(); - - if (driver != null) { - driver.quit(); - driver = null; - UiTestUtilities.setDriver(null); - } - } - - /** - * Test if stack to go back in collection history is working and putting paths - * in the correct order. Creates collection and enters them to fill stack - */ - @Test - public void stackSimpleBackHistory() { - - // Checks if back button is enabled - Assert.assertTrue(checkButtonEnabled(driver, wait, backButtonLocator)); - - // checks if current path is correct - Assert.assertTrue(checkCurrentPath(driver, wait, arrayPaths[3])); - - // checks if older paths are in the correct order - List liElements = driver.findElements(inactivePathHistory); - for (int i = 0; i < liElements.size(); i++) { - Assert.assertEquals(arrayPaths[liElements.size() - i - 1], liElements.get(i).getText()); - } - - } - - /** - * Test forward stack checking is function and order of the list - */ - @Test - public void stackSimpleForwardHistory() { - - // going back in history stack - wait.until(ExpectedConditions.elementToBeClickable(dropdownHistoryButtonLocator)).click(); - wait.until(ExpectedConditions.visibilityOfElementLocated(dropdownHistoryMenuLocator)); - driver.findElement(By.cssSelector("#directoryPath > .btn-group > ul.dropdown-menu > li:last-child a")).click(); - - // making sure forward button got enabled - Assert.assertTrue(checkButtonEnabled(driver, wait, forwardButtonLocator)); - - // checks if current path is correct - Assert.assertTrue(checkCurrentPath(driver, wait, CollectionUtils.RODS_COLL_PATH)); - - // checks if older paths are in the correct order - List liElements = driver.findElements(inactivePathHistory); - for (int i = 0; i < liElements.size(); i++) { - Assert.assertEquals(arrayPaths[liElements.size() - i], liElements.get(i).getText()); - } - - } - - /** - * Test if a path passed in editable breadcrumb is stored in history stack - */ - @Test - public void stackFromEditableBreadcrumb() { - - // going to: /zone/home/user -> /zone -> /zone/home/user - wait.until(ExpectedConditions.elementToBeClickable(By.className("breadcrumb"))); - CollectionUtils.writeOnEditableBreadCrumb(driver, wait, CollectionUtils.RODS_COLL_PATH); - wait.until(ExpectedConditions.elementToBeClickable(By.className("breadcrumb"))); - CollectionUtils.writeOnEditableBreadCrumb(driver, wait, "/" + UiTestUtilities.IRODS_ZONE); - wait.until(ExpectedConditions.elementToBeClickable(By.className("breadcrumb"))); - CollectionUtils.writeOnEditableBreadCrumb(driver, wait, CollectionUtils.RODS_COLL_PATH); - - // creating the expected stack history - List historyStackTemp = new ArrayList(Arrays.asList(arrayPaths)); - historyStackTemp.add(CollectionUtils.RODS_COLL_PATH); - historyStackTemp.add("/" + UiTestUtilities.IRODS_ZONE); - - // checks if current path is correct - Assert.assertTrue(checkCurrentPath(driver, wait, CollectionUtils.RODS_COLL_PATH)); - - // checks if older paths are in the correct order - List liElements = driver.findElements(inactivePathHistory); - for (int i = 0; i < liElements.size(); i++) { - Assert.assertEquals(historyStackTemp.get(liElements.size() - i - 1), liElements.get(i).getText()); - } - - } - - /** - * Test if both back and forward stacks are in order if more than 1 step back is - * taken - */ - @Test - public void stackJumpStepsBack() { - - // going back in history stack - clickNthChildInHistory(driver, wait, 3); - - // making sure forward button got enabled - Assert.assertTrue(checkButtonEnabled(driver, wait, forwardButtonLocator)); - - // checks if current path is correct - Assert.assertTrue(checkCurrentPath(driver, wait, arrayPaths[1])); - - // checks if older paths are in the correct order - List liElements = driver.findElements(inactivePathHistory); - String[] expectedPaths = { arrayPaths[3], arrayPaths[2], arrayPaths[0] }; - for (int i = 0; i < liElements.size(); i++) { - Assert.assertEquals(expectedPaths[i], liElements.get(i).getText()); - } - - } - - /** - * Test if back and forward stacks are in order is more than 1 step forward is - * taken - */ - @Test - public void stackJumpStepsForward() { - // going back in history stack - clickNthChildInHistory(driver, wait, 3); - - wait.until(ExpectedConditions.elementToBeClickable(forwardButtonLocator)); - - // going forward in history stack - clickNthChildInHistory(driver, wait, 2); - - // making sure forward button got enabled - Assert.assertTrue(checkButtonEnabled(driver, wait, forwardButtonLocator)); - - // wait.until(ExpectedConditions.elementToBeClickable(forwardButtonLocator)); - try { - wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("çççç"))); - } catch (Exception e) { - } - - // checks if current path is correct - Assert.assertTrue(checkCurrentPath(driver, wait, arrayPaths[2])); - - // checks if older paths are in the correct order - List liElements = driver.findElements(inactivePathHistory); - String[] expectedPaths = { arrayPaths[3], arrayPaths[1], arrayPaths[0] }; - for (int i = 0; i < liElements.size(); i++) { - Assert.assertEquals(expectedPaths[i], liElements.get(i).getText()); - } - - } - - /** - * Creates 3 collections, each a child of the previously created collection - * - * @param driver - * @param wait - */ - private static void createCollectionHistoryTree(WebDriver driver, WebDriverWait wait) { - // creating first level collection - CollectionUtils.createCollection(driver, collectionName1); - - // entering first level collection - CollectionUtils.goToCollection(driver, collectionName1); - - // creating second level collection - CollectionUtils.createCollection(driver, collectionName2); - - // entering second level collection - CollectionUtils.goToCollection(driver, collectionName2); - - // creating third level collection - CollectionUtils.createCollection(driver, collectionName3); - - // entering third level collection - CollectionUtils.goToCollection(driver, collectionName3); - } - - /** - * Check if current path in history stack is the same as the expected path - * - * @param driver - * @param wait - * @param expectedPath - * @return - */ - private boolean checkCurrentPath(WebDriver driver, WebDriverWait wait, String expectedPath) { - wait.until(ExpectedConditions.elementToBeClickable(dropdownHistoryButtonLocator)).click(); - wait.until(ExpectedConditions.elementToBeClickable(dropdownHistoryMenuLocator)); - String currentPathInStack = driver - .findElement(By.cssSelector("#directoryPath > .btn-group > .dropdown-menu > .active a")).getText(); - return expectedPath.equals(currentPathInStack); - } - - /** - * Check if the button indicated by the locator is enabled - * - * @param driver - * @param wait - * @param buttonLocator - * @return - */ - private boolean checkButtonEnabled(WebDriver driver, WebDriverWait wait, By buttonLocator) { - wait.until(ExpectedConditions.elementToBeClickable(buttonLocator)); - String buttonDisabled = driver.findElement(buttonLocator).getAttribute("disabled"); - if (buttonDisabled == null) { - return true; - } - return false; - } - - /** - * Click on the n-th child displayed in the drop down menu in history buttons - * - * @param driver - * @param wait - * @param nth - */ - private void clickNthChildInHistory(WebDriver driver, WebDriverWait wait, int nth) { - String selectorString = String.format("#directoryPath > .btn-group > ul.dropdown-menu > li:nth-child(%d) a", - nth); - wait.until(ExpectedConditions.elementToBeClickable(dropdownHistoryButtonLocator)).click(); - wait.until(ExpectedConditions.visibilityOfElementLocated(dropdownHistoryMenuLocator)); - driver.findElement(By.cssSelector(selectorString)).click(); - } -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/collection/MetadataTest.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/collection/MetadataTest.java deleted file mode 100755 index 79a814e66..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/collection/MetadataTest.java +++ /dev/null @@ -1,423 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.integration.test.collection; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import java.util.List; -import java.util.Random; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.Select; -import org.openqa.selenium.support.ui.WebDriverWait; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.emc.metalnx.integration.test.utils.MetadataUtils; -import com.emc.metalnx.test.generic.UiTestUtilities; - -@Deprecated -@Ignore -public class MetadataTest { - - private static final Logger logger = LoggerFactory.getLogger(MetadataTest.class); - private static WebDriver driver = null; - private static WebDriverWait wait = null; - - @BeforeClass - public static void setUpBeforeClass() { - // UITest.setUpBeforeClass(); - driver = UiTestUtilities.getDriver(); - wait = new WebDriverWait(driver, 10); - } - - /** - * Logs in before each test. - */ - @Before - public void setUp() { - UiTestUtilities.login(); - } - - /** - * After each test the user is logged out. - */ - @After - public void tearDown() { - UiTestUtilities.logout(); - } - - /** - * After all tests are done, the test must quit the driver. This will close - * every window associated with the current driver instance. - */ - - @AfterClass - public static void tearDownAfterClass() { - if (driver != null) { - driver.quit(); - driver = null; - UiTestUtilities.setDriver(null); - } - } - - /* - * ***************************************************************************** - * *************** ******************************* METADATA TAB - * ******************************************* - * ***************************************************************************** - * *************** - */ - - /** - * Test method for adding a new metadata tag to a collection or file. It - * verifies if this new metadata was added to the list and if metadata count was - * incremented by one - */ - @Test - public void testAddMetadata() { - - logger.info("Testing if adding metadata works"); - - String attribute = "timestamp"; - String value = String.valueOf(System.currentTimeMillis()); - String unit = "ms"; - - boolean foundRow = false; - driver.get(UiTestUtilities.COLLECTIONS_URL); - MetadataUtils.addMetadata(driver, attribute, value, unit); - - // checks if a success message is displayed - wait.until(ExpectedConditions.presenceOfElementLocated(By.id("metadataSuccessAddedMsg"))); - // check if success message is displayed - assertTrue(driver.findElement(By.id("metadataSuccessAddedMsg")).isDisplayed()); - - // checks if row is in the list of metadatas - filterTableAndWaitResult(value); - List metadataChkboxs = driver.findElements(By.className("metadataCheckbox")); - for (WebElement we : metadataChkboxs) { - if (avuExistsInWebElement(we, attribute, value, unit)) { - foundRow = true; - break; - } - } - - assertTrue(foundRow); - } - - /** - * Test method for modifying a metadata tag from a collection or file. It - * verifies if this new metadata was modified - */ - @Test - public void testModMetadata() { - - logger.info("Testing if modifying metadata works"); - - // adding a new metadata in case there is no metadata attached in the - // colletcion/file - String attributeTS = "timestamp"; - String valueTS = String.valueOf(System.currentTimeMillis()); - String unitTS = "ms"; - driver.get(UiTestUtilities.COLLECTIONS_URL); - MetadataUtils.addMetadata(driver, attributeTS, valueTS, unitTS); - - // MetadataUtils.openMetadataTab(driver); - - // find row to modify it - wait.until(ExpectedConditions.invisibilityOfElementLocated(By.cssSelector(".modal-backdrop.fade.in"))); - wait.until(ExpectedConditions.visibilityOfElementLocated( - By.cssSelector("#metadaTable tbody tr:first-child button.enableEditAVUActionColumn"))).click(); - // driver.findElement(By.cssSelector("#metadaTable tbody tr:first-child - // button.enableEditAVUActionColumn")).click(); - - // inputs of the form - wait.until(ExpectedConditions - .elementToBeClickable(By.cssSelector("#metadaTable tbody tr:first-child .saveEditAVUActionColumn"))); - driver.findElement(By.cssSelector("#metadaTable tbody tr:first-child .newAttrMetadataTable")).sendKeys("_mod"); - - // sending form - driver.findElement(By.cssSelector("#metadaTable tbody tr:first-child .saveEditAVUActionColumn")).click(); - - // checks if a success message is displayed - wait.until(ExpectedConditions.presenceOfElementLocated(By.id("metadataSuccessModMsg"))); - // check if success message is displayed - assertTrue(driver.findElement(By.id("metadataSuccessModMsg")).isDisplayed()); - - } - - /** - * Test method for deleting a metadata tag from a collection or file. It - * verifies if this new metadata was deleted from the list - */ - @Test - public void testDelMetadata() { - - logger.info("Testing if removing metadata works"); - - // adding a new metadata in case there is no metadata attached in the - // colletcion/file - String attributeTS = "timestamp"; - String valueTS = String.valueOf(System.currentTimeMillis()); - String unitTS = "ms"; - boolean foundRow = false; - driver.get(UiTestUtilities.COLLECTIONS_URL); - MetadataUtils.addMetadata(driver, attributeTS, valueTS, unitTS); - - MetadataUtils.openMetadataTab(driver); - - // find row to delete it - wait.until(ExpectedConditions - .visibilityOfElementLocated(By.cssSelector("#metadaTable tbody tr:first-child .metadataCheckbox"))); - WebElement chkbx = driver.findElement(By.cssSelector("#metadaTable tbody tr:first-child .metadataCheckbox")); - - String attr = chkbx.getAttribute("data-attr"); - String val = chkbx.getAttribute("data-val"); - String unit = chkbx.getAttribute("data-unit"); - chkbx.click(); - - // delete the metadata - driver.findElement(By.cssSelector("#metadaTable tbody tr:first-child .deleteAVUActionColumn")).click(); - wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("deleteMetadataModal"))); - driver.findElement(By.cssSelector("#deleteMetadataModal .btn-primary")).click(); - - // checking if element was indeed removed - filterTableAndWaitResult(val); - List metadataChkboxs = driver.findElements(By.className("metadataCheckbox")); - for (WebElement we : metadataChkboxs) { - if (avuExistsInWebElement(we, attr, val, unit)) { - foundRow = true; - break; - } - } - - assertFalse(foundRow); - } - - /** - * Test method to try creating an existing metadata tag from a collection or - * file. It verifies if this metadata was not duplicated - */ - @Test - public void testSaveExistingMetadata() { - - logger.info("Testing if saving an existing metadata fails"); - - // adding a new metadata in case there is no metadata attached in the - // colletcion/file - String attributeTS = "timestamp"; - String valueTS = String.valueOf(System.currentTimeMillis()); - String unitTS = "ms"; - int foundRow = 0; - driver.get(UiTestUtilities.COLLECTIONS_URL); - MetadataUtils.addMetadata(driver, attributeTS, valueTS, unitTS); - - // MetadataUtils.openMetadataTab(driver); - - // find first row to copy its values - wait.until(ExpectedConditions.presenceOfElementLocated(By.id("metadaTable"))); - WebElement chkbx = driver.findElement(By.cssSelector("#metadaTable tbody tr:first-child .metadataCheckbox")); - - String attr = chkbx.getAttribute("data-attr"); - String val = chkbx.getAttribute("data-val"); - String unit = chkbx.getAttribute("data-unit"); - - // openning addMetadata modal - MetadataUtils.openAddMetadataModalAndSendForm(driver, attr, val, unit); - - // checks if an error message is displayed - wait.until(ExpectedConditions - .visibilityOfElementLocated(By.cssSelector(".browse-collection-files-content .alert-danger"))); - WebElement divAlertError = driver.findElement(By.cssSelector(".browse-collection-files-content .alert-danger")); - // check if success message is displayed - assertTrue(divAlertError.isDisplayed()); - - // checking if element was not created indeed - filterTableAndWaitResult(val); - List metadataChkboxs = driver.findElements(By.className("metadataCheckbox")); - for (WebElement we : metadataChkboxs) { - if (avuExistsInWebElement(we, attr, val, unit)) { - foundRow++; - } - } - - // If foundRow is bigger than 1, it means there is a metadata duplicated. - // If it is 0, then for some reason the metadata was removed - assertEquals(1, foundRow); - } - - /** - * Test method to try creating an empty metadata tag in a collection or file. It - * verifies if this metadata was not created - */ - @Test - public void testSaveEmptyMetadata() { - - logger.info("Testing if saving an empty metadata fails"); - - boolean foundRow = false; - - driver.get(UiTestUtilities.COLLECTIONS_URL); - MetadataUtils.openMetadataTab(driver); - - String attr = ""; - String val = ""; - String unit = ""; - - // openning addMetadata modal - MetadataUtils.openAddMetadataModalAndSendForm(driver, attr, val, unit); - - // checks if an error message is displayed - wait.until(ExpectedConditions - .visibilityOfElementLocated(By.cssSelector(".browse-collection-files-content .alert-danger"))); - WebElement divAlertError = driver.findElement(By.cssSelector(".browse-collection-files-content .alert-danger")); - // check if success message is displayed - assertTrue(divAlertError.isDisplayed()); - - // checking if element was not created removed - filterTableAndWaitResult(val); - List metadataChkboxs = driver.findElements(By.className("metadataCheckbox")); - for (WebElement we : metadataChkboxs) { - if (avuExistsInWebElement(we, attr, val, unit)) { - foundRow = true; - } - } - - assertFalse(foundRow); - } - - /** - * Test method to try creating a large metadata tag in a collection or file. It - * verifies if this metadata was created without problems Limit for metadata - * value is 64 characters - */ - @Test - public void testSaveLargeMetadata() { - - logger.info("Testing if removing metadata works"); - - boolean foundRow = false; - - driver.get(UiTestUtilities.COLLECTIONS_URL); - MetadataUtils.openMetadataTab(driver); - - // generating a big string - char[] chars = "abcdefghijklmnopqrstuvwxyz".toCharArray(); - StringBuilder sb = new StringBuilder(); - Random random = new Random(); - for (int i = 0; i < 63; i++) { - char c = chars[random.nextInt(chars.length)]; - sb.append(c); - } - String attr = sb.toString(); - String val = sb.toString(); - String unit = sb.toString(); - - // openning addMetadata modal - MetadataUtils.openAddMetadataModalAndSendForm(driver, attr, val, unit); - - // checks if a success message is displayed - wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("metadataSuccessAddedMsg"))); - WebElement divAlertSuccess = driver.findElement(By.id("metadataSuccessAddedMsg")); - // check if success message is displayed - assertTrue(divAlertSuccess.isDisplayed()); - - // checking if element was created removed - filterTableAndWaitResult(val); - List metadataChkboxs = driver.findElements(By.className("metadataCheckbox")); - for (WebElement we : metadataChkboxs) { - if (avuExistsInWebElement(we, attr, val, unit)) { - foundRow = true; - } - } - - assertTrue(foundRow); - } - - /** - * Test method for deleting all metadata from a collection or file. It verifies - * if all metadata from a collection/file were deleted - */ - @Test - @Ignore - public void testDelAllMetadata() { - - logger.info("Testing if adding metadata works"); - - String attributeTS = "timestamp"; - String valueTS = String.valueOf(System.currentTimeMillis()); - String unitTS = "ms"; - driver.get(UiTestUtilities.COLLECTIONS_URL); - MetadataUtils.addMetadata(driver, attributeTS, valueTS, unitTS); - - // opens metadata tab - MetadataUtils.openMetadataTab(driver); - - // find select all metadata checkbox - wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("checkAllMetadata"))); - WebElement chkbx = driver.findElement(By.id("checkAllMetadata")); - chkbx.click(); - - // delete the metadata - driver.findElement(By.id("delMetadataBtn")).click(); - wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("#deleteMetadataModal .btn-primary"))); - driver.findElement(By.cssSelector("#deleteMetadataModal .btn-primary")).click(); - - // checks if row is in the list of metadatas - List metadataChkboxs = driver.findElements(By.className("metadataCheckbox")); - - assertTrue(metadataChkboxs.isEmpty()); - } - - /** - * Method to test if a certain WebElement contains the avu tuple passed as - * parameters - */ - private boolean avuExistsInWebElement(WebElement we, String attr, String val, String unit) { - if (attr.equals(we.getAttribute("data-attr")) && val.equals(we.getAttribute("data-val")) - && unit.equals(we.getAttribute("data-unit"))) { - return true; - } - return false; - } - - /** - * Search for a value in metadatatable and waits until the table is drawn again - */ - private void filterTableAndWaitResult(String searchString) { - wait.until(ExpectedConditions - .elementToBeClickable(By.cssSelector("#metadaTable_length select[name='metadaTable_length']"))); - Select selectPageSize = new Select( - driver.findElement(By.cssSelector("#metadaTable_length select[name='metadaTable_length']"))); - selectPageSize.selectByValue("100"); - wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("#metadaTable_filter input"))) - .sendKeys(searchString); - wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.cssSelector("#metadaTable tbody tr"))); - } - -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/collection/ReplicateFileTest.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/collection/ReplicateFileTest.java deleted file mode 100755 index ba07db14c..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/collection/ReplicateFileTest.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.integration.test.collection; - -import java.util.List; - -import org.irods.jargon.core.exception.JargonException; -import org.irods.jargon.core.pub.DataObjectAO; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; - -import com.emc.metalnx.core.domain.exceptions.DataGridException; -import com.emc.metalnx.integration.test.utils.CollectionUtils; -import com.emc.metalnx.integration.test.utils.FileUtils; -import com.emc.metalnx.test.generic.UiTestUtilities; - -@Deprecated -@Ignore -public class ReplicateFileTest { - private static int NUMBER_OF_ITERATIONS = 100; - private static WebDriver driver = null; - private static final String TEST_FILE = "1SeleniumTestMetadataSearch.png"; - private static String irodsCollectionAbsolutePath = String.format("/%s/home/%s/", UiTestUtilities.IRODS_ZONE, - UiTestUtilities.RODS_USERNAME); - private static String irodsFileAbsolutePath = String.format("%s%s", irodsCollectionAbsolutePath, TEST_FILE); - private static String targetResource = "targetResource"; - private static WebDriverWait wait; - - @BeforeClass - public static void setUpBeforeClass() { - // UITest.setUpBeforeClass(); - driver = UiTestUtilities.getDriver(); - wait = new WebDriverWait(driver, 10); - } - - @Before - public void setUp() throws Exception { - FileUtils.removeFilesFromHomeAsAdmin(TEST_FILE); - UiTestUtilities.login(); - } - - /** - * After each test the user created for the test should be removed. - */ - @After - public void tearDown() throws Exception { - FileUtils.removeFilesFromHomeAsAdmin(TEST_FILE); - UiTestUtilities.logout(); - } - - /** - * After all tests are done, the test must quit the driver. This will close - * every window associated with the current driver instance. - */ - - @AfterClass - public static void tearDownAfterClass() { - if (driver != null) { - driver.quit(); - driver = null; - UiTestUtilities.setDriver(null); - } - } - - @Test - public void testUploadAFileAndReplicateIt() throws DataGridException { - driver.get(UiTestUtilities.COLLECTIONS_URL); - - int i; - for (i = 0; i < NUMBER_OF_ITERATIONS; i++) { - FileUtils.uploadToHomeDirAsAdmin(TEST_FILE); - CollectionUtils.replicateFile(driver, targetResource, TEST_FILE); - Assert.assertTrue(isDataObjectReplicated(targetResource, TEST_FILE)); - FileUtils.removeFilesFromHomeAsAdmin(TEST_FILE); - } - - Assert.assertTrue(NUMBER_OF_ITERATIONS - i == 0); - } - - @Test - public void testReplicateFile() throws DataGridException { - FileUtils.uploadToHomeDirAsAdmin(TEST_FILE); - - driver.get(UiTestUtilities.COLLECTIONS_URL); - - int i; - for (i = 0; i < NUMBER_OF_ITERATIONS; i++) { - CollectionUtils.goToHomeCollection(driver); - CollectionUtils.replicateFile(driver, targetResource, TEST_FILE); - CollectionUtils.waitForSuccessMessage(driver); - CollectionUtils.deleteFileReplicas(driver, irodsFileAbsolutePath); - } - - Assert.assertTrue(NUMBER_OF_ITERATIONS - i == 0); - } - - @Test - public void testReplicateFileAfterUploadUsingJargonAPIDirectly() throws DataGridException, JargonException { - DataObjectAO dataObectAO = FileUtils.getDataObjectAO(UiTestUtilities.RODS_USERNAME, UiTestUtilities.RODS_PASSWORD); - driver.get(UiTestUtilities.COLLECTIONS_URL); - - int i; - for (i = 0; i < NUMBER_OF_ITERATIONS; i++) { - FileUtils.uploadToHomeDirAsAdmin(TEST_FILE); - dataObectAO.replicateIrodsDataObject(irodsFileAbsolutePath, targetResource); - FileUtils.removeFilesFromHomeAsAdmin(TEST_FILE); - } - - Assert.assertTrue(NUMBER_OF_ITERATIONS - i == 0); - } - - private boolean isDataObjectReplicated(String resource, String filename) { - CollectionUtils.goToHomeCollection(driver); - - By file = By.cssSelector("a[name=\"" + irodsFileAbsolutePath + "\"]"); - CollectionUtils.goToHomeCollection(driver); - - wait.until(ExpectedConditions.elementToBeClickable(file)); - driver.findElement(file).click(); - - CollectionUtils.waitForReplicasTable(driver); - - boolean isReplicated = false; - List replicas = driver.findElements(By.cssSelector("#replicaAndChecksumInfo table tbody tr td")); - for (WebElement r : replicas) { - if (resource.equalsIgnoreCase(r.getText())) { - isReplicated = true; - break; - } - } - - CollectionUtils.goToHomeCollection(driver); - - return isReplicated; - } -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/dashboard/DashboardIsilonTest.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/dashboard/DashboardIsilonTest.java deleted file mode 100755 index b77239b94..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/dashboard/DashboardIsilonTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.integration.test.dashboard; - -import com.emc.metalnx.core.domain.exceptions.DataGridException; -import com.emc.metalnx.integration.test.utils.ResourceUtils; -import com.emc.metalnx.test.generic.UiTestUtilities; -import org.junit.*; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; - -@Deprecated -@Ignore -public class DashboardIsilonTest { - - private static WebDriver driver = null; - private static WebDriverWait wait = null; - - private static final String RESOURCE_NAME = "fakeIsilonResc"; - private static final String RESOURCE_PATH = "/data/isilonVault1"; - private static final String ISILON_HOST = "192.168.11.2"; - private static final String ISILON_PORT = "8020"; - private static final String ISILON_USER = "root"; - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - UiTestUtilities.init(); - driver = UiTestUtilities.getDriver(); - } - - @Before - public void setUp() throws Exception { - wait = new WebDriverWait(driver, 8); - UiTestUtilities.login(); - ResourceUtils.addIsilonResource(RESOURCE_NAME, null, UiTestUtilities.IRODS_ZONE, RESOURCE_PATH, ISILON_HOST, ISILON_PORT, ISILON_USER, driver); - UiTestUtilities.logout(); - } - - @Test - public void testIsilonRescOnDashboard() { - UiTestUtilities.login(); - wait.until(ExpectedConditions.visibilityOfElementLocated(By.className("dashboardServersList"))); - wait.until(ExpectedConditions.invisibilityOfElementLocated(By.linkText("localhost"))); - UiTestUtilities.logout(); - } - - @After - public void tearDown() throws Exception { - UiTestUtilities.login(); - ResourceUtils.removeResource(RESOURCE_NAME, driver); - UiTestUtilities.logout(); - } - - @AfterClass - public static void tearDownAfterClass() throws DataGridException { - if (driver != null) { - driver.quit(); - driver = null; - UiTestUtilities.setDriver(null); - } - } - -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/datatables/PageSizeSelectorRodsUserTest.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/datatables/PageSizeSelectorRodsUserTest.java deleted file mode 100755 index baa19926e..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/datatables/PageSizeSelectorRodsUserTest.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.integration.test.datatables; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.openqa.selenium.WebDriver; - -import com.emc.metalnx.core.domain.exceptions.DataGridException; -import com.emc.metalnx.integration.test.utils.UserUtils; -import com.emc.metalnx.test.generic.UiTestUtilities; - -/** - * Class that tests the application of a template with metadata fields on files. - */ - -@Deprecated -@Ignore -public class PageSizeSelectorRodsUserTest { - - private static WebDriver driver = null; - private static String uname = "PageSizeUser" + System.currentTimeMillis(); - private static String pwd = "PageSize"; - - /************************************* - * TEST SET UP - *************************************/ - - @BeforeClass - public static void setUpBeforeClass() throws DataGridException { - // UITest.setUpBeforeClass(); - driver = UiTestUtilities.getDriver(); - UserUtils.createUser(uname, pwd, UiTestUtilities.RODS_USER_TYPE, driver); - } - - @Before - public void setUp() throws Exception { - UiTestUtilities.login(uname, pwd); - } - - @After - public void tearDown() throws Exception { - UiTestUtilities.logout(); - } - - /** - * After all tests are done, the test must quit the driver. This will close - * every window associated with the current driver instance. - */ - - @AfterClass - public static void tearDownAfterClass() { - if (driver != null) { - UserUtils.removeUser(uname, driver); - driver.quit(); - driver = null; - UiTestUtilities.setDriver(null); - } - } - - /************************************* - * TESTS - *************************************/ - - /** - * Method that the page size selector component on the collections page. - */ - @Test - public void testPageSizeSelectorOnCollsPage() { - for (String ps : PageSizeSelectorUtils.PAGE_SIZES) { - PageSizeSelectorUtils.assertPageSize(driver, UiTestUtilities.COLLECTIONS_URL, ps); - } - } - - /** - * Method that the page size selector component on the trash page. - */ - @Test - public void testPageSizeSelectorOnTrashPage() { - for (String ps : PageSizeSelectorUtils.PAGE_SIZES) { - PageSizeSelectorUtils.assertPageSize(driver, UiTestUtilities.TRASH_URL, ps); - } - } - - /** - * Method that the page size selector component on the trash page. - */ - @Test - public void testPageSizeSelectorOnPublicPage() { - for (String ps : PageSizeSelectorUtils.PAGE_SIZES) { - PageSizeSelectorUtils.assertPageSize(driver, UiTestUtilities.PUBLIC_URL, ps); - } - } -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/datatables/PageSizeSelectorTest.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/datatables/PageSizeSelectorTest.java deleted file mode 100755 index a0bf50265..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/datatables/PageSizeSelectorTest.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.integration.test.datatables; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.openqa.selenium.WebDriver; - -import com.emc.metalnx.core.domain.exceptions.DataGridException; -import com.emc.metalnx.test.generic.UiTestUtilities; - -/** - * Class that tests the application of a template with metadata fields on files. - */ - -@Deprecated -@Ignore -public class PageSizeSelectorTest { - - private static WebDriver driver = null; - - /************************************* - * TEST SET UP - *************************************/ - - @BeforeClass - public static void setUpBeforeClass() throws DataGridException { - // UITest.setUpBeforeClass(); - driver = UiTestUtilities.getDriver(); - } - - @Before - public void setUp() throws Exception { - UiTestUtilities.login(); - } - - @After - public void tearDown() throws Exception { - UiTestUtilities.logout(); - } - - /** - * After all tests are done, the test must quit the driver. This will close - * every window associated with the current driver instance. - */ - - @AfterClass - public static void tearDownAfterClass() { - if (driver != null) { - driver.quit(); - driver = null; - UiTestUtilities.setDriver(null); - } - } - - /************************************* - * TESTS - *************************************/ - - /** - * Method that the page size selector component on the collections page. - */ - @Test - public void testPageSizeSelectorOnCollsPage() { - for (String ps : PageSizeSelectorUtils.PAGE_SIZES) { - PageSizeSelectorUtils.assertPageSize(driver, UiTestUtilities.COLLECTIONS_URL, ps); - } - } - - /** - * Method that the page size selector component on the users page. - */ - @Test - public void testPageSizeSelectorOnUsersPage() { - for (String ps : PageSizeSelectorUtils.PAGE_SIZES) { - PageSizeSelectorUtils.assertPageSize(driver, UiTestUtilities.USERS_URL, ps); - } - } - - /** - * Method that the page size selector component on the groups page. - */ - @Test - public void testPageSizeSelectorOnGroupsPage() { - for (String ps : PageSizeSelectorUtils.PAGE_SIZES) { - PageSizeSelectorUtils.assertPageSize(driver, UiTestUtilities.GROUPS_URL, ps); - } - } - - /** - * Method that the page size selector component on the resources page. - */ - @Test - public void testPageSizeSelectorOnResourcesPage() { - for (String ps : PageSizeSelectorUtils.PAGE_SIZES) { - PageSizeSelectorUtils.assertPageSize(driver, UiTestUtilities.RESOURCES_URL, ps); - } - } -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/datatables/PageSizeSelectorUtils.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/datatables/PageSizeSelectorUtils.java deleted file mode 100755 index 61e177f72..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/datatables/PageSizeSelectorUtils.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.integration.test.datatables; - -import com.emc.metalnx.test.generic.UiTestUtilities; -import junit.framework.Assert; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.Select; -import org.openqa.selenium.support.ui.WebDriverWait; - -import java.util.HashMap; -import java.util.Map; - -@Deprecated -public class PageSizeSelectorUtils { - - public static final String[] PAGE_SIZES = { "10", "25", "50", "100" }; - - private static By collsPageSizeSelector = By.name("treeViewTable_length"); - private static By usersPageSizeSelector = By.name("usersListTable_length"); - private static By groupsPageSizeSelector = By.name("groupsListTable_length"); - private static By resourcesPageSizeSelector = By.name("resourcesListTable_length"); - - private static Map pageSizeSelectorMap; - static { - pageSizeSelectorMap = new HashMap(); - pageSizeSelectorMap.put(UiTestUtilities.COLLECTIONS_URL, collsPageSizeSelector); - pageSizeSelectorMap.put(UiTestUtilities.TRASH_URL, collsPageSizeSelector); - pageSizeSelectorMap.put(UiTestUtilities.PUBLIC_URL, collsPageSizeSelector); - pageSizeSelectorMap.put(UiTestUtilities.USERS_URL, usersPageSizeSelector); - pageSizeSelectorMap.put(UiTestUtilities.GROUPS_URL, groupsPageSizeSelector); - pageSizeSelectorMap.put(UiTestUtilities.RESOURCES_URL, resourcesPageSizeSelector); - } - - /** - * Auxiliar method that asserts if the page size selected matches the current page size - * displayed after refreshing the page. - * Table: Collections Management. - * - * @param driver - * @param pageSize - * {@link String} representing the page size (10, 25, 50, 100) - */ - public static void assertPageSize(WebDriver driver, String url, String pageSize) { - driver.get(url); - waitForTable(driver, url); - selectPageSize(driver, url, pageSize); - try { - new WebDriverWait(driver, 1).until(ExpectedConditions.elementToBeClickable(By.id("çççç"))); - } - catch (Exception e) { - - } - waitForTable(driver, url); - driver.get(url); - waitForTable(driver, url); - Assert.assertEquals(pageSize, findCurrentPageSize(driver, url)); - } - - /** - * Selects a page size from the page size selector list. - * - * @param pageSize - * {@link String} representing the required page size - */ - public static void selectPageSize(WebDriver driver, String url, String pageSize) { - waitForPageSizeSelector(driver, url); - new Select(driver.findElement(pageSizeSelectorMap.get(url))).selectByValue(pageSize); - waitForPageSizeSelector(driver, url); - } - - /** - * Finds what is the current page size. - * - * @return {@link String} representing the current page size - */ - public static String findCurrentPageSize(WebDriver driver, String url) { - return new Select(driver.findElement(pageSizeSelectorMap.get(url))).getFirstSelectedOption().getText(); - } - - /** - * Waits for the page size selector component to be loaded. - * - * @param driver - * @param url - */ - public static void waitForPageSizeSelector(WebDriver driver, String url) { - new WebDriverWait(driver, 10).until(ExpectedConditions.elementToBeClickable(pageSizeSelectorMap.get(url))); - } - - /** - * Waits for the current page's table to load. - * - * @param driver - * @param url - */ - public static void waitForTable(WebDriver driver, String url) { - new WebDriverWait(driver, 10).until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("table tbody tr:first-child td"))); - } -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/fileproperties/FilePropertiesSearchTest.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/fileproperties/FilePropertiesSearchTest.java deleted file mode 100755 index cbbce2c10..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/fileproperties/FilePropertiesSearchTest.java +++ /dev/null @@ -1,395 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.integration.test.fileproperties; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.Select; -import org.openqa.selenium.support.ui.WebDriverWait; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.emc.metalnx.core.domain.exceptions.DataGridException; -import com.emc.metalnx.integration.test.utils.FileUtils; -import com.emc.metalnx.integration.test.utils.UserUtils; -import com.emc.metalnx.test.generic.UiTestUtilities; - -@Deprecated -@Ignore -public class FilePropertiesSearchTest { - private static final Logger logger = LoggerFactory.getLogger(FilePropertiesSearchTest.class); - private static WebDriver driver = null; - private static WebDriverWait wait = null; - - private By submitPropertiesSearchLocator = By.id("submitPropertiesSearch"); - private By addSearchParamLocator = By.id("addPropertiesSearchRow"); - - public static final String[] SEARCH_FILES = { "1SeleniumTestMetadataSearch.png" }; - - private String userHomeColl = String.format("/%s/%s/%s", UiTestUtilities.IRODS_ZONE, "home", UiTestUtilities.RODS_USERNAME); - private String filePath = String.format("%s/%s", userHomeColl, SEARCH_FILES[0]); - - private enum AttributeOptions { - FILE_NAME, FILE_PATH, RESC_NAME, OWNER_NAME, CREATION_DATE, MODIFICATION_DATE, SIZE, REPLICA_NUMBER, CHECKSUM, COMMENT - } - - private enum OperatorOptions { - EQUAL, NOT_EQUAL, LIKE, NOT_LIKE, LESS_THAN, BIGGER_THAN - } - - @BeforeClass - public static void setUpBeforeClass() throws DataGridException { - // UITest.setUpBeforeClass(); - driver = UiTestUtilities.getDriver(); - wait = new WebDriverWait(driver, 10); - FileUtils.uploadToHomeDirAsAdmin(SEARCH_FILES); - } - - @Before - public void setUp() { - UiTestUtilities.login(); - - } - - @After - public void tearDown() { - UiTestUtilities.logout(); - } - - @AfterClass - public static void tearDownAfterClass() throws DataGridException { - FileUtils.forceRemoveFilesFromHomeAsAdmin(SEARCH_FILES); - - if (driver != null) { - driver.quit(); - driver = null; - UiTestUtilities.setDriver(null); - } - } - - /** - * Method to test if an empty search will generate an empty table - */ - @Test - public void emptySearch() { - logger.info("Testing file properties search"); - - // getting to the file properties search tab - getFilePropertiesSearchTab(); - - // hitting search without adding value in search - submitAndCheckEmptyTable(); - - } - - /** - * Search for files that have one file property that matches the search criteria - * - * @throws DataGridException - */ - @Test - public void searchEqualsOneCriteriaWithResults() throws DataGridException { - // getting to the file properties search tab - getFilePropertiesSearchTab(); - - fillSearchInFisrtField(AttributeOptions.FILE_PATH.toString(), OperatorOptions.EQUAL.toString(), filePath); - - submitAndCheckNotEmptyTable(); - checkIfUploadedFileExist(); - } - - /** - * Search by one file property and expects that no results will be found - */ - @Test - public void searchEqualsOneCriteriaWithoutResults() { - // getting to the file properties search tab - getFilePropertiesSearchTab(); - - fillSearchInFisrtField(AttributeOptions.OWNER_NAME.toString(), OperatorOptions.EQUAL.toString(), - "FilePropertyInexistentUser" + System.currentTimeMillis()); - - // submiting form and assert result - submitAndCheckEmptyTable(); - } - - /** - * Search using Not Equals - */ - @Test - public void searchNotEqualsOneCriteriaWithResults() { - // getting to the file properties search tab - getFilePropertiesSearchTab(); - - fillSearchInFisrtField(AttributeOptions.FILE_PATH.toString(), OperatorOptions.NOT_EQUAL.toString(), - userHomeColl); - - submitAndCheckNotEmptyTable(); - } - - /** - * Search using Contains with results - * - * @throws DataGridException - */ - @Test - public void searchContainsOneCriteriaWithResults() throws DataGridException { - // getting to the file properties search tab - getFilePropertiesSearchTab(); - - fillSearchInFisrtField(AttributeOptions.FILE_PATH.toString(), OperatorOptions.LIKE.toString(), filePath); - - submitAndCheckNotEmptyTable(); - checkIfUploadedFileExist(); - } - - /** - * Search using Contains with no results - */ - @Test - public void searchContainsOneCriteriaWithoutResults() { - // getting to the file properties search tab - getFilePropertiesSearchTab(); - - fillSearchInFisrtField(AttributeOptions.FILE_PATH.toString(), OperatorOptions.LIKE.toString(), - "/FilePropertyInexistentObj" + System.currentTimeMillis()); - - // submiting form and assert result - submitAndCheckEmptyTable(); - } - - /** - * Search using Not Contains with results - */ - @Test - public void searchNotContainsOneCriteriaWithResults() { - // getting to the file properties search tab - getFilePropertiesSearchTab(); - - fillSearchInFisrtField(AttributeOptions.FILE_PATH.toString(), OperatorOptions.NOT_LIKE.toString(), - userHomeColl); - - submitAndCheckNotEmptyTable(); - } - - /** - * Search using Not Contains with no results - */ - @Test - public void searchNotContainsOneCriteriaWithoutResults() { - // getting to the file properties search tab - getFilePropertiesSearchTab(); - - fillSearchInFisrtField(AttributeOptions.FILE_PATH.toString(), OperatorOptions.NOT_LIKE.toString(), "/"); - - // submiting form and assert result - submitAndCheckEmptyTable(); - } - - /** - * Search using 3 different criteria - */ - @Test - public void searchMultipleCriteriasWithResults() { - // getting to the file properties search tab - getFilePropertiesSearchTab(); - - // setting first criteria - fillSearchInFisrtField(AttributeOptions.OWNER_NAME.toString(), OperatorOptions.EQUAL.toString(), "rods"); - - // adding a new criteria search field - driver.findElement(addSearchParamLocator).click(); - wait.until( - ExpectedConditions.visibilityOfElementLocated(By.cssSelector(".propertiesSearchRow:nth-of-type(2)"))); - - // setting second criteria - fillSearchInNthField(AttributeOptions.FILE_PATH.toString(), OperatorOptions.LIKE.toString(), "rods", 2); - - // adding a new criteria search field - driver.findElement(addSearchParamLocator).click(); - wait.until( - ExpectedConditions.visibilityOfElementLocated(By.cssSelector(".propertiesSearchRow:nth-of-type(3)"))); - - // setting third criteria - fillSearchInNthField(AttributeOptions.SIZE.toString(), OperatorOptions.BIGGER_THAN.toString(), "0", 3); - - // submiting form and assert result - submitAndCheckNotEmptyTable(); - } - - /** - * Search using opposite operators: Equals and Not Equals - */ - @Test - public void searchEqualsAndNotEquals() { - // getting to the file properties search tab - getFilePropertiesSearchTab(); - - // setting first criteria - fillSearchInFisrtField(AttributeOptions.OWNER_NAME.toString(), OperatorOptions.EQUAL.toString(), "rods"); - - // adding a new criteria search field - driver.findElement(addSearchParamLocator).click(); - wait.until( - ExpectedConditions.visibilityOfElementLocated(By.cssSelector(".propertiesSearchRow:nth-of-type(2)"))); - - // setting second criteria - fillSearchInNthField(AttributeOptions.OWNER_NAME.toString(), OperatorOptions.NOT_EQUAL.toString(), "rods", 2); - - // submiting form and assert result - submitAndCheckEmptyTable(); - } - - /** - * Search using opposite operators: Contains and Not Contains - */ - @Test - public void searchContainsAndNotContains() { - // getting to the file properties search tab - getFilePropertiesSearchTab(); - - // setting first criteria - fillSearchInFisrtField(AttributeOptions.OWNER_NAME.toString(), OperatorOptions.LIKE.toString(), "rods"); - - // adding a new criteria search field - driver.findElement(addSearchParamLocator).click(); - wait.until( - ExpectedConditions.visibilityOfElementLocated(By.cssSelector(".propertiesSearchRow:nth-of-type(2)"))); - - // setting second criteria - fillSearchInNthField(AttributeOptions.OWNER_NAME.toString(), OperatorOptions.NOT_LIKE.toString(), "rods", 2); - - // submiting form and assert result - submitAndCheckEmptyTable(); - } - - /** - * Creates a new user to test if file properties search can find objects that - * rodsadmin user has no permission on - */ - @Test - public void searchForObjsWithoutPermission() { - // creating user for testing purposes - String uname = "filePropertiesSearch" + System.currentTimeMillis(); - String pwd = "webdriver"; - driver.get(UiTestUtilities.ADD_USERS_URL); - UserUtils.fillInUserGeneralInformation(uname, pwd, UiTestUtilities.RODS_USER_TYPE, driver); - UserUtils.submitUserForm(driver); - - // getting to the file properties search tab - getFilePropertiesSearchTab(); - - fillSearchInFisrtField(AttributeOptions.OWNER_NAME.toString(), OperatorOptions.EQUAL.toString(), uname); - - // submiting form and assert result - driver.findElement(submitPropertiesSearchLocator).click(); - - // if there is at least one tag, then it means there are objects which the - // current user has access to - wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.cssSelector("#treeViewTable tbody tr"))); - Assert.assertTrue( - driver.findElements(By.cssSelector("#treeViewTable tbody > tr > td:first-child > span")).size() != 0); - - // deleting test user - UiTestUtilities.logout(); - UserUtils.removeUser(uname, driver); - } - - /** - * Method to get to file properties search tab - */ - private void getFilePropertiesSearchTab() { - driver.get(UiTestUtilities.METADATA_SEARCH_URL); - wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("a[href=\"#properties-search\"]"))).click(); - wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.id("properties-search"))); - } - - /** - * Submits search and checks if there is no results (empty table) - */ - private void submitAndCheckEmptyTable() { - driver.findElement(submitPropertiesSearchLocator).click(); - wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#treeViewTable .dataTables_empty"))); - Assert.assertTrue(driver.findElement(By.cssSelector("#treeViewTable .dataTables_empty")).isDisplayed()); - } - - /** - * Submits search and checks if there is at least one result from this search - */ - private void submitAndCheckNotEmptyTable() { - // click submit - driver.findElement(submitPropertiesSearchLocator).click(); - // if there is at least one tag, then it means there are objects which the - // curretn user has access to - wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.cssSelector("#treeViewTable tbody tr"))); - Assert.assertTrue(driver.findElements(By.cssSelector("#treeViewTable tbody a")).size() != 0); - } - - /** - * Compares path column to check if value from the table is the same as the one - * expected to be - */ - private void checkIfUploadedFileExist() { - Assert.assertEquals(driver.findElements(By.cssSelector("#treeViewTable tbody a")).size(), 1); - Assert.assertEquals(filePath, - driver.findElement(By.cssSelector("#treeViewTable tbody tr td:nth-child(2)")).getText()); - } - - /** - * This method is used to fill the first line in file properties search - * - * @param attribute - * can be get from AttributeOptions enum - * @param operator - * can be get from OperatorOptions enum - * @param value - */ - private void fillSearchInFisrtField(String attribute, String operator, String value) { - fillSearchInNthField(attribute, operator, value, 1); - } - - /** - * This method is used to fill the nth line in file properties search - * - * @param attribute - * can be get from AttributeOptions enum - * @param operator - * can be get from OperatorOptions enum - * @param value - * @param nth - * represents the nth search parameter in which the options above are - * to be placed and it starts at 1 - */ - private void fillSearchInNthField(String attribute, String operator, String value, Integer nth) { - new Select(driver.findElement( - By.cssSelector(".propertiesSearchRow:nth-of-type(" + nth.toString() + ") .propertiesAttr"))) - .selectByValue(attribute); - new Select(driver.findElement( - By.cssSelector(".propertiesSearchRow:nth-of-type(" + nth.toString() + ") .propertiesOper"))) - .selectByValue(operator); - driver.findElement(By.cssSelector(".propertiesSearchRow:nth-of-type(" + nth.toString() + ") .propertiesVal")) - .sendKeys(value); - } -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/group/AdditionalPermissionsTest.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/group/AdditionalPermissionsTest.java deleted file mode 100755 index 014045734..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/group/AdditionalPermissionsTest.java +++ /dev/null @@ -1,274 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.integration.test.group; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.openqa.selenium.WebDriver; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.emc.metalnx.core.domain.exceptions.DataGridException; -import com.emc.metalnx.integration.test.utils.CollectionUtils; -import com.emc.metalnx.integration.test.utils.FileUtils; -import com.emc.metalnx.integration.test.utils.UserUtils; -import com.emc.metalnx.test.generic.UiTestUtilities; - -@Deprecated -@Ignore -public class AdditionalPermissionsTest extends UiTestUtilities { - private static final Logger logger = LoggerFactory.getLogger(AdditionalPermissionsTest.class); - - public static String uname = "useradditionalpermissionforgroup" + System.currentTimeMillis(); - public static String gname = "groupadditionalpermission" + System.currentTimeMillis(); - public static String pwd = "webdriver"; - - private static WebDriver driver = null; - - /************************************* - * TEST SET UP - * - * @throws DataGridException - *************************************/ - - @BeforeClass - public static void setUpBeforeClass() { - // UITest.setUpBeforeClass(); - driver = getDriver(); - - try { - FileUtils.forceRemoveFilesFromDirAsAdmin("/" + UiTestUtilities.IRODS_ZONE, UiTestUtilities.TEST_FILE_NAMES); - CollectionUtils.cleanUpCollectionsUnderZone(driver, UiTestUtilities.TEST_COLLECTION_NAMES); - - UiTestUtilities.login(); - for (String collName : UiTestUtilities.TEST_COLLECTION_NAMES) { - CollectionUtils.createCollectionUnderZone(driver, collName, UiTestUtilities.IRODS_ZONE); - } - FileUtils.uploadToDirAsAdmin("/" + UiTestUtilities.IRODS_ZONE, UiTestUtilities.TEST_FILE_NAMES); - UiTestUtilities.logout(); - } catch (DataGridException e) { - logger.error("Could not setup test."); - } - - } - - @Before - public void setUp() throws Exception { - login(); - } - - /** - * After each test the user created for the test should be removed. - */ - @After - public void tearDown() throws Exception { - logout(); - - UserUtils.removeUser(uname, driver); - - login(); - GroupUtils.removeGroup(gname, driver); - - logout(); - } - - /** - * After all tests are done, the test must quit the driver. This will close - * every window associated with the current driver instance. - * - * @throws DataGridException - */ - - @AfterClass - public static void tearDownAfterClass() throws DataGridException { - - UiTestUtilities.login(); - FileUtils.forceRemoveFilesFromDirAsAdmin("/" + UiTestUtilities.IRODS_ZONE, UiTestUtilities.TEST_FILE_NAMES); - CollectionUtils.cleanUpCollectionsUnderZone(driver, UiTestUtilities.TEST_COLLECTION_NAMES); - UiTestUtilities.logout(); - - if (driver != null) { - driver.quit(); - driver = null; - UiTestUtilities.setDriver(null); - } - } - - /************************************* - * RODS ADMIN TESTS - *************************************/ - - /** - * Grant READ permission and a bookmark to a rods admin user on data objects, - * log in as such user and check if these data object show up in the bookmarks - * page. - */ - @Test - public void testGrantReadPermissionAndBookmarkOnFilesToRodsAdminAndCheckIfBookmarksShowUp() throws Exception { - grantPermissionAndBookmarkToGroupAndCheckIfBookmarkShowUp(UiTestUtilities.READ_PERMISSION, UiTestUtilities.RODS_ADMIN_TYPE, - UiTestUtilities.TEST_FILE_NAMES); - } - - /** - * Grant READ permission and a bookmark to a rods admin user on collections, log - * in as such user and check if these collections show up in the bookmarks page. - */ - @Test - public void testGrantReadPermissionAndBookmarkOnCollsToRodsAdminAndCheckIfBookmarksShowUp() throws Exception { - grantPermissionAndBookmarkToGroupAndCheckIfBookmarkShowUp(UiTestUtilities.READ_PERMISSION, UiTestUtilities.RODS_ADMIN_TYPE, - UiTestUtilities.TEST_COLLECTION_NAMES); - } - - /** - * Grant READ permission and a bookmark to a rods admin user on data objects, - * log in as such user and check if the data object show up in the bookmarks - * page. - */ - @Test - public void testGrantWritePermissionAndBookmarkOnFilesToRodsAdminAndCheckIfBookmarksShowUp() throws Exception { - grantPermissionAndBookmarkToGroupAndCheckIfBookmarkShowUp(UiTestUtilities.WRITE_PERMISSION, UiTestUtilities.RODS_ADMIN_TYPE, - UiTestUtilities.TEST_FILE_NAMES); - } - - /** - * Grant READ permission and a bookmark to a rods admin user on collections, log - * in as such user and check if these collections show up in the bookmarks page. - */ - @Test - public void testGrantWritePermissionAndBookmarkOnCollsToRodsAdminAndCheckIfBookmarksShowUp() throws Exception { - grantPermissionAndBookmarkToGroupAndCheckIfBookmarkShowUp(UiTestUtilities.WRITE_PERMISSION, UiTestUtilities.RODS_ADMIN_TYPE, - UiTestUtilities.TEST_COLLECTION_NAMES); - } - - /** - * Grant READ permission and a bookmark to a rods admin user on data objects, - * log in as such user and check if these data objects show up in the bookmarks - * page. - */ - @Test - public void testGrantOwnPermissionAndBookmarkOnFilesToRodsAdminAndCheckIfBookmarksShowUp() throws Exception { - grantPermissionAndBookmarkToGroupAndCheckIfBookmarkShowUp(UiTestUtilities.OWN_PERMISSION, UiTestUtilities.RODS_ADMIN_TYPE, - UiTestUtilities.TEST_FILE_NAMES); - } - - /** - * Grant WRITE permission and a bookmark to a rods admin user on collections, - * log in as such user and check if these collections show up in the bookmarks - * page. - */ - @Test - public void testGrantOwnPermissionAndBookmarkOnCollsToRodsAdminAndCheckIfBookmarksShowUp() throws Exception { - grantPermissionAndBookmarkToGroupAndCheckIfBookmarkShowUp(UiTestUtilities.OWN_PERMISSION, UiTestUtilities.RODS_ADMIN_TYPE, - UiTestUtilities.TEST_COLLECTION_NAMES); - } - - /************************************* - * RODS USER TESTS - *************************************/ - - /** - * Grant READ permission and a bookmark to a rods user data objects, log in as - * such user and check if these data object shows up in the bookmarks page. - */ - @Test - public void testGrantReadPermissionAndBookmarkOnFilesToRodsUserAndCheckIfBookmarksShowUp() throws Exception { - grantPermissionAndBookmarkToGroupAndCheckIfBookmarkShowUp(UiTestUtilities.READ_PERMISSION, UiTestUtilities.RODS_USER_TYPE, - UiTestUtilities.TEST_FILE_NAMES); - } - - /** - * Grant READ permission and a bookmark to a rods user data objects, log in as - * such user and check if these data object shows up in the bookmarks page. - */ - @Test - public void testGrantReadPermissionAndBookmarkOnCollsToRodsUserAndCheckIfBookmarksShowUp() throws Exception { - grantPermissionAndBookmarkToGroupAndCheckIfBookmarkShowUp(UiTestUtilities.READ_PERMISSION, UiTestUtilities.RODS_USER_TYPE, - UiTestUtilities.TEST_COLLECTION_NAMES); - } - - /** - * Grant WRITE permission and a bookmark to a rods user on collections, log in - * as such user and check if these collections shows up in the bookmarks page. - */ - @Test - public void testGrantWritePermissionAndBookmarkOnFilesToRodsUserAndCheckIfBookmarksShowUp() throws Exception { - grantPermissionAndBookmarkToGroupAndCheckIfBookmarkShowUp(UiTestUtilities.WRITE_PERMISSION, UiTestUtilities.RODS_USER_TYPE, - UiTestUtilities.TEST_FILE_NAMES); - } - - /** - * Grant WRITE permission and a bookmark to a rods user on collections, log in - * as such user and check if these collections shows up in the bookmarks page. - */ - @Test - public void testGrantWritePermissionAndBookmarkOnCollsToRodsUserAndCheckIfBookmarksShowUp() throws Exception { - grantPermissionAndBookmarkToGroupAndCheckIfBookmarkShowUp(UiTestUtilities.WRITE_PERMISSION, UiTestUtilities.RODS_USER_TYPE, - UiTestUtilities.TEST_COLLECTION_NAMES); - } - - /** - * Grant OWN permission and a bookmark to a rods user data objects, log in as - * such user and check if the data object shows up in the bookmarks page. - */ - @Test - public void testGrantOwnPermissionAndBookmarkOnFilesToRodsUserAndCheckIfBookmarksShowUp() throws Exception { - grantPermissionAndBookmarkToGroupAndCheckIfBookmarkShowUp(UiTestUtilities.OWN_PERMISSION, UiTestUtilities.RODS_USER_TYPE, - UiTestUtilities.TEST_FILE_NAMES); - } - - /** - * Grant OWN permission and a bookmark to a rods user collections, log in as - * such user and check if these collections shows up in the bookmarks page. - */ - @Test - public void testGrantOwnPermissionAndBookmarkOnCollsToRodsUserAndCheckIfBookmarksShowUp() throws Exception { - grantPermissionAndBookmarkToGroupAndCheckIfBookmarkShowUp(UiTestUtilities.OWN_PERMISSION, UiTestUtilities.RODS_USER_TYPE, - UiTestUtilities.TEST_COLLECTION_NAMES); - } - - /** - * Generic test for granting permissions to an group on a data object and check - * if such data object shows up in the group bookmark list. - * - * @param permType - * type of permission (read, write, or own) to grant a user - * @param userType - * type of user (rods admin or rods user) who will be created to test - * granting permissions - */ - public void grantPermissionAndBookmarkToGroupAndCheckIfBookmarkShowUp(String permType, String userType, - String[] testItems) throws Exception { - logger.info("Test grant read permission and bookmark on a data object to a test user."); - - logout(); - UserUtils.createUser(uname, pwd, userType, driver); - login(); - - String[] users = { uname }; - GroupUtils.createGroupWithUsersAndPermissions(gname, users, testItems, permType, driver); - - logout(); - login(uname, pwd); - - GroupUtils.checkPermissionBookmarks(gname, testItems, driver); - - } -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/group/ExistingGroupPermissionsOnCollsTest.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/group/ExistingGroupPermissionsOnCollsTest.java deleted file mode 100755 index 54068db80..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/group/ExistingGroupPermissionsOnCollsTest.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.integration.test.group; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.openqa.selenium.WebDriver; - -import com.emc.metalnx.core.domain.exceptions.DataGridException; -import com.emc.metalnx.integration.test.utils.CollectionUtils; -import com.emc.metalnx.integration.test.utils.UserUtils; -import com.emc.metalnx.test.generic.UiTestUtilities; - -/** - * Tests that check group permissions for collections. - */ -@Deprecated -@Ignore -public class ExistingGroupPermissionsOnCollsTest { - - private String rodsUserName = "rodsuseradditionalpermissionforgroup" + System.currentTimeMillis(); - private String rodsAdminName = "rodsadminadditionalpermissionforgroup" + System.currentTimeMillis(); - private String gname = "groupadditionalpermission" + System.currentTimeMillis(); - private String pwd = "webdriver"; - - private static WebDriver driver = null; - - /************************************* - * TEST SET UP - *************************************/ - - @BeforeClass - public static void setUpBeforeClass() throws DataGridException { - // UITest.setUpBeforeClass(); - driver = UiTestUtilities.getDriver(); - CollectionUtils.cleanUpCollectionsUnderZone(driver, UiTestUtilities.TEST_COLLECTION_NAMES); - UiTestUtilities.login(); - for (String collName : UiTestUtilities.TEST_COLLECTION_NAMES) { - CollectionUtils.createCollectionUnderZone(driver, collName, UiTestUtilities.IRODS_ZONE); - } - UiTestUtilities.logout(); - } - - @Before - public void setUp() throws Exception { - UserUtils.createUser(rodsUserName, pwd, "rodsuser", driver); - UserUtils.createUser(rodsAdminName, pwd, "rodsadmin", driver); - - UiTestUtilities.login(); - - String[] users = { rodsAdminName, rodsUserName }; - GroupUtils.createGroupWithUsers(gname, users, driver); - } - - /** - * After each test the user created for the test should be removed. - */ - @After - public void tearDown() throws Exception { - UiTestUtilities.logout(); - UserUtils.removeUser(rodsUserName, driver); - UserUtils.removeUser(rodsAdminName, driver); - - UiTestUtilities.login(); - GroupUtils.removeGroup(gname, driver); - UiTestUtilities.logout(); - } - - /** - * After all tests are done, the test must quit the driver. This will close - * every window associated with the current driver instance. - * - * @throws DataGridException - */ - - @AfterClass - public static void tearDownAfterClass() throws DataGridException { - if (driver != null) { - CollectionUtils.cleanUpCollectionsUnderZone(driver, UiTestUtilities.TEST_COLLECTION_NAMES); - driver.quit(); - driver = null; - UiTestUtilities.setDriver(null); - } - } - - /** - * Grant read permission on a collection for an existing group and check if its - * users have access to the collection using bookmarks - */ - @Test - public void grantReadPermissionOnCollection() { - GroupUtils.grantPermissionAndBookmarkToGroupAndCheckIfBookmarkShowUp(driver, gname, UiTestUtilities.READ_PERMISSION, - rodsUserName, pwd, UiTestUtilities.TEST_COLLECTION_NAMES); - } - - /** - * Grant write permission on a collection for an existing group and check if its - * users have access to the collection using bookmarks - */ - @Test - public void grantWritePermissionOnCollection() { - GroupUtils.grantPermissionAndBookmarkToGroupAndCheckIfBookmarkShowUp(driver, gname, UiTestUtilities.WRITE_PERMISSION, - rodsUserName, pwd, UiTestUtilities.TEST_COLLECTION_NAMES); - } - - /** - * Grant owner permission on a collection for an existing group and check if its - * users have access to the collection using bookmarks - */ - @Test - public void grantOwnershipPermissionOnCollection() { - GroupUtils.grantPermissionAndBookmarkToGroupAndCheckIfBookmarkShowUp(driver, gname, UiTestUtilities.OWN_PERMISSION, - rodsUserName, pwd, UiTestUtilities.TEST_COLLECTION_NAMES); - } - - /** - * Grant read permission on a collection for an existing group and check if its - * users have access to the collection using bookmarks - */ - @Test - public void grantReadPermissionOnCollectionForAdmin() { - GroupUtils.grantPermissionAndBookmarkToGroupAndCheckIfBookmarkShowUp(driver, gname, UiTestUtilities.READ_PERMISSION, - rodsAdminName, pwd, UiTestUtilities.TEST_COLLECTION_NAMES); - } - - /** - * Grant write permission on a collection for an existing group and check if its - * users have access to the collection using bookmarks - */ - @Test - public void grantWritePermissionOnCollectionForAdmin() { - GroupUtils.grantPermissionAndBookmarkToGroupAndCheckIfBookmarkShowUp(driver, gname, UiTestUtilities.WRITE_PERMISSION, - rodsAdminName, pwd, UiTestUtilities.TEST_COLLECTION_NAMES); - } - - /** - * Grant owner permission on a collection for an existing group and check if its - * users have access to the collection using bookmarks - */ - @Test - public void grantOwnershipPermissionOnCollectionForAdmin() { - GroupUtils.grantPermissionAndBookmarkToGroupAndCheckIfBookmarkShowUp(driver, gname, UiTestUtilities.OWN_PERMISSION, - rodsAdminName, pwd, UiTestUtilities.TEST_COLLECTION_NAMES); - } -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/group/ExistingGroupPermissionsOnFilesTest.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/group/ExistingGroupPermissionsOnFilesTest.java deleted file mode 100755 index 0398a57a8..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/group/ExistingGroupPermissionsOnFilesTest.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.integration.test.group; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.openqa.selenium.WebDriver; - -import com.emc.metalnx.core.domain.exceptions.DataGridException; -import com.emc.metalnx.integration.test.utils.FileUtils; -import com.emc.metalnx.integration.test.utils.UserUtils; -import com.emc.metalnx.test.generic.UiTestUtilities; - -/** - * Tests that check group permissions for files. - */ -@Deprecated -@Ignore -public class ExistingGroupPermissionsOnFilesTest { - - private String rodsUserName = "rodsuseradditionalpermissionforgroup" + System.currentTimeMillis(); - private String rodsAdminName = "rodsadminadditionalpermissionforgroup" + System.currentTimeMillis(); - private String gname = "groupadditionalpermission" + System.currentTimeMillis(); - private String pwd = "webdriver"; - - private static WebDriver driver = null; - - /************************************* - * TEST SET UP - *************************************/ - - @BeforeClass - public static void setUpBeforeClass() throws DataGridException { - // UITest.setUpBeforeClass(); - driver = UiTestUtilities.getDriver(); - FileUtils.forceRemoveFilesFromDirAsAdmin("/" + UiTestUtilities.IRODS_ZONE, UiTestUtilities.TEST_FILE_NAMES); - } - - @Before - public void setUp() throws Exception { - FileUtils.uploadToDirAsAdmin("/" + UiTestUtilities.IRODS_ZONE, UiTestUtilities.TEST_FILE_NAMES); - - UserUtils.createUser(rodsUserName, pwd, "rodsuser", driver); - UserUtils.createUser(rodsAdminName, pwd, "rodsadmin", driver); - - UiTestUtilities.login(); - - String[] users = { rodsAdminName, rodsUserName }; - GroupUtils.createGroupWithUsers(gname, users, driver); - } - - /** - * After each test the user created for the test should be removed. - */ - @After - public void tearDown() throws Exception { - FileUtils.forceRemoveFilesFromDirAsAdmin("/" + UiTestUtilities.IRODS_ZONE, UiTestUtilities.TEST_FILE_NAMES); - - UiTestUtilities.logout(); - UserUtils.removeUser(rodsUserName, driver); - UserUtils.removeUser(rodsAdminName, driver); - - UiTestUtilities.login(); - GroupUtils.removeGroup(gname, driver); - UiTestUtilities.logout(); - } - - /** - * After all tests are done, the test must quit the driver. This will close - * every window associated with the current driver instance. - * - * @throws DataGridException - */ - - @AfterClass - public static void tearDownAfterClass() throws DataGridException { - if (driver != null) { - FileUtils.forceRemoveFilesFromDirAsAdmin("/" + UiTestUtilities.IRODS_ZONE, UiTestUtilities.TEST_FILE_NAMES); - driver.quit(); - driver = null; - UiTestUtilities.setDriver(null); - } - } - - /** - * Grant read permission on a data object for an existing group and check if its - * users have access to the collection using bookmarks - */ - @Test - public void grantReadPermissionOnDataObject() { - GroupUtils.grantPermissionAndBookmarkToGroupAndCheckIfBookmarkShowUp(driver, gname, UiTestUtilities.READ_PERMISSION, - rodsUserName, pwd, UiTestUtilities.TEST_FILE_NAMES); - } - - /** - * Grant write permission on a data object for an existing group and check if - * its users have access to the collection using bookmarks - */ - @Test - public void grantWritePermissionOnDataObject() { - GroupUtils.grantPermissionAndBookmarkToGroupAndCheckIfBookmarkShowUp(driver, gname, UiTestUtilities.WRITE_PERMISSION, - rodsUserName, pwd, UiTestUtilities.TEST_FILE_NAMES); - } - - /** - * Grant owner permission on a data object for an existing group and check if - * its users have access to the collection using bookmarks - */ - @Test - public void grantOwnershipPermissionOnDataObject() { - GroupUtils.grantPermissionAndBookmarkToGroupAndCheckIfBookmarkShowUp(driver, gname, UiTestUtilities.OWN_PERMISSION, - rodsUserName, pwd, UiTestUtilities.TEST_FILE_NAMES); - } - - /** - * Grant read permission on a data object for an existing group and check if its - * users have access to the collection using bookmarks - */ - @Test - public void grantReadPermissionOnDataObjectForAdmin() { - GroupUtils.grantPermissionAndBookmarkToGroupAndCheckIfBookmarkShowUp(driver, gname, UiTestUtilities.READ_PERMISSION, - rodsAdminName, pwd, UiTestUtilities.TEST_FILE_NAMES); - } - - /** - * Grant write permission on a data object for an existing group and check if - * its users have access to the collection using bookmarks - */ - @Test - public void grantWritePermissionOnDataObjectForAdmin() { - GroupUtils.grantPermissionAndBookmarkToGroupAndCheckIfBookmarkShowUp(driver, gname, UiTestUtilities.WRITE_PERMISSION, - rodsAdminName, pwd, UiTestUtilities.TEST_FILE_NAMES); - } - - /** - * Grant owner permission on a data object for an existing group and check if - * its users have access to the collection using bookmarks - */ - @Test - public void grantOwnershipPermissionOnDataObjectForAdmin() { - GroupUtils.grantPermissionAndBookmarkToGroupAndCheckIfBookmarkShowUp(driver, gname, UiTestUtilities.OWN_PERMISSION, - rodsAdminName, pwd, UiTestUtilities.TEST_FILE_NAMES); - } -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/group/GroupTest.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/group/GroupTest.java deleted file mode 100755 index a00eea453..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/group/GroupTest.java +++ /dev/null @@ -1,231 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.integration.test.group; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.util.List; -import java.util.concurrent.TimeUnit; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.emc.metalnx.test.generic.UiTestUtilities; - -@Deprecated -@Ignore -public class GroupTest { - - private static final Logger logger = LoggerFactory.getLogger(GroupTest.class); - private static WebDriver driver = null; - - @BeforeClass - public static void setUpBeforeClass() { - // UITest.setUpBeforeClass(); - driver = UiTestUtilities.getDriver(); - } - - /** - * Logs in before each test. - */ - @Before - public void setUp() throws Exception { - UiTestUtilities.login(); - } - - /** - * After each test the user is logged out. - */ - @After - public void tearDown() throws Exception { - UiTestUtilities.logout(); - } - - /** - * After all tests are done, the test must quit the driver. This will close - * every window associated with the current driver instance. - */ - - @AfterClass - public static void tearDownAfterClass() { - if (driver != null) { - driver.quit(); - driver = null; - UiTestUtilities.setDriver(null); - } - } - - /* - * ***************************************************************************** - * *************** ******************************* GROUP MANAGEMENT - * ******************************************* - * ***************************************************************************** - * *************** - */ - - /** - * Test method that checks if the add user button in the user management page - * always brings the user to the add user page. - */ - @Test - public void testCheckIfAddButtonWorks() { - logger.info("Testing if add button works"); - - try { - driver.get(UiTestUtilities.GROUPS_URL); - - WebElement addGroupBtn = driver.findElement(By.linkText("Add Group")); - addGroupBtn.click(); - - // checks if add group button brings the group to the add group page - Assert.assertEquals(UiTestUtilities.ADD_GROUPS_URL, driver.getCurrentUrl()); - } catch (Exception e) { - logger.error("Could not run test properly"); - } - } - - /* - * ***************************************************************************** - * *************** ***************************************** ADD GROUP - * **************************************** - * ***************************************************************************** - * *************** - */ - - /** - * Test method for adding a brand new group to the system. It verifies if after - * adding group, the group is redirected to the group management page; if this - * group now exists in the groups list; and if the number of groups existing was - * incremented by one. - */ - @Test - public void testAddGroup() { - logger.info("Testing add a brand new group"); - - try { - driver.get(UiTestUtilities.ADD_GROUPS_URL); - - WebElement inputGroupname = driver.findElement(By.id("inputGroupname")); - WebElement btnEditUsers = driver.findElement(By.id("showUsersListBtn")); - WebElement submitGroupFormBtn = driver.findElement(By.id("submitGroupFormBtn")); - - String newGroupname = "webdriver_group" + System.currentTimeMillis(); - - inputGroupname.sendKeys(newGroupname); - btnEditUsers.click(); - - List cbUsersList = driver.findElements(By.name("idsList")); - for (WebElement checkbox : cbUsersList) { - checkbox.click(); - } - - submitGroupFormBtn.click(); - - // checks after adding a Group, if the system returns to previous - // screen (Group mgmt.) - assertEquals(UiTestUtilities.GROUPS_URL, driver.getCurrentUrl()); - - // checks if a success message is displayed - WebElement divAlertSucess = driver.findElement(By.className("alert-success")); - - // check if success message is displayed - assertTrue(divAlertSucess.isDisplayed()); - - // check if the group was successfully added - assertTrue(divAlertSucess.getText().contains(newGroupname)); - } catch (Exception e) { - logger.error("Could not run the test properly: {}", e.getMessage()); - } - } - - /** - * Test method that checks when adding a user with an empty groupname if the UI - * gets this exception and shows an error message. - */ - @Test - public void testAddGroupWithEmptyName() { - logger.info("Testing add a group with an empty groupname"); - - try { - - driver.get(UiTestUtilities.ADD_GROUPS_URL); - - WebElement inputGroupname = driver.findElement(By.id("inputGroupname")); - WebElement submitGroupFormBtn = driver.findElement(By.id("submitGroupFormBtn")); - - inputGroupname.sendKeys(""); - submitGroupFormBtn.click(); - - WebElement emptyGroupnameMsg = driver.findElement(By.id("emptyGroupnameMsg")); - - assertTrue(emptyGroupnameMsg.isDisplayed()); - } catch (Exception e) { - logger.error("Could not run the test properly: {}", e.getMessage()); - } - } - - /** - * Test method that removes the group created by other test methods. It leaves - * the Group Management as it was before the test session started. - */ - @Test - public void testDeleteGroupCreatedByTests() { - logger.info("Testing removing all groups created by tests"); - WebElement deleteBtn = null; - WebElement deleteGroupConfBtn = null; - - try { - - driver.get(UiTestUtilities.GROUPS_URL); - - List groupsList = driver.findElements(By.className("col-groupname")); - - // looking for a webdriver group. If found, the group will be removed - for (WebElement group : groupsList) { - if (group.getText().startsWith("webdriver_group")) { - // clicking on the delete button - deleteBtn = driver.findElement(By.id("deleteBtn_" + group.getText())); - deleteBtn.click(); - - driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS); - - // confirmation modal - deleteGroupConfBtn = driver.findElement(By.id("deleteGroupConfBtn")); - deleteGroupConfBtn.click(); - - // checking if a feedback message is shown after deleting a group - WebElement feedbackMsg = driver.findElement(By.className("alert")); - assertTrue(feedbackMsg.isDisplayed()); - break; - } - } - } catch (Exception e) { - logger.error("Could not run the test properly: {}", e.getMessage()); - } - } -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/group/GroupUtils.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/group/GroupUtils.java deleted file mode 100755 index eabda93ad..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/group/GroupUtils.java +++ /dev/null @@ -1,348 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.integration.test.group; - -import com.emc.metalnx.test.generic.UiTestUtilities; -import junit.framework.Assert; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.Select; -import org.openqa.selenium.support.ui.WebDriverWait; - -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -@Deprecated -public class GroupUtils { - - private static final By GROUP_FILTER_INPUT = By.cssSelector("#groupsListTable_filter input"); - public static final By GROUP_LIST_TABLE = By.cssSelector("#groupsListTable tbody"); - - /** - * Generic test for granting permissions to an existing group on a data object and check if - * such data object shows up in the group bookmark list. - * - * @param gname - * group name - * @param permType - * type of permission (read, write, or own) to grant a user - * @param userName - * user name - * @param pwd - * @param testItems - * collections or data objects to be granted permission on - */ - public static void grantPermissionAndBookmarkToGroupAndCheckIfBookmarkShowUp(WebDriver driver, String gname, String permType, String userName, - String pwd, String... testItems) { - GroupUtils.modifyGroupWithPermission(gname, testItems, permType, driver); - - UiTestUtilities.logout(); - UiTestUtilities.login(userName, pwd); - - GroupUtils.checkPermissionBookmarks(gname, testItems, driver); - - } - - /** - * Creates a new group - * - * @param groupName - * {@link String} the name of the group - * @param driver - * {@link WebDriver} the Web Driver instance - */ - public static void createGroup(String groupName, WebDriver driver) { - driver.get(UiTestUtilities.ADD_GROUPS_URL); - fillGroupGeneralInformation(groupName, driver); - submitGroupForm(driver); - } - - /** - * Creates a new group containing the specified list of users - * - * @param groupName - * {@link String} the name of the group - * @param users - * {@link String[]} the list of user names that must be included on the group - * @param driver - * {@link WebDriver} the Web Driver instance - */ - public static void createGroupWithUsers(String groupName, String[] users, WebDriver driver) { - driver.get(UiTestUtilities.ADD_GROUPS_URL); - fillGroupGeneralInformation(groupName, driver); - assignUsersToGroup(users, driver); - submitGroupForm(driver); - } - - /** - * Creates a new group with the specified permissions on items. Recursive permission WILL be applied. - * - * @param groupName - * {@link String} the name of the group - * @param collsOrDataObjects - * {@link String[]} the list of items to be set permissions on (relative to - * /ZONE_NAME) - * @param permission - * {@link String} the permission type - * @param driver - * {@link WebDriver} the Web Driver instance - */ - public static void createGroupWithRecursivePermission(WebDriver driver, String groupName, String permission, String... collsOrDataObjects) { - driver.get(UiTestUtilities.ADD_GROUPS_URL); - fillGroupGeneralInformation(groupName, driver); - assignPermissionsOnCollectionsOrDataObjects(collsOrDataObjects, permission, driver, true); - submitGroupForm(driver); - } - - /** - * Creates a new group with the specified permissions on items. *Recursive permission will NOT be applied. - * - * @param groupName - * {@link String} the name of the group - * @param collsOrDataObjects - * {@link String[]} the list of items to be set permissions on (relative to - * /ZONE_NAME) - * @param permission - * {@link String} the permission type - * @param driver - * {@link WebDriver} the Web Driver instance - */ - public static void createGroupWithPermissions(WebDriver driver, String groupName, String permission, String... collsOrDataObjects) { - driver.get(UiTestUtilities.ADD_GROUPS_URL); - fillGroupGeneralInformation(groupName, driver); - assignPermissionsOnCollectionsOrDataObjects(collsOrDataObjects, permission, driver, false); - submitGroupForm(driver); - } - - /** - * Creates a new group with the specified list of users to be included and items to be set - * permissions to - * - * @param groupName - * {@link String} the name of the group - * @param users - * {@link String[]} the list of user names that must be included on the group - * @param collsOrDataObjects - * {@link String[]} the list of items to be set permissions on (relative to - * /ZONE_NAME) - * @param permission - * {@link String} the permission type - * @param driver - * {@link WebDriver} the Web Driver instance - */ - public static void createGroupWithUsersAndPermissions(String groupName, String[] users, String[] collsOrDataObjects, String permission, - WebDriver driver) { - driver.get(UiTestUtilities.ADD_GROUPS_URL); - fillGroupGeneralInformation(groupName, driver); - assignUsersToGroup(users, driver); - assignPermissionsOnCollectionsOrDataObjects(collsOrDataObjects, permission, driver, false); - submitGroupForm(driver); - } - - /** - * Modifies a group settings permissions to the specified items - * - * @param groupName - * {@link String} the name of the group - * @param collsOrDataObjects - * {@link String[]} the list of items to be set permissions on (relative to - * /ZONE_NAME) - * @param permission - * {@link String} the permission type - * @param driver - * {@link WebDriver} the Web Driver instance - */ - public static void modifyGroupWithPermission(String groupName, String[] collsOrDataObjects, String permission, WebDriver driver) { - driver.get(UiTestUtilities.getModifyGroupsPage(groupName)); - assignPermissionsOnCollectionsOrDataObjects(collsOrDataObjects, permission, driver, false); - driver.findElement(By.id("submitGroupFormBtn")).click(); - } - - /** - * Removes the specified group by its name - * - * @param groupName - * {@link String} the name of the group to be removed - * @param driver - * {@link WebDriver} the Web Driver instance - */ - public static void removeGroup(String groupName, WebDriver driver) { - - WebDriverWait wait = new WebDriverWait(driver, 5); - By groupsTable = By.cssSelector("#groupsListTable tbody"); - By buttonToRemoveGroup = By.id("deleteBtn_" + groupName); - By removalConfirmation = By.id("deleteGroupConfBtn"); - - driver.get(UiTestUtilities.GROUPS_URL); - Assert.assertEquals(driver.getCurrentUrl(), UiTestUtilities.GROUPS_URL); - - wait.until(ExpectedConditions.visibilityOfElementLocated(groupsTable)); - wait.until(ExpectedConditions.visibilityOfElementLocated(GROUP_FILTER_INPUT)).sendKeys(groupName); - - wait.until(ExpectedConditions.elementToBeClickable(buttonToRemoveGroup)); - driver.findElement(buttonToRemoveGroup).click(); - - wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("removalModal"))); - wait.until(ExpectedConditions.elementToBeClickable(removalConfirmation)); - driver.findElement(removalConfirmation).click(); - } - - /** - * Checks if the group bookmarks are available on the user interface - * - * @param groupName - * {@link String} the name of the group to be removed - * @param testItems - * {@link String[]} the list of items to be set permissions on (relative to - * /ZONE_NAME) - * @param driver - * {@link WebDriver} the Web Driver instance - */ - public static void checkPermissionBookmarks(String groupName, String[] testItems, WebDriver driver) { - WebDriverWait wait = new WebDriverWait(driver, 15); - - driver.get(UiTestUtilities.GROUP_BOOKMARKS_URL); - Assert.assertEquals(UiTestUtilities.GROUP_BOOKMARKS_URL, driver.getCurrentUrl()); - - driver.findElement(By.cssSelector("#groupBookmarksTable_filter input")).sendKeys(groupName); - try { - new WebDriverWait(driver, 1).until(ExpectedConditions.elementToBeClickable(By.id("çççç"))); - } - catch (Exception e) { - - } - - List bookmarks = driver.findElements(By.cssSelector("#groupBookmarksTable tbody tr td:first-child")); - Assert.assertEquals(testItems.length, bookmarks.size()); - - // Comparing bookmark links - Set bookmarksSet = new HashSet(); - for (String path : testItems) { - bookmarksSet.add(path); - } - - for (int i = 0; i < bookmarks.size(); i++) { - Assert.assertTrue(bookmarksSet.contains(bookmarks.get(i).getText())); - } - - bookmarks.get(0).click(); - - wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("#directoryPath .breadcrumb"))); - - Assert.assertEquals(UiTestUtilities.COLLECTIONS_URL, driver.getCurrentUrl()); - } - - /* **************************************************************************************** */ - /* *********************************** PRIVATE METHODS ************************************ */ - /* **************************************************************************************** */ - - /** - * Fills group general information on the group form page - * - * @param groupName - * {@link String} the name of the group to be modified - * @param driver - * {@link WebDriver} the Web Driver instance - */ - private static void fillGroupGeneralInformation(String groupName, WebDriver driver) { - driver.findElement(By.id("inputGroupname")).sendKeys(groupName); - } - - /** - * Assigns users to the group whose form is opened - * - * @param users - * {@link String[]} the list of user names that must be included on the group - * @param driver - * {@link WebDriver} the Web Driver instance - */ - private static void assignUsersToGroup(String[] users, WebDriver driver) { - driver.findElement(By.id("showUsersListBtn")).click(); - for (String user : users) { - driver.findElement(By.cssSelector("#usersListTable_filter input")).click(); - driver.findElement(By.cssSelector("#usersListTable_filter input")).clear(); - driver.findElement(By.cssSelector("#usersListTable_filter input")).sendKeys(user); - driver.findElement(By.cssSelector("#" + user + " input[type='checkbox']")).click(); - } - driver.findElement(By.id("hideUsersListBtn")).click(); - } - - /** - * Fills in the permission items to be set on the group - * - * @param collsOrDataObjects - * {@link String[]} the list of items to be set permissions on (relative to - * /ZONE_NAME) - * @param permission - * {@link String} the permission type - * @param applyPermRecursively - * {@link boolean} true, if the permission should be applied to subcollections and files. False, otherwise. - * @param driver - * {@link WebDriver} the Web Driver instance - */ - private static void assignPermissionsOnCollectionsOrDataObjects(String[] collsOrDataObjects, String permission, WebDriver driver, - boolean applyPermRecursively) { - WebDriverWait wait = new WebDriverWait(driver, 5); - wait.until(ExpectedConditions.elementToBeClickable(By.name(UiTestUtilities.IRODS_ZONE))); - - driver.findElement(By.name(UiTestUtilities.IRODS_ZONE)).click(); - - wait.until(ExpectedConditions.elementToBeClickable(By.id("permission_" + collsOrDataObjects[0]))); - - for (String item : collsOrDataObjects) { - new Select(driver.findElement(By.id("permission_" + item))).selectByValue(permission); - answerRecursiveQuestionGroupForm(driver, item, applyPermRecursively); - By permissionSelector = By.cssSelector(String.format("input[name='/%s/%s']", UiTestUtilities.IRODS_ZONE, item)); - wait.until(ExpectedConditions.elementSelectionStateToBe(permissionSelector, true)); - } - } - - /** - * Answers the question if the user wants to apply recursive permission on a collection. - * - * @param driver - * @param collection - * collection name to apply permission recursively - * @param applyPermRecursively - * True, if the chosen permission should be applied recursively. False, otherwise. - */ - private static void answerRecursiveQuestionGroupForm(WebDriver driver, String collection, boolean applyPermRecursively) { - // Eating the exception is needed in case a Data Object (no question will be asked) is given instead of a colletion. - // From Selenium, there is no easy way to check if an item is a collection or data object. - try { - String btnRecursive = applyPermRecursively ? " .btn-recursive-yes" : " .btn-recursive-no"; - String recursiveSelector = String.format("#recursiveQuestion_%s %s", collection, btnRecursive); - new WebDriverWait(driver, 10).until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(recursiveSelector))).click(); - } - catch (Exception e) {} - } - - /** - * Submits the group form with the created/modified information - * - * @param driver - * {@link WebDriver} the Web Driver instance - */ - private static void submitGroupForm(WebDriver driver) { - driver.findElement(By.id("submitGroupFormBtn")).click(); - Assert.assertEquals(UiTestUtilities.GROUPS_URL, driver.getCurrentUrl()); - } - -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/healthcheck/ITHealthCheckTest.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/healthcheck/ITHealthCheckTest.java deleted file mode 100644 index 6d5e65690..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/healthcheck/ITHealthCheckTest.java +++ /dev/null @@ -1,173 +0,0 @@ -package com.emc.metalnx.integration.test.healthcheck; - -import java.util.Properties; - -import org.irods.jargon.core.pub.IRODSFileSystem; -import org.irods.jargon.testutils.IRODSTestSetupUtilities; -import org.irods.jargon.testutils.TestingPropertiesHelper; -import org.irods.jargon.testutils.filemanip.ScratchFileUtils; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.support.ui.WebDriverWait; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.emc.metalnx.integration.test.utils.HealthCheckUtils; -import com.emc.metalnx.test.generic.UiTestUtilities; - -import junit.framework.Assert; - - -public class ITHealthCheckTest { - private static final Logger logger = LoggerFactory.getLogger(ITHealthCheckTest.class); - private static WebDriver driver = null; - private static WebDriverWait wait = null; - - private static Properties testingProperties = new Properties(); - private static ScratchFileUtils scratchFileUtils = null; - public static final String IRODS_TEST_SUBDIR_PATH = "ITHealthCheckTest"; - private static IRODSTestSetupUtilities irodsTestSetupUtilities = null; - private static IRODSFileSystem irodsFileSystem; - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - org.irods.jargon.testutils.TestingPropertiesHelper testingPropertiesLoader = new TestingPropertiesHelper(); - testingProperties = testingPropertiesLoader.getTestProperties(); - scratchFileUtils = new ScratchFileUtils(testingProperties); - scratchFileUtils.clearAndReinitializeScratchDirectory(IRODS_TEST_SUBDIR_PATH); - irodsTestSetupUtilities = new IRODSTestSetupUtilities(); - irodsTestSetupUtilities.initializeIrodsScratchDirectory(); - irodsTestSetupUtilities.initializeDirectoryForTest(IRODS_TEST_SUBDIR_PATH); - irodsFileSystem = IRODSFileSystem.instance(); - UiTestUtilities.init(); - driver = UiTestUtilities.getDriver(); - wait = new WebDriverWait(driver, 5); - UiTestUtilities.login(); - } - - @Before - public void setUp() { - //UiTestUtilities.login(); - - } - - @After - public void tearDown() { - //UiTestUtilities.logout(); - - } - - @AfterClass - public static void tearDownAfterClass() { - if (driver != null) { - driver.quit(); - driver = null; - UiTestUtilities.setDriver(null); - irodsFileSystem.closeAndEatExceptions(); - UiTestUtilities.logout(); - } - } - - /** - * Test fetches the web page url and compares the page header - */ - @Test - public void testGotoDashboard() { - String pageHeader = HealthCheckUtils.getPageHeader(driver, wait, UiTestUtilities.DASHBOARD_URL); - logger.info("Expected Header: " + UiTestUtilities.DASHBOARD_HDR + " Actual Header: " + pageHeader ); - Assert.assertEquals(UiTestUtilities.DASHBOARD_HDR, pageHeader); - } - - @Test - public void testGotoResources() { - String pageHeader = HealthCheckUtils.getPageHeader(driver, wait, UiTestUtilities.RESOURCES_URL); - logger.info("Expected Header: " + UiTestUtilities.RESOURCES_HDR + " Actual Header: " + pageHeader ); - Assert.assertEquals(UiTestUtilities.RESOURCES_HDR, pageHeader); - } - - @Test - public void testGotoRules() { - String pageHeader = HealthCheckUtils.getPageHeader(driver, wait, UiTestUtilities.RULES_URL); - logger.info("Expected Header: " + UiTestUtilities.RULES_HDR + " Actual Header: " + pageHeader ); - Assert.assertEquals(UiTestUtilities.RULES_HDR, pageHeader); - } - - @Test - public void testGotoUsers() { - String pageHeader = HealthCheckUtils.getPageHeader(driver, wait, UiTestUtilities.USERS_URL); - logger.info("Expected Header: " + UiTestUtilities.USERS_HDR + " Actual Header: " + pageHeader ); - Assert.assertEquals(UiTestUtilities.USERS_HDR, pageHeader); - } - - @Test - public void testGotoGroups() { - String pageHeader = HealthCheckUtils.getPageHeader(driver, wait, UiTestUtilities.GROUPS_URL); - logger.info("Expected Header: " + UiTestUtilities.GROUPS_HDR + " Actual Header: " + pageHeader ); - Assert.assertEquals(UiTestUtilities.GROUPS_HDR, pageHeader); - } - - @Test - public void testGotoProfile() { - String pageHeader = HealthCheckUtils.getPageHeader(driver, wait, UiTestUtilities.PROFILES_URL); - logger.info("Expected Header: " + UiTestUtilities.PROFILES_HDR+ " Actual Header: " + pageHeader ); - Assert.assertEquals(UiTestUtilities.PROFILES_HDR, pageHeader); - } - - @Test - public void testGotoCollections() { - String pageHeader = HealthCheckUtils.getPageHeader(driver, wait, UiTestUtilities.COLLECTIONS_URL); - logger.info("Expected Header: " + UiTestUtilities.COLLECTIONS_HDR + " Actual Header: " + pageHeader ); - Assert.assertEquals(UiTestUtilities.COLLECTIONS_HDR, pageHeader); - } - - @Test - public void testGotoSearch() { - String pageHeader = HealthCheckUtils.getPageHeader(driver, wait, UiTestUtilities.METADATA_SEARCH_URL); - logger.info("Expected Header: " + UiTestUtilities.SEARCH_HDR + " Actual Header: " + pageHeader ); - Assert.assertEquals(UiTestUtilities.SEARCH_HDR, pageHeader); - } - - @Test - public void testGotoTemplates() { - String pageHeader = HealthCheckUtils.getPageHeader(driver, wait, UiTestUtilities.TEMPLATES_URL); - logger.info("Expected Header: " + UiTestUtilities.TEMPLATES_HDR + " Actual Header: " + pageHeader ); - Assert.assertEquals(UiTestUtilities.TEMPLATES_HDR, pageHeader); - } - - @Test - public void testGotoFavorites() { - String pageHeader = HealthCheckUtils.getPageHeader(driver, wait, UiTestUtilities.USER_BOOKMARKS_URL); - logger.info("Expected Header: " + UiTestUtilities.SHARED_LINKS_HDR + " Actual Header: " + pageHeader ); - Assert.assertEquals(UiTestUtilities.SHARED_LINKS_HDR, pageHeader); - } - - @Test - public void testGotoTickets() { - String pageHeader = HealthCheckUtils.getPageHeader(driver, wait, UiTestUtilities.TICKETS_URL); - logger.info("Expected Header: " + UiTestUtilities.TICKETS_HDR + " Actual Header: " + pageHeader ); - Assert.assertEquals(UiTestUtilities.TICKETS_HDR, pageHeader); - } - - @Test - public void testGotoPublic() { - String pageHeader = HealthCheckUtils.getPageHeader(driver, wait, UiTestUtilities.PUBLIC_URL); - logger.info("Expected Header: " + UiTestUtilities.PUBLIC_HDR + " Actual Header: " + pageHeader ); - Assert.assertEquals(UiTestUtilities.PUBLIC_HDR, pageHeader); - } - - @Ignore - @Test - public void testGotoTrash() { - String pageHeader = HealthCheckUtils.getPageHeader(driver, wait, UiTestUtilities.TRASH_URL); - logger.info("Expected Header: " + UiTestUtilities.TRASH_HDR + " Actual Header: " + pageHeader ); - Assert.assertEquals(UiTestUtilities.TRASH_HDR, pageHeader); - } - - - -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/login/ITAdminLoginTest.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/login/ITAdminLoginTest.java deleted file mode 100755 index b45dbd4e1..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/login/ITAdminLoginTest.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.integration.test.login; - -import java.util.Properties; - -import org.irods.jargon.core.pub.IRODSFileSystem; -import org.irods.jargon.testutils.IRODSTestSetupUtilities; -import org.irods.jargon.testutils.TestingPropertiesHelper; -import org.irods.jargon.testutils.filemanip.ScratchFileUtils; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.openqa.selenium.WebDriver; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.emc.metalnx.test.generic.UiTestUtilities; - -import junit.framework.Assert; - -public class ITAdminLoginTest { - - private static final Logger logger = LoggerFactory.getLogger(ITAdminLoginTest.class); - - private static WebDriver driver = null; - - private static Properties testingProperties = new Properties(); - private static ScratchFileUtils scratchFileUtils = null; - public static final String IRODS_TEST_SUBDIR_PATH = "ITAdminLoginTest"; - private static IRODSTestSetupUtilities irodsTestSetupUtilities = null; - private static IRODSFileSystem irodsFileSystem; - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - org.irods.jargon.testutils.TestingPropertiesHelper testingPropertiesLoader = new TestingPropertiesHelper(); - testingProperties = testingPropertiesLoader.getTestProperties(); - scratchFileUtils = new ScratchFileUtils(testingProperties); - scratchFileUtils.clearAndReinitializeScratchDirectory(IRODS_TEST_SUBDIR_PATH); - irodsTestSetupUtilities = new IRODSTestSetupUtilities(); - irodsTestSetupUtilities.initializeIrodsScratchDirectory(); - irodsTestSetupUtilities.initializeDirectoryForTest(IRODS_TEST_SUBDIR_PATH); - irodsFileSystem = IRODSFileSystem.instance(); - UiTestUtilities.init(); - driver = UiTestUtilities.getDriver(); - - } - - /** - * After all tests are done, the test must quit the driver. This will close - * every window associated with the current driver instance. - */ - - @AfterClass - public static void tearDownAfterClass() { - if (driver != null) { - driver.quit(); - driver = null; - UiTestUtilities.setDriver(null); - irodsFileSystem.closeAndEatExceptions(); - } - } - - /** - * Test for admin log in. - * - * @throws Exception - */ - @Test - public void testLoginAsAdmin() throws Exception { - logger.info("Test logging in as a admin user"); - UiTestUtilities.login( - UiTestUtilities.testingProperties.getProperty(TestingPropertiesHelper.IRODS_USER_KEY), - UiTestUtilities.testingProperties.getProperty(TestingPropertiesHelper.IRODS_PASSWORD_KEY)); - Assert.assertEquals(UiTestUtilities.DASHBOARD_URL, driver.getCurrentUrl()); - } - -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/login/ITLoginTest.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/login/ITLoginTest.java deleted file mode 100755 index f182c682e..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/login/ITLoginTest.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.integration.test.login; - -import static org.junit.Assert.assertEquals; - -import java.util.Properties; - -import org.irods.jargon.core.pub.IRODSFileSystem; -import org.irods.jargon.testutils.IRODSTestSetupUtilities; -import org.irods.jargon.testutils.TestingPropertiesHelper; -import org.irods.jargon.testutils.filemanip.ScratchFileUtils; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.openqa.selenium.WebDriver; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.emc.metalnx.test.generic.UiTestUtilities; - -public class ITLoginTest { - - private static final Logger logger = LoggerFactory.getLogger(ITLoginTest.class); - - private static Properties testingProperties = new Properties(); - private static ScratchFileUtils scratchFileUtils = null; - public static final String IRODS_TEST_SUBDIR_PATH = "ITLoginTest"; - private static IRODSTestSetupUtilities irodsTestSetupUtilities = null; - private static IRODSFileSystem irodsFileSystem; - - private static WebDriver driver = null; - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - org.irods.jargon.testutils.TestingPropertiesHelper testingPropertiesLoader = new TestingPropertiesHelper(); - testingProperties = testingPropertiesLoader.getTestProperties(); - scratchFileUtils = new ScratchFileUtils(testingProperties); - scratchFileUtils.clearAndReinitializeScratchDirectory(IRODS_TEST_SUBDIR_PATH); - irodsTestSetupUtilities = new IRODSTestSetupUtilities(); - irodsTestSetupUtilities.initializeIrodsScratchDirectory(); - irodsTestSetupUtilities.initializeDirectoryForTest(IRODS_TEST_SUBDIR_PATH); - irodsFileSystem = IRODSFileSystem.instance(); - UiTestUtilities.init(); - driver = UiTestUtilities.getDriver(); - - } - - /** - * After all tests are done, the test must quit the driver. This will close - * every window associated with the current driver instance. - */ - - @AfterClass - public static void tearDownAfterClass() { - if (driver != null) { - driver.quit(); - driver = null; - UiTestUtilities.setDriver(null); - irodsFileSystem.closeAndEatExceptions(); - } - } - - /** - * Tests a valid username and password for login, and checks if it moves to the - * dashboard page - * - * @throws Exception - */ - @Test - public void testValidUsernameAndPasswordForLogin() throws Exception { - logger.info("Testing valid username and password for login"); - UiTestUtilities.login(UiTestUtilities.testingProperties.getProperty(TestingPropertiesHelper.IRODS_USER_KEY), - UiTestUtilities.testingProperties.getProperty(TestingPropertiesHelper.IRODS_PASSWORD_KEY)); - - // check if after login, the user is redirected to the dashboard page - assertEquals(UiTestUtilities.DASHBOARD_URL, driver.getCurrentUrl()); - UiTestUtilities.logout(); - } - - /** - * Tests an invalid username and password for login and checks if an error is - * shown - * - * @throws Exception - */ - @Test - public void testInvalidUsernameAndPasswordForLogin() throws Exception { - logger.info("Testing invalid username and password for login"); - UiTestUtilities.login("ThisIsAnInvalidUsername", "ThisIsAnInvalidPassword"); - - /* - * There is no error message for invalid login WebElement errorMsg = - * driver.findElement(By.className("errorMsg")); check if after entering invalid - * login credentials (username and password), an error message is shown - */ - Assert.assertEquals(UiTestUtilities.LOGINERROR_URL, driver.getCurrentUrl()); - } -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/metadata/MetadataSearchUnitsTest.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/metadata/MetadataSearchUnitsTest.java deleted file mode 100755 index a0f4e81bb..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/metadata/MetadataSearchUnitsTest.java +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.integration.test.metadata; - -import com.emc.metalnx.core.domain.exceptions.DataGridException; -import com.emc.metalnx.integration.test.utils.FileUtils; -import com.emc.metalnx.integration.test.utils.MetadataUtils; -import com.emc.metalnx.test.generic.UiTestUtilities; -import org.junit.*; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Date; -import java.util.List; - -@Deprecated -@Ignore -public class MetadataSearchUnitsTest { - private static final Logger logger = LoggerFactory.getLogger(MetadataSearchUnitsTest.class); - - private static WebDriver driver = null; - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - UiTestUtilities.init(); - driver = UiTestUtilities.getDriver(); - FileUtils.forceRemoveFilesFromHomeAsAdmin(MetadataUtils.METADATA_SEARCH_FILES); - FileUtils.uploadToHomeDirAsAdmin(MetadataUtils.METADATA_SEARCH_FILES); - - UiTestUtilities.login(); - for (String file : MetadataUtils.METADATA_SEARCH_FILES) { - MetadataUtils.addMetadata(driver, MetadataUtils.SELENIUM_ATTR, MetadataUtils.SELENIUM_VALUE, MetadataUtils.SELENIUM_UNIT, file); - try { - new WebDriverWait(driver, 1).until(ExpectedConditions.elementToBeClickable(By.id("çççç"))); - } - catch (Exception e) { - - } - } - UiTestUtilities.logout(); - } - - @Before - public void setUp() { - UiTestUtilities.login(); - } - - @After - public void tearDown() { - UiTestUtilities.logout(); - } - - @AfterClass - public static void tearDownAfterClass() throws DataGridException { - FileUtils.forceRemoveFilesFromHomeAsAdmin(MetadataUtils.METADATA_SEARCH_FILES); - - if (driver != null) { - driver.quit(); - driver = null; - UiTestUtilities.setDriver(null); - } - } - - /** - * Test metadata search using "Selenium" as attribute, "Test" as value, and "Mlx" as unit. - * Results expected: 1SeleniumTestMetadataSearch.png, 2SeleniumTestMetadataSearch.png, and - * 3SeleniumTestMetadataSearch.png. Results must appear in this particular order. - */ - @Test - public void testSeleniumAsAttrTestAsValueAndMlxAsUnit() { - logger.info("Testing Metadata search"); - - driver.get(UiTestUtilities.METADATA_SEARCH_URL); - MetadataUtils.fillInMetadataSearchAttrValAndUnit(driver, MetadataUtils.SELENIUM_ATTR, MetadataUtils.SELENIUM_VALUE, - MetadataUtils.SELENIUM_UNIT); - MetadataUtils.submitMetadataSearch(driver); - assertMetadataSearchResults(); - } - - /** - * Test metadata search using "Selenium" as attribute and "Mlx" as unit. - * Results expected: 1SeleniumTestMetadataSearch.png, 2SeleniumTestMetadataSearch.png, and - * 3SeleniumTestMetadataSearch.png. Results must appear in this particular order. - */ - @Test - public void testMetadataSearchAttrAndUnit() { - logger.info("Testing Metadata search"); - - driver.get(UiTestUtilities.METADATA_SEARCH_URL); - MetadataUtils.fillInMetadataSearchAttrUnit(driver, MetadataUtils.SELENIUM_ATTR, MetadataUtils.SELENIUM_UNIT); - MetadataUtils.submitMetadataSearch(driver); - assertMetadataSearchResults(); - } - - /** - * Test metadata search only using "Mlx" as unit. - * Results expected: 1SeleniumTestMetadataSearch.png, 2SeleniumTestMetadataSearch.png, and - * 3SeleniumTestMetadataSearch.png. Results must appear in this particular order. - */ - @Test - public void testMetadataSearchUnit() { - logger.info("Testing Metadata search"); - - driver.get(UiTestUtilities.METADATA_SEARCH_URL); - MetadataUtils.fillInMetadataSearchUnit(driver, MetadataUtils.SELENIUM_UNIT); - MetadataUtils.submitMetadataSearch(driver); - assertMetadataSearchResults(); - } - - /** - * Test the number of matches shown for each file used in the search. - * Search parameters: - * 1) Selenium Test Mlx - * 2) Selenium Test - * 3) Selenium Mlx - * Number of results expected: 3 - * Results expected: - * 1) 1SeleniumTestMetadataSearch.png (Number of matches: 3) - * 2) 2SeleniumTestMetadataSearch.png (Number of matches: 3) - * 3) 3SeleniumTestMetadataSearch.png (Number of matches: 3) - */ - @Test - public void testNumberOfMatchesDisplayedForEachFileAfterSearching() { - logger.info("Testing the number of matches displayed for each file after doing a search."); - - driver.get(UiTestUtilities.METADATA_SEARCH_URL); - - logger.info("Entering search criteria."); - - // Search for AVU - driver.findElement(By.id("metadataAttr0")).sendKeys(MetadataUtils.SELENIUM_ATTR); - driver.findElement(By.id("metadataValue0")).sendKeys(MetadataUtils.SELENIUM_VALUE); - driver.findElement(By.id("metadataUnit0")).sendKeys(MetadataUtils.SELENIUM_UNIT); - - driver.findElement(By.id("addMetadataSearchRow")).click(); - - // Search for AV - driver.findElement(By.id("metadataAttr1")).sendKeys(MetadataUtils.SELENIUM_ATTR); - driver.findElement(By.id("metadataValue1")).sendKeys(MetadataUtils.SELENIUM_VALUE); - - driver.findElement(By.id("addMetadataSearchRow")).click(); - - // Search for AU - driver.findElement(By.id("metadataAttr2")).sendKeys(MetadataUtils.SELENIUM_ATTR); - driver.findElement(By.id("metadataUnit2")).sendKeys(MetadataUtils.SELENIUM_UNIT); - - MetadataUtils.submitMetadataSearch(driver); - - assertMetadataSearchResults(); - - List numberOfMatchesForAllItems = driver.findElements(By.cssSelector("#treeViewTableBody tr td:last-child")); - - logger.info("Checking if the number of matches of each file is the same as expected."); - int numOfMatches = 0; - for (WebElement numOfMatchesForItem : numberOfMatchesForAllItems) { - numOfMatches = numOfMatchesForItem.findElements(By.tagName("i")).size(); - Assert.assertEquals(3, numOfMatches); - } - } - - @Test - public void testClickingOnSearchResultAndComingBackToMetadataSearch() { - logger.info("Test for clicking on a search result item and come back to the previous search results."); - - driver.get(UiTestUtilities.METADATA_SEARCH_URL); - - MetadataUtils.fillInMetadataSearchAttrUnit(driver, MetadataUtils.SELENIUM_ATTR, MetadataUtils.SELENIUM_UNIT); - MetadataUtils.submitMetadataSearch(driver); - - MetadataUtils.waitForSearchResults(driver); - - String itemNameSelector = String.format("/%s/home/%s/%s", UiTestUtilities.IRODS_ZONE, UiTestUtilities.RODS_USERNAME, MetadataUtils.METADATA_SEARCH_FILES[0]); - driver.findElement(By.name(itemNameSelector)).click(); - - new WebDriverWait(driver, 10).until( - ExpectedConditions.visibilityOfElementLocated(By - .cssSelector("#backToMetadataSearch a[href='/emc-metalnx-web/metadata/?backFromCollections=true']"))).click(); - - // after coming back from the colls page, the same results as before clicking on a metadata - // search result item should be shown - assertMetadataSearchResults(); - } - - /** - * Private method that checks is any result is got from the query. Also, checks if the number of - * results shown is the same as expected. Finally, it checks if the results are shown in the - * correct order. - */ - private void assertMetadataSearchResults() { - logger.info("Waiting for metadata search results {}...", new Date()); - - MetadataUtils.waitForSearchResults(driver); - - List metadataSearchResults = driver.findElements(By.cssSelector("#treeViewTable tbody a")); - - logger.info("Checking if any result was found", new Date()); - Assert.assertNotNull(metadataSearchResults); - - // check if the number of results found matches the number of files used for testing - Assert.assertEquals(MetadataUtils.TOTAL_FILES_METADATA_SEARCH, metadataSearchResults.size()); - - MetadataUtils.assertMetadataSearchResultsOrder(driver); - } -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/metadata/MetadataSearchWithDifferentOperatorsTest.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/metadata/MetadataSearchWithDifferentOperatorsTest.java deleted file mode 100755 index 4ba06f0c1..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/metadata/MetadataSearchWithDifferentOperatorsTest.java +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.integration.test.metadata; - -import com.emc.metalnx.core.domain.exceptions.DataGridException; -import com.emc.metalnx.integration.test.utils.FileUtils; -import com.emc.metalnx.integration.test.utils.MetadataUtils; -import com.emc.metalnx.test.generic.UiTestUtilities; -import org.junit.*; -import org.openqa.selenium.By; -import org.openqa.selenium.TimeoutException; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.List; - -import static org.junit.Assert.fail; - -@Deprecated -@Ignore -public class MetadataSearchWithDifferentOperatorsTest { - private static final Logger logger = LoggerFactory.getLogger(MetadataSearchWithDifferentOperatorsTest.class); - private static WebDriver driver = null; - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - UiTestUtilities.init(); - driver = UiTestUtilities.getDriver(); - FileUtils.forceRemoveFilesFromHomeAsAdmin(MetadataUtils.METADATA_SEARCH_FILES); - FileUtils.uploadToHomeDirAsAdmin(MetadataUtils.METADATA_SEARCH_FILES); - UiTestUtilities.login(); - - driver.get(UiTestUtilities.COLLECTIONS_URL); - WebDriverWait wait = new WebDriverWait(driver, 10); - wait.until(ExpectedConditions.elementToBeClickable(By.id("breadcrumbOptionsMenu"))); - for (String file : MetadataUtils.METADATA_SEARCH_FILES) { - try { - new WebDriverWait(driver, 1).until(ExpectedConditions.elementToBeClickable(By.id("çççç"))); - } - catch (Exception e) { - - } - MetadataUtils.addMetadata(driver, MetadataUtils.SELENIUM_ATTR, MetadataUtils.SELENIUM_VALUE, "", file); - } - - UiTestUtilities.logout(); - } - - @Before - public void setUp() throws Exception { - UiTestUtilities.login(); - } - - @After - public void tearDown() throws Exception { - UiTestUtilities.logout(); - } - - @AfterClass - public static void tearDownAfterClass() throws DataGridException { - FileUtils.forceRemoveFilesFromHomeAsAdmin(MetadataUtils.METADATA_SEARCH_FILES); - - if (driver != null) { - driver.quit(); - driver = null; - UiTestUtilities.setDriver(null); - } - } - - /** - * Method used for testing the equals operator for metadata search. - * Search criteria: Selenium EQUALS Test - * Number of results: 0 - * Results Expected: None - * Expected Exceptions: {@link TimeoutException} - */ - @Test(expected = TimeoutException.class) - public void testSeleniumAttributeNotEqualsTestValue() { - logger.info("Testing 'selenium' attribute not equals to 'test' value"); - - driver.get(UiTestUtilities.METADATA_SEARCH_URL); - MetadataUtils.fillInMetadataSearchAttrVal(driver, MetadataUtils.SELENIUM_ATTR, MetadataUtils.SELENIUM_VALUE); - MetadataUtils.fillInMetadataSearchOperator(driver, MetadataUtils.NOT_EQUAL); - MetadataUtils.submitMetadataSearch(driver); - MetadataUtils.waitForSearchResults(driver); - - fail("Metalnx should not find any results for this search (EQUALS)."); - } - - /** - * Method used for testing the contains operator for metadata search. - * Search criteria: Selenium CONTAINS Tes - * Number of results: 3 - * Results Expected: - * 1) 1SeleniumTestMetadataSearch.png - * 2) 2SeleniumTestMetadataSearch.png - * 3) 3SeleniumTestMetadataSearch.png - */ - @Test - public void testSeleniumAttributeContainsTeValue() { - logger.info("Testing 'selenium' attribute contains 'Tes' value"); - - driver.get(UiTestUtilities.METADATA_SEARCH_URL); - MetadataUtils.fillInMetadataSearchAttrVal(driver, MetadataUtils.SELENIUM_ATTR, MetadataUtils.SELENIUM_VALUE.subSequence(0, 2).toString()); - MetadataUtils.fillInMetadataSearchOperator(driver, MetadataUtils.LIKE); - MetadataUtils.submitMetadataSearch(driver); - MetadataUtils.waitForSearchResults(driver); - - List results = driver.findElements(MetadataUtils.METADATA_SEARCH_RESULTS); - - Assert.assertNotNull(results); - - logger.info("Check if the number of results found matches the number of files used for testing"); - Assert.assertEquals(MetadataUtils.TOTAL_FILES_METADATA_SEARCH, results.size()); - - logger.info("Check if each file found by the search is the same as expected."); - int index = 0; - for (WebElement metadataSearchResult : results) { - Assert.assertEquals(metadataSearchResult.getText().trim(), MetadataUtils.METADATA_SEARCH_FILES[index]); - index++; - } - } - - /** - * Method used for testing the NOT contains operator for metadata search. - * Search criteria: Selenium NOT CONTAINS Tes - * Number of results: 3 - * Results Expected: - * 1) 1SeleniumTestMetadataSearch.png - * 2) 2SeleniumTestMetadataSearch.png - * 3) 3SeleniumTestMetadataSearch.png - * Expected Exceptions: {@link TimeoutException} - */ - @Test(expected = TimeoutException.class) - public void testSeleniumAttributeNotContainsTeValue() { - logger.info("Testing 'Selenium' attribute NOT contains 'Tes' value"); - - driver.get(UiTestUtilities.METADATA_SEARCH_URL); - MetadataUtils.fillInMetadataSearchAttrVal(driver, MetadataUtils.SELENIUM_ATTR, MetadataUtils.SELENIUM_VALUE.subSequence(0, 2).toString()); - MetadataUtils.fillInMetadataSearchOperator(driver, MetadataUtils.NOT_LIKE); - MetadataUtils.submitMetadataSearch(driver); - MetadataUtils.waitForSearchResults(driver); - - fail("Metalnx should not find any results for this search (NOT CONTAINS)."); - } -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/metadata/MetadataTest.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/metadata/MetadataTest.java deleted file mode 100755 index 955b35247..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/metadata/MetadataTest.java +++ /dev/null @@ -1,392 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.integration.test.metadata; - -import com.emc.metalnx.core.domain.exceptions.DataGridException; -import com.emc.metalnx.integration.test.utils.CollectionUtils; -import com.emc.metalnx.integration.test.utils.FileUtils; -import com.emc.metalnx.integration.test.utils.MetadataUtils; -import com.emc.metalnx.test.generic.UiTestUtilities; -import org.apache.commons.lang3.RandomStringUtils; -import org.junit.*; -import org.openqa.selenium.By; -import org.openqa.selenium.TimeoutException; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Date; -import java.util.List; - -import static org.junit.Assert.fail; - -@Deprecated -@Ignore -public class MetadataTest { - private static final Logger logger = LoggerFactory.getLogger(MetadataTest.class); - - private static WebDriver driver = null; - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - UiTestUtilities.init(); - driver = UiTestUtilities.getDriver(); - FileUtils.forceRemoveFilesFromHomeAsAdmin(MetadataUtils.METADATA_SEARCH_FILES); - FileUtils.uploadToHomeDirAsAdmin(MetadataUtils.METADATA_SEARCH_FILES); - - UiTestUtilities.login(); - WebDriverWait wait = new WebDriverWait(driver, 10); - - MetadataUtils.realWaitMethod(driver); - driver.get(UiTestUtilities.COLLECTIONS_URL); - wait.until(ExpectedConditions.elementToBeClickable(MetadataUtils.TAB_LINKS)); - wait.until(ExpectedConditions.elementToBeClickable(CollectionUtils.COLLS_TABLE)); - MetadataUtils.addMetadata(driver, MetadataUtils.SELENIUM_ATTR, MetadataUtils.SELENIUM_VALUE, "", MetadataUtils.METADATA_SEARCH_FILES[0]); - - MetadataUtils.realWaitMethod(driver); - driver.get(UiTestUtilities.COLLECTIONS_URL); - wait.until(ExpectedConditions.elementToBeClickable(MetadataUtils.TAB_LINKS)); - wait.until(ExpectedConditions.elementToBeClickable(CollectionUtils.COLLS_TABLE)); - MetadataUtils.addMetadata(driver, MetadataUtils.SELENIUM_ATTR, MetadataUtils.SELENIUM_VALUE, "", MetadataUtils.METADATA_SEARCH_FILES[1]); - - MetadataUtils.realWaitMethod(driver); - driver.get(UiTestUtilities.COLLECTIONS_URL); - wait.until(ExpectedConditions.elementToBeClickable(MetadataUtils.TAB_LINKS)); - wait.until(ExpectedConditions.elementToBeClickable(CollectionUtils.COLLS_TABLE)); - MetadataUtils.addMetadata(driver, MetadataUtils.SELENIUM_ATTR, MetadataUtils.SELENIUM_VALUE, "", MetadataUtils.METADATA_SEARCH_FILES[2]); - - MetadataUtils.realWaitMethod(driver); - MetadataUtils.addMetadataToSpecificFiles(driver); - UiTestUtilities.logout(); - } - - /** - * Logs in before each test. - */ - @Before - public void setUp() throws Exception { - UiTestUtilities.login(); - } - - /** - * After each test the user is logged out. - */ - @After - public void tearDown() throws Exception { - UiTestUtilities.logout(); - } - - /** - * After all tests are done, the test must quit the driver. This will close every window - * associated with the current driver instance. - * - * @throws DataGridException - */ - @AfterClass - public static void tearDownAfterClass() throws DataGridException { - FileUtils.forceRemoveFilesFromHomeAsAdmin(MetadataUtils.METADATA_SEARCH_FILES); - - if (driver != null) { - driver.quit(); - driver = null; - UiTestUtilities.setDriver(null); - } - } - - /** - * Test metadata search using "Selenium" as attribute and "Test" as value. - * Number of results expected: 3. All files in {@code metadataSearchFiles} have this piece of - * metadata. - * Results expected: 1SeleniumTestMetadataSearch.png, 2SeleniumTestMetadataSearch.png, and - * 3SeleniumTestMetadataSearch.png. The results must appear in this particular order. - */ - @Test - public void testSeleniumAsAttrAndTestAsValue() { - logger.info("Testing Metadata search"); - - driver.get(UiTestUtilities.METADATA_SEARCH_URL); - MetadataUtils.fillInMetadataSearchAttrVal(driver, MetadataUtils.SELENIUM_ATTR, MetadataUtils.SELENIUM_VALUE); - MetadataUtils.submitMetadataSearch(driver); - MetadataUtils.waitForSearchResults(driver); - List results = driver.findElements(MetadataUtils.METADATA_SEARCH_RESULTS); - Assert.assertNotNull(results); - - // check if the number of results found matches the number of files used for testing - Assert.assertEquals(MetadataUtils.TOTAL_FILES_METADATA_SEARCH, results.size()); - - // check if each file found is the file used for testing - int index = 0; - for (WebElement metadataSearchResult : results) { - Assert.assertEquals(metadataSearchResult.getText().trim(), MetadataUtils.METADATA_SEARCH_FILES[index]); - index++; - } - } - - /** - * Test metadata search on the file 1SeleniumTestMetadataSearch. - * Search parameters: SeleniumTest (attribute) and 1 (value) - * Number of results expected: 1 (only this file should have this particular piece of metadata) - * Results expected: 1SeleniumTestMetadataSearch.png - */ - @Test - public void testSeleniumTestAsAttrAnd1AsValue() { - logger.info("Testing Metadata search using Selenium Test as the attribute and 1 as the value"); - driver.get(UiTestUtilities.METADATA_SEARCH_URL); - - MetadataUtils.fillInMetadataSearchAttrVal(driver, MetadataUtils.SELENIUM_TEST_ATTR, MetadataUtils.SELENIUM_TEST_VAL1); - MetadataUtils.submitMetadataSearch(driver); - MetadataUtils.waitForSearchResults(driver); - List results = driver.findElements(MetadataUtils.METADATA_SEARCH_RESULTS); - Assert.assertNotNull(results); - - // check if the number of results found matches the number of files used for testing - Assert.assertEquals(1, results.size()); - - // check if each file found is the file used for testing - Assert.assertEquals(results.get(0).getText().trim(), MetadataUtils.METADATA_SEARCH_FILES[0]); - } - - /** - * Test metadata search on the file 2SeleniumTestMetadataSearch. - * Search parameters: SeleniumTest (attribute) and 2 (value) - * Number of results expected: 1 (only this file should have this particular piece of metadata) - * Results expected: 2SeleniumTestMetadataSearch.png - */ - @Test - public void testSeleniumTestAsAttrAnd2AsValue() { - logger.info("Testing Metadata search using Selenium Test as the attribute and 2 as the value"); - - driver.get(UiTestUtilities.METADATA_SEARCH_URL); - MetadataUtils.fillInMetadataSearchAttrVal(driver, MetadataUtils.SELENIUM_TEST_ATTR, MetadataUtils.SELENIUM_TEST_VAL2); - MetadataUtils.submitMetadataSearch(driver); - MetadataUtils.waitForSearchResults(driver); - List results = driver.findElements(MetadataUtils.METADATA_SEARCH_RESULTS); - Assert.assertNotNull(results); - Assert.assertEquals(1, results.size()); - - // check if each file found is the file used for testing - Assert.assertEquals(results.get(0).getText().trim(), MetadataUtils.METADATA_SEARCH_FILES[1]); - } - - /** - * Test metadata search on the file 3SeleniumTestMetadataSearch. - * Search parameters: SeleniumTest (attribute) and 3 (value) - * Number of results expected: 1 (only this file should have this particular piece of metadata) - * Results expected: 3SeleniumTestMetadataSearch.png - */ - @Test - public void testSeleniumTestAsAttrAnd3AsValue() { - logger.info("Testing Metadata search using Selenium Test as the attribute and 3 as the value"); - driver.get(UiTestUtilities.METADATA_SEARCH_URL); - - MetadataUtils.fillInMetadataSearchAttrVal(driver, MetadataUtils.SELENIUM_TEST_ATTR, MetadataUtils.SELENIUM_TEST_VAL3); - MetadataUtils.submitMetadataSearch(driver); - MetadataUtils.waitForSearchResults(driver); - List results = driver.findElements(MetadataUtils.METADATA_SEARCH_RESULTS); - Assert.assertNotNull(results); - - // check if the number of results found matches the number of files used for testing - Assert.assertEquals(1, results.size()); - - // check if each file found is the file used for testing - Assert.assertEquals(results.get(0).getText().trim(), MetadataUtils.METADATA_SEARCH_FILES[2]); - } - - /** - * Test metadata search on the file 1SeleniumTestMetadataSearch and 2SeleniumTestMetadataSearch. - * Search parameters: SeleniumTest (attribute) and 12 (value) - * Number of results expected: 2 (both 1SeleniumTestMetadataSearch and - * 2SeleniumTestMetadataSearch files should have this particular piece of metadata) - * Results expected: 1SeleniumTestMetadataSearch.png and 2SeleniumTestMetadataSearch.png in this - * order. - */ - @Test - public void testSeleniumTestAsAttrAnd12AsValue() { - logger.info("Testing Metadata search using Selenium Test as the attribute and 12 as the value"); - - driver.get(UiTestUtilities.METADATA_SEARCH_URL); - - MetadataUtils.fillInMetadataSearchAttrVal(driver, MetadataUtils.SELENIUM_TEST_ATTR, MetadataUtils.SELENIUM_TEST_VAL12); - MetadataUtils.submitMetadataSearch(driver); - MetadataUtils.waitForSearchResults(driver); - List results = driver.findElements(MetadataUtils.METADATA_SEARCH_RESULTS); - Assert.assertNotNull(results); - - // check if the number of results matches the number of files used for testing - Assert.assertEquals(2, results.size()); - - // check if each file found is the file used for testing - int index = 0; - for (WebElement metadataSearchResult : results) { - Assert.assertEquals(metadataSearchResult.getText().trim(), MetadataUtils.METADATA_SEARCH_FILES[index]); - index++; - } - } - - /** - * Test looking for a piece of metadata that does not exist. - * Search parameters: Random string (attribute) and random string (value) - * Number of results expected: 0 - * Results expected: None - * Expected Exceptions: {@link TimeoutException} - */ - @Test(expected = TimeoutException.class) - public void testSearchUsingNonExistentMetadataTags() { - logger.info("Testing Metadata search using non-existent metadata tags"); - driver.get(UiTestUtilities.METADATA_SEARCH_URL); - - String attr = RandomStringUtils.randomAlphanumeric(4096); - String val = RandomStringUtils.randomAlphanumeric(4096); - MetadataUtils.fillInMetadataSearchAttrVal(driver, attr, val); - MetadataUtils.submitMetadataSearch(driver); - - // Expecting a Timeout exception to happen here since Metalnx is supposed to return - // nothing. Then, the metadata results table will not be displayed. - MetadataUtils.waitForSearchResults(driver); - - fail("Non-existing metadata is actually returning something from the search."); - } - - /** - * Test searching for metadata without giving any search criteria. In other words, testing a - * search without giving any attribute or value as the search criteria. - * Search parameters: None - * Number of results expected: 0 - * Results expected: None - * Expected Exceptions: {@link TimeoutException} - */ - @Test(expected = TimeoutException.class) - public void testSearchWithoutSearchCriteria() { - logger.info("Testing Metadata search using non-existent metadata tags"); - driver.get(UiTestUtilities.METADATA_SEARCH_URL); - - MetadataUtils.submitMetadataSearch(driver); - - // Expecting a Timeout exception to happen here since Metalnx is supposed to return - // nothing. Then, the metadata results table will not be displayed. - MetadataUtils.waitForSearchResults(driver); - - fail("Blank metadata search is actually returning something."); - } - - /** - * Test the number of matches shown for each file used in the search. - * Search parameters: - * 1) Selenium Test - * 2) SeleniumTest 1 - * 3) SeleniumTest 12 - * Number of results expected: 3 - * Results expected: - * 1) 1SeleniumTestMetadataSearch.png (Number of matches: 3) - * 2) 2SeleniumTestMetadataSearch.png (Number of matches: 2) - * 3) 3SeleniumTestMetadataSearch.png (Number of matches: 1) - */ - @Test - public void testNumberOfMatchesDisplayedForEachFileAfterSearching() { - logger.info("Testing the number of matches displayed for each file after doing a search."); - WebElement inputAttr = null; - WebElement inputValue = null; - WebElement addMetadataSearchRowBtn = null; - WebElement metadataSearchMatchColumn = null; - int[] expectedMatchingCounts = { 3, 2, 1 }; - - driver.get(UiTestUtilities.METADATA_SEARCH_URL); - - logger.info("Entering search criteria."); - // adding multiples search criteria to the search - inputAttr = driver.findElement(By.id("metadataAttr0")); - inputAttr.sendKeys(MetadataUtils.SELENIUM_ATTR); - - inputValue = driver.findElement(By.id("metadataValue0")); - inputValue.sendKeys(MetadataUtils.SELENIUM_VALUE); - - addMetadataSearchRowBtn = driver.findElement(By.id("addMetadataSearchRow")); - addMetadataSearchRowBtn.click(); - - inputAttr = driver.findElement(By.id("metadataAttr1")); - inputAttr.sendKeys(MetadataUtils.SELENIUM_TEST_ATTR); - - inputValue = driver.findElement(By.id("metadataValue1")); - inputValue.sendKeys(MetadataUtils.SELENIUM_TEST_VAL1); - - addMetadataSearchRowBtn.click(); - - inputAttr = driver.findElement(By.id("metadataAttr2")); - inputAttr.sendKeys(MetadataUtils.SELENIUM_TEST_ATTR); - - inputValue = driver.findElement(By.id("metadataValue2")); - inputValue.sendKeys(MetadataUtils.SELENIUM_TEST_VAL12); - - MetadataUtils.submitMetadataSearch(driver); - MetadataUtils.waitForSearchResults(driver); - List results = driver.findElements(MetadataUtils.METADATA_SEARCH_RESULTS); - - List metadataSearchResultsMatchesCount = driver.findElements(By.cssSelector("#treeViewTable tbody tr td:last-child")); - - logger.info("Checking if any result was found", new Date()); - Assert.assertNotNull(results); - - // check if the number of results found matches the number of files used for testing - Assert.assertEquals(MetadataUtils.TOTAL_FILES_METADATA_SEARCH, results.size()); - - logger.info("Checking if the number of matches of each file is the same as expected."); - int index = 0; - int matchingCount = 0; - for (WebElement r : results) { - Assert.assertEquals(r.getText().trim(), MetadataUtils.METADATA_SEARCH_FILES[index]); - - metadataSearchMatchColumn = metadataSearchResultsMatchesCount.get(index); - matchingCount = metadataSearchMatchColumn.findElements(By.tagName("i")).size(); - Assert.assertEquals(expectedMatchingCounts[index], matchingCount); - index++; - } - } - - /** - * Adds number maximum of parameters for the metadata search, which is five, and assures that - * add button is hidden when the maximum is reached - */ - @Test - public void testAddMaxNumOfSearchParams() { - MetadataUtils.addMaxNumberOfSearchParams(driver); - List metadataSearchParameters = driver.findElements(By.className("metadataSearchRow")); - - Assert.assertEquals(metadataSearchParameters.size(), 5); - } - - /** - * Adds number maximum of parameters for the metadata search, which is five, and assures that - * add button is hidden when the maximum is reached - */ - @Test - public void testRmvMaxNumOfSearchParams() { - MetadataUtils.addMaxNumberOfSearchParams(driver); - List metadataSearchParameters = driver.findElements(By.className("metadataSearchRow")); - - Assert.assertEquals(metadataSearchParameters.size(), 5); - - WebElement rmSearchParam = driver.findElement(By.className("rmMetadataSearchRow")); - rmSearchParam.click(); - - WebDriverWait wait = new WebDriverWait(driver, 10); - wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("addMetadataSearchRow"))); - - } -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/mygroups/RodsAdminNotInAnyGroupTest.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/mygroups/RodsAdminNotInAnyGroupTest.java deleted file mode 100755 index 0c10fc1df..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/mygroups/RodsAdminNotInAnyGroupTest.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.integration.test.mygroups; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; - -import com.emc.metalnx.core.domain.exceptions.DataGridException; -import com.emc.metalnx.integration.test.utils.UserUtils; -import com.emc.metalnx.test.generic.UiTestUtilities; - -import junit.framework.Assert; - -/** - * Test class that checks if a user who is not in any group can access the My - * Groups page. - * - */ -@Deprecated -@Ignore -public class RodsAdminNotInAnyGroupTest { - - private static String pwd = "webdriver"; - private static String rodsAdminUsername; - private static WebDriver driver = null; - private By groupBookmarksTable = By.id("groupBookmarksTable"); - private By groupBookmarksTableBody = By.cssSelector("#groupBookmarksTable tbody tr td"); - - /************************************* - * TEST SET UP - *************************************/ - - @BeforeClass - public static void setUpBeforeClass() throws DataGridException { - // UITest.setUpBeforeClass(); - driver = UiTestUtilities.getDriver(); - - rodsAdminUsername = "userMyGroupsRodsAdmin" + System.currentTimeMillis(); - UserUtils.createUser(rodsAdminUsername, pwd, UiTestUtilities.RODS_USER_TYPE, driver); - } - - @Before - public void setUp() { - UiTestUtilities.login(rodsAdminUsername, pwd); - } - - @After - public void tearDown() { - UiTestUtilities.logout(); - } - - @AfterClass - public static void tearDownAfterClass() throws DataGridException { - UserUtils.removeUser(rodsAdminUsername, driver); - - if (driver != null) { - driver.quit(); - driver = null; - UiTestUtilities.setDriver(null); - } - } - - @Test - public void testRodsUserNotInAnyGroupShouldSeeNothingOnMyGroupsPage() { - driver.get(UiTestUtilities.MY_GROUPS_PAGE); - new WebDriverWait(driver, 10).until(ExpectedConditions.presenceOfElementLocated(groupBookmarksTable)); - new WebDriverWait(driver, 10).until(ExpectedConditions.visibilityOfElementLocated(groupBookmarksTableBody)); - - Assert.assertNotNull(driver.findElement(By.cssSelector("#groupBookmarksTable .dataTables_empty"))); - } -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/mygroups/RodsUserNotInAnyGroupTest.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/mygroups/RodsUserNotInAnyGroupTest.java deleted file mode 100755 index 17d8fcb3d..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/mygroups/RodsUserNotInAnyGroupTest.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.integration.test.mygroups; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; - -import com.emc.metalnx.core.domain.exceptions.DataGridException; -import com.emc.metalnx.integration.test.utils.UserUtils; -import com.emc.metalnx.test.generic.UiTestUtilities; - -import junit.framework.Assert; - -/** - * Test class that checks if a user who is not in any group can access the My - * Groups page. - * - */ -@Deprecated -@Ignore -public class RodsUserNotInAnyGroupTest { - - private static String pwd = "webdriver"; - private static String rodsUsername; - private static WebDriver driver = null; - private By groupBookmarksTable = By.id("groupBookmarksTable"); - private By groupBookmarksTableBody = By.cssSelector("#groupBookmarksTable tbody tr td"); - - /************************************* - * TEST SET UP - *************************************/ - - @BeforeClass - public static void setUpBeforeClass() throws DataGridException { - // UITest.setUpBeforeClass(); - driver = UiTestUtilities.getDriver(); - - rodsUsername = "userMyGroupsRodsUser" + System.currentTimeMillis(); - UserUtils.createUser(rodsUsername, pwd, UiTestUtilities.RODS_USER_TYPE, driver); - } - - @Before - public void setUp() { - UiTestUtilities.login(rodsUsername, pwd); - } - - @After - public void tearDown() { - UiTestUtilities.logout(); - } - - @AfterClass - public static void tearDownAfterClass() throws DataGridException { - UserUtils.removeUser(rodsUsername, driver); - - if (driver != null) { - driver.quit(); - driver = null; - UiTestUtilities.setDriver(null); - } - } - - @Test - public void testRodsUserNotInAnyGroupShouldSeeNothingOnMyGroupsPage() { - driver.get(UiTestUtilities.MY_GROUPS_PAGE); - new WebDriverWait(driver, 10).until(ExpectedConditions.presenceOfElementLocated(groupBookmarksTable)); - new WebDriverWait(driver, 10).until(ExpectedConditions.visibilityOfElementLocated(groupBookmarksTableBody)); - - Assert.assertNotNull(driver.findElement(By.cssSelector("#groupBookmarksTable .dataTables_empty"))); - } -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/permissions/ChangeGroupPermissionOnCollRecursivelyTest.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/permissions/ChangeGroupPermissionOnCollRecursivelyTest.java deleted file mode 100755 index 3cf160a0e..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/permissions/ChangeGroupPermissionOnCollRecursivelyTest.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.integration.test.permissions; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.openqa.selenium.WebDriver; - -import com.emc.metalnx.core.domain.exceptions.DataGridException; -import com.emc.metalnx.integration.test.group.GroupUtils; -import com.emc.metalnx.integration.test.utils.CollectionUtils; -import com.emc.metalnx.test.generic.UiTestUtilities; - -import junit.framework.Assert; - -/** - * Selenium test for Group permission on the Collectinos Mgmt. Page. This class - * tests modifying a group permission on a collection. This permission is - * applied using the recursive option. - * - */ -@Deprecated -@Ignore -public class ChangeGroupPermissionOnCollRecursivelyTest { - - private static WebDriver driver = null; - private static String groupName = null; - - /************************************** - * TEST SET UP - **************************************/ - - @BeforeClass - public static void setUpBeforeClass() throws DataGridException { - // UITest.setUpBeforeClass(); - driver = UiTestUtilities.getDriver(); - - UiTestUtilities.login(); - - try { - for (String collName : UiTestUtilities.TEST_COLLECTION_NAMES) { - CollectionUtils.removeCollUnderZone(driver, collName, UiTestUtilities.IRODS_ZONE); - } - } catch (Exception e) { - } - - UiTestUtilities.logout(); - UiTestUtilities.login(); - - for (String collName : UiTestUtilities.TEST_COLLECTION_NAMES) { - CollectionUtils.createCollectionUnderZone(driver, collName, UiTestUtilities.IRODS_ZONE); - } - - UiTestUtilities.logout(); - } - - @Before - public void setUp() throws Exception { - UiTestUtilities.login(); - - groupName = "grouppermissionrecursive" + System.currentTimeMillis(); - GroupUtils.createGroupWithPermissions(driver, groupName, "read", UiTestUtilities.TEST_COLLECTION_NAMES); - } - - /** - * After each test the user created for the test should be removed. - */ - @After - public void tearDown() throws Exception { - GroupUtils.removeGroup(groupName, driver); - UiTestUtilities.logout(); - } - - /** - * After all tests are done, the test must quit the driver. This will close - * every window associated with the current driver instance. - * - * @throws DataGridException - */ - - @AfterClass - public static void tearDownAfterClass() throws DataGridException { - CollectionUtils.cleanUpCollectionsUnderZone(driver, UiTestUtilities.TEST_COLLECTION_NAMES); - - if (driver != null) { - driver.quit(); - driver = null; - UiTestUtilities.setDriver(null); - } - } - - /********************************************* - * TESTS - *********************************************/ - - /** - * Test changing the permission of a group to WRITE on a collection recursively. - */ - @Test - public void testChangePermissionOfGroupToWrite() { - CollectionUtils.changePermissionOfGroup(driver, groupName, "write", UiTestUtilities.TEST_COLLECTION_NAMES[0]); - Assert.assertFalse(driver.getCurrentUrl().equalsIgnoreCase(UiTestUtilities.HTTP_ERROR_500_URL)); - } - - /** - * Test changing the permission of a group to OWN on a collection recursively. - */ - @Test - public void testChangePermissionOfGroupToOwn() { - CollectionUtils.changePermissionOfGroup(driver, groupName, "own", UiTestUtilities.TEST_COLLECTION_NAMES[0]); - Assert.assertFalse(driver.getCurrentUrl().equalsIgnoreCase(UiTestUtilities.HTTP_ERROR_500_URL)); - } - - /** - * Test changing the permission of a group to NONE on a collection recursively. - */ - @Test - public void testChangePermissionOfGroupToNone() { - CollectionUtils.changePermissionOfGroup(driver, groupName, "none", UiTestUtilities.TEST_COLLECTION_NAMES[0]); - Assert.assertFalse(driver.getCurrentUrl().equalsIgnoreCase(UiTestUtilities.HTTP_ERROR_500_URL)); - } - - /** - * Test changing the permission of a group to READ on a collection recursively. - */ - @Test - public void testChangePermissionOfGroupToRead() { - /* - * In order for the group to show up in the permission table, the permission has - * to exist (different than NONE). Then, since the group is created with READ - * permission, we need to set it to WRITE or OWN to be able to test READ. - */ - CollectionUtils.changePermissionOfGroup(driver, groupName, "write", UiTestUtilities.TEST_COLLECTION_NAMES[0]); - - CollectionUtils.changePermissionOfGroup(driver, groupName, "read", UiTestUtilities.TEST_COLLECTION_NAMES[0]); - Assert.assertFalse(driver.getCurrentUrl().equalsIgnoreCase(UiTestUtilities.HTTP_ERROR_500_URL)); - } -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/permissions/ChangeGroupPermissionOnFileRecursivelyTest.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/permissions/ChangeGroupPermissionOnFileRecursivelyTest.java deleted file mode 100755 index e4ccc01aa..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/permissions/ChangeGroupPermissionOnFileRecursivelyTest.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.integration.test.permissions; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.openqa.selenium.WebDriver; - -import com.emc.metalnx.core.domain.exceptions.DataGridException; -import com.emc.metalnx.integration.test.group.GroupUtils; -import com.emc.metalnx.integration.test.utils.CollectionUtils; -import com.emc.metalnx.integration.test.utils.FileUtils; -import com.emc.metalnx.test.generic.UiTestUtilities; - -import junit.framework.Assert; - -/** - * Selenium test for Group permission on the Collectinos Mgmt. Page. This class - * tests modifying a group permission on a collection. This permission is - * applied using the recursive option. - * - */ -@Deprecated -@Ignore -public class ChangeGroupPermissionOnFileRecursivelyTest { - - private static WebDriver driver = null; - private static String groupName = null; - - /************************************** - * TEST SET UP - **************************************/ - - @BeforeClass - public static void setUpBeforeClass() throws DataGridException { - // UITest.setUpBeforeClass(); - driver = UiTestUtilities.getDriver(); - - FileUtils.forceRemoveFilesFromDirAsAdmin("/" + UiTestUtilities.IRODS_ZONE, UiTestUtilities.TEST_FILE_NAMES); - FileUtils.uploadToDirAsAdmin("/" + UiTestUtilities.IRODS_ZONE, UiTestUtilities.TEST_FILE_NAMES); - } - - @Before - public void setUp() throws Exception { - UiTestUtilities.login(); - - groupName = "grouppermissionrecursive" + System.currentTimeMillis(); - GroupUtils.createGroupWithPermissions(driver, groupName, "read", UiTestUtilities.TEST_FILE_NAMES); - } - - /** - * After each test the user created for the test should be removed. - */ - @After - public void tearDown() throws Exception { - GroupUtils.removeGroup(groupName, driver); - UiTestUtilities.logout(); - } - - /** - * After all tests are done, the test must quit the driver. This will close - * every window associated with the current driver instance. - * - * @throws DataGridException - */ - - @AfterClass - public static void tearDownAfterClass() throws DataGridException { - FileUtils.forceRemoveFilesFromDirAsAdmin("/" + UiTestUtilities.IRODS_ZONE, UiTestUtilities.TEST_FILE_NAMES); - - if (driver != null) { - driver.quit(); - driver = null; - UiTestUtilities.setDriver(null); - } - } - - /********************************************* - * TESTS - *********************************************/ - - /** - * Test changing the permission of a group to WRITE on a collection recursively. - */ - @Test - public void testChangePermissionOfGroupToWrite() { - CollectionUtils.changePermissionOfGroup(driver, groupName, "write", UiTestUtilities.TEST_FILE_NAMES[0]); - Assert.assertFalse(driver.getCurrentUrl().equalsIgnoreCase(UiTestUtilities.HTTP_ERROR_500_URL)); - } - - /** - * Test changing the permission of a group to OWN on a collection recursively. - */ - @Test - public void testChangePermissionOfGroupToOwn() { - CollectionUtils.changePermissionOfGroup(driver, groupName, "own", UiTestUtilities.TEST_FILE_NAMES[0]); - Assert.assertFalse(driver.getCurrentUrl().equalsIgnoreCase(UiTestUtilities.HTTP_ERROR_500_URL)); - } - - /** - * Test changing the permission of a group to NONE on a collection recursively. - */ - @Test - public void testChangePermissionOfGroupToNone() { - CollectionUtils.changePermissionOfGroup(driver, groupName, "none", UiTestUtilities.TEST_FILE_NAMES[0]); - Assert.assertFalse(driver.getCurrentUrl().equalsIgnoreCase(UiTestUtilities.HTTP_ERROR_500_URL)); - } - - /** - * Test changing the permission of a group to READ on a collection recursively. - */ - @Test - public void testChangePermissionOfGroupToRead() { - /* - * In order for the group to show up in the permission table, the permission has - * to exist (different than NONE). Then, since the group is created with READ - * permission, we need to set it to WRITE or OWN to be able to test READ. - */ - CollectionUtils.changePermissionOfGroup(driver, groupName, "write", UiTestUtilities.TEST_FILE_NAMES[0]); - - CollectionUtils.changePermissionOfGroup(driver, groupName, "read", UiTestUtilities.TEST_FILE_NAMES[0]); - Assert.assertFalse(driver.getCurrentUrl().equalsIgnoreCase(UiTestUtilities.HTTP_ERROR_500_URL)); - } -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/permissions/ExistingUserAdditionalPermissionTest.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/permissions/ExistingUserAdditionalPermissionTest.java deleted file mode 100755 index 668353768..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/permissions/ExistingUserAdditionalPermissionTest.java +++ /dev/null @@ -1,236 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.integration.test.permissions; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.openqa.selenium.WebDriver; - -import com.emc.metalnx.core.domain.exceptions.DataGridException; -import com.emc.metalnx.integration.test.utils.CollectionUtils; -import com.emc.metalnx.integration.test.utils.FileUtils; -import com.emc.metalnx.integration.test.utils.UserUtils; -import com.emc.metalnx.test.generic.UiTestUtilities; - -/** - * Selenium tests on the additional permission functionality when modifying an - * existing Metalnx user. This class tests adding read, write and ownership - * permissions to files and collections for an existing user. - * - */ -@Deprecated -@Ignore -public class ExistingUserAdditionalPermissionTest { - - private String uname = "existingUserAdditionalPermission" + System.currentTimeMillis(); - private String pwd = "webdriver"; - - private static WebDriver driver = null; - - /************************************** - * TEST SET UP - **************************************/ - - @BeforeClass - public static void setUpBeforeClass() throws DataGridException { - // UITest.setUpBeforeClass(); - driver = UiTestUtilities.getDriver(); - - FileUtils.forceRemoveFilesFromDirAsAdmin("/" + UiTestUtilities.IRODS_ZONE, UiTestUtilities.TEST_FILE_NAMES); - CollectionUtils.cleanUpCollectionsUnderZone(driver, UiTestUtilities.TEST_COLLECTION_NAMES); - - UiTestUtilities.login(); - for (String collName : UiTestUtilities.TEST_COLLECTION_NAMES) { - CollectionUtils.createCollectionUnderZone(driver, collName, UiTestUtilities.IRODS_ZONE); - } - - FileUtils.uploadToDirAsAdmin("/" + UiTestUtilities.IRODS_ZONE, UiTestUtilities.TEST_FILE_NAMES); - UiTestUtilities.logout(); - } - - @Before - public void setUp() throws Exception { - UserUtils.createUser(uname, pwd, UiTestUtilities.RODS_ADMIN_TYPE, driver); - UiTestUtilities.login(); - } - - /** - * After each test the user created for the test should be removed. - */ - @After - public void tearDown() throws Exception { - UiTestUtilities.logout(); - UserUtils.removeUser(uname, driver); - } - - /** - * After all tests are done, the test must quit the driver. This will close - * every window associated with the current driver instance. - * - * @throws DataGridException - */ - - @AfterClass - public static void tearDownAfterClass() throws DataGridException { - UiTestUtilities.login(); - FileUtils.forceRemoveFilesFromDirAsAdmin("/" + UiTestUtilities.IRODS_ZONE, UiTestUtilities.TEST_FILE_NAMES); - CollectionUtils.cleanUpCollectionsUnderZone(driver, UiTestUtilities.TEST_COLLECTION_NAMES); - UiTestUtilities.logout(); - - if (driver != null) { - driver.quit(); - driver = null; - UiTestUtilities.setDriver(null); - } - } - - /************************************* - * RODS ADMIN TESTS - *************************************/ - - /** - * Grant READ permission and a bookmark to a rods admin user on data objects, - * log in as such user and check if these data object show up in the bookmarks - * page. - */ - @Test - public void testGrantReadPermissionAndBookmarkOnFilesToRodsAdminAndCheckIfBookmarksShowUp() { - UserUtils.modifyUserGrantPermissionAndCheckBookmarks(UiTestUtilities.READ_PERMISSION, uname, UiTestUtilities.IRODS_ZONE, pwd, - UiTestUtilities.TEST_FILE_NAMES, driver); - } - - /** - * Grant READ permission and a bookmark to a rods admin user on collections, log - * in as such user and check if these collections show up in the bookmarks page. - */ - @Test - public void testGrantReadPermissionAndBookmarkOnCollsToRodsAdminAndCheckIfBookmarksShowUp() { - UserUtils.modifyUserGrantPermissionAndCheckBookmarks(UiTestUtilities.READ_PERMISSION, uname, UiTestUtilities.IRODS_ZONE, pwd, - UiTestUtilities.TEST_COLLECTION_NAMES, driver); - } - - /** - * Grant READ permission and a bookmark to a rods admin user on data objects, - * log in as such user and check if the data object show up in the bookmarks - * page. - */ - @Test - public void testGrantWritePermissionAndBookmarkOnFilesToRodsAdminAndCheckIfBookmarksShowUp() { - UserUtils.modifyUserGrantPermissionAndCheckBookmarks(UiTestUtilities.WRITE_PERMISSION, uname, UiTestUtilities.IRODS_ZONE, pwd, - UiTestUtilities.TEST_FILE_NAMES, driver); - } - - /** - * Grant READ permission and a bookmark to a rods admin user on collections, log - * in as such user and check if these collections show up in the bookmarks page. - */ - @Test - public void testGrantWritePermissionAndBookmarkOnCollsToRodsAdminAndCheckIfBookmarksShowUp() { - UserUtils.modifyUserGrantPermissionAndCheckBookmarks(UiTestUtilities.WRITE_PERMISSION, uname, UiTestUtilities.IRODS_ZONE, pwd, - UiTestUtilities.TEST_COLLECTION_NAMES, driver); - } - - /** - * Grant READ permission and a bookmark to a rods admin user on data objects, - * log in as such user and check if these data objects show up in the bookmarks - * page. - */ - @Test - public void testGrantOwnPermissionAndBookmarkOnFilesToRodsAdminAndCheckIfBookmarksShowUp() { - UserUtils.modifyUserGrantPermissionAndCheckBookmarks(UiTestUtilities.OWN_PERMISSION, uname, UiTestUtilities.IRODS_ZONE, pwd, - UiTestUtilities.TEST_FILE_NAMES, driver); - } - - /** - * Grant WRITE permission and a bookmark to a rods admin user on collections, - * log in as such user and check if these collections show up in the bookmarks - * page. - */ - @Test - public void testGrantOwnPermissionAndBookmarkOnCollsToRodsAdminAndCheckIfBookmarksShowUp() { - UserUtils.modifyUserGrantPermissionAndCheckBookmarks(UiTestUtilities.OWN_PERMISSION, uname, UiTestUtilities.IRODS_ZONE, pwd, - UiTestUtilities.TEST_COLLECTION_NAMES, driver); - } - - /************************************* - * RODS USER TESTS - *************************************/ - - /** - * Grant READ permission and a bookmark to a rods user data objects, log in as - * such user and check if these data object shows up in the bookmarks page. - */ - @Test - public void testGrantReadPermissionAndBookmarkOnFilesToRodsUserAndCheckIfBookmarksShowUp() { - UserUtils.modifyUserGrantPermissionAndCheckBookmarks(UiTestUtilities.READ_PERMISSION, uname, UiTestUtilities.IRODS_ZONE, pwd, - UiTestUtilities.TEST_FILE_NAMES, driver); - } - - /** - * Grant READ permission and a bookmark to a rods user data objects, log in as - * such user and check if these data object shows up in the bookmarks page. - */ - @Test - public void testGrantReadPermissionAndBookmarkOnCollsToRodsUserAndCheckIfBookmarksShowUp() { - UserUtils.modifyUserGrantPermissionAndCheckBookmarks(UiTestUtilities.READ_PERMISSION, uname, UiTestUtilities.IRODS_ZONE, pwd, - UiTestUtilities.TEST_COLLECTION_NAMES, driver); - } - - /** - * Grant WRITE permission and a bookmark to a rods user on collections, log in - * as such user and check if these collections shows up in the bookmarks page. - */ - @Test - public void testGrantWritePermissionAndBookmarkOnFilesToRodsUserAndCheckIfBookmarksShowUp() { - UserUtils.modifyUserGrantPermissionAndCheckBookmarks(UiTestUtilities.WRITE_PERMISSION, uname, UiTestUtilities.IRODS_ZONE, pwd, - UiTestUtilities.TEST_FILE_NAMES, driver); - } - - /** - * Grant WRITE permission and a bookmark to a rods user on collections, log in - * as such user and check if these collections shows up in the bookmarks page. - */ - @Test - public void testGrantWritePermissionAndBookmarkOnCollsToRodsUserAndCheckIfBookmarksShowUp() { - UserUtils.modifyUserGrantPermissionAndCheckBookmarks(UiTestUtilities.WRITE_PERMISSION, uname, UiTestUtilities.IRODS_ZONE, pwd, - UiTestUtilities.TEST_COLLECTION_NAMES, driver); - } - - /** - * Grant OWN permission and a bookmark to a rods user data objects, log in as - * such user and check if the data object shows up in the bookmarks page. - */ - @Test - public void testGrantOwnPermissionAndBookmarkOnFilesToRodsUserAndCheckIfBookmarksShowUp() { - UserUtils.modifyUserGrantPermissionAndCheckBookmarks(UiTestUtilities.OWN_PERMISSION, uname, UiTestUtilities.IRODS_ZONE, pwd, - UiTestUtilities.TEST_FILE_NAMES, driver); - } - - /** - * Grant OWN permission and a bookmark to a rods user collections, log in as - * such user and check if these collections shows up in the bookmarks page. - */ - @Test - public void testGrantOwnPermissionAndBookmarkOnCollsToRodsUserAndCheckIfBookmarksShowUp() { - UserUtils.modifyUserGrantPermissionAndCheckBookmarks(UiTestUtilities.OWN_PERMISSION, uname, UiTestUtilities.IRODS_ZONE, pwd, - UiTestUtilities.TEST_COLLECTION_NAMES, driver); - } -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/permissions/NewUserAdditionalPermissionTest.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/permissions/NewUserAdditionalPermissionTest.java deleted file mode 100755 index 2a958950c..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/permissions/NewUserAdditionalPermissionTest.java +++ /dev/null @@ -1,241 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.integration.test.permissions; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.openqa.selenium.WebDriver; - -import com.emc.metalnx.core.domain.exceptions.DataGridException; -import com.emc.metalnx.integration.test.utils.CollectionUtils; -import com.emc.metalnx.integration.test.utils.FileUtils; -import com.emc.metalnx.integration.test.utils.UserUtils; -import com.emc.metalnx.test.generic.UiTestUtilities; - -/** - * Selenium tests on the additional permission functionality when adding a new - * user into Metalnx. This class tests adding read, write and ownership - * permissions to files and collections for a brand new user. - * - */ -@Deprecated -@Ignore -public class NewUserAdditionalPermissionTest { - - private String uname = "userAdditionalPermission" + System.currentTimeMillis(); - private String pwd = "webdriver"; - - private static WebDriver driver = null; - - /************************************* - * TEST SET UP - * - * @throws DataGridException - *************************************/ - - @BeforeClass - public static void setUpBeforeClass() throws DataGridException { - // UITest.setUpBeforeClass(); - driver = UiTestUtilities.getDriver(); - - FileUtils.forceRemoveFilesFromDirAsAdmin("/" + UiTestUtilities.IRODS_ZONE, UiTestUtilities.TEST_FILE_NAMES); - CollectionUtils.cleanUpCollectionsUnderZone(driver, UiTestUtilities.TEST_COLLECTION_NAMES); - - UiTestUtilities.login(); - for (String collName : UiTestUtilities.TEST_COLLECTION_NAMES) { - CollectionUtils.createCollectionUnderZone(driver, collName, UiTestUtilities.IRODS_ZONE); - } - - FileUtils.uploadToDirAsAdmin("/" + UiTestUtilities.IRODS_ZONE, UiTestUtilities.TEST_FILE_NAMES); - UiTestUtilities.logout(); - } - - @Before - public void setUp() throws Exception { - UiTestUtilities.login(); - - } - - /** - * After each test the user created for the test should be removed. - */ - @After - public void tearDown() throws Exception { - - UiTestUtilities.logout(); - - UserUtils.removeUser(uname, driver); - } - - /** - * After all tests are done, the test must quit the driver. This will close - * every window associated with the current driver instance. - * - * @throws DataGridException - */ - - @AfterClass - public static void tearDownAfterClass() throws DataGridException { - - UiTestUtilities.login(); - FileUtils.forceRemoveFilesFromDirAsAdmin("/" + UiTestUtilities.IRODS_ZONE, UiTestUtilities.TEST_FILE_NAMES); - CollectionUtils.cleanUpCollectionsUnderZone(driver, UiTestUtilities.TEST_COLLECTION_NAMES); - UiTestUtilities.logout(); - - if (driver != null) { - driver.quit(); - driver = null; - UiTestUtilities.setDriver(null); - } - } - - /************************************* - * RODS ADMIN TESTS - *************************************/ - - /** - * Grant READ permission and a bookmark to a rods admin user on data objects, - * log in as such user and check if these data object show up in the bookmarks - * page. - */ - @Test - public void testGrantReadPermissionAndBookmarkOnFilesToRodsAdminAndCheckIfBookmarksShowUp() { - UserUtils.createUserGrantPermissionAndCheckBookmarks(UiTestUtilities.READ_PERMISSION, uname, UiTestUtilities.IRODS_ZONE, pwd, - UiTestUtilities.RODS_ADMIN_TYPE, UiTestUtilities.TEST_FILE_NAMES, driver); - } - - /** - * Grant READ permission and a bookmark to a rods admin user on collections, log - * in as such user and check if these collections show up in the bookmarks page. - */ - @Test - public void testGrantReadPermissionAndBookmarkOnCollsToRodsAdminAndCheckIfBookmarksShowUp() { - UserUtils.createUserGrantPermissionAndCheckBookmarks(UiTestUtilities.READ_PERMISSION, uname, UiTestUtilities.IRODS_ZONE, pwd, - UiTestUtilities.RODS_ADMIN_TYPE, UiTestUtilities.TEST_COLLECTION_NAMES, driver); - } - - /** - * Grant READ permission and a bookmark to a rods admin user on data objects, - * log in as such user and check if the data object show up in the bookmarks - * page. - */ - @Test - public void testGrantWritePermissionAndBookmarkOnFilesToRodsAdminAndCheckIfBookmarksShowUp() { - UserUtils.createUserGrantPermissionAndCheckBookmarks(UiTestUtilities.WRITE_PERMISSION, uname, UiTestUtilities.IRODS_ZONE, pwd, - UiTestUtilities.RODS_ADMIN_TYPE, UiTestUtilities.TEST_FILE_NAMES, driver); - } - - /** - * Grant READ permission and a bookmark to a rods admin user on collections, log - * in as such user and check if these collections show up in the bookmarks page. - */ - @Test - public void testGrantWritePermissionAndBookmarkOnCollsToRodsAdminAndCheckIfBookmarksShowUp() { - UserUtils.createUserGrantPermissionAndCheckBookmarks(UiTestUtilities.WRITE_PERMISSION, uname, UiTestUtilities.IRODS_ZONE, pwd, - UiTestUtilities.RODS_ADMIN_TYPE, UiTestUtilities.TEST_COLLECTION_NAMES, driver); - } - - /** - * Grant READ permission and a bookmark to a rods admin user on data objects, - * log in as such user and check if these data objects show up in the bookmarks - * page. - */ - @Test - public void testGrantOwnPermissionAndBookmarkOnFilesToRodsAdminAndCheckIfBookmarksShowUp() { - UserUtils.createUserGrantPermissionAndCheckBookmarks(UiTestUtilities.OWN_PERMISSION, uname, UiTestUtilities.IRODS_ZONE, pwd, - UiTestUtilities.RODS_ADMIN_TYPE, UiTestUtilities.TEST_FILE_NAMES, driver); - } - - /** - * Grant WRITE permission and a bookmark to a rods admin user on collections, - * log in as such user and check if these collections show up in the bookmarks - * page. - */ - @Test - public void testGrantOwnPermissionAndBookmarkOnCollsToRodsAdminAndCheckIfBookmarksShowUp() { - UserUtils.createUserGrantPermissionAndCheckBookmarks(UiTestUtilities.OWN_PERMISSION, uname, UiTestUtilities.IRODS_ZONE, pwd, - UiTestUtilities.RODS_ADMIN_TYPE, UiTestUtilities.TEST_COLLECTION_NAMES, driver); - } - - /************************************* - * RODS USER TESTS - *************************************/ - - /** - * Grant READ permission and a bookmark to a rods user data objects, log in as - * such user and check if these data object shows up in the bookmarks page. - */ - @Test - public void testGrantReadPermissionAndBookmarkOnFilesToRodsUserAndCheckIfBookmarksShowUp() { - UserUtils.createUserGrantPermissionAndCheckBookmarks(UiTestUtilities.READ_PERMISSION, uname, UiTestUtilities.IRODS_ZONE, pwd, - UiTestUtilities.RODS_USER_TYPE, UiTestUtilities.TEST_FILE_NAMES, driver); - } - - /** - * Grant READ permission and a bookmark to a rods user data objects, log in as - * such user and check if these data object shows up in the bookmarks page. - */ - @Test - public void testGrantReadPermissionAndBookmarkOnCollsToRodsUserAndCheckIfBookmarksShowUp() { - UserUtils.createUserGrantPermissionAndCheckBookmarks(UiTestUtilities.READ_PERMISSION, uname, UiTestUtilities.IRODS_ZONE, pwd, - UiTestUtilities.RODS_USER_TYPE, UiTestUtilities.TEST_COLLECTION_NAMES, driver); - } - - /** - * Grant WRITE permission and a bookmark to a rods user on collections, log in - * as such user and check if these collections shows up in the bookmarks page. - */ - @Test - public void testGrantWritePermissionAndBookmarkOnFilesToRodsUserAndCheckIfBookmarksShowUp() { - UserUtils.createUserGrantPermissionAndCheckBookmarks(UiTestUtilities.WRITE_PERMISSION, uname, UiTestUtilities.IRODS_ZONE, pwd, - UiTestUtilities.RODS_USER_TYPE, UiTestUtilities.TEST_FILE_NAMES, driver); - } - - /** - * Grant WRITE permission and a bookmark to a rods user on collections, log in - * as such user and check if these collections shows up in the bookmarks page. - */ - @Test - public void testGrantWritePermissionAndBookmarkOnCollsToRodsUserAndCheckIfBookmarksShowUp() { - UserUtils.createUserGrantPermissionAndCheckBookmarks(UiTestUtilities.WRITE_PERMISSION, uname, UiTestUtilities.IRODS_ZONE, pwd, - UiTestUtilities.RODS_USER_TYPE, UiTestUtilities.TEST_COLLECTION_NAMES, driver); - } - - /** - * Grant OWN permission and a bookmark to a rods user data objects, log in as - * such user and check if the data object shows up in the bookmarks page. - */ - @Test - public void testGrantOwnPermissionAndBookmarkOnFilesToRodsUserAndCheckIfBookmarksShowUp() { - UserUtils.createUserGrantPermissionAndCheckBookmarks(UiTestUtilities.OWN_PERMISSION, uname, UiTestUtilities.IRODS_ZONE, pwd, - UiTestUtilities.RODS_USER_TYPE, UiTestUtilities.TEST_FILE_NAMES, driver); - } - - /** - * Grant OWN permission and a bookmark to a rods user collections, log in as - * such user and check if these collections shows up in the bookmarks page. - */ - @Test - public void testGrantOwnPermissionAndBookmarkOnCollsToRodsUserAndCheckIfBookmarksShowUp() { - UserUtils.createUserGrantPermissionAndCheckBookmarks(UiTestUtilities.OWN_PERMISSION, uname, UiTestUtilities.IRODS_ZONE, pwd, - UiTestUtilities.RODS_USER_TYPE, UiTestUtilities.TEST_COLLECTION_NAMES, driver); - } -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/profiles/AddProfileTest.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/profiles/AddProfileTest.java deleted file mode 100755 index 00953e006..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/profiles/AddProfileTest.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.integration.test.profiles; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.emc.metalnx.integration.test.utils.ProfileUtils; -import com.emc.metalnx.test.generic.UiTestUtilities; - -import junit.framework.Assert; - -@Deprecated -@Ignore -public class AddProfileTest { - private static final Logger logger = LoggerFactory.getLogger(AddProfileTest.class); - - private static WebDriver driver = null; - - private static final String PROFILE_NAME = "Profile_Name"; - - private static final String PROFILE_DESCRIPTION = "Profile Description"; - - private static final String PUBLIC_GROUP_NAME = "public"; - - private static final String RODSADMIN_GROUP_NAME = "rodsadmin"; - - /************************************* - * TEST SET UP - *************************************/ - - @BeforeClass - public static void setUpBeforeClass() { - // UITest.setUpBeforeClass(); - driver = UiTestUtilities.getDriver(); - } - - @Before - public void setUp() throws Exception { - UiTestUtilities.login(); - WebDriverWait wait = new WebDriverWait(driver, 8); - wait.until(ExpectedConditions.presenceOfElementLocated(By.id("page-wrapper"))); - } - - /** - * After each test the user created for the test should be removed. - */ - @After - public void tearDown() throws Exception { - ProfileUtils.removeProfile(PROFILE_NAME, driver); - UiTestUtilities.logout(); - } - - /** - * After all tests are done, the test must quit the driver. This will close - * every window associated with the current driver instance. - */ - - @AfterClass - public static void tearDownAfterClass() { - if (driver != null) { - driver.quit(); - driver = null; - UiTestUtilities.setDriver(null); - } - } - - /* - * ***************************************************************************** - * *************** ************************************** ADD PROFILE - * ***************************************** - * ***************************************************************************** - * *************** - */ - - /** - * Test method for adding a user profile with valid name, description and groups - * names. It verifies if success message is displayed and profile appears in - * list after submit form. - */ - @Test - public void testAddUserProfile() { - logger.info("Test for adding a new user profile."); - - ProfileUtils.accessAddNewProfileForm(driver); - - assertEquals(driver.getCurrentUrl(), UiTestUtilities.ADD_PROFILES_URL); - - List groupsNames = new ArrayList(); - groupsNames.add(PUBLIC_GROUP_NAME); - groupsNames.add(RODSADMIN_GROUP_NAME); - - ProfileUtils.addUserProfile(PROFILE_NAME, PROFILE_DESCRIPTION, groupsNames, driver); - - WebDriverWait wait = new WebDriverWait(driver, 8); - wait.until(ExpectedConditions.presenceOfElementLocated(By.id("userProfilesListTable"))); - - WebElement divAlertSucess = driver.findElement(By.className("alert-success")); - assertTrue(divAlertSucess.isDisplayed()); - assertTrue(divAlertSucess.getText().contains(PROFILE_NAME)); - - Assert.assertTrue(ProfileUtils.isProfileInList(PROFILE_NAME, driver)); - } - - /** - * Test method for adding a user profile with a empty name. It verifies if it - * remains in same page and does not add new profile. - */ - @Test - public void testAddUserProfileWithEmptyName() { - logger.info("Test for adding a new user profile with empty name."); - - ProfileUtils.accessAddNewProfileForm(driver); - - ProfileUtils.addUserProfile("", "", null, driver); - - assertEquals(UiTestUtilities.ADD_PROFILES_URL, driver.getCurrentUrl()); - - assertTrue(ProfileUtils.errorMessageIsDisplayed("emptyProfileNameMsg", driver)); - } - - /** - * Test method for adding a user profile with an existent name. It verifies if - * it remains in same page and does not add new profile. - */ - @Test - public void testAddUserProfileWithExistentName() { - logger.info("Test for adding a new user profile with an existent name."); - - ProfileUtils.accessAddNewProfileForm(driver); - - ProfileUtils.addUserProfile(PROFILE_NAME, PROFILE_DESCRIPTION, null, driver); - - ProfileUtils.addUserProfile(PROFILE_NAME, PROFILE_DESCRIPTION, null, driver); - - assertEquals(UiTestUtilities.ADD_PROFILES_URL, driver.getCurrentUrl()); - - assertTrue(ProfileUtils.errorMessageIsDisplayed("invalidProfileNameMsg", driver)); - } -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/profiles/RemoveProfileTest.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/profiles/RemoveProfileTest.java deleted file mode 100755 index 1c7189ab8..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/profiles/RemoveProfileTest.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.integration.test.profiles; - -import static org.junit.Assert.assertTrue; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.emc.metalnx.integration.test.utils.ProfileUtils; -import com.emc.metalnx.test.generic.UiTestUtilities; - -import junit.framework.Assert; - -@Deprecated -@Ignore -public class RemoveProfileTest { - private static final Logger logger = LoggerFactory.getLogger(RemoveProfileTest.class); - - private static WebDriver driver = null; - - private static final String PROFILE_NAME = "Profile_Name"; - - private static final String PROFILE_DESCRIPTION = "Profile Description"; - - /************************************* - * TEST SET UP - *************************************/ - - @BeforeClass - public static void setUpBeforeClass() { - // UITest.setUpBeforeClass(); - driver = UiTestUtilities.getDriver(); - } - - @Before - public void setUp() throws Exception { - UiTestUtilities.login(); - WebDriverWait wait = new WebDriverWait(driver, 8); - wait.until(ExpectedConditions.presenceOfElementLocated(By.id("page-wrapper"))); - - ProfileUtils.addUserProfile(PROFILE_NAME, PROFILE_DESCRIPTION, null, driver); - } - - /** - * After each test the user created for the test should be removed. - */ - @After - public void tearDown() throws Exception { - UiTestUtilities.logout(); - } - - /** - * After all tests are done, the test must quit the driver. This will close - * every window associated with the current driver instance. - */ - - @AfterClass - public static void tearDownAfterClass() { - if (driver != null) { - driver.quit(); - driver = null; - UiTestUtilities.setDriver(null); - } - } - - /* - * ***************************************************************************** - * *************** *********************************** REMOVE PROFILE - * ***************************************** - * ***************************************************************************** - * *************** - */ - - /** - * Test method for removing a user profile. It verifies if success message is - * displayed and profile does not appear anymore in profile list. - */ - @Test - public void testRemoveUserProfile() { - logger.info("Test for removing a user profile"); - - driver.get(UiTestUtilities.PROFILES_URL); - - ProfileUtils.removeProfile(PROFILE_NAME, driver); - - WebDriverWait wait = new WebDriverWait(driver, 8); - wait.until(ExpectedConditions.presenceOfElementLocated(By.id("userProfilesListTable"))); - - WebElement divAlertSucess = driver.findElement(By.className("alert-success")); - assertTrue(divAlertSucess.isDisplayed()); - assertTrue(divAlertSucess.getText().contains(PROFILE_NAME)); - - Assert.assertTrue(!ProfileUtils.isProfileInList(PROFILE_NAME, driver)); - } - -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/resources/AddResourceTest.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/resources/AddResourceTest.java deleted file mode 100755 index 0cc92ecb7..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/resources/AddResourceTest.java +++ /dev/null @@ -1,265 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.integration.test.resources; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.emc.metalnx.integration.test.utils.ResourceUtils; -import com.emc.metalnx.test.generic.UiTestUtilities; - -@Deprecated -@Ignore -public class AddResourceTest { - - private static final Logger logger = LoggerFactory.getLogger(AddResourceTest.class); - - private static WebDriver driver = null; - - private static final String RESOURCE_NAME = "resourceName"; - - private static final String RESOURCE_NAME_BLANK_SPACE = "resource name"; - - private static final String CHILD_RESOURCE_NAME = "child_resourceName"; - - /************************************* - * TEST SET UP - *************************************/ - - @BeforeClass - public static void setUpBeforeClass() { - // UITest.setUpBeforeClass(); - driver = UiTestUtilities.getDriver(); - } - - @Before - public void setUp() throws Exception { - UiTestUtilities.login(); - WebDriverWait wait = new WebDriverWait(driver, 8); - wait.until(ExpectedConditions.presenceOfElementLocated(By.id("page-wrapper"))); - } - - /** - * After each test the user created for the test should be removed. - */ - @After - public void tearDown() throws Exception { - ResourceUtils.removeResource(RESOURCE_NAME, driver); - ResourceUtils.removeResource(CHILD_RESOURCE_NAME, driver); - UiTestUtilities.logout(); - } - - /** - * After all tests are done, the test must quit the driver. This will close - * every window associated with the current driver instance. - */ - - @AfterClass - public static void tearDownAfterClass() { - if (driver != null) { - driver.quit(); - driver = null; - UiTestUtilities.setDriver(null); - } - } - - /* - * ***************************************************************************** - * *************** ************************************ ADD RESOURCE - * ****************************************** - * ***************************************************************************** - * *************** - */ - - /** - * Test method for adding a brand new resource into the system. It verifies - * after adding a resource if the user is redirected to the resource management - * page and a successful message is displayed. - */ - @Test - public void testAddUnixFileSystemResource() { - logger.info("Testing add a brand new resource from resource management"); - driver.get(UiTestUtilities.RESOURCES_URL); - WebDriverWait wait = new WebDriverWait(driver, 8); - wait.until(ExpectedConditions.presenceOfElementLocated(By.id("addResourceButton"))); - driver.findElement(By.id("addResourceButton")).click(); - - ResourceUtils.addResource(UiTestUtilities.RESOURCES_URL, RESOURCE_NAME, ResourceUtils.RESC_UNIX_FILE_SYSTEM, null, null, - UiTestUtilities.IRODS_HOST, ResourceUtils.RESOURCE_PATH, driver); - } - - /** - * Test method for adding a resource with same name of another already created. - * It verifies if it remains in same page and does not add new resource. - * - * @throws Exception - */ - @Test - public void testAddSameResourceName() throws Exception { - logger.info("Testing add a resource name that already exists"); - - ResourceUtils.addResource(UiTestUtilities.RESOURCES_URL, RESOURCE_NAME, ResourceUtils.RESC_COMPOUND, null, null, null, - null, driver); - ResourceUtils.accessAddResourceFormFrom(UiTestUtilities.RESOURCES_URL, null, driver); - ResourceUtils.fillAndSubmitResourceForm(RESOURCE_NAME, ResourceUtils.RESC_COMPOUND, null, null, null, null, - driver); - - assertEquals(UiTestUtilities.ADD_RESOURCES_URL, driver.getCurrentUrl()); - - assertTrue(ResourceUtils.errorMessageIsDisplayed("invalidResourceNameMsg", driver)); - } - - /** - * Test method for adding a new resource in resource map. It adds parent - * resource through management page, adds its resource child through map page - * and verifies with both are displayed. - */ - @Test - @Ignore - // TODO2 Test ignored when executing HTMLUnit driver. There is no support for - // d3.select() function in SVG element. - public void testAddResourceFromResourceMap() { - logger.info("Testing add a brand new resource from resource map"); - ResourceUtils.addResource(UiTestUtilities.RESOURCES_URL, RESOURCE_NAME, ResourceUtils.RESC_COMPOUND, null, null, null, - null, driver); - ResourceUtils.addResource(UiTestUtilities.RESOURCES_MAP_URL, CHILD_RESOURCE_NAME, ResourceUtils.RESC_COMPOUND, - RESOURCE_NAME, null, null, null, driver); - - assertTrue(ResourceUtils.isInResourcesList(UiTestUtilities.RESOURCES_URL, RESOURCE_NAME, null, driver)); - assertTrue(ResourceUtils.isInResourcesList(UiTestUtilities.RESOURCES_MAP_URL, CHILD_RESOURCE_NAME, null, driver)); - } - - /** - * Test method for adding a new resource in servers view. It verifies if - * resource is displayed in servers view after adding. - */ - @Test - public void testAddResourceFromServersView() { - logger.info("Testing add a brand new resource from servers view"); - - ResourceUtils.addResource(UiTestUtilities.RESOURCES_SERVERS_URL, RESOURCE_NAME, ResourceUtils.RESC_DEFERRED, null, null, - UiTestUtilities.IRODS_HOST, ResourceUtils.RESOURCE_PATH, driver); - - assertTrue(ResourceUtils.isInResourcesList(UiTestUtilities.RESOURCES_SERVERS_URL, RESOURCE_NAME, UiTestUtilities.IRODS_HOST, - driver)); - } - - /** - * Test method for trying to add a brand new resource into the system with - * resource name empty. It verifies if system does not add it and throw a error - * message. - */ - @Test - public void testAddEmptyResourceName() { - logger.info("Testing add empty resource name"); - ResourceUtils.accessAddResourceFormFrom(UiTestUtilities.RESOURCES_URL, null, driver); - ResourceUtils.fillAndSubmitResourceForm("", ResourceUtils.RESC_COMPOUND, null, null, null, null, driver); - - assertEquals(UiTestUtilities.ADD_RESOURCES_URL, driver.getCurrentUrl()); - - assertTrue(ResourceUtils.errorMessageIsDisplayed("emptyResourceNameMsg", driver)); - } - - /** - * Test method for adding a resource with a invalid name, with blank spaces. It - * verifies if it remains in same page and does not add new resource. - */ - @Test - public void testAddResourceNameWithBlankSpace() { - logger.info("Testing add resource name with blank space"); - ResourceUtils.accessAddResourceFormFrom(UiTestUtilities.RESOURCES_URL, null, driver); - ResourceUtils.fillAndSubmitResourceForm(RESOURCE_NAME_BLANK_SPACE, ResourceUtils.RESC_COMPOUND, null, null, - null, null, driver); - - assertEquals(UiTestUtilities.ADD_RESOURCES_URL, driver.getCurrentUrl()); - - assertTrue(ResourceUtils.errorMessageIsDisplayed("invalidResourceNameMsg", driver)); - } - - /** - * Test method for adding a storage resource with empty host. It verifies if it - * remains in same page, displays error message and does not add new resource. - */ - @Test - public void testAddStorageResourceWithEmptyHost() { - logger.info("Testing add resource with empty host"); - ResourceUtils.accessAddResourceFormFrom(UiTestUtilities.RESOURCES_URL, null, driver); - ResourceUtils.fillAndSubmitResourceForm(RESOURCE_NAME, ResourceUtils.RESC_UNIX_FILE_SYSTEM, null, null, "", - ResourceUtils.RESOURCE_PATH, driver); - - assertEquals(UiTestUtilities.ADD_RESOURCES_URL, driver.getCurrentUrl()); - - assertTrue(ResourceUtils.errorMessageIsDisplayed("emptyResourceHostMsg", driver)); - } - - /** - * Test method for adding a storage resource with empty path. It verifies if it - * remains in same page, displays error message and does not add new resource. - */ - @Test - public void testAddStorageResourceWithEmptyPath() { - logger.info("Testing add resource with empty path"); - ResourceUtils.accessAddResourceFormFrom(UiTestUtilities.RESOURCES_URL, null, driver); - ResourceUtils.fillAndSubmitResourceForm(RESOURCE_NAME, ResourceUtils.RESC_UNIX_FILE_SYSTEM, null, null, - UiTestUtilities.IRODS_HOST, "", driver); - - assertEquals(UiTestUtilities.ADD_RESOURCES_URL, driver.getCurrentUrl()); - - assertTrue(ResourceUtils.errorMessageIsDisplayed("emptyResourcePathMsg", driver)); - } - - /** - * Test method for canceling add resource. It verifies if it redirects to - * Resources Management page and does not add new resource. - */ - @Test - public void testConfirmCancelingAddResource() { - logger.info("Testing cancel a resource creation"); - ResourceUtils.accessAddResourceFormFrom(UiTestUtilities.RESOURCES_URL, null, driver); - ResourceUtils.fillAndCancelResourceForm(RESOURCE_NAME, true, driver); - assertTrue(!ResourceUtils.isInResourcesList(UiTestUtilities.RESOURCES_URL, RESOURCE_NAME, null, driver)); - } - - /** - * Test method for not canceling add resource. It verifies if it remains in add - * resource form page. - */ - @Test - public void testNotConfirmCancelingAddResource() { - logger.info("Testing cancel a resource creation"); - ResourceUtils.accessAddResourceFormFrom(UiTestUtilities.RESOURCES_URL, null, driver); - ResourceUtils.fillAndCancelResourceForm(RESOURCE_NAME, false, driver); - - WebDriverWait wait = new WebDriverWait(driver, 8); - wait.until(ExpectedConditions.invisibilityOfElementLocated(By.id("cancelModal"))); - - assertEquals(UiTestUtilities.ADD_RESOURCES_URL, driver.getCurrentUrl()); - } -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/resources/RemoveResourceTest.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/resources/RemoveResourceTest.java deleted file mode 100755 index 4095502fc..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/resources/RemoveResourceTest.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.integration.test.resources; - -import static org.junit.Assert.assertTrue; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.emc.metalnx.integration.test.utils.ResourceUtils; -import com.emc.metalnx.test.generic.UiTestUtilities; - -@Deprecated -@Ignore -public class RemoveResourceTest { - - private static final Logger logger = LoggerFactory.getLogger(RemoveResourceTest.class); - - private static WebDriver driver = null; - - private static String RESOURCE_NAME = "resourceName"; - - /************************************* - * TEST SET UP - *************************************/ - - @BeforeClass - public static void setUpBeforeClass() { - // UITest.setUpBeforeClass(); - driver = UiTestUtilities.getDriver(); - } - - @Before - public void setUp() throws Exception { - UiTestUtilities.login(); - WebDriverWait wait = new WebDriverWait(driver, 8); - wait.until(ExpectedConditions.presenceOfElementLocated(By.id("page-wrapper"))); - - ResourceUtils.addResource(UiTestUtilities.RESOURCES_URL, RESOURCE_NAME, ResourceUtils.RESC_COMPOUND, null, null, null, - null, driver); - } - - /** - * After each test the user created for the test should be removed. - */ - @After - public void tearDown() throws Exception { - ResourceUtils.removeResource(RESOURCE_NAME, driver); - UiTestUtilities.logout(); - } - - /** - * After all tests are done, the test must quit the driver. This will close - * every window associated with the current driver instance. - */ - - @AfterClass - public static void tearDownAfterClass() { - if (driver != null) { - driver.quit(); - driver = null; - UiTestUtilities.setDriver(null); - } - } - - /* - * ***************************************************************************** - * *************** ************************************ REMOVE RESOURCE - * *************************************** - * ***************************************************************************** - * *************** - */ - - /** - * Test method for removing resource. It verifies if resource does not remain in - * resource list in Resource Management page. - * - * @throws Exception - */ - @Test - public void testRemoveResource() throws Exception { - logger.info("Testing remove resource from Resource Management"); - ResourceUtils.removeResource(RESOURCE_NAME, driver); - - WebDriverWait wait = new WebDriverWait(driver, 8); - wait.until(ExpectedConditions.presenceOfElementLocated(By.id("resourcesListTable"))); - assertTrue(!ResourceUtils.isInResourcesList(UiTestUtilities.RESOURCES_URL, RESOURCE_NAME, null, driver)); - } - - /** - * Test method for rejecting remove resource. It verifies if resource remains in - * resource list in Resource Management page. - */ - @Test - public void testRejectRemovingResource() { - logger.info("Testing reject removing resource"); - if (ResourceUtils.isInResourcesList(UiTestUtilities.RESOURCES_URL, RESOURCE_NAME, null, driver)) { - ResourceUtils.clickOnResouceRemoveIcon(RESOURCE_NAME, driver); - driver.findElement(By.id("btnConfRescRemoval_No")).click(); - } - - WebDriverWait wait = new WebDriverWait(driver, 8); - wait.until(ExpectedConditions.presenceOfElementLocated(By.id("resourcesListTable"))); - assertTrue(ResourceUtils.isInResourcesList(UiTestUtilities.RESOURCES_URL, RESOURCE_NAME, null, driver)); - } -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/resources/SearchResourceTest.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/resources/SearchResourceTest.java deleted file mode 100755 index 1fc15bbd9..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/resources/SearchResourceTest.java +++ /dev/null @@ -1,226 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.integration.test.resources; - -import java.util.UUID; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.emc.metalnx.integration.test.utils.ResourceUtils; -import com.emc.metalnx.test.generic.UiTestUtilities; - -import junit.framework.Assert; - -@Deprecated -@Ignore -public class SearchResourceTest { - - private static final Logger logger = LoggerFactory.getLogger(SearchResourceTest.class); - - private static WebDriver driver = null; - - private static final String RESC_NAME_1 = "demoResc1"; - private static final String RESC_NAME_2 = "demo_resc_2"; - private static final String RESC_NAME_3 = "demo_RESC_3"; - private static final String RESC_NAME_4 = "DEMORESC_4"; - - private static final String ONE_LETTER_SEARCH_ALL = "e"; - private static final String MORE_LETTER_SEARCH_ALL = "resc"; - private static final String MORE_LETTER_SEARCH_1 = "_3"; - private static final String MORE_LETTER_SEARCH_0 = UUID.randomUUID().toString(); - - /************************************* - * TEST SET UP - *************************************/ - - @BeforeClass - public static void setUpBeforeClass() { - // UITest.setUpBeforeClass(); - driver = UiTestUtilities.getDriver(); - - } - - @Before - public void setUp() throws Exception { - UiTestUtilities.login(); - WebDriverWait wait = new WebDriverWait(driver, 8); - wait.until(ExpectedConditions.presenceOfElementLocated(By.id("page-wrapper"))); - - // Adding resources to test search - ResourceUtils.addResource(UiTestUtilities.RESOURCES_URL, RESC_NAME_1, ResourceUtils.RESC_COMPOUND, null, null, null, - null, driver); - ResourceUtils.addResource(UiTestUtilities.RESOURCES_URL, RESC_NAME_2, ResourceUtils.RESC_COMPOUND, null, null, null, - null, driver); - ResourceUtils.addResource(UiTestUtilities.RESOURCES_URL, RESC_NAME_3, ResourceUtils.RESC_COMPOUND, null, null, null, - null, driver); - ResourceUtils.addResource(UiTestUtilities.RESOURCES_URL, RESC_NAME_4, ResourceUtils.RESC_COMPOUND, null, null, null, - null, driver); - } - - /** - * After each test the user created for the test should be removed. - */ - @After - public void tearDown() throws Exception { - driver.get(UiTestUtilities.RESOURCES_URL); - WebDriverWait wait = new WebDriverWait(driver, 15); - wait.until(ExpectedConditions.presenceOfElementLocated(By.id("resourcesListTable"))); - - ResourceUtils.removeResource(RESC_NAME_1, driver); - ResourceUtils.removeResource(RESC_NAME_2, driver); - ResourceUtils.removeResource(RESC_NAME_3, driver); - ResourceUtils.removeResource(RESC_NAME_4, driver); - - UiTestUtilities.logout(); - } - - /** - * After all tests are done, the test must quit the driver. This will close - * every window associated with the current driver instance. - * - * @throws Exception - */ - - @AfterClass - public static void tearDownAfterClass() throws Exception { - if (driver != null) { - driver.quit(); - driver = null; - UiTestUtilities.setDriver(null); - } - } - - /* - * ***************************************************************************** - * *************** *********************************** SEARCH RESOURCE - * **************************************** - * ***************************************************************************** - * *************** - */ - - /** - * Test method to make a search by empty content in search box. It verifies if - * same resources before search are displayed after type ENTER in search box. - */ - @Test - public void testSearchEmptyContent() { - logger.info("Testing search with none search content"); - - int initialCount = ResourceUtils.getResourcesCount(driver); - int resultCount = ResourceUtils.searchResource("", initialCount, driver); - - Assert.assertEquals(initialCount, resultCount); - } - - /** - * Test method to execute a search by one letter in upper case in search box. It - * verifies if no filtering is dispatched once that it will only be triggered by - * typing more than one letter. - */ - @Test - public void testSearchByOneLetterUpperCase() { - logger.info("Testing search by one letter upper case"); - - int initialCount = ResourceUtils.getResourcesCount(driver); - int resultCount = ResourceUtils.searchResource(ONE_LETTER_SEARCH_ALL.toUpperCase(), initialCount, driver); - - Assert.assertEquals(initialCount, resultCount); - } - - /** - * Test method to execute a search by one letter in lower case in search box. It - * verifies if no filtering is dispatched once that it will only be triggered by - * typing more than one letter. - */ - @Test - public void testSearchByOneLetterLowerCase() { - logger.info("Testing search by one letter lower case"); - - int initialCount = ResourceUtils.getResourcesCount(driver); - int resultCount = ResourceUtils.searchResource(ONE_LETTER_SEARCH_ALL.toLowerCase(), initialCount, driver); - - Assert.assertEquals(initialCount, resultCount); - } - - /** - * Test method to execute a search by more than one letter in upper case in - * search box. It verifies if search is case insensitive and filters resources - * correctly. - */ - @Test - public void testSearchByMoreThanOneLetterUpperCase() { - logger.info("Testing search by more letters upper case"); - - int initialCount = ResourceUtils.getResourcesCount(driver); - int resultCount = ResourceUtils.searchResource(MORE_LETTER_SEARCH_ALL.toUpperCase(), initialCount, driver); - - Assert.assertEquals(initialCount, resultCount); - } - - /** - * Test method to execute a search by more than one letter in lower case in - * search box. It verifies if search is case insensitive and filters resources - * correctly. - */ - @Test - public void testSearchByMoreThanOneLetterLowerCase() { - logger.info("Testing search by more letters lower case"); - - int initialCount = ResourceUtils.getResourcesCount(driver); - int resultCount = ResourceUtils.searchResource(MORE_LETTER_SEARCH_ALL.toLowerCase(), initialCount, driver); - Assert.assertEquals(initialCount, resultCount); - } - - /** - * Test method to execute a search by more than one letter. It verifies if only - * one resource will be show after search. - */ - @Test - public void testSearchByMoreThanOneLetterResultOne() { - logger.info("Testing search by more letters resulting only one result"); - - int expectedCount = 1; - int resultCount = ResourceUtils.searchResource(MORE_LETTER_SEARCH_1, expectedCount, driver); - - Assert.assertEquals(expectedCount, resultCount); - } - - /** - * Test method to execute a search by more than one letter. It verifies if no - * resources will be show after search. - */ - @Test - public void testSearchByMoreThanOneLetterEmptyResult() { - logger.info("Testing search by more letters resulting only one result"); - - int expectedCount = 0; - int resultCount = ResourceUtils.searchResource(MORE_LETTER_SEARCH_0, expectedCount, driver); - - Assert.assertEquals(expectedCount, resultCount); - } -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/resources/ViewInfoResourceTest.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/resources/ViewInfoResourceTest.java deleted file mode 100755 index b51479d50..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/resources/ViewInfoResourceTest.java +++ /dev/null @@ -1,225 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.integration.test.resources; - -import static org.junit.Assert.assertEquals; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.emc.metalnx.integration.test.utils.ResourceUtils; -import com.emc.metalnx.test.generic.UiTestUtilities; - -@Deprecated -@Ignore -public class ViewInfoResourceTest { - - private static final Logger logger = LoggerFactory.getLogger(ViewInfoResourceTest.class); - - private static WebDriver driver = null; - - private static String RESOURCE_COORDINATING_NAME = "coordinatingRescName"; - private static String RESOURCE_STORAGE_NAME = "storageRescName"; - private static String RESOURCE_COORDINATING_TYPE = ResourceUtils.RESC_LOAD_BAL; - private static String RESOURCE_STORAGE_TYPE = ResourceUtils.RESC_DEFERRED; - private static String RESOURCE_PARENT = UiTestUtilities.IRODS_ZONE; - private static String RESOURCE_ZONE = UiTestUtilities.IRODS_ZONE; - private static String RESOURCE_HOST = UiTestUtilities.IRODS_HOST; - private static String RESOURCE_PATH = ResourceUtils.RESOURCE_PATH; - - /************************************* - * TEST SET UP - *************************************/ - - @BeforeClass - public static void setUpBeforeClass() { - // UITest.setUpBeforeClass(); - driver = UiTestUtilities.getDriver(); - } - - @Before - public void setUp() throws Exception { - UiTestUtilities.login(); - WebDriverWait wait = new WebDriverWait(driver, 8); - wait.until(ExpectedConditions.presenceOfElementLocated(By.id("user-panel-name"))); - - ResourceUtils.addResource(UiTestUtilities.RESOURCES_MAP_URL, RESOURCE_COORDINATING_NAME, RESOURCE_COORDINATING_TYPE, - RESOURCE_PARENT, RESOURCE_ZONE, RESOURCE_HOST, RESOURCE_PATH, driver); - ResourceUtils.addResource(UiTestUtilities.RESOURCES_MAP_URL, RESOURCE_STORAGE_NAME, RESOURCE_STORAGE_TYPE, - RESOURCE_PARENT, RESOURCE_ZONE, RESOURCE_HOST, RESOURCE_PATH, driver); - } - - /** - * After each test the user created for the test should be removed. - */ - @After - public void tearDown() throws Exception { - ResourceUtils.removeResource(RESOURCE_COORDINATING_NAME, driver); - ResourceUtils.removeResource(RESOURCE_STORAGE_NAME, driver); - UiTestUtilities.logout(); - } - - /** - * After all tests are done, the test must quit the driver. This will close - * every window associated with the current driver instance. - */ - - @AfterClass - public static void tearDownAfterClass() { - if (driver != null) { - driver.quit(); - driver = null; - UiTestUtilities.setDriver(null); - } - } - - /* - * ***************************************************************************** - * *************** ********************************** VIEW INFO RESOURCE - * ************************************** - * ***************************************************************************** - * *************** - */ - - /** - * Test method for view info in resource management page. It verifies if - * information displayed in info modal matches with information added for a - * coordinating resource. - */ - @Test - @Ignore - // TODO2 Test ignored when executing HTMLUnit driver. There is no support for - // d3.select() function in SVG element. - public void testViewInfoCoordinatingRescInResourceManagement() { - logger.info("Testing access view info from resource management page"); - - driver.get(UiTestUtilities.RESOURCES_URL); - WebDriverWait wait = new WebDriverWait(driver, 8); - wait.until(ExpectedConditions.presenceOfElementLocated(By.id("resourcesListTable"))); - assertEquals(UiTestUtilities.RESOURCES_URL, driver.getCurrentUrl()); - - if (ResourceUtils.isInResourcesList(UiTestUtilities.RESOURCES_URL, RESOURCE_COORDINATING_NAME, null, driver)) { - driver.findElement(By.id("btn_info_" + RESOURCE_COORDINATING_NAME)).click(); - - By rescInfoModal = By.id("rescInfoModal"); - wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(rescInfoModal)); - - ResourceUtils.assertResourceInfo(RESOURCE_COORDINATING_NAME, RESOURCE_COORDINATING_TYPE, RESOURCE_ZONE, - RESOURCE_ZONE, RESOURCE_PATH, RESOURCE_PARENT, driver); - - driver.findElement(By.id("rescInfoModal")).findElement(By.tagName("button")).click(); - } - } - - /** - * Test method for view info in resource map page. It verifies if information - * displayed in info modal matches with information added for a coordinating - * resource. - */ - @Test - @Ignore - // TODO2 Test ignored when executing HTMLUnit driver. There is no support for - // d3.select() function in SVG element. - public void testViewInfoCoordinatingRescInResourceMap() { - logger.info("Testing access view info from resource map page"); - - driver.get(UiTestUtilities.RESOURCES_MAP_URL); - WebDriverWait wait = new WebDriverWait(driver, 8); - wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.id("resourceMapPanel"))); - assertEquals(UiTestUtilities.RESOURCES_MAP_URL, driver.getCurrentUrl()); - - ResourceUtils.rightClickOnNodeInMap(RESOURCE_COORDINATING_NAME, driver); - driver.findElement(By.linkText("View Info")).click(); - - By resourceInfo = By.id("resourceInfo"); - wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(resourceInfo)); - - ResourceUtils.assertResourceInfo(RESOURCE_COORDINATING_NAME, RESOURCE_COORDINATING_TYPE, RESOURCE_ZONE, - RESOURCE_ZONE, RESOURCE_PATH, RESOURCE_PARENT, driver); - - driver.findElement(resourceInfo).findElement(By.className("close")).click(); - } - - /** - * Test method for view info in resource management page. It verifies if - * information displayed in info modal matches with information added for a - * storage resource. - */ - @Test - @Ignore - // TODO2 Test ignored when executing HTMLUnit driver. There is no support for - // d3.select() function in SVG element. - public void testViewInfoStorageRescInResourceManagement() { - logger.info("Testing access view info from resource management page"); - - driver.get(UiTestUtilities.RESOURCES_URL); - WebDriverWait wait = new WebDriverWait(driver, 8); - wait.until(ExpectedConditions.presenceOfElementLocated(By.id("resourcesListTable"))); - assertEquals(UiTestUtilities.RESOURCES_URL, driver.getCurrentUrl()); - - if (ResourceUtils.isInResourcesList(UiTestUtilities.RESOURCES_URL, RESOURCE_STORAGE_NAME, null, driver)) { - driver.findElement(By.id("btn_info_" + RESOURCE_STORAGE_NAME)).click(); - - By rescInfoModal = By.id("rescInfoModal"); - wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(rescInfoModal)); - - ResourceUtils.assertResourceInfo(RESOURCE_STORAGE_NAME, RESOURCE_STORAGE_TYPE, RESOURCE_ZONE, RESOURCE_HOST, - RESOURCE_PATH, RESOURCE_PARENT, driver); - - driver.findElement(By.id("rescInfoModal")).findElement(By.tagName("button")).click(); - } - } - - /** - * Test method for view info in resource map page. It verifies if information - * displayed in info modal matches with information added for a storage - * resource. - */ - @Test - @Ignore - // TODO2 Test ignored when executing HTMLUnit driver. There is no support for - // d3.select() function in SVG element. - public void testViewInfoStorageRescInResourceMap() { - logger.info("Testing access view info from resource map page"); - - driver.get(UiTestUtilities.RESOURCES_MAP_URL); - WebDriverWait wait = new WebDriverWait(driver, 8); - wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.id("resourceMapPanel"))); - assertEquals(UiTestUtilities.RESOURCES_MAP_URL, driver.getCurrentUrl()); - - ResourceUtils.rightClickOnNodeInMap(RESOURCE_STORAGE_NAME, driver); - driver.findElement(By.linkText("View Info")).click(); - - By resourceInfo = By.id("resourceInfo"); - wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(resourceInfo)); - - ResourceUtils.assertResourceInfo(RESOURCE_STORAGE_NAME, RESOURCE_STORAGE_TYPE, RESOURCE_ZONE, RESOURCE_HOST, - RESOURCE_PATH, RESOURCE_PARENT, driver); - - driver.findElement(resourceInfo).findElement(By.className("close")).click(); - } -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/scenarios/ApplyProfileTest.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/scenarios/ApplyProfileTest.java deleted file mode 100755 index 4c2cee119..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/scenarios/ApplyProfileTest.java +++ /dev/null @@ -1,219 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.integration.test.scenarios; - -import java.io.IOException; -import java.net.MalformedURLException; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; - -import com.emc.metalnx.core.domain.exceptions.DataGridException; -import com.emc.metalnx.integration.test.group.GroupUtils; -import com.emc.metalnx.integration.test.utils.CollectionUtils; -import com.emc.metalnx.integration.test.utils.FileUtils; -import com.emc.metalnx.integration.test.utils.MetadataUtils; -import com.emc.metalnx.integration.test.utils.ProfileUtils; -import com.emc.metalnx.integration.test.utils.UserUtils; -import com.emc.metalnx.test.generic.UiTestUtilities; -import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException; - -/** - * Test class that represents the creation of a profile scenario. - * - */ -@Deprecated -@Ignore -public class ApplyProfileTest { - - private static String pwd = "webdriver"; - private static String adminUName = "webdriver_admin"; - private static String uname = "webdriver"; - private static String profileName = "profiletestscenario"; - private static String groupName = "grouptestscenario"; - private static String collName = "testscenariocoll"; - private static String collPath = null; - private static WebDriverWait wait = null; - private static WebDriver driver = null; - - /************************************* - * TEST SET UP - *************************************/ - - @BeforeClass - public static void setUpBeforeClass() throws DataGridException { - // UITest.setUpBeforeClass(); - driver = UiTestUtilities.getDriver(); - wait = new WebDriverWait(driver, 10); - } - - @Before - public void setUp() { - long currTime = System.currentTimeMillis(); - pwd = "webdriver"; - adminUName = "webdriver_admin" + currTime; - uname = "webdriver" + currTime; - profileName = "profiletestscenario" + currTime; - groupName = "grouptestscenario" + currTime; - collName = "testscenariocoll" + currTime; - collPath = String.format("/%s/%s", UiTestUtilities.IRODS_ZONE, collName); - } - - @After - public void tearDown() throws Exception { - cleanUp(); - } - - @AfterClass - public static void tearDownAfterClass() throws DataGridException { - if (driver != null) { - driver.quit(); - driver = null; - UiTestUtilities.setDriver(null); - } - } - - /* - * ***************************************************************************** - * *************** ******************************** SCENARIOS - * ************************************************* - * ***************************************************************************** - * *************** - */ - - /** - * Test scenario: As rods, create a collection As rods, create a group, give - * ownership of the collection above to this group. As different admin, create a - * profile and include the group created above in this profile. As different - * admin, apply this profile when creating a user. Check if the profile was - * applied and all groups the user is attached to Verify by direct entry on - * breadcrumb Verify that upload, file deletion for this user works in the - * collection above. - * - * @throws IOException - * @throws MalformedURLException - * @throws FailingHttpStatusCodeException - */ - @Test - public void testApplyProfileWhenAddingAUser() - throws FailingHttpStatusCodeException, MalformedURLException, IOException { - UiTestUtilities.login(); - CollectionUtils.createCollectionUnderZone(driver, collName, UiTestUtilities.IRODS_ZONE); - GroupUtils.createGroupWithPermissions(driver, groupName, UiTestUtilities.OWN_PERMISSION, collName); - UiTestUtilities.logout(); - - UserUtils.createUser(adminUName, pwd, UiTestUtilities.RODS_ADMIN_TYPE, driver); - - UserUtils.createProfileAndIncludeGroupToThisProfileAsAdmin(driver, adminUName, pwd, profileName, groupName); - - UserUtils.createUserAsAdminAndApplyProfile(driver, adminUName, pwd, uname, pwd, UiTestUtilities.RODS_USER_TYPE, - profileName); - - UserUtils.checkIfUserIsInGroup(driver, uname, groupName); - - UiTestUtilities.login(uname, pwd); - CollectionUtils.writeOnEditableBreadCrumb(driver, wait, collPath); - FileUtils.uploadFileThroughUI(driver, MetadataUtils.METADATA_SEARCH_FILES); - - driver.get(UiTestUtilities.COLLECTIONS_URL); - CollectionUtils.removeItems(driver, MetadataUtils.METADATA_SEARCH_FILES); - - cleanUpTrash(); - UiTestUtilities.logout(); - } - - /** - * Test scenario: As rods, create a collection As rods, create a group, give - * ownership of the collection above to this group. As different admin, create a - * profile and include the group created above in this profile. As different - * admin, apply this profile when modifying a user. Check if the profile was - * applied and all groups the user is attached to Verify by direct entry on - * breadcrumb Verify that upload, file deletion for this user works in the - * collection above. - * - * @throws IOException - * @throws MalformedURLException - * @throws FailingHttpStatusCodeException - */ - @Test - public void testApplyProfileWhenModifyingAUser() - throws FailingHttpStatusCodeException, MalformedURLException, IOException { - UiTestUtilities.login(); - CollectionUtils.createCollectionUnderZone(driver, collName, UiTestUtilities.IRODS_ZONE); - GroupUtils.createGroupWithPermissions(driver, groupName, UiTestUtilities.OWN_PERMISSION, collName); - UiTestUtilities.logout(); - - UserUtils.createUser(adminUName, pwd, UiTestUtilities.RODS_ADMIN_TYPE, driver); - - UserUtils.createProfileAndIncludeGroupToThisProfileAsAdmin(driver, adminUName, pwd, profileName, groupName); - - UserUtils.createUser(uname, pwd, UiTestUtilities.RODS_USER_TYPE, driver); - - UserUtils.modifyUserAsAdminAndApplyProfile(driver, adminUName, pwd, uname, UiTestUtilities.IRODS_ZONE, - UiTestUtilities.RODS_USER_TYPE, profileName); - - UserUtils.checkIfUserIsInGroup(driver, uname, groupName); - - UiTestUtilities.login(uname, pwd); - CollectionUtils.writeOnEditableBreadCrumb(driver, wait, collPath); - FileUtils.uploadFileThroughUI(driver, MetadataUtils.METADATA_SEARCH_FILES); - - driver.get(UiTestUtilities.COLLECTIONS_URL); - CollectionUtils.removeItems(driver, MetadataUtils.METADATA_SEARCH_FILES); - - cleanUpTrash(); - UiTestUtilities.logout(); - } - - /** - * Removes all items from the user's trash can. - */ - private void cleanUpTrash() { - driver.get(UiTestUtilities.TRASH_URL); - CollectionUtils.clickOnEmptyTrash(driver); - CollectionUtils.confirmEmptyTrash(driver); - wait.until(ExpectedConditions.visibilityOfElementLocated(CollectionUtils.COLLS_TABLE)); - wait.until(ExpectedConditions - .visibilityOfElementLocated(By.cssSelector("#treeViewTable tbody tr td[class='dataTables_empty']"))); - } - - /** - * Removes users and groups from the data grid before the tests start and after - * they are executed. - */ - private static void cleanUp() { - try { - UserUtils.removeUser(adminUName, driver); - UserUtils.removeUser(uname, driver); - UiTestUtilities.login(); - GroupUtils.removeGroup(groupName, driver); - ProfileUtils.removeProfile(profileName, driver); - CollectionUtils.cleanUpCollectionsUnderZone(driver, collName); - } catch (Exception e) { - } finally { - UiTestUtilities.logout(); - } - } -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/templates/ApplyEmptyTemplateTest.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/templates/ApplyEmptyTemplateTest.java deleted file mode 100755 index caa0ff77f..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/templates/ApplyEmptyTemplateTest.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.integration.test.templates; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.emc.metalnx.core.domain.exceptions.DataGridException; -import com.emc.metalnx.integration.test.utils.CollectionUtils; -import com.emc.metalnx.integration.test.utils.FileUtils; -import com.emc.metalnx.integration.test.utils.TemplateUtils; -import com.emc.metalnx.test.generic.UiTestUtilities; - -import junit.framework.Assert; - -/** - * Class that tests the application of an empty template (template with no - * metadata fields) on files and collections. - */ -@Deprecated -@Ignore -public class ApplyEmptyTemplateTest { - private static final Logger logger = LoggerFactory.getLogger(TemplateTest.class); - - private static WebDriver driver = null; - private String templateName = null; - - /************************************* - * TEST SET UP - *************************************/ - - @BeforeClass - public static void setUpBeforeClass() throws DataGridException { - // UITest.setUpBeforeClass(); - driver = UiTestUtilities.getDriver(); - - // Environment clean up - FileUtils.removeFilesFromHomeAsAdmin(TemplateUtils.TEST_FILES); - } - - @Before - public void setUp() throws Exception { - templateName = TemplateUtils.TEMPLATE_TEST_NAME + System.currentTimeMillis(); - UiTestUtilities.login(); - TemplateUtils.createTemplateWithNoFields(driver, templateName, TemplateUtils.SYSTEM_TEMPLATE_TYPE); - } - - @After - public void tearDown() throws Exception { - TemplateUtils.removeTemplate(templateName, driver); - UiTestUtilities.logout(); - } - - /** - * After all tests are done, the test must quit the driver. This will close - * every window associated with the current driver instance. - */ - - @AfterClass - public static void tearDownAfterClass() { - if (driver != null) { - driver.quit(); - driver = null; - UiTestUtilities.setDriver(null); - } - } - - /************************************* - * TESTS - *************************************/ - - /** - * Method that tests if Metalnx prevents an empty template from being applied to - * files. - * - * @throws DataGridException - */ - @Test - public void testApplyTemplateWithNoMetadataFieldsOnFile() throws DataGridException { - logger.info("Apply template with no metadata fields"); - - // Upload test files - FileUtils.uploadToHomeDirAsAdmin(TemplateUtils.TEST_FILES); - - driver.get(UiTestUtilities.COLLECTIONS_URL); - Assert.assertEquals(UiTestUtilities.COLLECTIONS_URL, driver.getCurrentUrl()); - - TemplateUtils.findTemplateToApply(driver, templateName, TemplateUtils.TEST_FILES); - - new WebDriverWait(driver, 10) - .until(ExpectedConditions.visibilityOfElementLocated(TemplateUtils.SUBMIT_TEMPLATE_BTN)); - Assert.assertFalse(driver.findElement(TemplateUtils.SUBMIT_TEMPLATE_BTN).isEnabled()); - - // Remove test files - FileUtils.removeFilesFromHomeAsAdmin(TemplateUtils.TEST_FILES); - } - - /** - * Method that tests if Metalnx prevents an empty template from being applied to - * collections. - */ - @Test - public void testApplyTemplateWithNoMetadataFieldsOnColl() { - logger.info("Apply template with no metadata fields"); - - CollectionUtils.createCollection(driver, TemplateUtils.TEST_COLLS[0]); - - driver.get(UiTestUtilities.COLLECTIONS_URL); - - Assert.assertEquals(UiTestUtilities.COLLECTIONS_URL, driver.getCurrentUrl()); - - TemplateUtils.findTemplateToApply(driver, templateName, TemplateUtils.TEST_COLLS); - - new WebDriverWait(driver, 10) - .until(ExpectedConditions.visibilityOfElementLocated(TemplateUtils.SUBMIT_TEMPLATE_BTN)); - Assert.assertFalse(driver.findElement(TemplateUtils.SUBMIT_TEMPLATE_BTN).isEnabled()); - - CollectionUtils.removeColl(driver, TemplateUtils.TEST_COLLS[0]); - } -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/templates/ApplyTemplateOnCollsTest.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/templates/ApplyTemplateOnCollsTest.java deleted file mode 100755 index 1d84a1951..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/templates/ApplyTemplateOnCollsTest.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.integration.test.templates; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.emc.metalnx.integration.test.utils.CollectionUtils; -import com.emc.metalnx.integration.test.utils.TemplateUtils; -import com.emc.metalnx.test.generic.UiTestUtilities; - -import junit.framework.Assert; - -/** - * Class that tests the application of a template with metadata fields on - * collections. - */ -@Deprecated -@Ignore -public class ApplyTemplateOnCollsTest { - private static final Logger logger = LoggerFactory.getLogger(TemplateTest.class); - - private static WebDriver driver = null; - - private static List attributes = null; - private static List values = null; - private static List units = null; - private String templateName = null; - - /************************************* - * TEST SET UP - *************************************/ - - @BeforeClass - public static void setUpBeforeClass() { - // UITest.setUpBeforeClass(); - driver = UiTestUtilities.getDriver(); - - attributes = new ArrayList(); - values = new ArrayList(); - units = new ArrayList(); - - for (int i = 0; i < TemplateUtils.TOTAL_METADATA_FIELDS; i++) { - attributes.add(TemplateUtils.attribute + i); - values.add(TemplateUtils.value + i); - units.add(TemplateUtils.unit + i); - } - } - - @Before - public void setUp() throws Exception { - templateName = TemplateUtils.TEMPLATE_TEST_NAME + System.currentTimeMillis(); - UiTestUtilities.login(); - TemplateUtils.createTemplateWithFields(driver, templateName, TemplateUtils.SYSTEM_TEMPLATE_TYPE); - CollectionUtils.createCollection(driver, TemplateUtils.TEST_COLLS[0]); - } - - @After - public void tearDown() throws Exception { - TemplateUtils.removeTemplate(templateName, driver); - CollectionUtils.goToUserHome(driver, UiTestUtilities.RODS_USERNAME); - CollectionUtils.removeColl(driver, TemplateUtils.TEST_COLLS[0]); - new WebDriverWait(driver, 10) - .until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#treeViewTable tbody tr td"))); - UiTestUtilities.logout(); - } - - /** - * After all tests are done, the test must quit the driver. This will close - * every window associated with the current driver instance. - */ - - @AfterClass - public static void tearDownAfterClass() { - if (driver != null) { - driver.quit(); - driver = null; - UiTestUtilities.setDriver(null); - } - } - - /************************************* - * TESTS - *************************************/ - - /** - * Method that tests if a template can be applied to a collection. The template - * is not changed. - */ - @Test - public void testApplyTemplate() { - logger.info("Apply template with no metadata fields"); - - driver.get(UiTestUtilities.COLLECTIONS_URL); - Assert.assertEquals(UiTestUtilities.COLLECTIONS_URL, driver.getCurrentUrl()); - - TemplateUtils.findTemplateToApply(driver, templateName, TemplateUtils.TEST_COLLS); - TemplateUtils.submitApplyTemplateForm(driver); - TemplateUtils.isSuccessMessageShown(driver); - TemplateUtils.checkIfMetadataWasAdded(driver, true, attributes, values, units, TemplateUtils.TEST_COLLS); - } -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/templates/ApplyTemplateOnFilesTest.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/templates/ApplyTemplateOnFilesTest.java deleted file mode 100755 index cf8acfce8..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/templates/ApplyTemplateOnFilesTest.java +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.integration.test.templates; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.TimeUnit; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.emc.metalnx.core.domain.exceptions.DataGridException; -import com.emc.metalnx.integration.test.utils.FileUtils; -import com.emc.metalnx.integration.test.utils.TemplateUtils; -import com.emc.metalnx.test.generic.UiTestUtilities; - -import junit.framework.Assert; - -/** - * Class that tests the application of a template with metadata fields on files. - */ -@Deprecated -@Ignore -public class ApplyTemplateOnFilesTest { - private static final Logger logger = LoggerFactory.getLogger(TemplateTest.class); - - private static WebDriver driver = null; - private static List attributes = null; - private static List values = null; - private static List units = null; - private static String templateName = null; - - /************************************* - * TEST SET UP - *************************************/ - - @BeforeClass - public static void setUpBeforeClass() throws DataGridException { - // UITest.setUpBeforeClass(); - driver = UiTestUtilities.getDriver(); - - attributes = new ArrayList(); - values = new ArrayList(); - units = new ArrayList(); - - for (int i = 0; i < TemplateUtils.TOTAL_METADATA_FIELDS; i++) { - attributes.add(TemplateUtils.attribute + i); - values.add(TemplateUtils.value + i); - units.add(TemplateUtils.unit + i); - } - - FileUtils.forceRemoveFilesFromHomeAsAdmin(TemplateUtils.TEST_FILES); - } - - @Before - public void setUp() throws Exception { - templateName = TemplateUtils.TEMPLATE_TEST_NAME + System.currentTimeMillis(); - UiTestUtilities.login(); - - // Upload test files - FileUtils.uploadToHomeDirAsAdmin(TemplateUtils.TEST_FILES); - TemplateUtils.createTemplateWithFields(driver, templateName, TemplateUtils.SYSTEM_TEMPLATE_TYPE); - } - - @After - public void tearDown() throws Exception { - TemplateUtils.removeTemplate(templateName, driver); - - // Remove test files - FileUtils.forceRemoveFilesFromHomeAsAdmin(TemplateUtils.TEST_FILES); - - UiTestUtilities.logout(); - } - - /** - * After all tests are done, the test must quit the driver. This will close - * every window associated with the current driver instance. - */ - - @AfterClass - public static void tearDownAfterClass() { - if (driver != null) { - driver.quit(); - driver = null; - UiTestUtilities.setDriver(null); - } - } - - /************************************* - * TESTS - *************************************/ - - /** - * Method that tests if a template can be applied to a file. The template is - * applied as it is. - */ - @Test - public void testApplyTemplate() { - logger.info("Apply template with metadata fields"); - - driver.get(UiTestUtilities.COLLECTIONS_URL); - driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); - Assert.assertEquals(UiTestUtilities.COLLECTIONS_URL, driver.getCurrentUrl()); - - TemplateUtils.findTemplateToApply(driver, templateName, TemplateUtils.TEST_FILES); - TemplateUtils.submitApplyTemplateForm(driver); - TemplateUtils.isSuccessMessageShown(driver); - TemplateUtils.checkIfMetadataWasAdded(driver, false, attributes, values, units, TemplateUtils.TEST_FILES); - } - - /** - * Method that tests if a template can be applied to a file. The template values - * are changed. - */ - @Test - public void testApplyTemplateChangingValues() { - logger.info("Apply template with metadata fields changing metadata values"); - - driver.get(UiTestUtilities.COLLECTIONS_URL); - Assert.assertEquals(UiTestUtilities.COLLECTIONS_URL, driver.getCurrentUrl()); - - TemplateUtils.findTemplateToApply(driver, templateName, TemplateUtils.TEST_FILES); - List changedValues = changeValuesOfTemplateBeforeApplying(); - TemplateUtils.submitApplyTemplateForm(driver); - TemplateUtils.isSuccessMessageShown(driver); - TemplateUtils.checkIfMetadataWasAdded(driver, false, attributes, changedValues, units, - TemplateUtils.TEST_FILES); - } - - /** - * Auxiliar method that changes the attribute values of a template just before - * it is applied to a file. It assumes the template was already found previously - * and the driver is on the right page. - */ - private List changeValuesOfTemplateBeforeApplying() { - List oldValues = driver.findElements(By.name("avuValues")); - List changedValues = new ArrayList(); - - if (oldValues != null) { - for (WebElement inputValue : oldValues) { - String newValue = "applyTemplate" + Math.round(Math.random()); - int index = values.lastIndexOf(inputValue.getAttribute("value")); - changedValues.add(index, newValue); - inputValue.click(); - inputValue.clear(); - inputValue.sendKeys(changedValues.get(index)); - } - } - - return changedValues; - } -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/templates/CancelApplyTemplateOnFilesTest.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/templates/CancelApplyTemplateOnFilesTest.java deleted file mode 100755 index 9853e01ce..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/templates/CancelApplyTemplateOnFilesTest.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.integration.test.templates; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.emc.metalnx.core.domain.exceptions.DataGridException; -import com.emc.metalnx.integration.test.utils.CollectionUtils; -import com.emc.metalnx.integration.test.utils.FileUtils; -import com.emc.metalnx.integration.test.utils.TemplateUtils; -import com.emc.metalnx.test.generic.UiTestUtilities; - -import junit.framework.Assert; - -/** - * Class that tests the cancel option when the user is applying a template on - * files. - */ -@Deprecated -@Ignore -public class CancelApplyTemplateOnFilesTest { - private static final Logger logger = LoggerFactory.getLogger(TemplateTest.class); - - private static WebDriver driver = null; - private static List attributes = null; - private static List values = null; - private static List units = null; - private String templateName = null; - - /************************************* - * TEST SET UP - *************************************/ - - @BeforeClass - public static void setUpBeforeClass() throws DataGridException { - // UITest.setUpBeforeClass(); - driver = UiTestUtilities.getDriver(); - - attributes = new ArrayList(); - values = new ArrayList(); - units = new ArrayList(); - - for (int i = 0; i < TemplateUtils.TOTAL_METADATA_FIELDS; i++) { - attributes.add(TemplateUtils.attribute + i); - values.add(TemplateUtils.value + i); - units.add(TemplateUtils.unit + i); - } - - FileUtils.removeFilesFromHomeAsAdmin(TemplateUtils.TEST_FILES); - } - - @Before - public void setUp() throws Exception { - templateName = TemplateUtils.TEMPLATE_TEST_NAME + System.currentTimeMillis(); - UiTestUtilities.login(); - - // Upload test files - FileUtils.uploadToHomeDirAsAdmin(TemplateUtils.TEST_FILES); - TemplateUtils.createTemplateWithFields(driver, templateName, TemplateUtils.SYSTEM_TEMPLATE_TYPE); - } - - @After - public void tearDown() throws Exception { - TemplateUtils.removeTemplate(templateName, driver); - - // Remove test files - FileUtils.removeFilesFromHomeAsAdmin(TemplateUtils.TEST_FILES); - - UiTestUtilities.logout(); - } - - /** - * After all tests are done, the test must quit the driver. This will close - * every window associated with the current driver instance. - */ - - @AfterClass - public static void tearDownAfterClass() { - if (driver != null) { - driver.quit(); - driver = null; - UiTestUtilities.setDriver(null); - } - } - - /************************************* - * TESTS - *************************************/ - - /** - * Test that checks if the cancel button in the step 1 (Template selection) - * works. No metadata should be added. - */ - @Test - public void testCancelApplyTemplateStep1() { - WebDriverWait wait = new WebDriverWait(driver, 10); - - logger.info("Cancel apply template selection"); - - driver.get(UiTestUtilities.COLLECTIONS_URL); - Assert.assertEquals(UiTestUtilities.COLLECTIONS_URL, driver.getCurrentUrl()); - - CollectionUtils.waitForItemToLoad(driver, TemplateUtils.TEST_FILES[TemplateUtils.TEST_FILES.length - 1]); - driver.findElement(By.id(TemplateUtils.TEST_FILES[0])).click(); - - CollectionUtils.waitForSelectActionBtnToBeEnabled(driver); - driver.findElement(CollectionUtils.SELECT_ACTION_BTN).click(); - - CollectionUtils.waitForActionsDropdownToBeShown(driver); - driver.findElement(CollectionUtils.APPLY_TEMPLATE_BTN).click(); - - By templateList = By.id("templateList"); - wait.until(ExpectedConditions.visibilityOfElementLocated(templateList)); - Assert.assertTrue(driver.findElement(templateList).isDisplayed()); - - driver.findElement(By.cssSelector("#templateList .modal-dialog .modal-footer .cancelBtn")).click(); - wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("treeViewTable"))); - Assert.assertTrue(driver.findElement(By.id("treeViewTable")).isDisplayed()); - } - - /** - * Test that checks if the cancel button in the step 2 (Templates' fields list) - * works. No metadata should be added. - */ - @Test - public void testCancelApplyTemplateStep2() { - WebDriverWait wait = new WebDriverWait(driver, 10); - - logger.info("Cancel apply template selection"); - - driver.get(UiTestUtilities.COLLECTIONS_URL); - Assert.assertEquals(UiTestUtilities.COLLECTIONS_URL, driver.getCurrentUrl()); - - TemplateUtils.findTemplateToApply(driver, templateName, TemplateUtils.TEST_FILES); - - By templateFieldsList = By.id("templateFieldsList"); - wait.until(ExpectedConditions.visibilityOfElementLocated(templateFieldsList)); - Assert.assertTrue(driver.findElement(templateFieldsList).isDisplayed()); - - driver.findElement(By.cssSelector("#templateFieldsList .modal-dialog .modal-footer .cancelBtn")).click(); - wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("treeViewTable"))); - Assert.assertTrue(driver.findElement(By.id("treeViewTable")).isDisplayed()); - } -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/templates/DuplicatedNameTemplateTest.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/templates/DuplicatedNameTemplateTest.java deleted file mode 100755 index 1910e1451..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/templates/DuplicatedNameTemplateTest.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.integration.test.templates; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.emc.metalnx.integration.test.utils.TemplateUtils; -import com.emc.metalnx.test.generic.UiTestUtilities; - -/** - * Class created in order to create a template with a name that is already in - * use by another template. - * - */ -@Deprecated -@Ignore -public class DuplicatedNameTemplateTest { - - private static final Logger logger = LoggerFactory.getLogger(DuplicatedNameTemplateTest.class); - - private static WebDriver driver = null; - private String templateName = null; - - /************************************* - * TEST SET UP - *************************************/ - - @BeforeClass - public static void setUpBeforeClass() { - // UITest.setUpBeforeClass(); - driver = UiTestUtilities.getDriver(); - } - - @Before - public void setUp() throws Exception { - templateName = TemplateUtils.TEMPLATE_TEST_NAME + System.currentTimeMillis(); - UiTestUtilities.login(); - TemplateUtils.createTemplateWithNoFields(driver, templateName, TemplateUtils.PRIVATE_TEMPLATE_TYPE); - } - - @After - public void tearDown() throws Exception { - TemplateUtils.removeTemplate(templateName, driver); - UiTestUtilities.logout(); - } - - /** - * After all tests are done, the test must quit the driver. This will close - * every window associated with the current driver instance. - */ - - @AfterClass - public static void tearDownAfterClass() { - if (driver != null) { - driver.quit(); - driver = null; - UiTestUtilities.setDriver(null); - } - } - - /**************************************** - * TESTS - ****************************************/ - - /** - * Test method for adding a brand new private template with no metadata fields - * with an existing name; - */ - @Test - public void testAddPrivateTemplateWithDuplicatedName() { - logger.info("Testing add a new private template with an existing name"); - addTemplateWithDuplicatedNameAndCheckErrorMsg(templateName, TemplateUtils.PRIVATE_TEMPLATE_TYPE); - } - - /** - * Test method for adding a brand new system template with no metadata fields - * with an existing name; - */ - @Test - public void testAddSystemTemplateWithDuplicatedName() { - logger.info("Testing add a new system template with an existing name"); - addTemplateWithDuplicatedNameAndCheckErrorMsg(templateName, TemplateUtils.SYSTEM_TEMPLATE_TYPE); - } - - /** - * Generic method used for testing template creation failure message due to - * duplicated-template-name error. - * - * @param type - */ - private void addTemplateWithDuplicatedNameAndCheckErrorMsg(String template, String type) { - driver.get(UiTestUtilities.ADD_TEMPLATES_URL); - TemplateUtils.fillInTemplateInformation(template, TemplateUtils.TEMPLATE_TEST_DESC, - TemplateUtils.TEMPLATE_USE_INFO, type, driver); - - new WebDriverWait(driver, 15) - .until(ExpectedConditions.visibilityOfElementLocated(By.id("invalidTemplateNameMsg"))); - - Assert.assertTrue(driver.findElement(By.id("invalidTemplateNameMsg")).isDisplayed()); - } -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/templates/LongTemplateAVUFieldsTest.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/templates/LongTemplateAVUFieldsTest.java deleted file mode 100755 index 9399f112b..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/templates/LongTemplateAVUFieldsTest.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.integration.test.templates; - -import org.apache.commons.lang3.RandomStringUtils; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; - -import com.emc.metalnx.core.domain.exceptions.DataGridException; -import com.emc.metalnx.integration.test.utils.TemplateUtils; -import com.emc.metalnx.test.generic.UiTestUtilities; - -import junit.framework.Assert; - -/** - * Test adding a long attribute field to a template. - * - */ -@Deprecated -@Ignore -public class LongTemplateAVUFieldsTest { - private static WebDriver driver = null; - private static String templateName = null; - - /************************************* - * TEST SET UP - *************************************/ - - @BeforeClass - public static void setUpBeforeClass() throws DataGridException { - // UITest.setUpBeforeClass(); - driver = UiTestUtilities.getDriver(); - - try { - UiTestUtilities.login(); - driver.get(UiTestUtilities.TEMPLATES_URL); - TemplateUtils.removeAllTemplates(driver); - } catch (Exception e) { - } finally { - UiTestUtilities.logout(); - } - } - - @Before - public void setUp() throws Exception { - templateName = RandomStringUtils.randomAlphanumeric(60) + System.currentTimeMillis(); - UiTestUtilities.login(); - } - - @After - public void tearDown() throws Exception { - UiTestUtilities.logout(); - } - - /** - * After all tests are done, the test must quit the driver. This will close - * every window associated with the current driver instance. - */ - - @AfterClass - public static void tearDownAfterClass() { - UiTestUtilities.login(); - driver.get(UiTestUtilities.TEMPLATES_URL); - TemplateUtils.removeAllTemplates(driver); - UiTestUtilities.logout(); - - if (driver != null) { - driver.quit(); - driver = null; - UiTestUtilities.setDriver(null); - } - } - - @Test - public void testSystemTemplateAVUsWith100Characters() { - String[] attrs = { RandomStringUtils.randomAlphanumeric(100) }; - String[] values = { RandomStringUtils.randomAlphanumeric(100) }; - String[] units = { RandomStringUtils.randomAlphanumeric(100) }; - - TemplateUtils.createTemplateWithFields(driver, templateName, TemplateUtils.SYSTEM_TEMPLATE_TYPE, attrs, values, - units); - TemplateUtils.assertTemplateSuccessfulCreation(driver, templateName); - - TemplateUtils.searchByTemplateName(driver, templateName); - Assert.assertNotNull( - driver.findElement(By.cssSelector("#templatesListTable tbody tr td[title='" + templateName + "']"))); - } - - @Test - public void testPrivateTemplateAVUsWith100Characters() { - String[] attrs = { RandomStringUtils.randomAlphanumeric(100) }; - String[] values = { RandomStringUtils.randomAlphanumeric(100) }; - String[] units = { RandomStringUtils.randomAlphanumeric(100) }; - - TemplateUtils.createTemplateWithFields(driver, templateName, TemplateUtils.PRIVATE_TEMPLATE_TYPE, attrs, values, - units); - TemplateUtils.assertTemplateSuccessfulCreation(driver, templateName); - - TemplateUtils.searchByTemplateName(driver, templateName); - Assert.assertNotNull( - driver.findElement(By.cssSelector("#templatesListTable tbody tr td[title='" + templateName + "']"))); - } -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/templates/LongTemplateNameTest.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/templates/LongTemplateNameTest.java deleted file mode 100755 index 1b80d0529..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/templates/LongTemplateNameTest.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.integration.test.templates; - -import org.apache.commons.lang3.RandomStringUtils; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; - -import com.emc.metalnx.core.domain.exceptions.DataGridException; -import com.emc.metalnx.integration.test.utils.TemplateUtils; -import com.emc.metalnx.test.generic.UiTestUtilities; - -import junit.framework.Assert; - -@Deprecated -@Ignore -public class LongTemplateNameTest { - private static WebDriver driver = null; - private String longTemplateName = null; - - /************************************* - * TEST SET UP - *************************************/ - - @BeforeClass - public static void setUpBeforeClass() throws DataGridException { - // UITest.setUpBeforeClass(); - driver = UiTestUtilities.getDriver(); - } - - @Before - public void setUp() throws Exception { - UiTestUtilities.login(); - } - - @After - public void tearDown() throws Exception { - UiTestUtilities.logout(); - } - - /** - * After all tests are done, the test must quit the driver. This will close - * every window associated with the current driver instance. - */ - - @AfterClass - public static void tearDownAfterClass() { - UiTestUtilities.login(); - driver.get(UiTestUtilities.TEMPLATES_URL); - TemplateUtils.removeAllTemplates(driver); - UiTestUtilities.logout(); - - if (driver != null) { - driver.quit(); - driver = null; - UiTestUtilities.setDriver(null); - } - } - - /************************************* - * TESTS - *************************************/ - @Test - public void testSystemTemplateNameWith60Characters() { - longTemplateName = RandomStringUtils.randomAlphanumeric(60); - TemplateUtils.createTemplateWithNoFields(driver, longTemplateName, TemplateUtils.SYSTEM_TEMPLATE_TYPE); - TemplateUtils.assertTemplateSuccessfulCreation(driver, longTemplateName); - - TemplateUtils.searchByTemplateName(driver, longTemplateName); - Assert.assertNotNull(driver - .findElement(By.cssSelector("#templatesListTable tbody tr td[title='" + longTemplateName + "']"))); - } - - @Test - public void testPrivateTemplateNameWith60Characters() { - longTemplateName = RandomStringUtils.randomAlphanumeric(60); - TemplateUtils.createTemplateWithNoFields(driver, longTemplateName, TemplateUtils.PRIVATE_TEMPLATE_TYPE); - TemplateUtils.assertTemplateSuccessfulCreation(driver, longTemplateName); - - TemplateUtils.searchByTemplateName(driver, longTemplateName); - Assert.assertNotNull(driver - .findElement(By.cssSelector("#templatesListTable tbody tr td[title='" + longTemplateName + "']"))); - } - - @Test - public void testSystemTemplateNameWith100Characters() { - longTemplateName = RandomStringUtils.randomAlphanumeric(100); - TemplateUtils.createTemplateWithNoFields(driver, longTemplateName, TemplateUtils.SYSTEM_TEMPLATE_TYPE); - TemplateUtils.assertTemplateSuccessfulCreation(driver, longTemplateName); - - TemplateUtils.searchByTemplateName(driver, longTemplateName); - Assert.assertNotNull(driver - .findElement(By.cssSelector("#templatesListTable tbody tr td[title='" + longTemplateName + "']"))); - } - - @Test - public void testPrivateTemplateNameWith100Characters() { - longTemplateName = RandomStringUtils.randomAlphanumeric(100); - TemplateUtils.createTemplateWithNoFields(driver, longTemplateName, TemplateUtils.PRIVATE_TEMPLATE_TYPE); - TemplateUtils.assertTemplateSuccessfulCreation(driver, longTemplateName); - - TemplateUtils.searchByTemplateName(driver, longTemplateName); - Assert.assertNotNull(driver - .findElement(By.cssSelector("#templatesListTable tbody tr td[title='" + longTemplateName + "']"))); - } - - @Test - public void testSystemTemplateNameWith200Characters() { - longTemplateName = RandomStringUtils.randomAlphanumeric(200); - String allowedTemplatedName = (String) longTemplateName.subSequence(0, 100); - - TemplateUtils.createTemplateWithNoFields(driver, longTemplateName, TemplateUtils.SYSTEM_TEMPLATE_TYPE); - TemplateUtils.assertTemplateSuccessfulCreation(driver, allowedTemplatedName); - - TemplateUtils.searchByTemplateName(driver, longTemplateName); - Assert.assertNotNull(driver.findElement(By.className("dataTables_empty"))); - - TemplateUtils.searchByTemplateName(driver, allowedTemplatedName); - Assert.assertNotNull(driver - .findElement(By.cssSelector("#templatesListTable tbody tr td[title='" + allowedTemplatedName + "']"))); - - longTemplateName = allowedTemplatedName; - } - - @Test - public void testPrivateTemplateNameWith200Characters() { - longTemplateName = RandomStringUtils.randomAlphanumeric(200); - String allowedTemplatedName = (String) longTemplateName.subSequence(0, 100); - - TemplateUtils.createTemplateWithNoFields(driver, longTemplateName, TemplateUtils.PRIVATE_TEMPLATE_TYPE); - TemplateUtils.assertTemplateSuccessfulCreation(driver, allowedTemplatedName); - - TemplateUtils.searchByTemplateName(driver, longTemplateName); - Assert.assertNotNull(driver.findElement(By.className("dataTables_empty"))); - - TemplateUtils.searchByTemplateName(driver, allowedTemplatedName); - Assert.assertNotNull(driver - .findElement(By.cssSelector("#templatesListTable tbody tr td[title='" + allowedTemplatedName + "']"))); - - longTemplateName = allowedTemplatedName; - } -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/templates/TemplateTest.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/templates/TemplateTest.java deleted file mode 100755 index d68712d6b..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/templates/TemplateTest.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.integration.test.templates; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.openqa.selenium.WebDriver; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.emc.metalnx.integration.test.utils.TemplateUtils; -import com.emc.metalnx.test.generic.UiTestUtilities; - -@Deprecated -@Ignore -public class TemplateTest { - - private static final Logger logger = LoggerFactory.getLogger(TemplateTest.class); - - private static WebDriver driver = null; - private String templateName = null; - - /************************************* - * TEST SET UP - *************************************/ - - @BeforeClass - public static void setUpBeforeClass() { - // UITest.setUpBeforeClass(); - driver = UiTestUtilities.getDriver(); - } - - @Before - public void setUp() throws Exception { - templateName = TemplateUtils.TEMPLATE_TEST_NAME + System.currentTimeMillis(); - UiTestUtilities.login(); - } - - @After - public void tearDown() throws Exception { - TemplateUtils.removeTemplate(templateName, driver); - UiTestUtilities.logout(); - } - - /** - * After all tests are done, the test must quit the driver. This will close - * every window associated with the current driver instance. - */ - - @AfterClass - public static void tearDownAfterClass() { - if (driver != null) { - driver.quit(); - driver = null; - UiTestUtilities.setDriver(null); - } - } - - /************************************* - * TESTS - *************************************/ - - /** - * Test method for adding a brand new private template with no metadata fields. - * It verifies if after adding a template, the user is redirected to the - * template mgmt. page and if this template was created successfully; - */ - @Test - public void testAddPrivateTemplateWithNoMetadataFields() { - logger.info("Testing add a new private template with no metadata fields"); - TemplateUtils.createTemplateWithNoFields(driver, templateName, TemplateUtils.PRIVATE_TEMPLATE_TYPE); - TemplateUtils.assertTemplateSuccessfulCreation(driver, templateName); - } - - /** - * Test method for adding a brand new public template with no metadata fields. - * It verifies if after adding a template, the user is redirected to the - * template mgmt. page and if this template was created successfully; - */ - @Test - public void testAddSystemTemplateWithNoMetadataFields() { - logger.info("Testing add a new public template with no metadata fields"); - TemplateUtils.createTemplateWithNoFields(driver, templateName, TemplateUtils.SYSTEM_TEMPLATE_TYPE); - TemplateUtils.assertTemplateSuccessfulCreation(driver, templateName); - } - - /** - * Test method for adding a brand new private template with metadata fields. It - * verifies if after adding a template, the user is redirected to the template - * mgmt. page and if this template was created successfully; - */ - @Test - public void testAddPrivateTemplateWithMetadataFields() { - logger.info("Testing add a new private template with metadata fields"); - TemplateUtils.createTemplateWithFields(driver, templateName, TemplateUtils.PRIVATE_TEMPLATE_TYPE); - } - - /** - * Test method for adding a brand new public template with metadata fields. It - * verifies if after adding a template, the user is redirected to the template - * mgmt. page and if this template was created successfully; - */ - @Test - public void testAddSystemTemplateWithMetadataFields() { - logger.info("Testing add a new public template with metadata fields"); - TemplateUtils.createTemplateWithFields(driver, templateName, TemplateUtils.SYSTEM_TEMPLATE_TYPE); - } -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/upload/UploadTests.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/upload/UploadTests.java deleted file mode 100755 index da5a2e3f5..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/upload/UploadTests.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.integration.test.upload; - -import java.io.IOException; -import java.net.MalformedURLException; -import java.util.Set; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.JavascriptExecutor; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.emc.metalnx.integration.test.utils.UserUtils; -import com.emc.metalnx.test.generic.UiTestUtilities; -import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException; - -@Deprecated -@Ignore -public class UploadTests { - - private static final Logger logger = LoggerFactory.getLogger(UploadTests.class); - private static WebDriver driver = null; - private static WebDriverWait wait = null; - - private static final String username = "admin_user_" + System.currentTimeMillis(); - private static final String password = "pwd_" + +System.currentTimeMillis(); - - @BeforeClass - public static void setUpBeforeClass() { - logger.info("Before class: Creating admin user {}", username); - // UITest.setUpBeforeClass(); - driver = UiTestUtilities.getDriver(); - wait = new WebDriverWait(driver, 30); - - UserUtils.createUser(username, password, "rodsadmin", driver); - } - - /** - * After all tests are done, the test must quit the driver. This will close - * every window associated with the current driver instance. - */ - - @AfterClass - public static void tearDownAfterClass() { - logger.info("After class: Removing admin user {}", username); - UserUtils.removeUser(username, driver); - - if (driver != null) { - driver.quit(); - driver = null; - UiTestUtilities.setDriver(null); - } - } - - @Test - @Ignore - public void test1() throws FailingHttpStatusCodeException, MalformedURLException, IOException { - UiTestUtilities.login(username, password); - - driver.get(UiTestUtilities.COLLECTIONS_URL); - wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#treeViewTable tbody tr td"))); - wait.until(ExpectedConditions.elementToBeClickable(By.id("uploadIcon"))).click(); - wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("#browseButton"))); - - JavascriptExecutor jsExecutor = (JavascriptExecutor) driver; - jsExecutor.executeScript("document.getElementById('inputFiles').style.display='block';"); - - By fileInput = By.cssSelector("#inputFiles"); - wait.until(ExpectedConditions.visibilityOfElementLocated(fileInput)) - .sendKeys("C:\\Users\\ipenoguh.TPA-ELD\\Documents\\docs\\apostila_conteudo_cursojulho2013.pdf"); - jsExecutor.executeScript("document.getElementById('inputFiles').style.display='none';"); - - wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#filesList p"))); - wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("#uploadButton"))).click(); - - String base = driver.getWindowHandle(); - Set set = driver.getWindowHandles(); - set.remove(base); - - driver.switchTo().window((String) set.toArray()[0]); - - driver.close(); - driver.switchTo().window(base); - - wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#treeViewTable tbody tr td"))); - - wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#treeViewTable_filter input"))) - .sendKeys("apostila_conteudo_cursojulho2013.pdf"); - wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#treeViewTable tbody tr td"))); - } - -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/users/UserTest.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/users/UserTest.java deleted file mode 100755 index bdfcf5729..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/users/UserTest.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.integration.test.users; - -import static org.junit.Assert.assertEquals; - -import java.util.List; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.emc.metalnx.integration.test.utils.UserUtils; -import com.emc.metalnx.test.generic.UiTestUtilities; - -@Deprecated -@Ignore -public class UserTest { - - private static final Logger logger = LoggerFactory.getLogger(UserTest.class); - - private String uname = "webdriver" + System.currentTimeMillis(); - private String pwd = "webdriver"; - private static WebDriver driver = null; - - /************************************* - * TEST SET UP - *************************************/ - - @BeforeClass - public static void setUpBeforeClass() { - // UITest.setUpBeforeClass(); - driver = UiTestUtilities.getDriver(); - } - - @Before - public void setUp() throws Exception { - UiTestUtilities.login(); - } - - @After - public void tearDown() throws Exception { - UiTestUtilities.logout(); - } - - /** - * After all tests are done, the test must quit the driver. This will close - * every window associated with the current driver instance. - */ - - @AfterClass - public static void tearDownAfterClass() { - if (driver != null) { - driver.quit(); - driver = null; - UiTestUtilities.setDriver(null); - } - } - - /* - * ***************************************************************************** - * *************** ******************************** USER MANAGEMENT - * ******************************************* - * ***************************************************************************** - * *************** - */ - - /** - * Test method that checks if the add user button in the user management page - * always brings the user to the add user page. - */ - @Test - public void testCheckIfAddButtonWorks() { - logger.info("Testing if add button works"); - driver.get(UiTestUtilities.USERS_URL); - - driver.findElement(By.cssSelector("a[href='add/']")).click(); - - // checks if add user button brings the user to the add user page - Assert.assertEquals(UiTestUtilities.ADD_USERS_URL, driver.getCurrentUrl()); - UiTestUtilities.logout(); - } - - /* - * ***************************************************************************** - * *************** ***************************************** ADD USER - * ***************************************** - * ***************************************************************************** - * *************** - */ - - /** - * Test method for adding a brand new user to the system. It verifies if after - * adding user, the user is redirected to the user management page; if this user - * now exists in the users list; and if the number of users existing was - * incremented by one. - * - * @throws Exception - */ - @Test - public void testAddUser() throws Exception { - logger.info("Testing add a brand new user"); - - driver.get(UiTestUtilities.ADD_USERS_URL); - UserUtils.fillInUserGeneralInformation(uname, pwd, UiTestUtilities.RODS_ADMIN_TYPE, driver); - UserUtils.fillInPersonalInfo(driver, "web", "driver", "webdriver@testing.com"); - - driver.findElement(By.id("showGroupsListBtn")).click(); - - List cbGroupIdsList = driver.findElements(By.name("groupIdsList")); - for (WebElement checkbox : cbGroupIdsList) { - checkbox.click(); - } - - UserUtils.submitUserForm(driver); - assertEquals(UiTestUtilities.USERS_URL, driver.getCurrentUrl()); - UserUtils.searchUser(driver, uname); - isSuccessMessageDisplayed(); - UiTestUtilities.logout(); - UserUtils.removeUser(uname, driver); - } - - /** - * Test method that checks when adding a user with an empty username if the UI - * gets this exception and shows an error message. - */ - @Test - public void testAddUserWithEmptyUsername() { - logger.info("Testing add a user with an empty username"); - - driver.get(UiTestUtilities.ADD_USERS_URL); - - // Creating user for testing - new WebDriverWait(driver, 15).until(ExpectedConditions.elementToBeClickable(UserUtils.ZONE_FOLDER)); - - driver.findElement(UserUtils.USERNAME_INPUT).sendKeys(""); - driver.findElement(UserUtils.PWD_INPUT).sendKeys(pwd); - driver.findElement(UserUtils.PWD_CONF_INPUT).sendKeys(pwd); - - Assert.assertTrue(driver.findElement(By.id("emptyUsernameMsg")).isDisplayed()); - } - - /** - * Method that checks if a success message is displayed and if the user was - * successfully added - */ - private void isSuccessMessageDisplayed() { - WebElement divAlertSucess = driver.findElement(By.className("alert-success")); - Assert.assertTrue(divAlertSucess.isDisplayed()); - Assert.assertTrue(divAlertSucess.getText().contains(uname)); - } -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/utils/AllTests.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/utils/AllTests.java deleted file mode 100644 index 3890cb81f..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/utils/AllTests.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.emc.metalnx.integration.test.utils; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -@RunWith(Suite.class) -@SuiteClasses({}) -public class AllTests { - -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/utils/CollectionUtils.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/utils/CollectionUtils.java deleted file mode 100755 index 9c6aa5d7b..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/utils/CollectionUtils.java +++ /dev/null @@ -1,585 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.integration.test.utils; - -import static org.junit.Assert.assertTrue; - -import java.util.List; - -import org.openqa.selenium.By; -import org.openqa.selenium.Keys; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.Select; -import org.openqa.selenium.support.ui.WebDriverWait; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.emc.metalnx.test.generic.UiTestUtilities; - - -public class CollectionUtils { - private static final Logger logger = LoggerFactory.getLogger(CollectionUtils.class); - private static By publicSidebarBtnCssSelectorAdmin = By.cssSelector("#side-menu li a[href='/emc-metalnx-web/collections/public/']"); - private static By publicSidebarBtnCssSelectorUser = By.cssSelector("#side-menu li a[href='/emc-metalnx-web/collections/public/']"); - private static By directoryPathId = By.id("directoryPath"); - private static By inputUsernameLoginId = By.id("inputUsernameLogin"); - private static By homeLinkText = By.linkText("home"); - private static By publicCollSelectorA = By.cssSelector(String.format("a[title=\"/%s/home/public\"]", UiTestUtilities.IRODS_ZONE)); - private static By publicCollSelectorSpan = By.cssSelector(String.format("span[title=\"/%s/home/public\"]", UiTestUtilities.IRODS_ZONE)); - private static By breadcrumbLocator = By.className("breadcrumb"); - private static By navigationInputLocator = By.id("navigationInput"); - - public static final By EMPTY_TRASH_CONF_BTN = By.id("emptyTrashConfBtn"); - public static final By EMPTY_TRASH_BTN = By.id("emptyTrashBtn"); - public static final By EMPTY_TRASH_MODAL = By.id("emptyTrashModal"); - public static final By COLLS_TABLE = By.id("treeViewTable"); - public static final By DELETE_MODAL = By.id("deleteModal"); - - public static final By SELECT_ACTION_BTN = By.cssSelector("#actions button"); - public static final By BROWSE_TAB = By.cssSelector("button[onclick='goBackHistory(1);']"); - public static final By METADATA_TAB = By.id("metadataTab"); - public static final By APPLY_TEMPLATE_BTN = By.id("applyTemplatesBtn"); - public static String RODS_COLL_PATH = String.format("/%s/home/%s", UiTestUtilities.IRODS_ZONE, UiTestUtilities.RODS_USERNAME); - - /** - * Method that waits for the select action button to be enabled for clicking. - * - * @param driver - */ - public static void waitForSelectActionBtnToBeEnabled(WebDriver driver) { - WebDriverWait wait = new WebDriverWait(driver, 15); - wait.until(ExpectedConditions.elementToBeClickable(CollectionUtils.SELECT_ACTION_BTN)); - } - - /** - * Method that waits for the select action options to be enabled for clicking. - * - * @param driver - */ - public static void waitForActionsDropdownToBeShown(WebDriver driver) { - WebDriverWait wait = new WebDriverWait(driver, 15); - wait.until(ExpectedConditions.elementToBeClickable(CollectionUtils.APPLY_TEMPLATE_BTN)); - } - - /** - * Get the locator of a file or collection under the rods home folder. - * - * @param item - * file or collection to be found - * @return - */ - public static By getFileLocatorUnderRodsHome(String item) { - return getFileLocator(item, UiTestUtilities.IRODS_ZONE, UiTestUtilities.RODS_USERNAME); - } - - /** - * Get the locator of a file or collection. - * - * @param item - * file or collection to be found - * @return - */ - public static By getFileLocator(String item, String zone, String user) { - String collPattern = String.format("/%s/home/%s/%s", UiTestUtilities.IRODS_ZONE, UiTestUtilities.RODS_USERNAME, item); - return By.name(collPattern); - } - - /** - * Navigate through metalnx to get to the zone folder using a rodsadmin or rodsuser type. - * Depending on the type, the navigation changes because the menu options are different - * - * @param driver - * WebDriver of the current browser - * @param userType - * type of the user currently being used in the test - * @param uname - * username being used in the current test - * @param pwd - * password of the user being used in the test - */ - - public static void goToZoneCollection(WebDriver driver, String userType, String uname, String pwd) { - logger.info("Beggining navigation to the public collection..."); - if (UiTestUtilities.RODS_ADMIN_TYPE.equals(userType)) { - goToPublicCollectionByAdmin(driver, uname, pwd); - } - else { - goToPublicCollectionByUser(driver, uname, pwd); - } - } - - /** - * Navigate through metalnx to get to the public page using a rodsadmin or rodsuser type. - * Depending on the type, the navigation changes because the menu options are different - * - * @param driver - * WebDriver of the current browser - * @param userType - * type of the user currently being used in the test - * @param uname - * username being used in the current test - * @param pwd - * password of the user being used in the test - */ - - public static void goToPublicCollection(WebDriver driver, String userType, String uname, String pwd) { - logger.info("Beggining navigation to the public collection..."); - if (UiTestUtilities.RODS_ADMIN_TYPE.equals(userType)) { - goToPublicCollectionByAdmin(driver, uname, pwd); - } - else { - goToPublicCollectionByUser(driver, uname, pwd); - } - } - - /** - * Waits for the metadata table of a file or collection to be shown. - * - * @param driver - */ - public static void waitForMetadataToBeLoaded(WebDriver driver) { - WebDriverWait wait = new WebDriverWait(driver, 10); - wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#metadaTable tbody tr td"))); - } - - /** - * Method that waits for an item to be shown in the collections page. - * - * @param item - * file or collection name - */ - public static void waitForItemToLoad(WebDriver driver, String item) { - new WebDriverWait(driver, 10).until(ExpectedConditions.elementToBeClickable(By.id(item))); - } - - /** - * Creates a collection through Metalnx. - * - * @param driver - * @param collName - * collection name to be created - */ - public static void createCollection(WebDriver driver, String collName) { - - WebDriverWait wait = new WebDriverWait(driver, 10); - By collFormBtn = By.id("showCollectionFormBtn"); - By collNameLoc = By.id("inputCollectionName"); - - driver.get(UiTestUtilities.COLLECTIONS_URL); - - wait.until(ExpectedConditions.elementToBeClickable(collFormBtn)).click(); - - // Line below had to be added so that the driver also waits for the modal to be fully shown - // and only then it will try to access inputCollectioName - wait.until(ExpectedConditions.elementToBeClickable(collNameLoc)).click(); - driver.findElement(collNameLoc).clear(); - driver.findElement(collNameLoc).sendKeys(collName); - driver.findElement(By.id("submitCollectionFormBtn")).click(); - wait.until(ExpectedConditions.invisibilityOfElementLocated(By.id("addAndModifyModal"))); - wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#treeViewTable tbody tr td"))); - } - - /** - * Creates a collection through Metalnx. - * - * @param driver - * @param collName - * collection name to be created - */ - public static void createCollectionUnderZone(WebDriver driver, String collName, String zone) { - WebDriverWait wait = new WebDriverWait(driver, 15); - driver.get(UiTestUtilities.COLLECTIONS_URL); - - wait.until(ExpectedConditions.elementToBeClickable(By.linkText(zone))).click(); - wait.until(ExpectedConditions.elementToBeClickable(CollectionUtils.COLLS_TABLE)); - driver.findElement(By.id("showCollectionFormBtn")).click(); - - // Line below had to be added so that the driver also waits for the modal to be fully shown - // and only then it will try to access inputCollectioName - wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.id("inputCollectionName"))); - driver.findElement(By.id("inputCollectionName")).click(); - driver.findElement(By.id("inputCollectionName")).clear(); - driver.findElement(By.id("inputCollectionName")).sendKeys(collName); - driver.findElement(By.id("submitCollectionFormBtn")).click(); - wait.until(ExpectedConditions.invisibilityOfElementLocated(By.id("addAndModifyModal"))); - } - - /** - * Goes to the given user's home folder using the breadcrumb. - * - * @param driver - * @param user - * user's name - */ - public static void goToUserHome(WebDriver driver, String user) { - - WebDriverWait wait = new WebDriverWait(driver, 10); - - driver.get(UiTestUtilities.COLLECTIONS_URL); - String collLink = String.format("a[title='/%s/home/%s']", UiTestUtilities.IRODS_ZONE, user); - - wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector(collLink))).click(); - wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#treeViewTable tbody tr td"))); - } - - /** - * Removes a collection from Metalnx. - * - * @param driver - * @param collName - * collection name to be removed - */ - public static void removeColl(WebDriver driver, String collName) { - driver.get(UiTestUtilities.COLLECTIONS_URL); - removeItem(driver, collName); - } - - /** - * Removes a collection from Metalnx. - * - * @param driver - * @param collName - * collection name to be removed - */ - public static void removeCollUnderZone(WebDriver driver, String collName, String zone) { - driver.get(UiTestUtilities.COLLECTIONS_URL); - new WebDriverWait(driver, 10).until(ExpectedConditions.elementToBeClickable(By.linkText(zone))).click(); - removeItem(driver, collName); - } - - /** - * Removes a collection or data object from the data grid. - * - * @param driver - * @param item - * name of the collection or the data object that will be removed - */ - public static void removeItem(WebDriver driver, String item) { - WebDriverWait wait = new WebDriverWait(driver, 10); - waitForItemToLoad(driver, item); - - wait.until(ExpectedConditions.elementToBeClickable(By.id(item))).click(); - - waitForSelectActionBtnToBeEnabled(driver); - driver.findElement(CollectionUtils.SELECT_ACTION_BTN).click(); - - waitForActionsDropdownToBeShown(driver); - driver.findElement(By.id("deleteBtn")).click(); - - wait.until(ExpectedConditions.visibilityOfElementLocated(DELETE_MODAL)); - driver.findElement(By.cssSelector("#deleteModal .modal-footer .btn-primary")).click(); - wait.until(ExpectedConditions.invisibilityOfElementLocated(DELETE_MODAL)); - - wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#treeViewTable tbody tr td"))); - } - - /** - * Removes a list of collections or data objects from the data grid. - * - * @param driver - * @param item - * name of the collection or the data object that will be removed - */ - public static void removeItems(WebDriver driver, String... items) { - for (String item : items) { - removeItem(driver, item); - } - } - - /** - * Clicks on the empty trash button available in the trash can. - * - * @param driver - * web driver of the current browser - */ - public static void clickOnEmptyTrash(WebDriver driver) { - logger.info("Clicking on the empty trash button"); - WebDriverWait wait = new WebDriverWait(driver, 15); - wait.until(ExpectedConditions.elementToBeClickable(EMPTY_TRASH_BTN)); - driver.findElement(EMPTY_TRASH_BTN).click(); - } - - /** - * Confirms empty trash operation. - * - * @param driver - * web driver of the current browser - */ - public static void confirmEmptyTrash(WebDriver driver) { - logger.info("Confirm empty trash operation"); - WebDriverWait wait = new WebDriverWait(driver, 15); - wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(EMPTY_TRASH_MODAL)); - driver.findElement(EMPTY_TRASH_CONF_BTN).click(); - } - - /** - * This method writes a string on editable breadcrumb - * - * @param driver - * @param wait - * @param pathToBeWritten - */ - public static void writeOnEditableBreadCrumb(WebDriver driver, WebDriverWait wait, String pathToBeWritten) { - driver.get(UiTestUtilities.COLLECTIONS_URL); - // clicking on breadcrumb - wait.until(ExpectedConditions.elementToBeClickable(breadcrumbLocator)); - driver.findElement(breadcrumbLocator).click(); - - // waiting for the breacrumb to turn into an input text - wait.until(ExpectedConditions.visibilityOfElementLocated(navigationInputLocator)); - driver.findElement(navigationInputLocator).sendKeys(pathToBeWritten); - driver.findElement(navigationInputLocator).sendKeys(Keys.ENTER); - - } - - /** - * Removes collections from the data grid. - * - * @param driver - * @param collections - * list of collections to be removed from the grid. - */ - public static void cleanUpCollectionsUnderZone(WebDriver driver, String... collections) { - try { - UiTestUtilities.login(); - for (String collName : collections) { - CollectionUtils.removeCollUnderZone(driver, collName, UiTestUtilities.IRODS_ZONE); - } - } - catch (Exception e) {} - finally { - UiTestUtilities.logout(); - } - } - - /** - * Navigate through metalnx to get to the public page using a rodsadmin type - * - * @param driver - * WebDriver of the current browser - * @param uname - * username being used in the current test - * @param pwd - * password of the user being used in the test - */ - private static void goToPublicCollectionByAdmin(WebDriver driver, String uname, String pwd) { - logger.info("Navigating to public collection by admin interface..."); - WebDriverWait wait = new WebDriverWait(driver, 15); - wait.until(ExpectedConditions.presenceOfElementLocated(inputUsernameLoginId)); - if (uname == null) { - UiTestUtilities.login(); - } - else { - UiTestUtilities.login(uname, pwd); - } - driver.get(UiTestUtilities.COLLECTIONS_URL); - - // clicking on collections link on the left menu bar - wait.until(ExpectedConditions.elementToBeClickable(publicSidebarBtnCssSelectorAdmin)).click(); - - // going to home collection through breadcrumb - wait.until(ExpectedConditions.visibilityOfElementLocated(directoryPathId)).findElement(homeLinkText).click(); - - // clicking on public - By searchInputField = By.cssSelector("#treeViewTable_filter input"); - wait.until(ExpectedConditions.visibilityOfElementLocated(searchInputField)).click(); - wait.until(ExpectedConditions.visibilityOfElementLocated(searchInputField)).clear(); - for (char letter : "public".toCharArray()) { - wait.until(ExpectedConditions.visibilityOfElementLocated(searchInputField)).sendKeys(Character.toString(letter)); - } - - wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(CollectionUtils.COLLS_TABLE)); - wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("#treeViewTable tbody tr[role='row']"))); - wait.until(ExpectedConditions.elementToBeClickable(publicCollSelectorA)).click(); - - // checking if we did in fact got inside the public collection - assertTrue(wait.until(ExpectedConditions.visibilityOfElementLocated(publicCollSelectorSpan)).getText().contains("public")); - } - - /** - * Navigate through metalnx to get to the public page using a rodsuser type - * - * @param driver - * WebDriver of the current browser - * @param uname - * username being used in the current test - * @param pwd - * password of the user being used in the test - */ - - private static void goToPublicCollectionByUser(WebDriver driver, String uname, String pwd) { - logger.info("Navigating to public collection by user interface..."); - WebDriverWait wait = new WebDriverWait(driver, 15); - - UiTestUtilities.logout(); - UiTestUtilities.login(uname, pwd); - - driver.get(UiTestUtilities.COLLECTIONS_URL); - - // "publicSidebarBtnCssSelector" is being used both by admin and user only because this - // button is in the same position in both interfaces, but it is possible that eventually its - // position will differ - wait.until(ExpectedConditions.elementToBeClickable(publicSidebarBtnCssSelectorUser)).click(); - - wait.until(ExpectedConditions.presenceOfElementLocated(directoryPathId)); - WebElement breacrumb = driver.findElement(directoryPathId); - assertTrue(breacrumb.getText().contains("public")); - } - - /** - * Gets into a given collection. - * - * @param driver - * @param collection - * collection name to get in - */ - public static void goToCollection(WebDriver driver, String collection) { - By directoryPathLiSpan = By.cssSelector("#directoryPath .breadcrumb > li > span"); - By locator = By.cssSelector(String.format("#treeViewTable tbody tr:first-child td a", collection)); - WebDriverWait wait = new WebDriverWait(driver, 10); - wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#treeViewTable_filter input"))).sendKeys(collection); - try { - wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("çççç"))); - } - catch (Exception e) {} - wait.until(ExpectedConditions.elementToBeClickable(locator)).click(); - wait.until(ExpectedConditions.textToBePresentInElementLocated(directoryPathLiSpan, collection)); - } - - /** - * Changes the permission of a group on a collection or data object to the given permission - * - * @param group - * group that will get permission changed - * @param permission - * new permission to be set - */ - public static void changePermissionOfGroup(WebDriver driver, String group, String permission, String... items) { - driver.get(UiTestUtilities.COLLECTIONS_URL); - - for (String collection : items) { - WebDriverWait wait = new WebDriverWait(driver, 10); - wait.until(ExpectedConditions.elementToBeClickable(By.linkText(UiTestUtilities.IRODS_ZONE))).click(); - - CollectionUtils.goToCollection(driver, collection); - - By breadcrumbOptions = By.id("breadcrumbOptions"); - By permissions = By.id("permissions"); - By groupPermissionTab = By.cssSelector("a[href='#groupPermissions']"); - By groupPermissionsTable = By.id("groupPermissionsTable"); - By groupPermissionSelector = By.id("groupOptionForPermission_" + group); - By applyRecursionMsg = By.className("confirm-msg-table"); - By applyRecursionMsgYes = By.className("confirm-msg-table-yes"); - - wait.until(ExpectedConditions.elementToBeClickable(breadcrumbOptions)); - driver.findElement(breadcrumbOptions).click(); - - wait.until(ExpectedConditions.elementToBeClickable(permissions)); - driver.findElement(permissions).click(); - - wait.until(ExpectedConditions.elementToBeClickable(groupPermissionTab)); - driver.findElement(groupPermissionTab).click(); - - wait.until(ExpectedConditions.presenceOfElementLocated(groupPermissionsTable)); - wait.until(ExpectedConditions.presenceOfElementLocated(groupPermissionSelector)); - new Select(driver.findElement(groupPermissionSelector)).selectByVisibleText(permission.toUpperCase()); - - wait.until(ExpectedConditions.presenceOfElementLocated(applyRecursionMsg)); - wait.until(ExpectedConditions.elementToBeClickable(applyRecursionMsgYes)); - driver.findElement(applyRecursionMsgYes).click(); - } - } - - /** - * Replicates a file to a resource. - * @param driver - * @param file - * file path that will be replicated - * @param resource - * resource where the file will be replicated - */ - public static void replicateFile(WebDriver driver, String resource, String file) { - WebDriverWait wait = new WebDriverWait(driver, 10); - By fileCheckBox = By.id(file); - By selectActionBtn = By.cssSelector("#actions .btn-group button.btn-default"); - By replicateBtn = By.id("replicateBtn"); - By resourceSelectBox = By.id("selectResourceForReplication"); - By resourceOption = By.cssSelector("option[value=" + resource + "]"); - By replicateModalBtn = By.id("replicateButton"); - By replicateModal = By.id("replicateModal"); - - driver.get(UiTestUtilities.COLLECTIONS_URL); - wait.until(ExpectedConditions.elementToBeClickable(fileCheckBox)); - driver.findElement(fileCheckBox).click(); - wait.until(ExpectedConditions.elementToBeClickable(selectActionBtn)); - driver.findElement(selectActionBtn).click(); - wait.until(ExpectedConditions.elementToBeClickable(replicateBtn)); - driver.findElement(replicateBtn).click(); - wait.until(ExpectedConditions.visibilityOfElementLocated(resourceSelectBox)); - driver.findElement(resourceSelectBox).click(); - wait.until(ExpectedConditions.elementToBeClickable(resourceOption)); - driver.findElement(resourceOption).click(); - wait.until(ExpectedConditions.elementToBeClickable(replicateModalBtn)); - driver.findElement(replicateModalBtn).click(); - driver.findElement(replicateModalBtn).click(); - wait.until(ExpectedConditions.invisibilityOfElementLocated(replicateModal)); - wait.until(ExpectedConditions.elementToBeClickable(fileCheckBox)); - } - - /** - * Trim the replicas of a file down to one. - * @param driver - * @param string - */ - public static void deleteFileReplicas(WebDriver driver, String irodsFileAbsolutePath) { - WebDriverWait wait = new WebDriverWait(driver, 10); - By file = By.cssSelector("a[name=\"" + irodsFileAbsolutePath +"\"]"); - By deleteReplicaBtn = By.cssSelector("#deleteReplicaModal button.btn-primary"); - - driver.get(UiTestUtilities.COLLECTIONS_URL); - wait.until(ExpectedConditions.elementToBeClickable(file)); - driver.findElement(file).click(); - - waitForReplicasTable(driver); - - List replicaBtns = driver.findElements(By.cssSelector("#replicaAndChecksumInfo table tbody tr td button")); - replicaBtns.remove(0); - for (WebElement btn : replicaBtns) { - btn.click(); - wait.until(ExpectedConditions.elementToBeClickable(deleteReplicaBtn)); - driver.findElement(deleteReplicaBtn).click(); - waitForSuccessMessage(driver); - } - } - - public static void waitForSuccessMessage(WebDriver driver) { - new WebDriverWait(driver, 10).until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("div.alert-success"))); - } - - public static void waitForReplicasTable(WebDriver driver) { - By replicasTable = By.id("replicaAndChecksumInfo"); - new WebDriverWait(driver, 10).until(ExpectedConditions.visibilityOfElementLocated(replicasTable)); - } - - public static void goToHomeCollection(WebDriver driver) { - By userHomeBtn = By.id("breadcrumbHome"); - new WebDriverWait(driver, 10).until(ExpectedConditions.elementToBeClickable(userHomeBtn)); - driver.findElement(userHomeBtn).click(); - } -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/utils/FileUtils.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/utils/FileUtils.java deleted file mode 100755 index 35dcbed40..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/utils/FileUtils.java +++ /dev/null @@ -1,581 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.integration.test.utils; - -import com.emc.metalnx.core.domain.exceptions.DataGridException; -import com.emc.metalnx.test.generic.UiTestUtilities; -import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException; -import org.irods.jargon.core.connection.AuthScheme; -import org.irods.jargon.core.connection.IRODSAccount; -import org.irods.jargon.core.connection.IRODSSession; -import org.irods.jargon.core.connection.IRODSSimpleProtocolManager; -import org.irods.jargon.core.connection.auth.AuthResponse; -import org.irods.jargon.core.exception.JargonException; -import org.irods.jargon.core.exception.JargonFileOrCollAlreadyExistsException; -import org.irods.jargon.core.pub.*; -import org.irods.jargon.core.pub.io.IRODSFile; -import org.irods.jargon.core.pub.io.IRODSFileFactory; -import org.openqa.selenium.By; -import org.openqa.selenium.JavascriptExecutor; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.net.MalformedURLException; -import java.util.Set; - - -public class FileUtils { - - private static IRODSSimpleProtocolManager irodsSimpleProtocolManager; - private static IRODSSession irodsSession; - private static IRODSAccessObjectFactory irodsAccessObjectFactory; - - private static boolean initiated = false; - - private static final int MEGABYTE = 1 * 1024 * 1024; - private static final Logger logger = LoggerFactory.getLogger(FileUtils.class); - - public static final String RESOURCE_PATH = "/upload-tests/%s"; - - public static DataObjectAO getDataObjectAO(String user, String pwd) { - try { - IRODSAccount account = authenticateUser(user, pwd); - return irodsAccessObjectFactory.getDataObjectAO(account); - } catch (JargonException e) { - e.printStackTrace(); - } catch (DataGridException e) { - e.printStackTrace(); - } - - return null; - } - - /** - * Uploads a file to the data grid through the Metalnx UI. - * - * @param driver - * @param files file names under the class path - * @throws FailingHttpStatusCodeException - * @throws MalformedURLException - * @throws IOException - */ - public static void uploadFileThroughUI(WebDriver driver, String... files) - throws FailingHttpStatusCodeException, IOException { - StringBuilder baseDir = new StringBuilder(); - baseDir.append(System.getProperty("user.dir")); - baseDir.append(File.separator); - baseDir.append("src"); - baseDir.append(File.separator); - baseDir.append("test"); - baseDir.append(File.separator); - baseDir.append("resources"); - baseDir.append(File.separator); - baseDir.append("upload-tests"); - baseDir.append(File.separator); - - for (String file : files) { - By tableRow = By.cssSelector("#treeViewTable tbody tr td"); - - WebDriverWait wait = new WebDriverWait(driver, 10); - wait.until(ExpectedConditions.visibilityOfElementLocated(tableRow)); - wait.until(ExpectedConditions.elementToBeClickable(By.id("uploadIcon"))).click(); - wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("#browseButton"))); - - JavascriptExecutor jsExecutor = (JavascriptExecutor) driver; - jsExecutor.executeScript("document.getElementById('inputFiles').style.display='block';"); - - String path = baseDir.toString() + file; - wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#inputFiles"))).sendKeys(path); - jsExecutor.executeScript("document.getElementById('inputFiles').style.display='none';"); - - wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#filesList p"))); - wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("#uploadButton"))).click(); - - String base = driver.getWindowHandle(); - Set set = driver.getWindowHandles(); - set.remove(base); - driver.switchTo().window((String) set.toArray()[0]); - driver.close(); - driver.switchTo().window(base); - - wait.until(ExpectedConditions.visibilityOfElementLocated(tableRow)); - wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#treeViewTable_filter input"))).click(); - wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#treeViewTable_filter input"))).clear(); - wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#treeViewTable_filter input"))).sendKeys(file); - wait.until(ExpectedConditions.visibilityOfElementLocated(tableRow)); - } - } - - /** - * Uploads a list of files to the home directory of the current administrator user - * - * @param files - * array of {@link String} containing the files residing on the /upload-tests/ directory inside the classpath - * @return confirmation {@link boolean} the confirmation that the operation is successful - * @throws DataGridException - */ - public static boolean uploadToHomeDirAsAdmin(String... files) throws DataGridException { - String user = UiTestUtilities.RODS_USERNAME; - String password = UiTestUtilities.RODS_PASSWORD; - String path = String.format("/%s/home/%s", UiTestUtilities.IRODS_ZONE, user); - - return uploadWithUserToResc(user, password, path, UiTestUtilities.DEFAULT_RESC, files); - } - - /** - * Uploads a file to the given user's home directory - * - * @param user - * {@link String} the username - * @param password - * {@link String} the password of the user - * @param files - * array of {@link String} containing the files residing on the /upload-tests/ directory inside the classpath - * @return rc {@link boolean} the confirmation that the operation is successful - * @throws DataGridException - */ - public static boolean uploadToHomeDirAsUser(String user, String password, String... files) throws DataGridException { - String path = String.format("/%s/home/%s", UiTestUtilities.IRODS_ZONE, user); - return uploadWithUserToResc(user, password, path, UiTestUtilities.DEFAULT_RESC, files); - } - - /** - * Uploads a list of files to the given path as a rodsadmin user - * - * @param path - * {@link String} the destination path - * @param files - * array of {@link String} containing the files residing on the /upload-tests/ directory inside the classpath - * @return rc {@link boolean} the confirmation that the operation is successful - * @throws DataGridException - */ - public static boolean uploadToDirAsAdmin(String path, String... files) throws DataGridException { - String user = UiTestUtilities.RODS_USERNAME; - String password = UiTestUtilities.RODS_PASSWORD; - return uploadWithUserToResc(user, password, path, UiTestUtilities.DEFAULT_RESC, files); - } - - /** - * Uploads a list of files to the specified path as the given user - * - * @param user - * {@link String} the username - * @param password - * {@link String} the password - * @param path - * {@link String} the destination path - * @param files - * array of {@link String} containing the files residing on the /upload-tests/ directory inside the classpath - * @return rc {@link boolean} the confirmation that the operation is successful - * @throws DataGridException - */ - public static boolean uploadToDirAsUser(String user, String password, String path, String... files) throws DataGridException { - return uploadWithUserToResc(user, password, path, UiTestUtilities.DEFAULT_RESC, files); - } - - /** - * Uploads a list of file to the rodsadmin's home folder on the given resource name - * - * @param rescName - * {@link String} the password - * @param files - * array of {@link String} containing the files residing on the /upload-tests/ directory inside the classpath - * @return rc {@link boolean} the confirmation that the operation is successful - * @throws DataGridException - */ - public static boolean uploadToHomeDirAsAdminOnResc(String rescName, String... files) throws DataGridException { - String user = UiTestUtilities.RODS_USERNAME; - String password = UiTestUtilities.RODS_PASSWORD; - String path = String.format("/%s/home/%s", UiTestUtilities.IRODS_ZONE, user); - return uploadWithUserToResc(user, password, path, rescName, files); - } - - /** - * Uploads a list of file to the given user's home folder on the given resource name - * - * @param user - * {@link String} the username - * @param password - * {@link String} the password - * @param rescName - * {@link String} the target resource name - * @param files - * array of {@link String} containing the files residing on the /upload-tests/ directory inside the classpath - * @return rc {@link boolean} the confirmation that the operation is successful - * @throws DataGridException - */ - public static boolean uploadToHomeDirAsUserOnResc(String user, String password, String rescName, String... files) throws DataGridException { - String path = String.format("/%s/home/%s", UiTestUtilities.IRODS_ZONE, user); - return uploadWithUserToResc(user, password, path, rescName, files); - } - - /** - * Uploads a list of files to the given directory on a given resource server as an admin user - * - * @param path - * {@link String} the destination path - * @param rescName - * {@link String} the target resource name - * @param files - * array of {@link String} containing the files residing on the /upload-tests/ directory inside the classpath - * @return rc {@link boolean} the confirmation that the operation is successful - * @throws DataGridException - */ - public static boolean uploadToDirAsAdminOnResc(String path, String rescName, String... files) throws DataGridException { - String user = UiTestUtilities.RODS_USERNAME; - String password = UiTestUtilities.RODS_PASSWORD; - return uploadWithUserToResc(user, password, path, rescName, files); - } - - /** - * Uploads a list of files to the given directory on a given resource server as the given user - * - * @param user - * {@link String} the username - * @param password - * {@link String} the password - * @param path - * {@link String} the destination path - * @param rescName - * {@link String} the target resource name - * @param files - * array of {@link String} containing the files residing on the /upload-tests/ directory inside the classpath - * @return rc {@link boolean} the confirmation that the operation is successful - * @throws DataGridException - */ - public static boolean uploadToDirAsUserOnResc(String user, String password, String path, String rescName, String... files) - throws DataGridException { - return uploadWithUserToResc(user, password, path, rescName, files); - } - - /**************************************************************************************/ - - /**************************** REMOVE METHODS SECTION **********************************/ - /**************************************************************************************/ - - /** - * Remove the given list of files from the rodsadmin's home folder - * - * @param files - * array of {@link String} containing the file names to be removed from the grid - * @throws DataGridException - */ - public static void removeFilesFromHomeAsAdmin(String... files) throws DataGridException { - String path = String.format("/%s/home/%s", UiTestUtilities.IRODS_ZONE, UiTestUtilities.RODS_USERNAME); - remove(UiTestUtilities.RODS_USERNAME, UiTestUtilities.RODS_PASSWORD, path, false, files); - } - - /** - * Removes the list of files from the data grid as the given user - * - * @param user - * {@link String} the username - * @param pwd - * {@link String} the password - * @param files - * array of {@link String} containing the file names to be removed from the grid - * @throws DataGridException - */ - public static void removeFilesFromHomeAsUser(String user, String pwd, String... files) throws DataGridException { - String path = String.format("/%s/home/%s", UiTestUtilities.IRODS_ZONE, user); - remove(user, pwd, path, false, files); - } - - /** - * Removes the list of files from the grid on the specified path as a grid administrator - * - * @param path - * {@link String} the target path - * @param files - * array of {@link String} containing the file names to be removed from the grid - * @throws DataGridException - */ - public static void removeFilesFromDirAsAdmin(String path, String... files) throws DataGridException { - remove(UiTestUtilities.RODS_USERNAME, UiTestUtilities.RODS_PASSWORD, path, false, files); - } - - /** - * Removes the given list of files from the grid as the given user - * - * @param user - * {@link String} the username - * @param pwd - * {@link String} the password - * @param path - * {@link String} the target path - * @param files - * array of {@link String} containing the file names to be removed from the grid - * @throws DataGridException - */ - public static void removeFilesFromDirAsUser(String user, String pwd, String path, String... files) throws DataGridException { - remove(user, pwd, path, false, files); - } - - /** - * Remove (with force option) the given list of files from the rodsadmin's home folder - * - * @param files - * array of {@link String} containing the file names to be removed from the grid - * @throws DataGridException - */ - public static void forceRemoveFilesFromHomeAsAdmin(String... files) throws DataGridException { - String path = String.format("/%s/home/%s", UiTestUtilities.IRODS_ZONE, UiTestUtilities.RODS_USERNAME); - remove(UiTestUtilities.RODS_USERNAME, UiTestUtilities.RODS_PASSWORD, path, true, files); - } - - /** - * Removes (with force option) the list of files from the data grid as the given user - * - * @param user - * {@link String} the username - * @param pwd - * {@link String} the password - * @param files - * array of {@link String} containing the file names to be removed from the grid - * @throws DataGridException - */ - public static void forceRemoveFilesFromHomeAsUser(String user, String pwd, String... files) throws DataGridException { - String path = String.format("/%s/home/%s", UiTestUtilities.IRODS_ZONE, user); - remove(user, pwd, path, true, files); - } - - /** - * Removes (with force option) the list of files from the grid on the specified path as a grid administrator - * - * @param path - * {@link String} the target path - * @param files - * array of {@link String} containing the file names to be removed from the grid - * @throws DataGridException - */ - public static void forceRemoveFilesFromDirAsAdmin(String path, String... files) throws DataGridException { - remove(UiTestUtilities.RODS_USERNAME, UiTestUtilities.RODS_PASSWORD, path, true, files); - } - - /** - * Removes (with force option) the given list of files from the grid as the given user - * - * @param user - * {@link String} the username - * @param pwd - * {@link String} the password - * @param path - * {@link String} the target path - * @param files - * array of {@link String} containing the file names to be removed from the grid - * @throws DataGridException - */ - public static void forceRemoveFilesFromDirAsUser(String user, String pwd, String path, String... files) throws DataGridException { - remove(user, pwd, path, true, files); - } - - /**************************************************************************************/ - /**************************** PRIVATE METHOD SECTION **********************************/ - /**************************************************************************************/ - - /** - * Auxiliary method that initializes the Jargon context - * for this class. It aims to create the Access Object - * Factory which gives us access to all other access objects - * available on Jargon. - * - * @throws DataGridException - */ - private static void init() throws DataGridException { - try { - if (!initiated) { - irodsSimpleProtocolManager = new IRODSSimpleProtocolManager(); - irodsSimpleProtocolManager.initialize(); - irodsSession = new IRODSSession(irodsSimpleProtocolManager); - irodsAccessObjectFactory = new IRODSAccessObjectFactoryImpl(irodsSession); - initiated = true; - } - } - catch (JargonException e) { - String message = "Could not instantiate Jargon Protocol Handler"; - logger.error(message, e); - throw new DataGridException(message); - } - } - - /** - * Authenticates user agains iRODS and returns the authenticated - * IRODSAccount object. - * - * @param user - * {@link String} containing the username to be used on login - * @param password - * {@link String} containing the password to be used on login - * @return - * @throws DataGridException - */ - private static IRODSAccount authenticateUser(String user, String password) throws DataGridException { - // Connection information - String host = UiTestUtilities.IRODS_HOST; - int port = UiTestUtilities.IRODS_PORT; - String zone = UiTestUtilities.IRODS_ZONE; - String homeDir = String.format("/%s/home/%s", zone, user); - String defStorage = "demoResc"; - - IRODSAccount irodsAccount = null; - AuthResponse response = null; - - if (!initiated) { - init(); - } - - // Creating iRODSAccount instance - try { - irodsAccount = IRODSAccount.instance(host, port, user, password, homeDir, zone, defStorage); - irodsAccount.setAuthenticationScheme(AuthScheme.STANDARD); - response = irodsAccessObjectFactory.authenticateIRODSAccount(irodsAccount); - logger.info("User {} connected and authenticated", user); - } - catch (JargonException e) { - logger.error("Could not authenticate user {} instance due to: ", user, e); - } - - return response.getAuthenticatedIRODSAccount(); - } - - /** - * Closes the session on iRODS using an authenticated account - * - * @param account - * {@link IRODSAccount} the authenticated account - * @throws DataGridException - */ - private static void closeSession(IRODSAccount account) throws DataGridException { - - if (!initiated) { - init(); - } - - logger.info("Closing session for user {}", account.getUserName()); - irodsAccessObjectFactory.closeSessionAndEatExceptions(account); - irodsAccessObjectFactory.closeSessionAndEatExceptions(); - } - - /** - * Generic method that uploads a list of files to a given directory using - * the specified user on a given resource server. - * - * @param user - * {@link String} the username - * @param pwd - * {@link String} the password - * @param path - * {@link String} the destination path - * @param resc - * {@link String} the resource name - * @param files - * array of {@link String} containing the file names present on the classpath:/upload-tests/ directory - * @return rc {@link boolean} the confirmation that the operation is successful - * @throws DataGridException - */ - private static boolean uploadWithUserToResc(String user, String pwd, String path, String resc, String... files) throws DataGridException { - - IRODSAccount account = authenticateUser(user, pwd); - boolean result = true; - - try { - Stream2StreamAO streamAO = irodsAccessObjectFactory.getStream2StreamAO(account); - IRODSFileFactory fileFactory = irodsAccessObjectFactory.getIRODSFileFactory(account); - - for (String file : files) { - logger.info("Trying to upload file {} to path {} as {}", file, path, user); - IRODSFile targetFile = fileFactory.instanceIRODSFile(path, file); - targetFile.setResource(resc); - - logger.info("Checking if file already exists."); - if (targetFile.exists()) { - logger.error("File {}/{} already exists. Not uploading.", path, file); - throw new JargonFileOrCollAlreadyExistsException(String.format("File %s already exists on %s", file, path)); - } - - logger.info("Reading original file from classpath."); - String originalFilePath = String.format(RESOURCE_PATH, file); - InputStream in = ClassLoader.class.getResourceAsStream(originalFilePath); - - logger.info("Transfering file to iRODS"); - streamAO.transferStreamToFileUsingIOStreams(in, (File) targetFile, 0, MEGABYTE); - logger.info("Done!"); - - in.close(); - targetFile.close(); - } - - } - catch (JargonException | IOException e) { - logger.info("Could not upload to path {}", path, e); - result = false; - } - - closeSession(account); - - return result; - } - - /** - * Removes the given file from the iRODS grid - * - * @param user - * {@link String} the username - * @param pwd - * {@link String} the password - * @param path - * {@link String} the target path - * @param force - * {@link boolean} flag indicating whether the operation must be forced or not - * @param files - * array of {@link String} containing the file names to be removed from the grid - * @throws DataGridException - */ - private static void remove(String user, String pwd, String path, boolean force, String... files) throws DataGridException { - IRODSAccount account = authenticateUser(user, pwd); - - try { - IRODSFileFactory fileFactory = irodsAccessObjectFactory.getIRODSFileFactory(account); - IRODSFileSystemAO irodsFileSystemAO = irodsAccessObjectFactory.getIRODSFileSystemAO(account); - - for (String file : files) { - logger.info("Trying to remove file {} to path {} as {}", file, path, user); - IRODSFile targetFile = fileFactory.instanceIRODSFile(path, file); - - if (force) { - irodsFileSystemAO.fileDeleteForce(targetFile); - } - else if (irodsFileSystemAO.isFileExists(targetFile)) { - irodsFileSystemAO.fileDeleteNoForce(targetFile); - } - } - - } - catch (JargonException e) { - logger.info("Could not remove file path {}", path, e); - } - - closeSession(account); - } - -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/utils/HealthCheckUtils.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/utils/HealthCheckUtils.java deleted file mode 100644 index c5afcbfc0..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/utils/HealthCheckUtils.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.emc.metalnx.integration.test.utils; - -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; - -import com.emc.metalnx.test.generic.UiTestUtilities; - -public class HealthCheckUtils { - - public static String getPageHeader(WebDriver driver, WebDriverWait wait, String url) { - driver.get(url); - wait.until(ExpectedConditions.visibilityOfElementLocated(UiTestUtilities.dashboardHdrLocator)); - return driver.findElement(UiTestUtilities.dashboardHdrLocator).getText(); - } -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/utils/MetadataUtils.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/utils/MetadataUtils.java deleted file mode 100755 index aadf1d6f1..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/utils/MetadataUtils.java +++ /dev/null @@ -1,391 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.integration.test.utils; - -import com.emc.metalnx.test.generic.UiTestUtilities; -import org.junit.Assert; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.interactions.Actions; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.Select; -import org.openqa.selenium.support.ui.WebDriverWait; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.List; - -import static org.junit.Assert.assertTrue; - -/** - * Contains all common operations and attributes for metadata search testing. - * - */ - -public class MetadataUtils { - public static final String SELENIUM_ATTR = "Selenium"; - public static final String SELENIUM_VALUE = "Test"; - public static final String SELENIUM_UNIT = "Mlx"; - public static final String SELENIUM_TEST_ATTR = "SeleniumTest"; - public static final String SELENIUM_TEST_VAL1 = "1"; - public static final String SELENIUM_TEST_VAL2 = "2"; - public static final String SELENIUM_TEST_VAL3 = "3"; - public static final String SELENIUM_TEST_VAL12 = "12"; - - public static final String[] METADATA_SEARCH_FILES = { "1SeleniumTestMetadataSearch.png", "2SeleniumTestMetadataSearch.png", - "3SeleniumTestMetadataSearch.png" }; - - public static final int TOTAL_FILES_METADATA_SEARCH = 3; - - public static final By TAB_LINKS = By.id("breadcrumbOptionsMenu"); - public static final By BROWSE_TAB = By.cssSelector("#breadcrumbOptions ul.dropdown-menu li:first-child a"); - public static final By METADATA_TAB = By.cssSelector("#breadcrumbOptions ul.dropdown-menu li:nth-child(2) a"); - public static final By METADATA_SEARCH_RESULTS = By.cssSelector("#treeViewTable tbody a"); - public static final By SUBMIT_SEARCH_BTN = By.id("submitMetadataSearch"); - public static final By SEARCH_OPERATOR = By.name("operator"); - public static final String EQUAL = "EQUAL"; - public static final String NOT_EQUAL = "NOT_EQUAL"; - public static final String LIKE = "LIKE"; - public static final String NOT_LIKE = "NOT_LIKE"; - - // metadata table columns - public static final By METADATA_ATTR_COL = By.cssSelector("#metadaTable tbody tr td:nth-child(2)"); - public static final By METADATA_VAL_COL = By.cssSelector("#metadaTable tbody tr td:nth-child(3)"); - public static final By METADATA_UNIT_COL = By.cssSelector("#metadaTable tbody tr td:nth-child(4)"); - - private static final Logger logger = LoggerFactory.getLogger(MetadataUtils.class); - - /** - * Goes back to the collections list from the metadata tab. - * - * @param driver - */ - public static void goBackToBrowseTab(WebDriver driver) { - WebDriverWait wait = new WebDriverWait(driver, 15); - wait.until(ExpectedConditions.elementToBeClickable(CollectionUtils.BROWSE_TAB)); - WebElement backBtn = driver.findElement(CollectionUtils.BROWSE_TAB); - new Actions(driver).moveToElement(backBtn).perform(); - backBtn.click(); - } - - /** - * Add an AVU tag to the given file. - * - * @param driver - * @param attribute - * attribute to be added to the file - * @param value - * value to be added to the file - * @param unit - * unit to be added to the file - * @param file - * name of the file that will have the AVU - */ - public static void addMetadata(WebDriver driver, String attribute, String value, String unit, String file) { - driver.get(UiTestUtilities.COLLECTIONS_URL); - - WebDriverWait wait = new WebDriverWait(driver, 10); - String locator = String.format("#treeViewTable a[name='/%s/home/%s/%s']", UiTestUtilities.IRODS_ZONE, UiTestUtilities.RODS_USERNAME, file); - wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("treeViewTable"))); - driver.findElement(By.cssSelector("#treeViewTable_filter input")).sendKeys(file); - // driver.manage().timeouts().implicitlyWait(10L, TimeUnit.SECONDS); - realWaitMethod(driver); - wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector(locator))); - // wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#treeViewTable tbody tr:first-child"))); - driver.findElement(By.cssSelector(locator)).click(); - - openMetadataTab(driver); - - // opening addMetadata modal - openAddMetadataModalAndSendForm(driver, attribute, value, unit); - goBackToBrowseTab(driver); - } - - /** - * Method that removes all metadata tags added by a template to a given file or collection. - * - * @param item - * file or collection a template added metadata previously - */ - public static void removeAllMetadata(WebDriver driver, String item) { - WebDriverWait wait = new WebDriverWait(driver, 10); - - By metadataBulkDel = By.cssSelector("#metadaTable #checkAllMetadata"); - By delMetadataBtn = By.id("delMetadataBtn"); - By deleteMetadataModal = By.id("deleteMetadataModal"); - By metadataDelConf = By.cssSelector("#deleteMetadataModal .btn-primary"); - - driver.get(UiTestUtilities.COLLECTIONS_URL); - - CollectionUtils.waitForItemToLoad(driver, item); - driver.findElement(CollectionUtils.getFileLocatorUnderRodsHome(item)).click(); - - wait.until(ExpectedConditions.textToBePresentInElementLocated(CollectionUtils.BROWSE_TAB, "Back")); - driver.findElement(CollectionUtils.METADATA_TAB).click(); - - CollectionUtils.waitForMetadataToBeLoaded(driver); - driver.findElement(metadataBulkDel).click(); - - wait.until(ExpectedConditions.visibilityOfElementLocated(delMetadataBtn)); - driver.findElement(delMetadataBtn).click(); - - wait.until(ExpectedConditions.visibilityOfElementLocated(deleteMetadataModal)); - wait.until(ExpectedConditions.elementToBeClickable(metadataDelConf)); - driver.findElement(metadataDelConf).click(); - } - - public static void waitForSearchResults(WebDriver driver) { - logger.info("Waiting for metadata search results {}..."); - WebDriverWait wait = new WebDriverWait(driver, 10); - wait.until(ExpectedConditions.elementToBeClickable(MetadataUtils.METADATA_SEARCH_RESULTS)); - } - - public static void addMetadata(WebDriver driver, String attribute, String value, String unit) { - - openMetadataTab(driver); - - // openning addMetadata modal - openAddMetadataModalAndSendForm(driver, attribute, value, unit); - } - - /** - * Method that opens metadata tab in the user management page always brings to the - * collection's metadata page. - */ - public static void openMetadataTab(WebDriver driver) { - logger.info("Testing if metadata tab button works"); - - WebDriverWait wait = new WebDriverWait(driver, 10); - - realWaitMethod(driver); - wait.until(ExpectedConditions.elementToBeClickable(TAB_LINKS)); - driver.findElement(TAB_LINKS).click(); - wait.until(ExpectedConditions.elementToBeClickable(METADATA_TAB)); - driver.findElement(METADATA_TAB).click(); - - By idMetadataCollection = By.id("metadataActions"); - - WebElement metadataDiv = wait.until(ExpectedConditions.presenceOfElementLocated(idMetadataCollection)); - - assertTrue(metadataDiv.isDisplayed()); - } - - public static void openAddMetadataModalAndSendForm(WebDriver driver, String attribute, String value, String unit) { - - By idAddMetadataBtn = By.id("addMetadataBtn"); - WebDriverWait wait = new WebDriverWait(driver, 15); - wait.until(ExpectedConditions.elementToBeClickable(idAddMetadataBtn)); - driver.findElement(idAddMetadataBtn).click(); - - // inputs of the form - wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#metadataModal .modal-dialog"))); - WebElement inputAttr = driver.findElement(By.id("newAttrModal")); - WebElement inputVal = driver.findElement(By.id("newValModal")); - WebElement inputUnit = driver.findElement(By.id("newUnitModal")); - - inputAttr.click(); - inputAttr.clear(); - inputAttr.sendKeys(attribute); - - inputVal.click(); - inputVal.clear(); - inputVal.sendKeys(value); - - inputUnit.click(); - inputUnit.clear(); - inputUnit.sendKeys(unit); - - // sending form - driver.findElement(By.id("saveMetadata")).click(); - wait.until(ExpectedConditions.invisibilityOfElementLocated(By.id("newAttrModal"))); - } - - /** - * This method exists so that metadata search test can be successful. - * It will insert certain metadata tags in three specific files in rods collection - */ - public static void addMetadataToSpecificFiles(WebDriver driver) { - WebDriverWait wait = new WebDriverWait(driver, 15); - driver.get(UiTestUtilities.COLLECTIONS_URL); - wait.until(ExpectedConditions.elementToBeClickable(TAB_LINKS)); - - for (int i = 0; i < METADATA_SEARCH_FILES.length; i++) { - MetadataUtils.realWaitMethod(driver); - driver.findElement(By.cssSelector("#treeViewTable_filter input")).sendKeys(METADATA_SEARCH_FILES[i]); - MetadataUtils.realWaitMethod(driver); - WebElement file = driver.findElement(By.cssSelector("#treeViewTable tr:first-child td:nth-child(2) a")); - if (i == 0) { - file.click(); - addMetadata(driver, SELENIUM_TEST_ATTR, SELENIUM_TEST_VAL1, ""); - addMetadata(driver, SELENIUM_TEST_ATTR, SELENIUM_TEST_VAL12, ""); - } - else if (i == 1) { - file.click(); - addMetadata(driver, SELENIUM_TEST_ATTR, SELENIUM_TEST_VAL2, ""); - addMetadata(driver, SELENIUM_TEST_ATTR, SELENIUM_TEST_VAL12, ""); - } - else if (i == 2) { - file.click(); - addMetadata(driver, SELENIUM_TEST_ATTR, SELENIUM_TEST_VAL3, ""); - } - - goBackToBrowseTab(driver); - } - } - - /** - * Method that asserts the order of results shown after a metadata search is done. - * - * @param driver - */ - public static void assertMetadataSearchResultsOrder(WebDriver driver) { - List metadataSearchResults = driver.findElements(By.cssSelector("#treeViewTableBody a")); - - int index = 0; - for (WebElement metadataSearchResult : metadataSearchResults) { - Assert.assertEquals(metadataSearchResult.getText().trim(), MetadataUtils.METADATA_SEARCH_FILES[index]); - index++; - } - } - - /** - * Method that submits a metadata search form to apply the search against the data grid. - * - * @param driver - */ - public static void submitMetadataSearch(WebDriver driver) { - WebDriverWait wait = new WebDriverWait(driver, 10); - wait.until(ExpectedConditions.elementToBeClickable(MetadataUtils.SUBMIT_SEARCH_BTN)); - driver.findElement(MetadataUtils.SUBMIT_SEARCH_BTN).click(); - } - - /** - * Fills search criteria for a metadata search. - * - * @param driver - * @param attr - * attribute to be filled in the attribute field - * @param val - * value to be filled in the value field - * @param unit - * unit to be filled in the unit field - */ - public static void fillInMetadataSearchAttrValAndUnit(WebDriver driver, String attr, String val, String unit) { - WebDriverWait wait = new WebDriverWait(driver, 10); - wait.until(ExpectedConditions.elementToBeClickable(By.name("attribute"))); - wait.until(ExpectedConditions.elementToBeClickable(By.name("value"))); - wait.until(ExpectedConditions.elementToBeClickable(By.name("unit"))); - - driver.findElement(By.name("attribute")).sendKeys(attr); - driver.findElement(By.name("value")).sendKeys(val); - driver.findElement(By.name("unit")).sendKeys(unit); - } - - /** - * Fills search criteria for a metadata search. - * - * @param driver - * @param attr - * attribute to be filled in the attribute field - * @param val - * value to be filled in the value field - */ - public static void fillInMetadataSearchAttrVal(WebDriver driver, String attr, String val) { - WebDriverWait wait = new WebDriverWait(driver, 10); - wait.until(ExpectedConditions.elementToBeClickable(By.name("attribute"))); - wait.until(ExpectedConditions.elementToBeClickable(By.name("value"))); - - driver.findElement(By.name("attribute")).sendKeys(attr); - driver.findElement(By.name("value")).sendKeys(val); - } - - /** - * Fills search criteria for a metadata search. - * - * @param driver - * @param attr - * attribute to be filled in the attribute field - * @param unit - * unit to be filled in the unit field - */ - public static void fillInMetadataSearchAttrUnit(WebDriver driver, String attr, String unit) { - WebDriverWait wait = new WebDriverWait(driver, 10); - wait.until(ExpectedConditions.elementToBeClickable(By.name("attribute"))); - wait.until(ExpectedConditions.elementToBeClickable(By.name("unit"))); - - driver.findElement(By.name("attribute")).sendKeys(attr); - driver.findElement(By.name("unit")).sendKeys(unit); - } - - /** - * Fills search criteria for a metadata search. - * - * @param driver - * @param unit - * unit to be filled in the unit field - */ - public static void fillInMetadataSearchUnit(WebDriver driver, String unit) { - WebDriverWait wait = new WebDriverWait(driver, 10); - wait.until(ExpectedConditions.elementToBeClickable(By.name("unit"))); - - driver.findElement(By.name("unit")).sendKeys(unit); - } - - /** - * Fills search criteria for a metadata search. - * - * @param driver - * @param operator - * operator to be applied to the search (EQUAL, NOT_EQUAL, LIKE, NOT_LIKE) - */ - public static void fillInMetadataSearchOperator(WebDriver driver, String operator) { - WebDriverWait wait = new WebDriverWait(driver, 10); - wait.until(ExpectedConditions.elementToBeClickable(SEARCH_OPERATOR)); - - new Select(driver.findElement(SEARCH_OPERATOR)).selectByValue(operator); - } - - /** - * Keeps adding search parameters field until it reaches a maximum - * - * @param driver - */ - public static void addMaxNumberOfSearchParams(WebDriver driver) { - driver.get(UiTestUtilities.METADATA_SEARCH_URL); - - WebDriverWait wait = new WebDriverWait(driver, 10); - wait.until(ExpectedConditions.elementToBeClickable(By.id("addMetadataSearchRow"))); - WebElement addMetadataSearchRow = driver.findElement(By.id("addMetadataSearchRow")); - - for (int i = 0; i < 4; i++) { - addMetadataSearchRow.click(); - } - - wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.className("metadataSearchRow"))); - - } - - public static void realWaitMethod(WebDriver driver) { - try { - new WebDriverWait(driver, 1).until(ExpectedConditions.elementToBeClickable(By.id("çççç"))); - } - catch (Exception e) { - - } - } -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/utils/ProfileUtils.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/utils/ProfileUtils.java deleted file mode 100755 index 833a5751f..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/utils/ProfileUtils.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.integration.test.utils; - -import com.emc.metalnx.test.generic.UiTestUtilities; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; - -import java.util.List; - - -public class ProfileUtils { - public static void accessAddNewProfileForm(WebDriver driver) { - driver.get(UiTestUtilities.PROFILES_URL); - WebDriverWait wait = new WebDriverWait(driver, 8); - wait.until(ExpectedConditions.presenceOfElementLocated(By.id("addProfileButton"))); - - driver.findElement(By.id("addProfileButton")).click(); - } - - public static void fillProfileForm(String name, String description, List groupsNames, WebDriver driver) { - driver.findElement(By.id("inputProfileName")).sendKeys(name); - driver.findElement(By.id("inputDescription")).sendKeys(description); - - if (groupsNames != null) { - for (String groupName : groupsNames) { - driver.findElement(By.cssSelector("#groupsListTable_filter input")).clear(); - driver.findElement(By.cssSelector("#groupsListTable_filter input")).sendKeys(groupName); - driver.findElement(By.id("chk_" + groupName)).click(); - } - } - } - - public static void submitProfileForm(WebDriver driver) { - WebDriverWait wait = new WebDriverWait(driver, 8); - wait.until(ExpectedConditions.presenceOfElementLocated(By.id("submitProfileFormBtn"))); - - driver.findElement(By.id("submitProfileFormBtn")).click(); - } - - public static void addUserProfile(String name, String description, List groupsNames, WebDriver driver) { - driver.get(UiTestUtilities.ADD_PROFILES_URL); - WebDriverWait wait = new WebDriverWait(driver, 8); - - wait.until(ExpectedConditions.presenceOfElementLocated(By.id("inputProfileName"))); - - fillProfileForm(name, description, groupsNames, driver); - submitProfileForm(driver); - } - - public static boolean isProfileInList(String name, WebDriver driver) { - if (!driver.getCurrentUrl().equals(UiTestUtilities.PROFILES_URL)) { - driver.get(UiTestUtilities.PROFILES_URL); - - } - WebDriverWait wait = new WebDriverWait(driver, 8); - wait.until(ExpectedConditions.presenceOfElementLocated(By.id("userProfilesListTable"))); - - List profilesNamesElements = driver.findElements(By.className("col-profile-name")); - - for (WebElement e : profilesNamesElements) { - if (e.getText().equals(name)) { - return true; - } - } - - return false; - } - - public static void clickOnRemoveIcon(String name, WebDriver driver) { - if (!driver.getCurrentUrl().equals(UiTestUtilities.PROFILES_URL)) { - driver.get(UiTestUtilities.PROFILES_URL); - - } - WebDriverWait wait = new WebDriverWait(driver, 8); - wait.until(ExpectedConditions.presenceOfElementLocated(By.id("userProfilesListTable"))); - - driver.findElement(By.id("btn_removal_" + name)).click(); - - wait.until(ExpectedConditions.elementToBeClickable(By.id("btnConfProfileRemoval_Yes"))); - } - - public static void removeProfile(String name, WebDriver driver) { - if (isProfileInList(name, driver)) { - clickOnRemoveIcon(name, driver); - driver.findElement(By.id("btnConfProfileRemoval_Yes")).click(); - } - } - - public static boolean errorMessageIsDisplayed(String errorMessageElementId, WebDriver driver) { - WebDriverWait wait = new WebDriverWait(driver, 8); - wait.until(ExpectedConditions.presenceOfElementLocated(By.id(errorMessageElementId))); - - WebElement invalidMsg = driver.findElement(By.id(errorMessageElementId)); - return invalidMsg.isDisplayed(); - } -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/utils/ResourceUtils.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/utils/ResourceUtils.java deleted file mode 100755 index aba37df00..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/utils/ResourceUtils.java +++ /dev/null @@ -1,332 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.integration.test.utils; - -import com.emc.metalnx.test.generic.UiTestUtilities; -import junit.framework.Assert; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.interactions.Actions; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.Select; -import org.openqa.selenium.support.ui.WebDriverWait; - -import java.util.List; - -import static org.junit.Assert.assertTrue; - - -public class ResourceUtils { - public static final String RESC_COMPOUND = "compound"; - public static final String RESC_LOAD_BAL = "load_balanced"; - public static final String RESC_PASSTHRU = "passthru"; - public static final String RESC_RANDOM = "random"; - public static final String RESC_REPL = "replication"; - public static final String RESC_ROUND_ROBIN = "roundrobin"; - public static final String RESC_DEFERRED = "deferred"; - public static final String RESC_ECS = "ecs"; - public static final String RESC_ISILON = "isilon"; - public static final String RESC_MOCK = "mockarchive"; - public static final String RESC_MSO = "mso"; - public static final String RESC_MSO_FILE = "mssofile"; - public static final String RESC_NON_BLOCKING = "nonblocking"; - public static final String RESC_STRUCT_FILE = "structfile"; - public static final String RESC_UNIVMSS = "univmss"; - public static final String RESC_UNIX_FILE_SYSTEM = "unixfilesystem"; - public static final String RESC_WOS = "wos"; - - public static final String RESOURCE_PATH = "/var/lib/irods/iRODS/Vault"; - - private static final String[] COORDINATING_RESOURCES = { RESC_COMPOUND, RESC_LOAD_BAL, RESC_PASSTHRU, RESC_RANDOM, RESC_REPL, RESC_ROUND_ROBIN }; - - public static final By RESC_LIST_TABLE = By.cssSelector("#resourcesListTable tbody"); - - private static boolean isCoordinatingResource(String resourceType) { - for (int i = 0; i < COORDINATING_RESOURCES.length; i++) { - if (COORDINATING_RESOURCES[i].equals(resourceType)) { - return true; - } - } - return false; - } - - public static void accessAddResourceFormFrom(String url, String parent, WebDriver driver) { - driver.get(url); - WebDriverWait wait = new WebDriverWait(driver, 15); - - if (url.equals(UiTestUtilities.RESOURCES_MAP_URL)) { - wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("resourceMapPanel"))); - - rightClickOnNodeInMap(parent, driver); - driver.findElement(By.id("addChildMenuItem")).click(); - - } - else { - wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("addResourceButton"))); - driver.findElement(By.id("addResourceButton")).click(); - } - } - - public static void rightClickOnNodeInMap(String resourceName, WebDriver driver) { - List nodes = driver.findElements(By.className("node")); - WebElement parentNode = null; - for (WebElement node : nodes) { - String nodeName = node.findElement(By.tagName("text")).getText(); - if (nodeName.equals(resourceName)) { - parentNode = node; - break; - } - } - if (parentNode != null) { - Actions action = new Actions(driver); - action.contextClick(parentNode).build().perform(); - - WebDriverWait wait = new WebDriverWait(driver, 8); - wait.until(ExpectedConditions.elementToBeClickable(By.id("addChildMenuItem"))); - } - } - - public static void fillResourceForm(String resourceName, String resourceType, String parent, String zone, String host, String path, - WebDriver driver) { - WebDriverWait wait = new WebDriverWait(driver, 8); - wait.until(ExpectedConditions.presenceOfElementLocated(By.id("submitResourceFormBtn"))); - - if (parent != null) { - Assert.assertEquals(UiTestUtilities.ADD_RESOURCES_URL + parent + "/", driver.getCurrentUrl()); - } - else { - Assert.assertEquals(UiTestUtilities.ADD_RESOURCES_URL, driver.getCurrentUrl()); - } - - driver.findElement(By.id("inputResourceName")).sendKeys(resourceName); - - new Select(driver.findElement(By.id("selectResourceType"))).selectByValue(resourceType); - - if (isCoordinatingResource(resourceType)) { - if (parent != null) { - new Select(driver.findElement(By.id("selectResourceParent"))).selectByValue(parent); - } - - if (zone != null) { - new Select(driver.findElement(By.id("selectZone"))).selectByValue(zone); - } - } - else { - // It is a storage resource - wait.until(ExpectedConditions.presenceOfElementLocated(By.id("inputResourceHost"))); - - driver.findElement(By.id("inputResourceHost")).sendKeys(host); - driver.findElement(By.id("inputResourcePath")).sendKeys(path); - } - } - - public static void fillResourceFormForIsilon(String resourceName, String parent, String zone, String path, String isiHost, String isiPort, - String isiUser, WebDriver driver) { - - By isiHostInput = By.id("inputIsilonResourceHost"); - By isiPortInput = By.id("inputIsilonResourcePort"); - By isiUserInput = By.id("inputIsilonResourceUser"); - - fillResourceForm(resourceName, ResourceUtils.RESC_ISILON, parent, zone, "", path, driver); - - WebDriverWait wait = new WebDriverWait(driver, 8); - wait.until(ExpectedConditions.visibilityOfElementLocated(isiHostInput)); - wait.until(ExpectedConditions.visibilityOfElementLocated(isiPortInput)); - wait.until(ExpectedConditions.visibilityOfElementLocated(isiUserInput)); - - driver.findElement(isiHostInput).sendKeys(isiHost); - driver.findElement(isiPortInput).sendKeys(isiPort); - driver.findElement(isiUserInput).sendKeys(isiUser); - } - - public static void fillAndCancelResourceForm(String resourceName, boolean confirmCancel, WebDriver driver) { - fillResourceForm(resourceName, ResourceUtils.RESC_COMPOUND, null, null, null, null, driver); - - driver.findElement(By.id("cancelResourceFormBtn")).click(); - - WebDriverWait wait = new WebDriverWait(driver, 8); - wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("cancelModal"))); - - WebElement modalFooter = driver.findElement(By.className("modal-footer")); - if (confirmCancel) { - WebElement yesLink = modalFooter.findElement(By.linkText("Yes")); - wait.until(ExpectedConditions.elementToBeClickable(yesLink)); - yesLink.click(); - } - else { - WebElement noButton = modalFooter.findElement(By.tagName("button")); - wait.until(ExpectedConditions.elementToBeClickable(noButton)); - noButton.click(); - } - } - - public static void fillAndSubmitResourceForm(String resourceName, String resourceType, String parent, String zone, String host, String path, - WebDriver driver) { - fillResourceForm(resourceName, resourceType, parent, zone, host, path, driver); - driver.findElement(By.id("submitResourceFormBtn")).click(); - } - - public static void fillAndSubmitIsilonResourceForm(String resourceName, String parent, String zone, String path, String isiHost, String isiPort, - String isiUser, WebDriver driver) { - fillResourceFormForIsilon(resourceName, parent, zone, path, isiHost, isiPort, isiUser, driver); - driver.findElement(By.id("submitResourceFormBtn")).click(); - } - - public static void addResource(String from, String resourceName, String resourceType, String parent, String zone, String host, String path, - WebDriver driver) { - accessAddResourceFormFrom(from, parent, driver); - - fillAndSubmitResourceForm(resourceName, resourceType, parent, zone, host, path, driver); - - if (!from.equals(UiTestUtilities.RESOURCES_MAP_URL)) { - // checks if a success message is displayed and if the resource was successfully added - WebElement divAlertSucess = driver.findElement(By.className("alert-success")); - assertTrue(divAlertSucess.isDisplayed()); - assertTrue(divAlertSucess.getText().contains(resourceName)); - } - } - - public static void addIsilonResource(String resourceName, String parent, String zone, String path, String isiHost, String isiPort, - String isiUser, WebDriver driver) { - - // By submitFormBtn = By.id("submitResourceFormBtn"); - // WebDriverWait wait = new WebDriverWait(driver, 8); - - accessAddResourceFormFrom(UiTestUtilities.RESOURCES_URL, parent, driver); - fillAndSubmitIsilonResourceForm(resourceName, parent, zone, path, isiHost, isiPort, isiUser, driver); - - // wait.until(ExpectedConditions.elementToBeClickable(submitFormBtn)); - // driver.findElement(submitFormBtn).click(); - new WebDriverWait(driver, 8).until(ExpectedConditions.visibilityOfElementLocated(By.id("resourcesListTable"))); - } - - public static void removeResource(String resourceName, WebDriver driver) throws Exception { - if (ResourceUtils.isInResourcesList(UiTestUtilities.RESOURCES_URL, resourceName, null, driver)) { - clickOnResouceRemoveIcon(resourceName, driver); - driver.findElement(By.id("btnConfRescRemoval_Yes")).click(); - } - } - - public static void clickOnResouceRemoveIcon(String resourceName, WebDriver driver) { - - driver.get(UiTestUtilities.RESOURCES_URL); - WebDriverWait wait = new WebDriverWait(driver, 10); - wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("btn_removal_" + resourceName))); - driver.findElement(By.id("btn_removal_" + resourceName)).click(); - - wait = new WebDriverWait(driver, 5); - wait.until(ExpectedConditions.elementToBeClickable(By.id("btnConfRescRemoval_Yes"))); - } - - public static int searchResource(String searchBy, int expectedResults, WebDriver driver) { - - WebDriverWait wait = new WebDriverWait(driver, 15); - By resourcesFilter = By.cssSelector("#resourcesListTable_filter input"); - By resourcesTable = By.cssSelector("#resourcesListTable tbody tr td"); - - driver.get(UiTestUtilities.RESOURCES_URL); - wait.until(ExpectedConditions.visibilityOfElementLocated(resourcesTable)); - Assert.assertEquals(UiTestUtilities.RESOURCES_URL, driver.getCurrentUrl()); - - for (char c : searchBy.toCharArray()) { - char letters[] = { c }; - wait.until(ExpectedConditions.visibilityOfElementLocated(resourcesFilter)); - driver.findElement(resourcesFilter).sendKeys(new String(letters)); - wait.until(ExpectedConditions.visibilityOfElementLocated(resourcesTable)); - } - - return getResourcesCount(driver); - } - - public static int getResourcesCount(WebDriver driver) { - By isThereATable = By.cssSelector("#resourcesListTable tbody tr td"); - By rescRowSelector = By.cssSelector("tbody tr[role='row']"); - WebDriverWait wait = new WebDriverWait(driver, 8); - wait.until(ExpectedConditions.visibilityOfElementLocated(isThereATable)); - return driver.findElements(rescRowSelector).size(); - } - - public static boolean isInResourcesList(String url, String resourceName, String host, WebDriver driver) { - - By resourceTable = By.cssSelector("#resourcesListTable tbody"); - - if (!driver.getCurrentUrl().equals(url)) { - driver.get(url); - } - - WebDriverWait wait = new WebDriverWait(driver, 8); - if (url.equals(UiTestUtilities.RESOURCES_URL)) { - wait.until(ExpectedConditions.visibilityOfElementLocated(resourceTable)); - - WebElement resourcesListTable = driver.findElement(resourceTable); - List elements = resourcesListTable.findElements(By.className("col-resource-name")); - for (WebElement e : elements) { - if (e.getText().equals(resourceName)) { - return true; - } - } - } - else if (url.equals(UiTestUtilities.RESOURCES_MAP_URL)) { - wait.until(ExpectedConditions.presenceOfElementLocated(By.id("resourceMapPanel"))); - - List nodes = driver.findElements(By.className("node")); - for (WebElement node : nodes) { - if (node.findElement(By.tagName("text")).getText().equals(resourceName)) { - return true; - } - } - } - else if (url.equals(UiTestUtilities.RESOURCES_SERVERS_URL)) { - wait.until(ExpectedConditions.presenceOfElementLocated(By.id("resourcesByServerList"))); - - List elements = driver.findElements(By.id("hostname")); - for (WebElement e : elements) { - if (e.getText().equals(host)) { - e.click(); - By resourceInfo = By.id("info_" + resourceName); - wait.until(ExpectedConditions.visibilityOfElementLocated(resourceInfo)); - return driver.findElement(resourceInfo).findElement(By.cssSelector("#info_" + resourceName + " td:first-child span")).getText() - .equals(resourceName); - } - } - } - - return false; - } - - public static void assertResourceInfo(String resourceName, String resourceType, String zone, String host, String path, String parent, - WebDriver driver) { - assertTrue(driver.findElement(By.id("name")).getText().equals(resourceName)); - assertTrue(driver.findElement(By.id("type")).getText().equals(resourceType)); - assertTrue(driver.findElement(By.id("zone")).getText().equals(zone)); - if (!isCoordinatingResource(resourceType)) { - System.out.println(driver.findElement(By.id("host")).getText() + ", " + host); - assertTrue(driver.findElement(By.id("host")).getText().equals(host)); - assertTrue(driver.findElement(By.id("path")).getText().equals(path)); - } - assertTrue(driver.findElement(By.id("parent")).getText().equals(parent)); - } - - public static boolean errorMessageIsDisplayed(String errorMessageElementId, WebDriver driver) { - WebDriverWait wait = new WebDriverWait(driver, 8); - wait.until(ExpectedConditions.presenceOfElementLocated(By.id(errorMessageElementId))); - - WebElement invalidMsg = driver.findElement(By.id(errorMessageElementId)); - return invalidMsg.isDisplayed(); - } -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/utils/TemplateUtils.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/utils/TemplateUtils.java deleted file mode 100755 index 418771940..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/utils/TemplateUtils.java +++ /dev/null @@ -1,435 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.integration.test.utils; - -import com.emc.metalnx.test.generic.UiTestUtilities; -import org.junit.Assert; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.Select; -import org.openqa.selenium.support.ui.WebDriverWait; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.ArrayList; -import java.util.List; - -import static org.junit.Assert.assertTrue; - - -public class TemplateUtils { - private static final Logger logger = LoggerFactory.getLogger(TemplateUtils.class); - - public static final int TOTAL_METADATA_FIELDS = 5; - - public static final String TEMPLATE_TEST_NAME = "templateTest"; - public static final String TEMPLATE_TEST_DESC = "template description test"; - public static final String TEMPLATE_USE_INFO = "template use info"; - - public static final String PRIVATE_TEMPLATE_TYPE = "private"; - public static final String SYSTEM_TEMPLATE_TYPE = "system"; - - public static final String attribute = "attrTest"; - public static final String value = "valueTest"; - public static final String unit = "unitTest"; - public static final String[] TEST_FILES = { "applyTemplateTest.png" }; - public static final String[] TEST_COLLS = { "applyTemplateTestColl" + System.currentTimeMillis() }; - - public static final By TEMPLATES_LIST_TABLE = By.id("templatesListTable"); - public static final By LIST_TEMPLATE_FIELDS_BTN = By.id("listTemplateFieldsBtn"); - public static final By SUBMIT_TEMPLATE_BTN = By.id("submitTemplateBtn"); - - /** - * Searches for a template by its name. - * - * @param driver - * @param template - * name of the template name to be found - */ - public static void searchByTemplateName(WebDriver driver, String template) { - driver.get(UiTestUtilities.TEMPLATES_URL); - WebDriverWait wait = new WebDriverWait(driver, 10); - wait.until(ExpectedConditions.elementToBeClickable(By.id("templatesListTable_filter"))); - driver.findElement(By.cssSelector("#templatesListTable_filter input[type='search']")).click(); - driver.findElement(By.cssSelector("#templatesListTable_filter input[type='search']")).clear(); - driver.findElement(By.cssSelector("#templatesListTable_filter input[type='search']")).sendKeys(template); - wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("#templateListAsync tbody"))); - } - - /** - * Removes all existing templates from Metalnx. - * - * @param driver - */ - public static void removeAllTemplates(WebDriver driver) { - WebDriverWait wait = new WebDriverWait(driver, 10); - - By delTemplatesCb = By.cssSelector("#templatesListTable input[name='selectAllCheckboxes']"); - By remoteTemplatesBtn = By.id("removeTemplatesBtn"); - By remoteTemplatesConfBtn = By.cssSelector("#removalModal .btn-primary"); - - driver.get(UiTestUtilities.TEMPLATES_URL); - - wait.until(ExpectedConditions.visibilityOfElementLocated(delTemplatesCb)); - driver.findElement(delTemplatesCb).click(); - - wait.until(ExpectedConditions.visibilityOfElementLocated(remoteTemplatesBtn)); - driver.findElement(remoteTemplatesBtn).click(); - - wait.until(ExpectedConditions.visibilityOfElementLocated(remoteTemplatesConfBtn)); - driver.findElement(remoteTemplatesConfBtn).click(); - } - - /** - * Creates a template in Metalnx. - * - * @param template - * name of the template being created - * @param desc - * template description - * @param desc - * template usage information - * @param templateType - * type of the template (System or Private) - * @param driver - */ - public static void createTemplateWithNoFields(String template, String desc, String useInfo, String templateType, WebDriver driver) { - logger.info("Creating a template without any metadata fields"); - driver.get(UiTestUtilities.ADD_TEMPLATES_URL); - fillInTemplateInformation(template, desc, useInfo, templateType, driver); - submitTemplateForm(driver); - } - - public static void createTemplateWithNoFields(WebDriver driver, String template, String templateType) { - createTemplateWithNoFields(template, TEMPLATE_TEST_DESC, TEMPLATE_USE_INFO, templateType, driver); - } - - /** - * Method used for adding a brand new system or private template with metadata fields. - * It verifies if after adding a template, the user is redirected to the template mgmt. page and - * if this template was created successfully; - */ - public static void createTemplateWithFields(WebDriver driver, String template, String templateType) { - driver.get(UiTestUtilities.ADD_TEMPLATES_URL); - addFieldsToTemplate(driver); - fillInTemplateInformation(template, TEMPLATE_TEST_DESC, TEMPLATE_USE_INFO, templateType, driver); - TemplateUtils.submitTemplateForm(driver); - TemplateUtils.assertTemplateSuccessfulCreation(driver, template); - } - - /** - * Method used for adding a brand new system or private template with the given metadata fields. - * It verifies if after adding a template, the user is redirected to the template mgmt. page and - * if this template was created successfully; - */ - public static void createTemplateWithFields(WebDriver driver, String template, String templateType, String[] attrs, String[] values, - String[] units) { - driver.get(UiTestUtilities.ADD_TEMPLATES_URL); - addFieldsToTemplate(driver, attrs, values, units); - fillInTemplateInformation(template, TEMPLATE_TEST_DESC, TEMPLATE_USE_INFO, templateType, driver); - TemplateUtils.submitTemplateForm(driver); - TemplateUtils.assertTemplateSuccessfulCreation(driver, template); - } - - /** - * Removes the template created for testing purposes. - * - * @param template - * name of the template that will be removed - * @throws Exception - */ - public static void removeTemplate(String templateName, WebDriver driver) throws Exception { - logger.info("Removing template {}", templateName); - - WebDriverWait wait = new WebDriverWait(driver, 15); - - searchByTemplateName(driver, templateName); - - wait.until(ExpectedConditions.elementToBeClickable(By.id("templatesListTable"))); - String cssSelector = "#" + templateName + " input[name=selectedTemplates]"; - wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector(cssSelector))); - driver.findElement(By.cssSelector(cssSelector)).click(); - driver.findElement(By.id("removeTemplatesBtn")).click(); - - // wait for the template removal confirmation modal to show up - wait.until(ExpectedConditions.elementToBeClickable(By.id("removeTemplatesConfBtn"))); - driver.findElement(By.id("removeTemplatesConfBtn")).click(); - wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(".alert-success"))); - } - - /** - * Method used for filling in template information when creating a template. - * - * @param templateAccessType - * template type being added (system or private) - */ - public static void fillInTemplateInformation(String templateName, String templateDescription, String templateUseInfo, String templateAccessType, - WebDriver driver) { - driver.findElement(By.id("templateName")).click(); - driver.findElement(By.id("templateName")).clear(); - driver.findElement(By.id("templateName")).sendKeys(templateName); - driver.findElement(By.id("templateDescription")).click(); - driver.findElement(By.id("templateDescription")).clear(); - driver.findElement(By.id("templateDescription")).sendKeys(templateDescription); - new Select(driver.findElement(By.id("templateAccessType"))).selectByValue(templateAccessType); - } - - /** - * Checks if after adding a Template, if the system returns to the template mgmt. screen and a - * feedback message is displayed. - * - * @param driver - */ - public static void assertTemplateSuccessfulCreation(WebDriver driver, String template) { - new WebDriverWait(driver, 10).until(ExpectedConditions.visibilityOfElementLocated(By.id("templatesListTable"))); - Assert.assertEquals(UiTestUtilities.TEMPLATES_URL, driver.getCurrentUrl()); - WebElement divAlertSucess = driver.findElement(By.className("alert-success")); - assertTrue(divAlertSucess.isDisplayed()); - assertTrue(divAlertSucess.getText().contains(template)); - } - - /** - * Submits the template form. - * - * @param driver - */ - public static void submitTemplateForm(WebDriver driver) { - driver.findElement(By.id("submitTemplateFormBtn")).click(); - } - - /** - * Checks if a list of AVUs were added to a file. - * - * @param driver - * @param items - * files or collections to check metadata - * @param attributes - * list of attributes to check - * @param values - * list of values to check - * @param units - * list of units to check - */ - public static void checkIfMetadataWasAdded(WebDriver driver, boolean isCollection, List attributes, List values, - List units, String... items) { - - WebDriverWait wait = new WebDriverWait(driver, 10); - driver.get(UiTestUtilities.COLLECTIONS_URL); - - CollectionUtils.waitForItemToLoad(driver, items[items.length - 1]); - for (String item : items) { - driver.findElement(By.cssSelector("#treeViewTable_filter input")).clear(); - driver.findElement(By.cssSelector("#treeViewTable_filter input")).sendKeys(item); - driver.findElement(CollectionUtils.getFileLocatorUnderRodsHome(item)).click(); - - MetadataUtils.openMetadataTab(driver); - - wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#metadaTable tbody tr:nth-child(5)"))); - List attributesFromMlx = convertWebElementListToString(driver.findElements(MetadataUtils.METADATA_ATTR_COL)); - List valuesFromMlx = convertWebElementListToString(driver.findElements(MetadataUtils.METADATA_VAL_COL)); - List unitsFromMlx = convertWebElementListToString(driver.findElements(MetadataUtils.METADATA_UNIT_COL)); - - for (int i = 0; i < TemplateUtils.TOTAL_METADATA_FIELDS; i++) { - Assert.assertTrue(attributesFromMlx.contains(attributes.get(i))); - Assert.assertTrue(valuesFromMlx.contains(values.get(i))); - Assert.assertTrue(unitsFromMlx.contains(units.get(i))); - } - } - } - - /** - * Auxiliar method that finds a given template to be applied against a file. - * - * @param files - * files' names the template will be applied - * @param template - * template name - */ - public static void findTemplateToApply(WebDriver driver, String template, String... files) { - - WebDriverWait wait = new WebDriverWait(driver, 10); - - By waitCondition = By.cssSelector("#treeViewTable tbody tr td a span"); - wait.until(ExpectedConditions.visibilityOfElementLocated(waitCondition)); - - for (String f : files) { - driver.findElement(By.id(f)).click(); - - CollectionUtils.waitForSelectActionBtnToBeEnabled(driver); - driver.findElement(CollectionUtils.SELECT_ACTION_BTN).click(); - - CollectionUtils.waitForActionsDropdownToBeShown(driver); - driver.findElement(CollectionUtils.APPLY_TEMPLATE_BTN).click(); - - waitForTemplatesToBeLoadedUnderCollsPage(driver); - driver.findElement(By.id(template)).click(); - - wait.until(ExpectedConditions.elementToBeClickable(TemplateUtils.LIST_TEMPLATE_FIELDS_BTN)); - driver.findElement(TemplateUtils.LIST_TEMPLATE_FIELDS_BTN).click(); - } - } - - /** - * Converts a list of Web elements to a set of strings. - * - * @param webElements - * web elements to be converted - * @return {@link List} with the text present in all elements - */ - public static List convertWebElementListToString(List webElements) { - List elements = new ArrayList(); - - if (webElements != null) { - for (WebElement e : webElements) { - String text = e.getText(); - if (text != null && !text.isEmpty()) { - elements.add(text); - } - } - } - - return elements; - } - - /** - * Submits a template to be applied. - */ - public static void submitApplyTemplateForm(WebDriver driver) { - By submitTemplateBtn = By.id("submitTemplateBtn"); - new WebDriverWait(driver, 10).until(ExpectedConditions.elementToBeClickable(submitTemplateBtn)); - driver.findElement(submitTemplateBtn).click(); - new WebDriverWait(driver, 10).until(ExpectedConditions.elementToBeClickable(By.cssSelector("#treeViewTable tbody tr td"))); - } - - /** - * Checks if a success message is displayed after applying a template. - * - * @param driver - */ - public static void isSuccessMessageShown(WebDriver driver) { - waitForAlertToBeShown(driver); - Assert.assertNotNull(driver.findElement(By.className("alert-success"))); - } - - /** - * Waits for the templates table to be loaded under the collections page. - * - * @param driver - */ - public static void waitForTemplatesToBeLoadedUnderCollsPage(WebDriver driver) { - WebDriverWait wait = new WebDriverWait(driver, 15); - wait.until(ExpectedConditions.visibilityOfElementLocated(TemplateUtils.TEMPLATES_LIST_TABLE)); - } - - /** - * Waits for the templates table to be loaded under the collections page. - * - * @param driver - */ - public static void waitForTemplatesToBeLoaded(WebDriver driver) { - WebDriverWait wait = new WebDriverWait(driver, 15); - wait.until(ExpectedConditions.visibilityOfElementLocated(TemplateUtils.TEMPLATES_LIST_TABLE)); - } - - /** - * Waits for an alert box to be shown after an apply template operation. - * - * @param driver - */ - public static void waitForAlertToBeShown(WebDriver driver) { - WebDriverWait wait = new WebDriverWait(driver, 15); - wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#applyTemplateSuccess"))); - } - - /** - * Adds the given AVUs to a template. - */ - public static void addFieldsToTemplate(WebDriver driver, String[] attrs, String[] values, String[] units) { - WebDriverWait wait = new WebDriverWait(driver, 15); - - By inputAttr = By.id("attribute"); - By inputValue = By.id("value"); - By inputUnit = By.id("unit"); - By addAttributeBtn = By.id("addAttributeBtn"); - - // adding metadata fields to the template - for (int i = 0; i < attrs.length; i++) { - wait.until(ExpectedConditions.elementToBeClickable(addAttributeBtn)); - driver.findElement(addAttributeBtn).click(); - - wait.until(ExpectedConditions.elementToBeClickable(inputAttr)); - driver.findElement(inputAttr).click(); - driver.findElement(inputAttr).clear(); - driver.findElement(inputAttr).sendKeys(attrs[i] + i); - - driver.findElement(inputValue).click(); - driver.findElement(inputValue).clear(); - driver.findElement(inputValue).sendKeys(values[i] + i); - - driver.findElement(inputUnit).click(); - driver.findElement(inputUnit).clear(); - driver.findElement(inputUnit).sendKeys(units[i] + i); - - driver.findElement(By.id("addFieldBtn")).click(); - - wait.until(ExpectedConditions.invisibilityOfElementLocated(By.id("newTemplateAVU"))); - - driver.get(driver.getCurrentUrl()); - wait.until(ExpectedConditions.elementToBeClickable(addAttributeBtn)); - } - } - - /** - * Adds several metadata fields to a template. - */ - public static void addFieldsToTemplate(WebDriver driver) { - WebDriverWait wait = new WebDriverWait(driver, 15); - - By inputAttr = By.id("attribute"); - By inputValue = By.id("value"); - By inputUnit = By.id("unit"); - By addAttributeBtn = By.id("addAttributeBtn"); - - // adding metadata fields to the template - for (int i = 0; i < TOTAL_METADATA_FIELDS; i++) { - wait.until(ExpectedConditions.elementToBeClickable(addAttributeBtn)); - driver.findElement(addAttributeBtn).click(); - - wait.until(ExpectedConditions.elementToBeClickable(inputAttr)); - driver.findElement(inputAttr).click(); - driver.findElement(inputAttr).clear(); - driver.findElement(inputAttr).sendKeys(attribute + i); - - driver.findElement(inputValue).click(); - driver.findElement(inputValue).clear(); - driver.findElement(inputValue).sendKeys(value + i); - - driver.findElement(inputUnit).click(); - driver.findElement(inputUnit).clear(); - driver.findElement(inputUnit).sendKeys(unit + i); - - driver.findElement(By.id("addFieldBtn")).click(); - - wait.until(ExpectedConditions.invisibilityOfElementLocated(By.id("newTemplateAVU"))); - - driver.get(driver.getCurrentUrl()); - wait.until(ExpectedConditions.elementToBeClickable(By.id("addAttributeBtn"))); - } - } -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/utils/UserUtils.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/utils/UserUtils.java deleted file mode 100755 index 631ba61b8..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/integration/test/utils/UserUtils.java +++ /dev/null @@ -1,441 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.integration.test.utils; - -import com.emc.metalnx.test.generic.UiTestUtilities; -import junit.framework.Assert; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.Select; -import org.openqa.selenium.support.ui.WebDriverWait; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import static org.junit.Assert.*; - - -public class UserUtils { - private static final Logger logger = LoggerFactory.getLogger(UserUtils.class); - - public static final By BOOKMARKS = By.cssSelector("#userBookmarksTable tbody tr"); - public static final By ZONE_FOLDER = By.name("/" + UiTestUtilities.IRODS_ZONE); - public static final By USERNAME_INPUT = By.id("inputUsername"); - public static final By PWD_INPUT = By.id("inputPassword"); - public static final By PWD_CONF_INPUT = By.id("inputPasswordConfirmation"); - public static final By USER_TYPE_SELECT = By.id("selectUserType"); - public static final By SEARCH_INPUT = By.cssSelector("#usersListTable_filter input"); - - private static final String userModifyStr = "modify/%s/%s/"; - - /** - * Checks if a user is in the group(s) given. - * - * @param driver - * @param uname - * user name - * @param group - * group name - */ - public static void checkIfUserIsInGroup(WebDriver driver, String uname, String... group) { - WebDriverWait wait = new WebDriverWait(driver, 10); - UiTestUtilities.login(); - driver.get(UiTestUtilities.USERS_URL); - UserUtils.searchUser(driver, uname); - - By MODIFY_USER_BTN = By.id(String.format(userModifyStr, uname, UiTestUtilities.IRODS_ZONE)); - wait.until(ExpectedConditions.elementToBeClickable(MODIFY_USER_BTN)).click(); - wait.until(ExpectedConditions.visibilityOfElementLocated(UserUtils.ZONE_FOLDER)); - - for (String grp : group) { - assertNotNull(driver.findElement(By.id(grp))); - } - - UiTestUtilities.logout(); - } - - /** - * As given Admin, this method created a profile, and includes the given group to this profile. - * - * @param driver - * @param adminUser - * admin username to log in Metalnx - * @param adminPwd - * admin password to log in Metalnx - * @param profile - * profile name that will be created - * @param group - * name of the group that will be inserted into the profile - */ - public static void createProfileAndIncludeGroupToThisProfileAsAdmin(WebDriver driver, String adminUser, String adminPwd, String profile, - String group) { - List groupNames = new ArrayList(); - groupNames.add(group); - - UiTestUtilities.login(adminUser, adminPwd); - driver.get(UiTestUtilities.ADD_PROFILES_URL); - ProfileUtils.addUserProfile(profile, "profileTestScenarioDesc", groupNames, driver); - new WebDriverWait(driver, 10).until(ExpectedConditions.presenceOfElementLocated(By.id("userProfilesListTable"))); - assertTrue(driver.findElement(By.className("alert-success")).isDisplayed()); - UiTestUtilities.logout(); - } - - /** - * Fills in user information (username, password, and confirmation password) and save this user. - * - * @param uname - * username - * @param pwd - * password - * @param driver - * driver already logged in the application - */ - public static void createUser(String uname, String pwd, String userType, WebDriver driver) { - UiTestUtilities.login(); - driver.get(UiTestUtilities.ADD_USERS_URL); - fillInUserGeneralInformation(uname, pwd, userType, driver); - submitUserForm(driver); - UiTestUtilities.logout(); - } - - /** - * As an admin, opens the modify user form to apply a profile to the given user. - * - * @param driver - * @param adminUname - * administrator username to log in - * @param adminPwd - * administrator password to log in - * @param uname - * user who will be applied the given profile - * @param rodsUserType - * user type - * @param profile - * profile name that will be applied on the rods user - */ - public static void modifyUserAsAdminAndApplyProfile(WebDriver driver, String adminUname, String adminPwd, String uname, String zone, - String rodsUserType, String profile) { - UiTestUtilities.login(adminUname, adminPwd); - modifyUser(uname, zone, driver); - new WebDriverWait(driver, 15).until(ExpectedConditions.elementToBeClickable(By.id("selectProfile"))); - new Select(driver.findElement(By.id("selectProfile"))).selectByVisibleText(profile); - submitUserForm(driver); - UiTestUtilities.logout(); - } - - /** - * Fills in user information (username, password, and confirmation password) and save this user using a given admin account. - * - * @param adminUname - * admin username used to create the user account - * @param adminPwd - * admin passwrod - * @param uname - * name of the user - * @param pwd - * password - * @param userType - * @param driver - */ - public static void createUserAsAdminAndApplyProfile(WebDriver driver, String adminUname, String adminPwd, String uname, String pwd, - String userType, String profile) { - - UiTestUtilities.login(adminUname, adminPwd); - driver.get(UiTestUtilities.ADD_USERS_URL); - fillInUserGeneralInformation(uname, pwd, userType, driver); - WebDriverWait wait = new WebDriverWait(driver, 15); - wait.until(ExpectedConditions.elementToBeClickable(By.id("showGroupsListBtn"))).click(); - wait.until(ExpectedConditions.elementToBeClickable(By.id("selectProfile"))); - new Select(driver.findElement(By.id("selectProfile"))).selectByVisibleText(profile); - submitUserForm(driver); - UiTestUtilities.logout(); - } - - /** - * Removes a user from the application based on his username. - * - * @param uname - * username - * @param driver - * driver already logged in the application - */ - public static void removeUser(String uname, WebDriver driver) { - - WebDriverWait wait = new WebDriverWait(driver, 15); - - UiTestUtilities.login(); - driver.get(UiTestUtilities.USERS_URL); - - By removeButton = By.id("btn_remove_" + uname); - By removeConfirmationButton = By.id("btnConfUserRemoval_Yes"); - - searchUser(driver, uname); - - try { - wait.until(ExpectedConditions.elementToBeClickable(removeButton)); - - driver.findElement(removeButton).click(); - wait.until(ExpectedConditions.elementToBeClickable(removeConfirmationButton)); - driver.findElement(removeConfirmationButton).click(); - } - catch (Exception e) { - logger.error("Could not remove user [{}]", uname); - } - UiTestUtilities.logout(); - } - - /** - * Goes to the modify user page based on the given username and zone. - * - * @param uname - * username to be modified - * @param zone - * zone where the user is - * @param driver - * web driver already logged in the application - */ - public static void modifyUser(String uname, String zone, WebDriver driver) { - driver.get(UiTestUtilities.USERS_URL); - - WebDriverWait wait = new WebDriverWait(driver, 15); - - By modifyButton = By.id(String.format(userModifyStr, uname, zone)); - - searchUser(driver, uname); - wait.until(ExpectedConditions.elementToBeClickable(modifyButton)); - - // find the user to modify - - driver.findElement(modifyButton).click(); - - // checking if Mlx goes to the user modify form - String modifyUserURL = UiTestUtilities.USERS_URL + String.format(userModifyStr, uname, zone); - Assert.assertEquals(modifyUserURL, driver.getCurrentUrl()); - } - - /** - * Generic test for granting permissions to an user on a data object or collection and check if - * such data object shows up in the user bookmark list. - * - * @param permType - * type of permission that will be granted - * @param uname - * name of the user the permission will be granted - * @param zone - * zone name where the user is - * @param pwd - * user password - * @param runTestForCollection - * permissions - * @param driver - */ - public static void createUserGrantPermissionAndCheckBookmarks(String permType, String uname, String zone, String pwd, String userType, - String[] testItems, WebDriver driver) { - logger.info("Test grant read permission and bookmark on a data object to a test user."); - - try { - driver.get(UiTestUtilities.ADD_USERS_URL); - fillInUserGeneralInformation(uname, pwd, userType, driver); - grantPermissionToUserAndCheckBookmarks(permType, uname, zone, pwd, testItems, driver); - } - catch (Exception e) { - logger.error("Could not run test properly: {}", e.getMessage()); - fail("Fail to grant read permission and bookmarks to user 'Test': " + e.getMessage()); - } - } - - /** - * Generic test for granting permissions to an user on a data object or collection and check if - * such data object shows up in the user bookmark list. - * - * @param permType - * type of permission (read, write, or own) to grant a user - */ - public static void modifyUserGrantPermissionAndCheckBookmarks(String permType, String uname, String zone, String pwd, String[] testItems, - WebDriver driver) { - logger.info("Test grant read permission and bookmark on a data object to an existing user."); - UserUtils.modifyUser(uname, zone, driver); - grantPermissionToUserAndCheckBookmarks(permType, uname, zone, pwd, testItems, driver); - } - - /** - * Checks if for a given user, all items (collections or data objects) are marked as bookmarks. - * - * @param uname - * username - * @param pwd - * user password - * @param testItems - * list of collections or data objects - * @param driver - */ - public static void checkIfBookmarksExist(String uname, String pwd, String[] testItems, WebDriver driver) { - - // logout from Metalnx and login as the test user - UiTestUtilities.logout(); - UiTestUtilities.login(uname, pwd); - - driver.get(UiTestUtilities.USER_BOOKMARKS_URL); - Assert.assertEquals(UiTestUtilities.USER_BOOKMARKS_URL, driver.getCurrentUrl()); - - new WebDriverWait(driver, 15).until(ExpectedConditions.visibilityOfAllElementsLocatedBy(BOOKMARKS)); - List bookmarks = driver.findElements(BOOKMARKS); - Assert.assertTrue(testItems.length <= bookmarks.size()); - - logger.info("Checking if bookmarks show up in order"); - Arrays.sort(testItems); - for (int i = 0; i < testItems.length; i++) { - Assert.assertTrue(bookmarks.get(i).getText().contains(testItems[i])); - } - - UiTestUtilities.logout(); - UiTestUtilities.login(); - } - - /** - * Grants permission on a set of items (collection or data objects). - * - * @param permType - * type of permission to be granted (read, write, own or none) - * @param testItems - * array of items (collections or data objects) that the permission will be applied - * @param driver - * driver already logged in the application - */ - private static void grantPermissionOnItems(String permType, String[] testItems, WebDriver driver) { - - WebDriverWait wait = new WebDriverWait(driver, 15); - - // Setting Read, write, or ownership permission on the test files or test collection - for (String item : testItems) { - - By permissionValue = By.id("permission_" + item); - By fileItem = By.cssSelector(String.format("input[name='/%s/%s']", UiTestUtilities.IRODS_ZONE, item)); - - wait.until(ExpectedConditions.elementToBeClickable(By.id("permission_" + item))); - new Select(driver.findElement(permissionValue)).selectByValue(permType); - String recursiveSelector = String.format("#recursiveQuestion_%s .btn-recursive-no", item); - try { - new WebDriverWait(driver, 5).until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(recursiveSelector))).click(); - } - catch (Exception e) {} - wait.until(ExpectedConditions.elementToBeClickable(fileItem)); - wait.until(ExpectedConditions.elementSelectionStateToBe(fileItem, true)); - } - } - - /** - * Fills in user information (username, password, and confirmation password) but does not save - * the user. The user form remains open for future edition. - * - * @param uname - * username - * @param pwd - * password - * @param driver - * driver already logged in the application - */ - public static void fillInUserGeneralInformation(String uname, String pwd, String userType, WebDriver driver) { - - WebDriverWait wait = new WebDriverWait(driver, 15); - - wait.until(ExpectedConditions.visibilityOfElementLocated(UserUtils.USERNAME_INPUT)); - wait.until(ExpectedConditions.visibilityOfElementLocated(UserUtils.ZONE_FOLDER)); - - driver.findElement(USERNAME_INPUT).sendKeys(uname); - driver.findElement(PWD_INPUT).sendKeys(pwd); - driver.findElement(PWD_CONF_INPUT).sendKeys(pwd); - new Select(driver.findElement(USER_TYPE_SELECT)).selectByValue(userType); - } - - /** - * Grants permission to user on a set of items. - * - * @param permType - * permission type to be granted to user - * @param uname - * username to give permissions - * @param zone - * zone name where the user is - * @param pwd - * user password - * @param testItems - * array of items (collections or data objects) that will be given permission - * @param driver - * web driver already logged in the application - */ - private static void grantPermissionToUserAndCheckBookmarks(String permType, String uname, String zone, String pwd, String[] testItems, - WebDriver driver) { - - WebDriverWait wait = new WebDriverWait(driver, 8); - wait.until(ExpectedConditions.elementToBeClickable(By.name("/" + zone))); - - // navigating to where the test items are located (/zoneName) - driver.findElement(By.name("/" + zone)).click(); - - grantPermissionOnItems(permType, testItems, driver); - submitUserForm(driver); - searchUser(driver, uname); - checkIfBookmarksExist(uname, pwd, testItems, driver); - } - - /** - * Method that submits a user form and checks whether or not after that the application shows - * the list of users page. - * - * @param driver - * web driver already in the user form - */ - public static void submitUserForm(WebDriver driver) { - driver.findElement(By.id("submitUserFormBtn")).click(); - Assert.assertEquals(UiTestUtilities.USERS_URL, driver.getCurrentUrl()); - } - - /** - * Method that fills in the personal information section of the user form. - * - * @param driver - * @param fname - * user's first name - * @param lname - * user's last name - * @param email - * user's email - */ - public static void fillInPersonalInfo(WebDriver driver, String fname, String lname, String email) { - new WebDriverWait(driver, 15).until(ExpectedConditions.elementToBeClickable(By.id("inputFirstName"))); - - driver.findElement(By.id("inputFirstName")).sendKeys(fname); - driver.findElement(By.id("inputLastName")).sendKeys(lname); - driver.findElement(By.id("inputEmail")).sendKeys(email); - } - - public static void searchUser(WebDriver driver, String username) { - WebDriverWait wait = new WebDriverWait(driver, 5); - try { - wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("çççç"))); - } - catch (Exception e) {} - wait.until(ExpectedConditions.visibilityOfElementLocated(SEARCH_INPUT)); - driver.findElement(SEARCH_INPUT).sendKeys(username); - } -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/test/generic/UiTestUtilities.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/test/generic/UiTestUtilities.java deleted file mode 100755 index c3f876141..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/test/generic/UiTestUtilities.java +++ /dev/null @@ -1,376 +0,0 @@ -/* - * Copyright (c) 2015-2017, Dell EMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.emc.metalnx.test.generic; - -import java.util.Properties; - -import org.irods.jargon.testutils.TestingPropertiesHelper; -import org.junit.Assert; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.chrome.ChromeDriver; -import org.openqa.selenium.htmlunit.HtmlUnitDriver; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.w3c.css.sac.CSSParseException; - -import com.emc.metalnx.utils.EmcMetalnxVersion; -import com.gargoylesoftware.htmlunit.BrowserVersion; -import com.gargoylesoftware.htmlunit.SilentCssErrorHandler; - -public class UiTestUtilities { - - private static final Logger logger = LoggerFactory.getLogger(UiTestUtilities.class); - private static boolean isDevEnv = EmcMetalnxVersion.BUILD_NUMBER.equals("DEV"); - - // to read properties from testing.properties file - public static Properties testingProperties = new Properties(); - - // Metalnx URL Connection parts - public static final String http = "http://"; - // public static final String HOST = isDevEnv ? "localhost" : - // "metalnx.localdomain"; - public static final String HOST = "localhost"; - public static final String PORT = "8080"; - public static final String URL_PREFIX = http + HOST + ":" + PORT; - - // Data Grid Info - public static String RODS_USERNAME = TestingPropertiesHelper.IRODS_USER_KEY; - public static String RODS_PASSWORD = TestingPropertiesHelper.IRODS_PASSWORD_KEY; - public static String IRODS_ZONE = isDevEnv ? "tempZone" : "testZone"; - public static String IRODS_HOST = isDevEnv ? "icat.localdomain" : "icat.prod.localdomain"; - public static String DEFAULT_RESC = "demoResc"; - public static int IRODS_PORT = 1247; - - // Metalnx pages - public static String LOGIN_URL = URL_PREFIX + "/emc-metalnx-web/login/"; - public static String LOGINERROR_URL = URL_PREFIX + "/emc-metalnx-web/login/exception/"; - public static String DASHBOARD_URL = URL_PREFIX + "/emc-metalnx-web/dashboard/"; - public static String RULES_URL = URL_PREFIX + "/emc-metalnx-web/rules/"; - public static String PREFERENCES_URL = URL_PREFIX + "/emc-metalnx-web/preferences/"; - public static String USERS_URL = URL_PREFIX + "/emc-metalnx-web/users/"; - public static String ADD_USERS_URL = URL_PREFIX + "/emc-metalnx-web/users/add/"; - public static String PROFILES_URL = URL_PREFIX + "/emc-metalnx-web/users/profile/"; - public static String ADD_PROFILES_URL = URL_PREFIX + "/emc-metalnx-web/users/profile/create/"; - public static String GROUPS_URL = URL_PREFIX + "/emc-metalnx-web/groups/"; - public static String ADD_GROUPS_URL = URL_PREFIX + "/emc-metalnx-web/groups/add/"; - public static String MODIFY_GROUPS_URL = URL_PREFIX + "/emc-metalnx-web/groups/modify/"; - public static String RESOURCES_URL = URL_PREFIX + "/emc-metalnx-web/resources/"; - public static String ADD_RESOURCES_URL = URL_PREFIX + "/emc-metalnx-web/resources/add/"; - public static String TEMPLATES_URL = URL_PREFIX + "/emc-metalnx-web/templates/"; - public static String ADD_TEMPLATES_URL = URL_PREFIX + "/emc-metalnx-web/templates/add/"; - public static String METADATA_SEARCH_URL = URL_PREFIX + "/emc-metalnx-web/metadata/"; - public static String COLLECTIONS_URL = URL_PREFIX + "/emc-metalnx-web/collections/"; - public static String TRASH_URL = URL_PREFIX + "/emc-metalnx-web/collections/trash/"; - public static String PUBLIC_URL = URL_PREFIX + "/emc-metalnx-web/collections/public/"; - public static String USER_BOOKMARKS_URL = URL_PREFIX + "/emc-metalnx-web/userBookmarks/"; - public static String GROUP_BOOKMARKS_URL = URL_PREFIX + "/emc-metalnx-web/groupBookmarks/groups/"; - public static String FAVORITES_URL = URL_PREFIX + "/emc-metalnx-web/favorites/"; - public static String TICKETS_URL = URL_PREFIX + "/emc-metalnx-web/tickets/"; - - public static String LOGOUT_URL = URL_PREFIX + "/emc-metalnx-web/logout/"; - public static String RESOURCES_MAP_URL = URL_PREFIX + "/emc-metalnx-web/resources/map/"; - public static String RESOURCES_SERVERS_URL = URL_PREFIX + "/emc-metalnx-web/resources/servers/"; - public static String HTTP_ERROR_500_URL = URL_PREFIX + "/emc-metalnx-web/httpError/500/"; - public static String MY_GROUPS_PAGE = URL_PREFIX + "/emc-metalnx-web/groupBookmarks/groups/"; - - - // metalnx page header locator - public static By dashboardHdrLocator = By.cssSelector(".page-header.pull-left"); - - // metalnx page header text - public static String DASHBOARD_HDR = "Dashboard"; - public static String RESOURCES_HDR = "Resources"; - public static String RULES_HDR = "Rules"; - public static String USERS_HDR = "Users"; - public static String GROUPS_HDR = "Groups"; - public static String PROFILES_HDR = "Profiles"; - public static String COLLECTIONS_HDR = "Collections"; - public static String SEARCH_HDR = "Search"; - public static String TEMPLATES_HDR = "Templates"; - public static String SHARED_LINKS_HDR = "Shared"; - public static String FAVORITES_HDR = "Favorites"; - public static String TICKETS_HDR = "Tickets"; - public static String PUBLIC_HDR = "Collections"; - public static String TRASH_HDR = "Collections"; - - // permission types used in the tests - public static final String READ_PERMISSION = "read"; - public static final String WRITE_PERMISSION = "write"; - public static final String OWN_PERMISSION = "own"; - public static final String NONE_PERMISSION = "none"; - - // user types used in the tests - public static final String RODS_ADMIN_TYPE = "rodsadmin"; - public static final String RODS_USER_TYPE = "rodsuser"; - - private static WebDriver driver = null; - - // driver used for testing - public static final String FIREFOX = "FIREFOX"; - public static final String CHROME = "CHROME"; - - public static String[] TEST_FILE_NAMES = { "1SeleniumTestUserAdditionalPermission.png" }; - - public static String[] TEST_COLLECTION_NAMES = { "SeleniumTestAdditionalPermCol" }; - - public static final String CHROME_DRIVER = "selenium.test.chrome.driver"; - public static final String CHROME_DRIVER_LOCATION = "selenium.test.chrome.driver.loaction"; - - public static void init() throws Exception { - TestingPropertiesHelper testingPropertiesLoader = new TestingPropertiesHelper(); - testingProperties = testingPropertiesLoader.getTestProperties(); - - // driver used for testing - driver = getDriver(); - } - - /** - * Logs the rods user into the UI. - */ - public static void login() { - login(UiTestUtilities.testingProperties.getProperty(TestingPropertiesHelper.IRODS_USER_KEY), UiTestUtilities.testingProperties.getProperty(TestingPropertiesHelper.IRODS_PASSWORD_KEY)); - } - - /** - * Logs in the application using the username and password given as parameters. - * - * @param uname - * username - */ - public static void login(String uname, String pwd) { - logger.info("Logging into Metalnx using " + uname + " and " + pwd); - - if (driver == null) { - Assert.fail("No driver found."); - } - - driver.get(LOGIN_URL); - - new WebDriverWait(driver, 15).until(ExpectedConditions.visibilityOfElementLocated(By.id("inputUsernameLogin"))); - - Assert.assertEquals(LOGIN_URL, driver.getCurrentUrl()); - - WebElement inputUsername = driver.findElement(By.id("inputUsernameLogin")); - WebElement inputPassword = driver.findElement(By.id("inputPasswordLogin")); - WebElement inputSubmit = driver.findElement(By.id("loginBtn")); - - inputUsername.sendKeys(uname); - inputPassword.sendKeys(pwd); - inputSubmit.click(); - } - - public static void logout() { - - logger.info("Logging out of Metalnx"); - if (driver == null) { - return; - } - - getDriver().get(LOGOUT_URL); - //getDriver().get(LOGIN_URL); - //new WebDriverWait(driver, 15).until(ExpectedConditions.visibilityOfElementLocated(By.id("inputUsernameLogin"))); - - } - - public static WebDriver getDriver() { - System.setProperty(testingProperties.getProperty(CHROME_DRIVER), - testingProperties.getProperty(CHROME_DRIVER_LOCATION)); - // return driver == null ? new FirefoxDriver() : driver; - return driver == null ? new ChromeDriver() : driver; - } - - /** - * @param driver - * the driver to set - */ - public static void setDriver(WebDriver driver) { - UiTestUtilities.driver = driver; - } - - // class that removes the amount of logs displayed in the console by validating - // CSS - protected class SilentHtmlUnitDriver extends HtmlUnitDriver { - SilentHtmlUnitDriver() { - super(BrowserVersion.FIREFOX_24); - setJavascriptEnabled(true); - getWebClient().setCssErrorHandler(new SilentCssErrorHandler()); - } - - public void warning(CSSParseException e) { - // no warning logs - } - - public void error(CSSParseException e) { - // no error logs - } - } - - public static String getModifyGroupsPage(String gname) { - return String.format("%s%s/%s/", MODIFY_GROUPS_URL, gname, IRODS_ZONE); - } - - /** - * @return the host - */ - public String getHost() { - return HOST; - } - - /** - * @return the port - */ - public String getPort() { - return PORT; - } - - /** - * @return the loginPage - */ - public String getLoginPage() { - return LOGIN_URL; - } - - /** - * @return the dashboardPage - */ - public String getDashboardPage() { - return DASHBOARD_URL; - } - - /** - * @return the preferencesPage - */ - public String getPreferencesPage() { - return PREFERENCES_URL; - } - - /** - * @return the usersPage - */ - public String getUsersPage() { - return USERS_URL; - } - - /** - * @return the addUsersPage - */ - public String getAddUsersPage() { - return ADD_USERS_URL; - } - - /** - * @return the addProfilesPage - */ - public String getAddProfilesPage() { - return ADD_PROFILES_URL; - } - - /** - * @return the profilesPage - */ - public String getProfilesPage() { - return PROFILES_URL; - } - - /** - * @return the groupsPage - */ - public String getGroupsPage() { - return GROUPS_URL; - } - - /** - * @return the addGroupsPage - */ - public String getAddGroupsPage() { - return ADD_GROUPS_URL; - } - - /** - * @return the resourcesPage - */ - public String getResourcesPage() { - return RESOURCES_URL; - } - - /** - * @return the addResourcesPage - */ - public String getAddResourcesPage() { - return ADD_RESOURCES_URL; - } - - /** - * @return the irodsHost - */ - public String getIrodsHost() { - return IRODS_HOST; - } - - /** - * @return the templatesPage - */ - public String getTemplatesPage() { - return TEMPLATES_URL; - } - - /** - * @return the addTemplatesPage - */ - public String getAddTemplatesPage() { - return ADD_TEMPLATES_URL; - } - - /** - * @return the metadataSearchPage - */ - public String getMetadataSearchPage() { - return METADATA_SEARCH_URL; - } - - /** - * @return the collectionsPage - */ - public String getCollectionsPage() { - return COLLECTIONS_URL; - } - - /** - * @return the userBookmarks - */ - public String getUserBookmarks() { - return USER_BOOKMARKS_URL; - } - - /** - * @return the logout - */ - public String getLogout() { - return LOGOUT_URL; - } - - /** - * @return the zone - */ - public String getZone() { - return IRODS_ZONE; - } -} diff --git a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/testutils/TestConfigurationException.java b/src/emc-metalnx-web/src/test/java/com/emc/metalnx/testutils/TestConfigurationException.java deleted file mode 100644 index 48f795678..000000000 --- a/src/emc-metalnx-web/src/test/java/com/emc/metalnx/testutils/TestConfigurationException.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.emc.metalnx.testutils; - - -public class TestConfigurationException extends Exception { - - /** - * - */ - private static final long serialVersionUID = 2124699560973645080L; - - /** - * - */ - public TestConfigurationException() { - super(); - } - - /** - * @param arg0 - */ - public TestConfigurationException(final String arg0) { - super(arg0); - - } - - /** - * @param arg0 - */ - public TestConfigurationException(final Throwable arg0) { - super(arg0); - - } - - /** - * @param arg0 - * @param arg1 - */ - public TestConfigurationException(final String arg0, final Throwable arg1) { - super(arg0, arg1); - - } - -}