diff options
| author | Nejc Habjan <nejc.habjan@siemens.com> | 2022-11-17 18:19:29 +0100 |
|---|---|---|
| committer | John Villalovos <john@sodarock.com> | 2022-11-17 14:46:04 -0800 |
| commit | 3a61f601adaec7751cdcfbbcb88aa544326b1730 (patch) | |
| tree | 3f44d745dd12830402e4259b3a62ab3c5e46df80 /tests | |
| parent | 0c98b2d8f4b8c1ac6a4b496282f307687b652759 (diff) | |
| download | gitlab-3a61f601adaec7751cdcfbbcb88aa544326b1730.tar.gz | |
feat(groups): add LDAP link manager and deprecate old API endpoints
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/functional/api/test_groups.py | 34 | ||||
| -rw-r--r-- | tests/unit/objects/test_groups.py | 8 |
2 files changed, 32 insertions, 10 deletions
diff --git a/tests/functional/api/test_groups.py b/tests/functional/api/test_groups.py index 0210a32..51fbe32 100644 --- a/tests/functional/api/test_groups.py +++ b/tests/functional/api/test_groups.py @@ -139,15 +139,37 @@ def test_group_labels(group): @pytest.mark.gitlab_premium -@pytest.mark.xfail(reason="/ldap/groups endpoint is gone") -def test_group_ldap_links(gl, group): +@pytest.mark.xfail(reason="/ldap/groups endpoint not documented") +def test_ldap_groups(gl): + assert isinstance(gl.ldapgroups.list(), list) + + +@pytest.mark.gitlab_premium +def test_group_ldap_links(group): ldap_cn = "common-name" ldap_provider = "ldap-provider" - assert gl.ldapgroups.list() - group.add_ldap_group_link(ldap_cn, 30, ldap_provider) - group.ldap_sync() - group.delete_ldap_group_link(ldap_cn) + ldap_cn_link = group.ldap_group_links.create( + {"provider": ldap_provider, "group_access": 30, "cn": ldap_cn} + ) + ldap_filter_link = group.ldap_group_links.create( + {"provider": ldap_provider, "group_access": 30, "filter": "(cn=Common Name)"} + ) + + ldap_links = group.ldap_group_links.list() + + assert ldap_cn_link.cn == ldap_links[0].cn + assert ldap_filter_link.filter == ldap_links[1].filter + + with pytest.raises(gitlab.GitlabCreateError): + # todo - can we configure dummy LDAP in the container? + group.ldap_sync() + + ldap_filter_link.delete() + group.ldap_group_links.delete(provider=ldap_provider, cn=ldap_cn) + + with pytest.raises(gitlab.GitlabListError, match="No linked LDAP groups found"): + group.ldap_group_links.list() def test_group_notification_settings(group): diff --git a/tests/unit/objects/test_groups.py b/tests/unit/objects/test_groups.py index 5cba6dc..29e3c1a 100644 --- a/tests/unit/objects/test_groups.py +++ b/tests/unit/objects/test_groups.py @@ -8,7 +8,7 @@ import pytest import responses import gitlab -from gitlab.v4.objects import GroupDescendantGroup, GroupSubgroup +from gitlab.v4.objects import GroupDescendantGroup, GroupLDAPGroupLink, GroupSubgroup from gitlab.v4.objects.projects import GroupProject, SharedProject content = {"name": "name", "id": 1, "path": "path"} @@ -283,9 +283,9 @@ def test_list_group_descendant_groups(group, resp_list_subgroups_descendant_grou def test_list_ldap_group_links(group, resp_list_ldap_group_links): - ldap_group_links = group.list_ldap_group_links() - assert isinstance(ldap_group_links, list) - assert ldap_group_links[0]["provider"] == ldap_group_links_content[0]["provider"] + ldap_group_links = group.ldap_group_links.list() + assert isinstance(ldap_group_links[0], GroupLDAPGroupLink) + assert ldap_group_links[0].provider == ldap_group_links_content[0]["provider"] @pytest.mark.skip("GitLab API endpoint not implemented") |
