| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -194,6 +194,23 @@ def delete_ldap_group_link( | |||
| 194 | 194 | path += f"/{cn}" | |
| 195 | 195 | self.manager.gitlab.http_delete(path, **kwargs) | |
| 196 | 196 | ||
| 197 | + @cli.register_custom_action("Group") | ||
| 198 | + @exc.on_http_error(exc.GitlabGetError) | ||
| 199 | + def list_ldap_group_links( | ||
| 200 | + self, **kwargs: Any | ||
| 201 | + ) -> Union[gitlab.GitlabList, List[Dict[str, Any]]]: | ||
| 202 | + """List LDAP group links. | ||
| 203 | + | ||
| 204 | + Args: | ||
| 205 | + **kwargs: Extra options to send to the server (e.g. sudo) | ||
| 206 | + | ||
| 207 | + Raises: | ||
| 208 | + GitlabAuthenticationError: If authentication is not correct | ||
| 209 | + GitlabGetError: If the server cannot perform the request | ||
| 210 | + """ | ||
| 211 | + path = f"/groups/{self.encoded_id}/ldap_group_links" | ||
| 212 | + return self.manager.gitlab.http_list(path, **kwargs) | ||
| 213 | + | ||
| 197 | 214 | @cli.register_custom_action("Group") | |
| 198 | 215 | @exc.on_http_error(exc.GitlabCreateError) | |
| 199 | 216 | def ldap_sync(self, **kwargs: Any) -> None: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,6 +12,14 @@ | |||
| 12 | 12 | from gitlab.v4.objects.projects import GroupProject, SharedProject | |
| 13 | 13 | ||
| 14 | 14 | content = {"name": "name", "id": 1, "path": "path"} | |
| 15 | + ldap_group_links_content = [ | ||
| 16 | + { | ||
| 17 | + "cn": None, | ||
| 18 | + "group_access": 40, | ||
| 19 | + "provider": "ldapmain", | ||
| 20 | + "filter": "(memberOf=cn=some_group,ou=groups,ou=fake_ou,dc=sub_dc,dc=example,dc=tld)", | ||
| 21 | + } | ||
| 22 | + ] | ||
| 15 | 23 | projects_content = [ | |
| 16 | 24 | { | |
| 17 | 25 | "id": 9, | |
@@ -216,6 +224,19 @@ def resp_delete_push_rules_group(no_content): | |||
| 216 | 224 | yield rsps | |
| 217 | 225 | ||
| 218 | 226 | ||
| 227 | + @pytest.fixture | ||
| 228 | + def resp_list_ldap_group_links(no_content): | ||
| 229 | + with responses.RequestsMock() as rsps: | ||
| 230 | + rsps.add( | ||
| 231 | + method=responses.GET, | ||
| 232 | + url="http://localhost/api/v4/groups/1/ldap_group_links", | ||
| 233 | + json=ldap_group_links_content, | ||
| 234 | + content_type="application/json", | ||
| 235 | + status=200, | ||
| 236 | + ) | ||
| 237 | + yield rsps | ||
| 238 | + | ||
| 239 | + | ||
| 219 | 240 | def test_get_group(gl, resp_groups): | |
| 220 | 241 | data = gl.groups.get(1) | |
| 221 | 242 | assert isinstance(data, gitlab.v4.objects.Group) | |
@@ -261,6 +282,12 @@ def test_list_group_descendant_groups(group, resp_list_subgroups_descendant_grou | |||
| 261 | 282 | assert descendant_groups[0].path == subgroup_descgroup_content[0]["path"] | |
| 262 | 283 | ||
| 263 | 284 | ||
| 285 | + def test_list_ldap_group_links(group, resp_list_ldap_group_links): | ||
| 286 | + ldap_group_links = group.list_ldap_group_links() | ||
| 287 | + assert isinstance(ldap_group_links, list) | ||
| 288 | + assert ldap_group_links[0]["provider"] == ldap_group_links_content[0]["provider"] | ||
| 289 | + | ||
| 290 | + | ||
| 264 | 291 | @pytest.mark.skip("GitLab API endpoint not implemented") | |
| 265 | 292 | def test_refresh_group_export_status(group, resp_export): | |
| 266 | 293 | export = group.exports.create() | |
| Back | FazBrowse Home | New Git URL |
0 commit comments