Commit 69a439745c8 by Georges Racinet

Configurable root password, same default as GDK

Having the same default as the GDK will be convenient in the future.
parent 164f6623919
Pipeline #2143 passed with stage
in 14 seconds
......@@ -23,8 +23,8 @@ instance
if you want to change these defaults).
- The tests will issue `docker exec` commands, HTTP requests and SSH
connections.
- The Gitlab root password will be initialized by the test and is not currently
customizable. The tests will fail if the Gitlab root password is already set
- The Gitlab root password will be initialized by the first test to run.
The tests will fail if the Gitlab root password is already set
and does not match the expected one.
## Running the tests
......@@ -55,7 +55,9 @@ Here are the custom options for these tests:
address, such as `127.0.0.2`, to minimize risks with your SSH
`known_hosts` file.
- `--heptapod-container-name` (default `heptapod`)
- `--heptapod-root-password` (default `5iveL!fe`). The password to use and maybe
set for the `root` user. The default value is the same as with the GitLab
Development Kit (GDK).
### Choosing the version to test
......
......@@ -32,6 +32,7 @@ def pytest_addoption(parser):
parser.addoption('--heptapod-url', default='http://heptapod:81')
parser.addoption('--heptapod-ssh-port', type=int, default=2022)
parser.addoption('--heptapod-docker-container', default='heptapod')
parser.addoption('--heptapod-root-password', default='5iveL!fe')
@attr.s
......@@ -72,7 +73,7 @@ class Heptapod(object):
def basic_user_token_headers(self):
return {'Private-Token': self.users['test_basic']['token']}
def prepare(self):
def prepare(self, root_password):
"""Make all preparations for the Heptapod instance to be testable.
This currently amounts to
......@@ -116,7 +117,7 @@ class Heptapod(object):
driver = selenium.webdriver.Chrome(options=options)
# guaranteeing driver to be available for teardown as soon as created
root['webdriver'] = driver
session.login_as_root(driver, self)
session.login_as_root(driver, self, root_password)
self.set_application_settings(
default_branch_protection=BRANCH_PROTECTIONS['none'])
basic, driver = session.ensure_user(self, 'test_basic',
......@@ -196,7 +197,7 @@ def heptapod(pytestconfig):
docker_container=pytestconfig.getoption('heptapod_docker_container')
)
try:
heptapod.prepare()
heptapod.prepare(pytestconfig.getoption('heptapod_root_password'))
yield heptapod
finally:
heptapod.close()
......
......@@ -4,18 +4,16 @@ from selenium.webdriver.common.keys import Keys
from .selenium import webdriver_wait_get
from .user import default_password, User
ROOT_PASSWORD = 'p4s5w0rd'
def initialize_root(driver, heptapod):
def initialize_root(driver, heptapod, password):
# Create initial password
elem = driver.find_element_by_name('user[password]')
elem.send_keys(ROOT_PASSWORD)
elem.send_keys(password)
elem = driver.find_element_by_name('user[password_confirmation]')
elem.send_keys(ROOT_PASSWORD)
elem.send_keys(password)
elem.send_keys(Keys.RETURN)
sign_in_page_login(driver, heptapod, 'root', password=ROOT_PASSWORD)
sign_in_page_login(driver, heptapod, 'root', password=password)
generate_private_token(driver, heptapod, 'root')
......@@ -60,15 +58,15 @@ def sign_in_page_login(driver, heptapod, user, password=None):
elem.send_keys(Keys.RETURN)
def login_as_root(driver, heptapod):
def login_as_root(driver, heptapod, password):
webdriver_wait_get(heptapod, driver)
assert 'GitLab' in driver.title
html = driver.find_element_by_tag_name('html').get_attribute('innerHTML')
if 'Please create a password for your new account.' in html:
return initialize_root(driver, heptapod)
return initialize_root(driver, heptapod, password)
sign_in_page_login(driver, heptapod, 'root', password=ROOT_PASSWORD)
sign_in_page_login(driver, heptapod, 'root', password)
generate_private_token(driver, heptapod, 'root')
......
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