Skip to content

Commit

Permalink
Test: Ignore string check for locales other than english
Browse files Browse the repository at this point in the history
  • Loading branch information
SaptakS committed May 12, 2019
1 parent 6581c62 commit 4714f72
Showing 1 changed file with 17 additions and 95 deletions.
112 changes: 17 additions & 95 deletions securedrop/tests/functional/journalist_navigation_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,49 +444,6 @@ def edit_page_loaded():
assert "/account/reset-2fa-totp" in totp_reset_button.get_attribute("action")
hotp_reset_button = self.driver.find_elements_by_css_selector("#reset-two-factor-hotp")[0]
assert "/account/reset-2fa-hotp" in hotp_reset_button.get_attribute("action")
# 2FA reset buttons show a tooltip with explanatory text on hover.
# Also, confirm the text on the tooltip is the correct one.
totp_reset_button = self.driver.find_elements_by_css_selector(
'#button-reset-two-factor-totp')[0]
ActionChains(self.driver).move_to_element(totp_reset_button).perform()
time.sleep(1)
explanatory_totp_tooltip_opacity = self.driver.execute_script(
'return \
window.getComputedStyle(\
document.querySelector("#button-reset-two-factor-totp"), \
":after"\
).getPropertyValue("opacity")'
)
explanatory_totp_tooltip_content = self.driver.execute_script(
'return \
window.getComputedStyle(\
document.querySelector("#button-reset-two-factor-totp"), \
":after"\
).getPropertyValue("content")'
)
assert explanatory_totp_tooltip_opacity == "1"
assert explanatory_totp_tooltip_content == "attr(tooltip)"

hotp_reset_button = self.driver.find_elements_by_css_selector(
'#button-reset-two-factor-hotp')[0]
ActionChains(self.driver).move_to_element(hotp_reset_button).perform()
time.sleep(1)
explanatory_hotp_tooltip_opacity = self.driver.execute_script(
'return \
window.getComputedStyle(\
document.querySelector("#button-reset-two-factor-hotp"), \
":after"\
).getPropertyValue("opacity")'
)
explanatory_hotp_tooltip_content = self.driver.execute_script(
'return \
window.getComputedStyle(\
document.querySelector("#button-reset-two-factor-hotp"), \
":after"\
).getPropertyValue("content")'
)
assert explanatory_hotp_tooltip_opacity == "1"
assert explanatory_hotp_tooltip_content == "attr(tooltip)"

def _edit_user(self, username, is_admin=False):
self.wait_for(lambda: self.driver.find_element_by_id("users"))
Expand Down Expand Up @@ -740,19 +697,20 @@ def _visit_edit_secret(self, otp_type, tooltip_text=''):
)
assert "/account/reset-2fa-" + otp_type in reset_form.get_attribute("action")
reset_button = self.driver.find_elements_by_css_selector(
'#button-reset-two-factor-' + type)[0]
"#button-reset-two-factor-" + type)[0]

# 2FA reset buttons show a tooltip with explanatory text on hover.
# Also, confirm the text on the tooltip is the correct one.
ActionChains(self.driver).move_to_element(reset_button).perform()
time.sleep(1)
explanatory_tooltip_opacity = self.driver.find_elements_by_css_selector(
'#button-reset-two-factor-' + type + ' span')[0].value_of_css_property('opacity')
"#button-reset-two-factor-" + type + " span")[0].value_of_css_property("opacity")
explanatory_tooltip_content = self.driver.find_elements_by_css_selector(
'#button-reset-two-factor-' + type + ' span')[0].text
"#button-reset-two-factor-" + type + " span")[0].text

assert explanatory_tooltip_opacity == '1'
assert explanatory_tooltip_content == tooltip_text
assert explanatory_tooltip_opacity == "1"
if not hasattr(self, "accept_languages"):
assert explanatory_tooltip_content == tooltip_text
reset_form.submit()

alert = self.driver.switch_to_alert()
Expand Down Expand Up @@ -796,23 +754,23 @@ def _admin_visits_edit_user(self):
self.safe_click_by_css_selector(selector)
self.wait_for(lambda: self.driver.find_element_by_id("new-password"))

<<<<<<< HEAD
def _admin_visits_reset_2fa_hotp(self):
for i in range(3):
try:
# 2FA reset buttons show a tooltip with explanatory text on hover.
# Also, confirm the text on the tooltip is the correct one.
hotp_reset_button = self.driver.find_elements_by_css_selector(
'#button-reset-two-factor-hotp')[0]
"#button-reset-two-factor-hotp")[0]
ActionChains(self.driver).move_to_element(hotp_reset_button).perform()
time.sleep(1)
explanatory_tooltip_opacity = self.driver.find_elements_by_css_selector(
'#button-reset-two-factor-hotp span')[0].value_of_css_property('opacity')
"#button-reset-two-factor-hotp span")[0].value_of_css_property('opacity')
explanatory_tooltip_content = self.driver.find_elements_by_css_selector(
'#button-reset-two-factor-hotp span')[0].text
"#button-reset-two-factor-hotp span")[0].text

assert explanatory_tooltip_opacity == "1"
assert explanatory_tooltip_content == "Reset 2FA for hardware tokens like Yubikey"
if not hasattr(self, "accept_languages"):
assert explanatory_tooltip_content == "Reset 2FA for hardware tokens like Yubikey"
self.safe_click_by_id("button-reset-two-factor-hotp")
self._alert_wait()
self._alert_accept()
Expand All @@ -831,54 +789,18 @@ def _admin_visits_reset_2fa_totp(self):
# 2FA reset buttons show a tooltip with explanatory text on hover.
# Also, confirm the text on the tooltip is the correct one.
totp_reset_button = self.driver.find_elements_by_css_selector(
'#button-reset-two-factor-totp')[0]
"#button-reset-two-factor-totp")[0]
ActionChains(self.driver).move_to_element(totp_reset_button).perform()
time.sleep(1)
explanatory_tooltip_opacity = self.driver.find_elements_by_css_selector(
'#button-reset-two-factor-' + type + ' span')[0].value_of_css_property('opacity')
"#button-reset-two-factor-totp span")[0].value_of_css_property('opacity')
explanatory_tooltip_content = self.driver.find_elements_by_css_selector(
'#button-reset-two-factor-' + type + ' span')[0].text
"#button-reset-two-factor-totp span")[0].text

assert explanatory_tooltip_opacity == '1'
assert explanatory_tooltip_content == 'Reset 2FA for mobile apps such as FreeOTP or Google Authenticator'
assert explanatory_tooltip_opacity == "1"
if not hasattr(self, "accept_languages"):
assert explanatory_tooltip_content == "Reset 2FA for mobile apps such as FreeOTP or Google Authenticator"
totp_reset_button.click()
=======
def _admin_visits_reset_secret(self, type, tooltip_text=''):
reset_form = self.driver.find_elements_by_css_selector(
'#reset-two-factor-' + type)[0]
assert ('/admin/reset-2fa-' + type in
reset_form.get_attribute('action'))

# 2FA reset buttons show a tooltip with explanatory text on hover.
# Also, confirm the text on the tooltip is the correct one.
reset_button = self.driver.find_elements_by_css_selector(
'#button-reset-two-factor-' + type)[0]

ActionChains(self.driver).move_to_element(reset_button).perform()
time.sleep(1)
explanatory_tooltip_opacity = self.driver.find_elements_by_css_selector(
'#button-reset-two-factor-' + type + ' span')[0].value_of_css_property('opacity')
explanatory_tooltip_content = self.driver.find_elements_by_css_selector(
'#button-reset-two-factor-' + type + ' span')[0].text

assert explanatory_tooltip_opacity == '1'
assert explanatory_tooltip_content == tooltip_text
reset_button.click()

def _admin_visits_reset_2fa_hotp(self):
self._admin_visits_reset_secret(
'hotp',
'Reset 2FA for hardware tokens like Yubikey')

def _admin_accepts_2fa_js_alert(self):
self._alert_wait()
self._alert_accept()

def _admin_visits_reset_2fa_totp(self):
self._admin_visits_reset_secret(
'totp',
'Reset 2FA for mobile apps such as FreeOTP or Google Authenticator')
>>>>>>> Tests: Fixes functional tests based on the new tooltip SASS

def _admin_creates_a_user(self, hotp):
self.safe_click_by_id("add-user")
Expand Down

0 comments on commit 4714f72

Please sign in to comment.