Commit 14d61b5f authored by Georges Racinet's avatar Georges Racinet 🦑
Browse files

Production Server tests: supporting Clever Cloud SSO

This gives us post-install tests capability for heptapod.host.
parent c5b7d3f57360
Pipeline #20060 passed with stages
in 23 minutes and 14 seconds
...@@ -192,6 +192,10 @@ Example: ...@@ -192,6 +192,10 @@ Example:
where ID is the numeric user id, and USERNAME is the user login name where ID is the numeric user id, and USERNAME is the user login name
(e.g `testfonct`). (e.g `testfonct`).
To launch tests on an instance tied to the Clever Cloud SSO,
use additionally the `--heptapod-clever-cloud-sso` option.
Remarks and safety: Remarks and safety:
- The user password must be fully operational: the functional tests won't - The user password must be fully operational: the functional tests won't
......
...@@ -45,6 +45,9 @@ def pytest_addoption(parser): ...@@ -45,6 +45,9 @@ def pytest_addoption(parser):
parser.addoption('--heptapod-omnibus', action="store_true", parser.addoption('--heptapod-omnibus', action="store_true",
help="Test a Heptapod Omnibus by running the tests " help="Test a Heptapod Omnibus by running the tests "
"as root on the same system ") "as root on the same system ")
parser.addoption('--heptapod-clever-cloud-sso', action='store_true',
help="Use Clever Cloud SSO for all authentications.")
parser.addoption('--heptapod-prod-server', action='store_true', parser.addoption('--heptapod-prod-server', action='store_true',
help="Run only those tests that are suitable " help="Run only those tests that are suitable "
"for a production installation, with precreated " "for a production installation, with precreated "
...@@ -224,6 +227,7 @@ def heptapod(pytestconfig): ...@@ -224,6 +227,7 @@ def heptapod(pytestconfig):
'heptapod_webdriver_remote_url'), 'heptapod_webdriver_remote_url'),
wait_after_first_response=pytestconfig.getoption( wait_after_first_response=pytestconfig.getoption(
'heptapod_wait_after_first_response'), 'heptapod_wait_after_first_response'),
clever_cloud_sso=pytestconfig.getoption('heptapod_clever_cloud_sso'),
hg_native=pytestconfig.getoption('heptapod_hg_native') hg_native=pytestconfig.getoption('heptapod_hg_native')
) )
......
...@@ -67,6 +67,10 @@ class Heptapod: ...@@ -67,6 +67,10 @@ class Heptapod:
chrome_driver_args = () chrome_driver_args = ()
clever_cloud_sso = False
"""If ``True``, authentications will got through the Clever Cloud SSO.
"""
default_user_name = 'root' default_user_name = 'root'
"""Default user for project, group creation etc.""" """Default user for project, group creation etc."""
...@@ -86,6 +90,7 @@ class Heptapod: ...@@ -86,6 +90,7 @@ class Heptapod:
def __init__(self, url, ssh_user, ssh_port, def __init__(self, url, ssh_user, ssh_port,
hg_native=False, hg_native=False,
clever_cloud_sso=False,
reverse_call_host=None, reverse_call_host=None,
wait_after_first_response=0, wait_after_first_response=0,
webdriver_remote_url=None): webdriver_remote_url=None):
...@@ -94,6 +99,7 @@ class Heptapod: ...@@ -94,6 +99,7 @@ class Heptapod:
self.ssh_port = ssh_port self.ssh_port = ssh_port
self.ssh_user = ssh_user self.ssh_user = ssh_user
self.hg_native = hg_native self.hg_native = hg_native
self.clever_cloud_sso = clever_cloud_sso
self.users = {} self.users = {}
if reverse_call_host is not None: if reverse_call_host is not None:
self.reverse_call_host = reverse_call_host self.reverse_call_host = reverse_call_host
......
...@@ -2,7 +2,10 @@ import logging ...@@ -2,7 +2,10 @@ import logging
from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.keys import Keys
import time import time
from .selenium import webdriver_wait_get from .selenium import (
wait_could_click_element,
webdriver_wait_get,
)
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
...@@ -45,6 +48,9 @@ def sign_in_page_login(driver, heptapod, user_name, password=None): ...@@ -45,6 +48,9 @@ def sign_in_page_login(driver, heptapod, user_name, password=None):
password = user.password password = user.password
else: else:
user.password = password user.password = password
if heptapod.clever_cloud_sso:
user.vcs_token_only = True
return sign_in_page_clever_cloud_login(driver, user)
elem = driver.find_element_by_name('user[login]') elem = driver.find_element_by_name('user[login]')
elem.send_keys(user_name) elem.send_keys(user_name)
...@@ -53,6 +59,21 @@ def sign_in_page_login(driver, heptapod, user_name, password=None): ...@@ -53,6 +59,21 @@ def sign_in_page_login(driver, heptapod, user_name, password=None):
elem.send_keys(Keys.RETURN) elem.send_keys(Keys.RETURN)
def sign_in_page_clever_cloud_login(driver, user):
wait_could_click_element(
driver,
lambda d: d.find_element_by_id('oauth-login-saml'))
assert 'clever-cloud.com' in driver.current_url
elem = driver.find_element_by_id('login-email')
elem.send_keys(user.email)
elem = driver.find_element_by_id('login-pwd')
elem.send_keys(user.password)
elem.send_keys(Keys.RETURN)
assert driver.current_url.startswith(user.heptapod.url)
def page_is_password_setup(driver): def page_is_password_setup(driver):
"""Return if the current page is the password setup page. """Return if the current page is the password setup page.
......
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