Commit 73b81b64 authored by Georges Racinet's avatar Georges Racinet 🦑
Browse files

Heptapod 0.19 is the new stable

Merged default branch into stable and fixed CI image

--HG--
branch : stable
Pipeline #17862 passed with stages
in 21 minutes and 51 seconds
variables:
TARGET_HEPTAPOD_IMAGE: "0-18-testing"
TARGET_HEPTAPOD_IMAGE: "0-19-testing"
HEPTAPOD_BASE_IMAGE: registry.heptapod.net/heptapod/omnibus-heptapod
stages:
......
......@@ -6,6 +6,8 @@ from .utils import (
from .utils.group import Group
from .utils.project import Project
from .test_push import prepare_simple_repo
parametrize = pytest.mark.parametrize
......@@ -64,6 +66,20 @@ def test_group_project(heptapod, hashed_storage):
group.api_delete()
def test_group_project_push(heptapod, tmpdir):
with Group.api_create(heptapod, unique_name('test_group'),
user_name='test_basic') as group:
with Project.api_create(heptapod,
project_name='test_proj',
user_name='test_basic',
group=group) as project:
prepare_simple_repo(project, tmpdir / 'repo')
assert project.api_branch_titles() == {
'branch/default': 'Commit 0',
'topic/default/zetop': 'Commit 1',
}
@needs.services
@parametrize('hashed_storage', [True, False])
def test_subgroups(heptapod, hashed_storage):
......
......@@ -582,6 +582,65 @@ def test_mergerequest_api_fast_forward_required(test_project, tmpdir):
assert log.splitlines() == ['2:whale:draft', '1::public', '0::public']
def test_mergerequest_api_semi_linear(test_project, tmpdir):
"""Accepting a MR configured for semi-linear workflow.
"""
repo = hg.LocalRepo.init(tmpdir.join('repo'),
default_url=test_project.owner_basic_auth_url)
test_project.webdriver_update_merge_request_settings(
merge_method='rebase_merge',
)
topic = prepare_topic(repo, needing_rebase=False)
mr_id = create_mr(test_project, topic=topic)
api_accept_merge_request(test_project, mr_id)
repo.hg('pull')
log = repo.hg('log', '-T', '{rev}:{phase}\n')
# unchanged revnos proves that Heptapod didn't do anything funky
assert log.splitlines() == ['2:public', '1:public', '0:public']
merge_desc = "Merge branch 'topic/default/antelope' into 'branch/default'"
test_project.wait_assert_api_branches(
lambda branches: extract_gitlab_branch_titles(branches) == {
'branch/default': merge_desc
})
# now let's make a new changeset that would be a fast-forward for
# Git at first sight (DAG is linear) but wouldn't be for Mercurial
# because it has a different named branch
repo.hg('topic', 'whale')
repo.hg('branch', 'sea')
repo.path.join('whale').write("A lion would be puzzled to see a whale")
repo.hg('commit', '-Am', "Whale")
repo.hg('push')
assert test_project.api_branch_titles() == {
'branch/default': merge_desc,
'topic/sea/whale': 'Whale',
}
mr_id = test_project.api_create_merge_request(source='topic/sea/whale',
target='branch/default')
api_accept_merge_request(test_project, mr_id, check_merged=False)
# Ideally we should have had an error, but that's not the case as of
# this writing. In the meanwhile, nothing has changed
assert test_project.api_branch_titles() == {
'branch/default': merge_desc,
'topic/sea/whale': 'Whale',
}
repo.hg('pull')
log = repo.hg('log', '-T', '{rev}:{topic}:{phase}\n')
# unchanged revnos proves that Heptapod didn't do anything funky
assert log.splitlines() == [
'3:whale:draft',
'2::public',
'1::public',
'0::public',
]
def test_mergerequest_api_fast_forward_refusal_rebase(test_project, tmpdir):
"""Accepting the MR via API with rebase scenario.
......@@ -645,7 +704,7 @@ def test_mergerequest_developer_cannot_merge(test_project, tmpdir):
def merge_button(webdriver):
return webdriver.find_element_by_xpath(
'//button[contains(text(), "Merge")]')
'//button[span[contains(text(), "Merge")]]')
driver.get('%s/merge_requests/%d' % (test_project.url, mr_id))
wait = WebDriverWait(driver, 10)
......
......@@ -17,6 +17,7 @@ from .utils.project import (
)
from .utils.group import Group
from .utils.hg import LocalRepo
from .utils.selenium import could_click_element
parametrize = pytest.mark.parametrize
......@@ -188,7 +189,7 @@ def test_cli_404(test_project):
def test_hgrc_get_put(test_project):
resp = test_project.owner_api_hgrc_get()
assert resp.status_code == 200
assert resp.json() == dict(inherit=True, content=None)
assert resp.json() == dict(inherit=True)
resp = test_project.owner_api_hg_heptapod_config()
assert resp.status_code == 200
......@@ -200,14 +201,7 @@ def test_hgrc_get_put(test_project):
resp = test_project.owner_api_hgrc_get()
assert resp.status_code == 200
as_dict = resp.json()
assert as_dict.get('inherit') is True
content = as_dict['content']
iter_lines = (l.strip() for l in content.splitlines())
while next(iter_lines) != "[heptapod]":
pass
assert [l for l in iter_lines if l] == ['auto-publish = nothing']
assert resp.json() == dict(inherit=True, auto_publish='nothing')
resp = test_project.owner_api_hg_heptapod_config()
assert resp.status_code == 200
......@@ -246,9 +240,9 @@ def test_hgrc_get_put(test_project):
assert resp.status_code == 200
as_json = resp.json()
assert as_json['inherit'] is True
content = as_json['content']
assert "last update by user root (id=1)" in content
assert all(l.startswith('#') for l in content.splitlines())
# TODO after heptapod#301, last update info are not provided
# any more. Would be nice to get it back.
@needs.services
......@@ -384,6 +378,11 @@ def test_external_user_can_create_project(test_group, external_user):
link.click()
WebDriverWait(webdriver, 10).until(
could_click_element(
lambda d: d.find_element_by_xpath(
'//a[@href = "#blank_project"]')))
# The default selected namespace is test_group
# (hoping its id won't change too much with GitLab versions)
default_namespace_id = 'select2-chosen-1'
......
......@@ -949,6 +949,11 @@ class Project(object):
assert 'GitLab' in driver.title
assert 'New Project' in driver.title
WebDriverWait(driver, 10).until(
could_click_element(
lambda d: d.find_element_by_xpath(
'//a[@href = "#blank_project"]')))
# the project path (slug) attribute is derived automatically from
# its (human readable) name. The names given in these tests all
# transform identically into paths.
......
......@@ -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.send_keys(current_password)
elem = driver.find_element_by_name('user[password]')
elem.send_keys(password)
elem = driver.find_element_by_name('user[password_confirmation]')
elem.send_keys(password)
elem.send_keys(Keys.RETURN)
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):
elem.send_keys(Keys.RETURN)
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)
else:
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)
logger.info("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