Commit 4d5d5407 authored by Georges Racinet's avatar Georges Racinet 🦑
Browse files

Confirm root password if only initial value is set

Recent HDK installations have a tendency to prepare the password,
but not to confirm them so that heptapod-tests get stuck at the
final password setting page after initial login.

Closes #16
parent 24b45f7436f3
Pipeline #15939 passed with stages
in 40 minutes and 17 seconds
......@@ -20,6 +20,21 @@ def initialize_root(driver, heptapod, password):
sign_in_page_login(driver, heptapod, 'root', password=password)
def finalize_password(driver, heptapod, user, password, current_password=None):
"""Enter the final password, if already on the "Set up new password" page.
if current_password is None:
current_password = password
elem = driver.find_element_by_name('user[current_password]')
elem = driver.find_element_by_name('user[password]')
elem = driver.find_element_by_name('user[password_confirmation]')
def sign_in_page_login(driver, heptapod, user, password=None):
"""Perform login as user, with webdriver already on the signin page.
......@@ -37,6 +52,16 @@ def sign_in_page_login(driver, heptapod, user, password=None):
def page_is_password_setup(driver):
"""Return if the current page is the password setup page.
This happens for instance after first login with a password considered
to be temporary
# plural form to get an empty list instead of an exception
return bool(driver.find_elements_by_name('user[password_confirmation]'))
def login_as_root(driver, heptapod, password):
start = time.time()
webdriver_wait_get(heptapod, driver, relative_uri='/users/sign_in')
......@@ -47,6 +72,9 @@ def login_as_root(driver, heptapod, password):
initialize_root(driver, heptapod, password)
sign_in_page_login(driver, heptapod, 'root', password)
if page_is_password_setup(driver):
finalize_password(driver, heptapod, 'root', password)
sign_in_page_login(driver, heptapod, 'root', password)"Made signed-in webdriver for user %r in %.2f seconds",
'root', time.time() - start)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment