From 8c30410f9eb40f3f65c8cb5ec4572b61d919b965 Mon Sep 17 00:00:00 2001 From: Juan David Mendez Solano Date: Fri, 13 Mar 2020 14:07:36 +0100 Subject: [PATCH 1/5] Tests for the change password webpage --- lib/galaxy/selenium/navigation.yml | 5 + .../selenium/test_change_password.py | 91 +++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 lib/galaxy_test/selenium/test_change_password.py diff --git a/lib/galaxy/selenium/navigation.yml b/lib/galaxy/selenium/navigation.yml index c6160ba379d..b9a6d0ccdae 100644 --- a/lib/galaxy/selenium/navigation.yml +++ b/lib/galaxy/selenium/navigation.yml @@ -70,6 +70,7 @@ masthead: preferences: selectors: + change_password: "#edit-preferences-password" manage_information: '#edit-preferences-information' current_email: "#user-preferences-current-email" @@ -77,6 +78,10 @@ change_user_email: selectors: submit: '#submit' +change_user_password: + selectors: + submit: '#submit' + change_user_address: selectors: address_button: diff --git a/lib/galaxy_test/selenium/test_change_password.py b/lib/galaxy_test/selenium/test_change_password.py new file mode 100644 index 00000000000..759ae672292 --- /dev/null +++ b/lib/galaxy_test/selenium/test_change_password.py @@ -0,0 +1,91 @@ +import time +from .framework import ( + selenium_test, + SeleniumTestCase +) + +class ChangePasswordTestCase(SeleniumTestCase): + @selenium_test + def test_change_password(self): + self.home() + email = self._get_random_email() + password = self.default_password + confirm = password + username = email.split("@")[0] + self.register(email, password, username, confirm) + self.navigate_to_password() + self.fill_input_fields(password, "123123", "123123") + self.logout_if_needed() + self.submit_login(email, "123123") + + @selenium_test + def test_new_password_password(self): + self.home() + email = self._get_random_email() + password = self.default_password + confirm = password + username = email.split("@")[0] + self.register(email, password, username, confirm) + self.navigate_to_password() + self.fill_input_fields(password, "", "123123") + self.assert_error_message(contains='Please provide a new password.') + + @selenium_test + def test_no_password_confirmation(self): + self.home() + email = self._get_random_email() + password = self.default_password + confirm = password + username = email.split("@")[0] + self.register(email, password, username, confirm) + self.navigate_to_password() + self.fill_input_fields(password, "123123", "") + self.assert_error_message(contains='Passwords do not match.') + + @selenium_test + def test_currect_password_incorrect(self): + self.home() + email = self._get_random_email() + password = self.default_password + confirm = password + username = email.split("@")[0] + self.register(email, password, username, confirm) + self.navigate_to_password() + time.sleep(5) + self.fill_input_fields("4444444", "123123", "123123") + self.assert_error_message(contains='Invalid current password.') + + @selenium_test + def test_new_password_short(self): + self.home() + email = self._get_random_email() + password = self.default_password + confirm = password + username = email.split("@")[0] + self.register(email, password, username, confirm) + self.navigate_to_password() + self.fill_input_fields(password, "123", "123") + self.assert_error_message(contains='Use a password of at least 6 characters.') + + @selenium_test + def test_new_password_same_password(self): + self.home() + email = self._get_random_email() + password = self.default_password + confirm = password + username = email.split("@")[0] + self.register(email, password, username, confirm) + self.navigate_to_password() + self.fill_input_fields(password, password, password) + + def navigate_to_password(self): + self.click_masthead_user() + self.components.masthead.preferences.wait_for_and_click() + self.components.preferences.change_password.wait_for_and_click() + + def fill_input_fields(self, password, new_password, password_confirm): + self.sleep_for(self.wait_types.UX_TRANSITION) + self.driver.find_element_by_id('field-uid-5').send_keys(password) + self.driver.find_element_by_id('field-uid-6').send_keys(new_password) + self.driver.find_element_by_id('field-uid-7').send_keys(password_confirm) + self.components.change_user_password.submit.wait_for_and_click() \ No newline at end of file From 766bd0fcc1451587633067354ea1e5631e43c091 Mon Sep 17 00:00:00 2001 From: Juan David Mendez Solano Date: Fri, 13 Mar 2020 14:46:15 +0100 Subject: [PATCH 2/5] Change to use tour_id instead of id --- lib/galaxy_test/selenium/test_change_password.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/galaxy_test/selenium/test_change_password.py b/lib/galaxy_test/selenium/test_change_password.py index 759ae672292..39b6751a267 100644 --- a/lib/galaxy_test/selenium/test_change_password.py +++ b/lib/galaxy_test/selenium/test_change_password.py @@ -83,9 +83,9 @@ class ChangePasswordTestCase(SeleniumTestCase): self.components.masthead.preferences.wait_for_and_click() self.components.preferences.change_password.wait_for_and_click() - def fill_input_fields(self, password, new_password, password_confirm): + def fill_input_fields(self, current, password, confirm): self.sleep_for(self.wait_types.UX_TRANSITION) - self.driver.find_element_by_id('field-uid-5').send_keys(password) - self.driver.find_element_by_id('field-uid-6').send_keys(new_password) - self.driver.find_element_by_id('field-uid-7').send_keys(password_confirm) + self.driver.find_element_by_css_selector("[tour_id='current'] input").send_keys(current) + self.driver.find_element_by_css_selector("[tour_id='password'] input").send_keys(password) + self.driver.find_element_by_css_selector("[tour_id='confirm'] input").send_keys(confirm) self.components.change_user_password.submit.wait_for_and_click() \ No newline at end of file From 4bcaf8a0110403e7a92c52929f7fd9fb59b84692 Mon Sep 17 00:00:00 2001 From: Juan David Mendez Solano Date: Fri, 13 Mar 2020 14:55:16 +0100 Subject: [PATCH 3/5] Remove one unneeded import --- lib/galaxy_test/selenium/test_change_password.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/galaxy_test/selenium/test_change_password.py b/lib/galaxy_test/selenium/test_change_password.py index 39b6751a267..e7ba3bc4020 100644 --- a/lib/galaxy_test/selenium/test_change_password.py +++ b/lib/galaxy_test/selenium/test_change_password.py @@ -1,4 +1,3 @@ -import time from .framework import ( selenium_test, SeleniumTestCase @@ -51,7 +50,6 @@ class ChangePasswordTestCase(SeleniumTestCase): username = email.split("@")[0] self.register(email, password, username, confirm) self.navigate_to_password() - time.sleep(5) self.fill_input_fields("4444444", "123123", "123123") self.assert_error_message(contains='Invalid current password.') From 4b1b7b62b24d540d32c046be4afa67de977bcc25 Mon Sep 17 00:00:00 2001 From: Juan David Mendez Solano Date: Fri, 13 Mar 2020 15:29:12 +0100 Subject: [PATCH 4/5] Fix lint rules violations --- lib/galaxy_test/selenium/test_change_password.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/galaxy_test/selenium/test_change_password.py b/lib/galaxy_test/selenium/test_change_password.py index e7ba3bc4020..a51adb555a0 100644 --- a/lib/galaxy_test/selenium/test_change_password.py +++ b/lib/galaxy_test/selenium/test_change_password.py @@ -3,6 +3,7 @@ from .framework import ( SeleniumTestCase ) + class ChangePasswordTestCase(SeleniumTestCase): @selenium_test def test_change_password(self): @@ -13,7 +14,7 @@ class ChangePasswordTestCase(SeleniumTestCase): username = email.split("@")[0] self.register(email, password, username, confirm) self.navigate_to_password() - self.fill_input_fields(password, "123123", "123123") + self.fill_input_fields(password, "123123", "123123") self.logout_if_needed() self.submit_login(email, "123123") @@ -86,4 +87,4 @@ class ChangePasswordTestCase(SeleniumTestCase): self.driver.find_element_by_css_selector("[tour_id='current'] input").send_keys(current) self.driver.find_element_by_css_selector("[tour_id='password'] input").send_keys(password) self.driver.find_element_by_css_selector("[tour_id='confirm'] input").send_keys(confirm) - self.components.change_user_password.submit.wait_for_and_click() \ No newline at end of file + self.components.change_user_password.submit.wait_for_and_click() From 40be7e409959d4317643c33142e33e62e0e39387 Mon Sep 17 00:00:00 2001 From: Juan David Mendez Solano Date: Fri, 13 Mar 2020 17:30:09 +0100 Subject: [PATCH 5/5] Condense the code --- .../selenium/test_change_password.py | 60 +++++-------------- 1 file changed, 16 insertions(+), 44 deletions(-) diff --git a/lib/galaxy_test/selenium/test_change_password.py b/lib/galaxy_test/selenium/test_change_password.py index a51adb555a0..f088b992b6e 100644 --- a/lib/galaxy_test/selenium/test_change_password.py +++ b/lib/galaxy_test/selenium/test_change_password.py @@ -9,75 +9,47 @@ class ChangePasswordTestCase(SeleniumTestCase): def test_change_password(self): self.home() email = self._get_random_email() - password = self.default_password - confirm = password - username = email.split("@")[0] - self.register(email, password, username, confirm) - self.navigate_to_password() - self.fill_input_fields(password, "123123", "123123") + self.register(email) + self.click_masthead_user() + self.components.masthead.preferences.wait_for_and_click() + self.components.preferences.change_password.wait_for_and_click() + self.fill_input_fields(self.default_password, "123123", "123123") self.logout_if_needed() self.submit_login(email, "123123") @selenium_test def test_new_password_password(self): - self.home() - email = self._get_random_email() - password = self.default_password - confirm = password - username = email.split("@")[0] - self.register(email, password, username, confirm) - self.navigate_to_password() - self.fill_input_fields(password, "", "123123") + self.register_and_change_password() + self.fill_input_fields(self.default_password, "", "123123") self.assert_error_message(contains='Please provide a new password.') @selenium_test def test_no_password_confirmation(self): - self.home() - email = self._get_random_email() - password = self.default_password - confirm = password - username = email.split("@")[0] - self.register(email, password, username, confirm) - self.navigate_to_password() - self.fill_input_fields(password, "123123", "") + self.register_and_change_password() + self.fill_input_fields(self.default_password, "123123", "5444484") self.assert_error_message(contains='Passwords do not match.') @selenium_test def test_currect_password_incorrect(self): - self.home() - email = self._get_random_email() - password = self.default_password - confirm = password - username = email.split("@")[0] - self.register(email, password, username, confirm) - self.navigate_to_password() + self.register_and_change_password() self.fill_input_fields("4444444", "123123", "123123") self.assert_error_message(contains='Invalid current password.') @selenium_test def test_new_password_short(self): - self.home() - email = self._get_random_email() - password = self.default_password - confirm = password - username = email.split("@")[0] - self.register(email, password, username, confirm) - self.navigate_to_password() - self.fill_input_fields(password, "123", "123") + self.register_and_change_password() + self.fill_input_fields(self.default_password, "123", "123") self.assert_error_message(contains='Use a password of at least 6 characters.') @selenium_test def test_new_password_same_password(self): - self.home() - email = self._get_random_email() + self.register_and_change_password() password = self.default_password - confirm = password - username = email.split("@")[0] - self.register(email, password, username, confirm) - self.navigate_to_password() self.fill_input_fields(password, password, password) - def navigate_to_password(self): + def register_and_change_password(self): + self.home() + self.register() self.click_masthead_user() self.components.masthead.preferences.wait_for_and_click() self.components.preferences.change_password.wait_for_and_click()