From a998a20d91da0d89a4a31c0ef5764204d2cd3ffa Mon Sep 17 00:00:00 2001 From: Eric Turgeon <4249848+ericbsd@users.noreply.github.com> Date: Mon, 6 Nov 2023 12:06:45 -0400 Subject: [PATCH] TE-1232 / 13.0-U6 / Removed 2FA UI test since API call are not supported without API key. (#9151) * Removed 2FA UI test since API call are not supported without API key. * Changed BOX and Google could test to avoid common point of failures --- tests/bdd/core/test_NAS_T1128.py | 5 +- tests/bdd/core/test_NAS_T1141.py | 2 +- tests/bdd/ha-bhyve02/test_NAS_T1073.py | 155 ------------------------- tests/bdd/xpaths.py | 5 + 4 files changed, 9 insertions(+), 158 deletions(-) delete mode 100644 tests/bdd/ha-bhyve02/test_NAS_T1073.py diff --git a/tests/bdd/core/test_NAS_T1128.py b/tests/bdd/core/test_NAS_T1128.py index ae66eb179a0..9172b887f52 100644 --- a/tests/bdd/core/test_NAS_T1128.py +++ b/tests/bdd/core/test_NAS_T1128.py @@ -99,8 +99,9 @@ def click_proceed_then_enter_the_login_user_name_and_password(driver, user_name, @then('click Authorize and then click Grant Access to Box') def click_authorize_and_then_click_grant_access_to_box(driver): """click Authorize and then click Grant Access to Box.""" - assert wait_on_element(driver, 5, '//button[@id="consent_accept_button"]', 'clickable') - driver.find_element_by_xpath('//button[@id="consent_accept_button"]').click() + assert wait_on_element(driver, 5, xpaths.authorization.box_Auth_Message) + assert wait_on_element(driver, 5, xpaths.authorization.Grant_Access_To_Box_Button, 'clickable') + driver.find_element_by_xpath(xpaths.authorization.Grant_Access_To_Box_Button).click() assert rsc.wait_For_The_Tab_To_Close(driver) is True driver.switch_to.window(driver.window_handles[0]) diff --git a/tests/bdd/core/test_NAS_T1141.py b/tests/bdd/core/test_NAS_T1141.py index b4086f44b64..743a258950b 100644 --- a/tests/bdd/core/test_NAS_T1141.py +++ b/tests/bdd/core/test_NAS_T1141.py @@ -278,9 +278,9 @@ def click_on_folder1_then_click_on_the_test_folder(driver, folder1): action = ActionChains(driver) action.double_click(driver.find_element_by_xpath(f'//div[@data-tooltip="Google Drive Folder: {folder1}"]')).perform() assert wait_on_element(driver, 7, f'//div[@data-tooltip="{folder1}" and @role="button"]') - time.sleep(1) assert wait_on_element(driver, 7, '//div[@data-tooltip="Google Drive Folder: initial"]', 'clickable') assert wait_on_element(driver, 5, '//div[@data-tooltip="Google Drive Folder: test"]', 'clickable') + time.sleep(1) action = ActionChains(driver) action.double_click(driver.find_element_by_xpath('//div[@data-tooltip="Google Drive Folder: test"]')).perform() time.sleep(1) diff --git a/tests/bdd/ha-bhyve02/test_NAS_T1073.py b/tests/bdd/ha-bhyve02/test_NAS_T1073.py deleted file mode 100644 index c469c91fc63..00000000000 --- a/tests/bdd/ha-bhyve02/test_NAS_T1073.py +++ /dev/null @@ -1,155 +0,0 @@ -# coding=utf-8 -"""Enterprise HA UI feature tests.""" - -import reusableSeleniumCode as rsc -import xpaths -import time -from function import ( - wait_on_element, - is_element_present, - attribute_value_exist, - wait_on_element_disappear, - put - -) -from pytest_bdd import ( - given, - scenario, - then, - when, - parsers -) - - -@scenario('features/NAS-T1073.feature', 'Verify 2FA Login after Failover') -def test_verify_2fa_login_after_failover(): - """Verify 2FA Login after Failover.""" - - -@given(parsers.parse('the browser is open, navigate to "{nas_host}"')) -def the_browser_is_open_navigate_to_tnbhyve03tnixsystemsnet(driver, nas_host): - """the browser is open, navigate to "{nas_host}".""" - global hostname - hostname = nas_host - if nas_host not in driver.current_url: - driver.get(f"http://{nas_host}") - time.sleep(2) - - -@when(parsers.parse('if the login page appears, enter "{user}" and "{password}"')) -def if_the_login_page_appears_enter_user_and_password(driver, user, password): - """if the login page appears, enter "{user}" and "{password}".""" - global passwd - passwd = password - if not is_element_present(driver, '//mat-list-item[@ix-auto="option__Dashboard"]'): - assert wait_on_element(driver, 5, xpaths.login.user_input) - driver.find_element_by_xpath(xpaths.login.user_input).clear() - driver.find_element_by_xpath(xpaths.login.user_input).send_keys(user) - driver.find_element_by_xpath(xpaths.login.password_input).clear() - driver.find_element_by_xpath(xpaths.login.password_input).send_keys(password) - assert wait_on_element(driver, 5, xpaths.login.signin_button) - driver.find_element_by_xpath(xpaths.login.signin_button).click() - else: - assert wait_on_element(driver, 5, '//mat-list-item[@ix-auto="option__Dashboard"]', 'clickable') - driver.find_element_by_xpath('//mat-list-item[@ix-auto="option__Dashboard"]').click() - - -@then('on the dashboard, click on Systems on the side menu, and click on 2FA') -def on_the_dashboard_click_on_systems_on_the_side_menu_and_click_on_2fa(driver): - """on the dashboard, click on Systems on the side menu, and click on 2FA.""" - assert wait_on_element(driver, 5, '//mat-list-item[@ix-auto="option__System"]', 'clickable') - driver.find_element_by_xpath('//mat-list-item[@ix-auto="option__System"]').click() - assert wait_on_element(driver, 5, '//mat-list-item[@ix-auto="option__Reporting"]', 'clickable') - driver.find_element_by_xpath('//mat-list-item[@ix-auto="option__2FA"]').click() - - -@then('on the Two-Factor Auth page, ensure Enable 2-Factor Auth for SSH checkbox is unset') -def on_the_twofactor_auth_page_ensure_enable_2factor_auth_for_ssh_checkbox_is_unset(driver): - """on the Two-Factor Auth page, ensure Enable 2-Factor Auth for SSH checkbox is unset.""" - assert wait_on_element(driver, 5, '//li[contains(.,"Two-Factor Auth")]') - assert wait_on_element(driver, 5, '//mat-checkbox[@ix-auto="checkbox__Enable Two-Factor Auth for SSH"]', 'clickable') - # if Two-Factor Auth for SSH in enable disable - value_exist = attribute_value_exist(driver, '//mat-checkbox[@ix-auto="checkbox__Enable Two-Factor Auth for SSH"]', 'class', 'mat-checkbox-checked') - if value_exist: - driver.find_element_by_xpath('//mat-checkbox[@ix-auto="checkbox__Enable Two-Factor Auth for SSH"]').click() - - -@then('click on Enable Two-Factor Authentication button then confirm') -def click_on_enable_twofactor_authentication_button_then_confirm(driver): - """click on Enable Two-Factor Authentication button then confirm.""" - assert wait_on_element(driver, 5, '//button[@ix-auto="button__ENABLE TWO-FACTOR AUTHENTICATION"]', 'clickable') - driver.find_element_by_xpath('//button[@ix-auto="button__ENABLE TWO-FACTOR AUTHENTICATION"]').click() - assert wait_on_element(driver, 5, '//h1[contains(.,"Enable Two-Factor Authentication")]') - assert wait_on_element(driver, 5, '//button[@ix-auto="button__CONFIRM"]', 'clickable') - driver.find_element_by_xpath('//button[@ix-auto="button__CONFIRM"]').click() - - -@then('when Two-factor Authentication is enabled, logout') -def when_twofactor_authentication_is_enabled_logout(driver): - """when Two-factor Authentication is enabled, logout.""" - assert wait_on_element_disappear(driver, 20, xpaths.popup.please_wait) - assert wait_on_element(driver, 5, '//p[contains(.,"Two-factor authentication IS currently enabled")]') - assert wait_on_element(driver, 5, '//button[@ix-auto="button__power"]', 'clickable') - driver.find_element_by_xpath('//button[@ix-auto="button__power"]').click() - assert wait_on_element(driver, 5, '//button[@ix-auto="option__Log Out"]', 'clickable') - driver.find_element_by_xpath('//button[@ix-auto="option__Log Out"]').click() - assert wait_on_element(driver, 5, xpaths.login.user_input) - assert wait_on_element(driver, 60, xpaths.login.ha_status('HA is enabled')) - - -@then('verify the Two-Factor Authentication code entry is visible') -def verify_the_twofactor_authentication_code_entry_is_visible(driver): - """verify the Two-Factor Authentication code entry is visible.""" - # refresh before verifying Two-Factor Authentication is there - driver.refresh() - assert wait_on_element(driver, 10, '//input[@placeholder="Two-Factor Authentication Code"]') - - -@then('disable Two-Factor Authentication with API and login') -def disable_twofactor_authentication_with_api_and_login(driver): - """disable Two-Factor Authentication with API and login.""" - results = put(hostname, 'auth/twofactor/', ('root', passwd), {"enabled": False}) - assert results.status_code == 200, results.text - driver.refresh() - time.sleep(2) - assert wait_on_element(driver, 7, xpaths.login.user_input) - driver.find_element_by_xpath(xpaths.login.user_input).clear() - driver.find_element_by_xpath(xpaths.login.user_input).send_keys('root') - driver.find_element_by_xpath(xpaths.login.password_input).clear() - driver.find_element_by_xpath(xpaths.login.password_input).send_keys(passwd) - assert wait_on_element(driver, 5, xpaths.login.signin_button) - driver.find_element_by_xpath(xpaths.login.signin_button).click() - - if wait_on_element(driver, 7, xpaths.button.i_Agree, 'clickable'): - driver.find_element_by_xpath(xpaths.button.i_Agree).click() - - -@then('enable Two-Factor Authentication with API') -def enable_twofactor_authentication_with_api(driver): - """enable Two-Factor Authentication with API.""" - results = put(hostname, 'auth/twofactor/', ('root', passwd), {"enabled": True}) - assert results.status_code == 200, results.text - - -@then('on the dashboard, click on failover INITIATE FAILOVER') -def on_the_dashboard_click_on_failover_initiate_failover(driver): - """on the dashboard, click on failover INITIATE FAILOVER.""" - # scroll up the side menu - element = driver.find_element_by_xpath('//span[contains(.,"root")]') - driver.execute_script("arguments[0].scrollIntoView();", element) - assert wait_on_element(driver, 5, '//mat-list-item[@ix-auto="option__Dashboard"]', 'clickable') - driver.find_element_by_xpath('//mat-list-item[@ix-auto="option__Dashboard"]').click() - assert wait_on_element(driver, 60, xpaths.button.initiate_failover, 'clickable') - driver.find_element_by_xpath(xpaths.button.initiate_failover).click() - assert wait_on_element(driver, 5, xpaths.popup.initiate_failover) - driver.find_element_by_xpath(xpaths.checkbox.confirm).click() - assert wait_on_element(driver, 5, xpaths.button.failover) - driver.find_element_by_xpath(xpaths.button.failover).click() - - -@then('wait on the login to appear') -def wait_on_the_login_to_appear(driver): - """wait on the login to appear.""" - assert wait_on_element(driver, 120, xpaths.login.user_input) - # wait_on_element need to be replace with wait_on_element when NAS-118299 - assert wait_on_element(driver, 120, xpaths.login.ha_status('HA is enabled')) diff --git a/tests/bdd/xpaths.py b/tests/bdd/xpaths.py index db742da6396..591f03dba90 100644 --- a/tests/bdd/xpaths.py +++ b/tests/bdd/xpaths.py @@ -3,6 +3,11 @@ class add_Dataset: unencrypted_Error_Message = '//mat-error[contains(.,"Cannot create an unencrypted dataset within an encrypted dataset (encrypted)")]' +class authorization: + box_Auth_Message = '//*[contains(text(),"Read and write all files and folders stored in Box")]' + Grant_Access_To_Box_Button = '//button[@id="consent_accept_button"]' + + class breadcrumb: dashboard = '//a[text()="Dashboard"]'