From cd30232380cb78c2a23abf6333fda0223419600d Mon Sep 17 00:00:00 2001 From: "John L. Villalovos" Date: Mon, 13 Feb 2023 07:45:43 -0800 Subject: [PATCH 1/4] test: don't use weak passwords Newer versions of GitLab will refuse to create a user with a weak password. In order for us to move to a newer GitLab version in testing use a stronger password for the tests that create a user. --- tests/functional/api/test_groups.py | 4 ++-- tests/functional/api/test_users.py | 6 +++--- tests/functional/cli/test_cli_v4.py | 2 +- tests/functional/conftest.py | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/functional/api/test_groups.py b/tests/functional/api/test_groups.py index ec381d594..14e6a06c9 100644 --- a/tests/functional/api/test_groups.py +++ b/tests/functional/api/test_groups.py @@ -10,7 +10,7 @@ def test_groups(gl): "email": "user@test.com", "username": "user", "name": "user", - "password": "user_pass", + "password": "E4596f8be406Bc3a14a4ccdb1df80587#!1", } ) user2 = gl.users.create( @@ -18,7 +18,7 @@ def test_groups(gl): "email": "user2@test.com", "username": "user2", "name": "user2", - "password": "user2_pass", + "password": "E4596f8be406Bc3a14a4ccdb1df80587#!#2", } ) group1 = gl.groups.create( diff --git a/tests/functional/api/test_users.py b/tests/functional/api/test_users.py index 3209e65c8..92418e8f5 100644 --- a/tests/functional/api/test_users.py +++ b/tests/functional/api/test_users.py @@ -12,7 +12,7 @@ def test_create_user(gl, fixture_dir): "email": "foo@bar.com", "username": "foo", "name": "foo", - "password": "foo_password", + "password": "E4596f8be406Bc3a14a4ccdb1df80587#!", "avatar": open(fixture_dir / "avatar.png", "rb"), } ) @@ -65,7 +65,7 @@ def test_delete_user(gl, wait_for_sidekiq): "email": "delete-user@test.com", "username": "delete-user", "name": "delete-user", - "password": "delete-user-pass", + "password": "E4596f8be406Bc3a14a4ccdb1df80587#!", } ) @@ -100,7 +100,7 @@ def test_list_multiple_users(gl, user): "email": second_email, "username": second_username, "name": "Foo Bar", - "password": "foobar_password", + "password": "E4596f8be406Bc3a14a4ccdb1df80587#!", } ) assert gl.users.list(search=second_user.username)[0].id == second_user.id diff --git a/tests/functional/cli/test_cli_v4.py b/tests/functional/cli/test_cli_v4.py index 684293f30..7bc3a050c 100644 --- a/tests/functional/cli/test_cli_v4.py +++ b/tests/functional/cli/test_cli_v4.py @@ -103,7 +103,7 @@ def test_create_user(gitlab_cli, gl): email = "fake@email.com" username = "user1" name = "User One" - password = "fakepassword" + password = "E4596f8be406Bc3a14a4ccdb1df80587#!" cmd = [ "user", diff --git a/tests/functional/conftest.py b/tests/functional/conftest.py index 34b286b4d..949f57239 100644 --- a/tests/functional/conftest.py +++ b/tests/functional/conftest.py @@ -523,7 +523,7 @@ def user(gl): email = f"user{_id}@email.com" username = f"user{_id}" name = f"User {_id}" - password = "fakepassword" + password = "E4596f8be406Bc3a14a4ccdb1df80587#!" user = gl.users.create(email=email, username=username, name=name, password=password) From 7d6f26049687f83e6fee9ad8d39f331c816d8541 Mon Sep 17 00:00:00 2001 From: "John L. Villalovos" Date: Mon, 13 Feb 2023 08:29:00 -0800 Subject: [PATCH 2/4] test: don't expect an empty list of custom attributes Now GitLab is returning two custom attributes for a user. So don't assert that there are no custom attributes on a new user. [1] https://gitlab.com/gitlab-org/gitlab/-/merge_requests/108250 --- tests/functional/api/test_users.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/functional/api/test_users.py b/tests/functional/api/test_users.py index 92418e8f5..70e0ee51d 100644 --- a/tests/functional/api/test_users.py +++ b/tests/functional/api/test_users.py @@ -143,9 +143,6 @@ def test_user_email(gl, user): def test_user_custom_attributes(gl, user): - attrs = user.customattributes.list() - assert not attrs - attr = user.customattributes.set("key", "value1") assert user in gl.users.list(custom_attributes={"key": "value1"}) assert attr.key == "key" From 93b5da0eb9005b5ba67890ba062d3701b379e883 Mon Sep 17 00:00:00 2001 From: "John L. Villalovos" Date: Mon, 13 Feb 2023 07:25:08 -0800 Subject: [PATCH 3/4] test: use GITLAB_TAG=15.8.1-ee.0 Switch to newer version of GitLab for testing. --- tests/functional/fixtures/.env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/fixtures/.env b/tests/functional/fixtures/.env index 449bc84a1..855565ccf 100644 --- a/tests/functional/fixtures/.env +++ b/tests/functional/fixtures/.env @@ -1,2 +1,2 @@ GITLAB_IMAGE=gitlab/gitlab-ee -GITLAB_TAG=15.4.0-ee.0 +GITLAB_TAG=15.8.1-ee.0 From 97e8044a8614d4f21e8e89aa30a3cd28394454d4 Mon Sep 17 00:00:00 2001 From: Nejc Habjan Date: Tue, 29 Aug 2023 01:09:50 +0200 Subject: [PATCH 4/4] test(functional): enable bulk import feature flag before test --- tests/functional/api/test_bulk_imports.py | 27 ++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/tests/functional/api/test_bulk_imports.py b/tests/functional/api/test_bulk_imports.py index 899d35840..6eda12ab9 100644 --- a/tests/functional/api/test_bulk_imports.py +++ b/tests/functional/api/test_bulk_imports.py @@ -1,4 +1,29 @@ -def test_bulk_imports(gl, group): +import time +import pytest + +import gitlab + + +@pytest.fixture +def bulk_import_enabled(gl: gitlab.Gitlab): + settings = gl.settings.get() + bulk_import_default = settings.bulk_import_enabled + + settings.bulk_import_enabled = True + settings.save() + + # todo: why so fussy with feature flag timing? + time.sleep(5) + get_settings = gl.settings.get() + assert get_settings.bulk_import_enabled == True + + yield settings + + settings.bulk_import_enabled = bulk_import_default + settings.save() + + +def test_bulk_imports(gl, group, bulk_import_enabled): destination = f"{group.full_path}-import" configuration = { "url": gl.url,