Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitad7c8fa

Browse files
authored
feat(groups): add support for listing ldap_group_links (#2371)
1 parenta0553c2 commitad7c8fa

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

‎gitlab/v4/objects/groups.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,23 @@ def delete_ldap_group_link(
194194
path+=f"/{cn}"
195195
self.manager.gitlab.http_delete(path,**kwargs)
196196

197+
@cli.register_custom_action("Group")
198+
@exc.on_http_error(exc.GitlabGetError)
199+
deflist_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+
returnself.manager.gitlab.http_list(path,**kwargs)
213+
197214
@cli.register_custom_action("Group")
198215
@exc.on_http_error(exc.GitlabCreateError)
199216
defldap_sync(self,**kwargs:Any)->None:

‎tests/unit/objects/test_groups.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@
1212
fromgitlab.v4.objects.projectsimportGroupProject,SharedProject
1313

1414
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+
]
1523
projects_content= [
1624
{
1725
"id":9,
@@ -216,6 +224,19 @@ def resp_delete_push_rules_group(no_content):
216224
yieldrsps
217225

218226

227+
@pytest.fixture
228+
defresp_list_ldap_group_links(no_content):
229+
withresponses.RequestsMock()asrsps:
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+
yieldrsps
238+
239+
219240
deftest_get_group(gl,resp_groups):
220241
data=gl.groups.get(1)
221242
assertisinstance(data,gitlab.v4.objects.Group)
@@ -261,6 +282,12 @@ def test_list_group_descendant_groups(group, resp_list_subgroups_descendant_grou
261282
assertdescendant_groups[0].path==subgroup_descgroup_content[0]["path"]
262283

263284

285+
deftest_list_ldap_group_links(group,resp_list_ldap_group_links):
286+
ldap_group_links=group.list_ldap_group_links()
287+
assertisinstance(ldap_group_links,list)
288+
assertldap_group_links[0]["provider"]==ldap_group_links_content[0]["provider"]
289+
290+
264291
@pytest.mark.skip("GitLab API endpoint not implemented")
265292
deftest_refresh_group_export_status(group,resp_export):
266293
export=group.exports.create()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp