From f12446ee66bdd427e35d3ca390c2101042cf6a7c Mon Sep 17 00:00:00 2001 From: Leo Antunes Date: Fri, 16 Sep 2016 14:38:41 +0200 Subject: [PATCH 1/3] fix Gitlab.delete() error reporting on missing arg --- gitlab/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitlab/__init__.py b/gitlab/__init__.py index fa1927d80..623456525 100644 --- a/gitlab/__init__.py +++ b/gitlab/__init__.py @@ -528,7 +528,7 @@ def delete(self, obj, id=None, **kwargs): if k not in params: try: params[k] = getattr(obj, k) - except KeyError: + except AttributeError: missing.append(k) if missing: raise GitlabDeleteError('Missing attribute(s): %s' % From 8ea7c67b3f49ee124cac2f345e784818857ccb26 Mon Sep 17 00:00:00 2001 From: Leo Antunes Date: Fri, 16 Sep 2016 16:27:02 +0200 Subject: [PATCH 2/3] groups: add initial support for LDAP links --- docs/gl_objects/groups.py | 21 +++++++++++++++++++++ docs/gl_objects/groups.rst | 12 ++++++++++++ gitlab/objects.py | 17 ++++++++++++++++- 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/docs/gl_objects/groups.py b/docs/gl_objects/groups.py index 8b4e88888..f8ab1291e 100644 --- a/docs/gl_objects/groups.py +++ b/docs/gl_objects/groups.py @@ -64,3 +64,24 @@ # or member.delete() # end member delete + +# ldap sync list +group.ldap_group_links +# end ldap sync list + +# ldap sync create +gl.group_ldap_links.create({'cn': 'some_ldap_group_name', + 'provider': 'ldapmain', 'group_access': 50}, + group_id=1) +# or +group.ldaplinks.create({'cn': 'some_ldap_group_name', + 'provider': 'ldapmain', 'group_access': 50}) +# end ldap sync create + +# ldap sync delete +gl.group_ldap_links.delete('some_ldap_group_name', group_id=1) +# or +group.ldaplinks.delete('some_ldap_group_name') +# or +ldaplink.delete() +# end ldap sync delete diff --git a/docs/gl_objects/groups.rst b/docs/gl_objects/groups.rst index b2c0ed865..67bb377a4 100644 --- a/docs/gl_objects/groups.rst +++ b/docs/gl_objects/groups.rst @@ -109,3 +109,15 @@ Remove a member from the group: .. literalinclude:: groups.py :start-after: # member delete :end-before: # end member delete + +Add an LDAP group for synchronization: + +.. literalinclude:: groups.py + :start-after: # ldap sync create + :end-before: # end ldap sync create + +Remove an LDAP group for synchronization: + +.. literalinclude:: groups.py + :start-after: # ldap sync delete + :end-before: # end ldap sync delete diff --git a/gitlab/objects.py b/gitlab/objects.py index 660641634..a26f9c6c3 100644 --- a/gitlab/objects.py +++ b/gitlab/objects.py @@ -737,6 +737,20 @@ class GroupIssueManager(BaseManager): obj_cls = GroupIssue +class GroupLdapSyncLink(GitlabObject): + _url = '/groups/%(group_id)s/ldap_group_links' + idAttr = 'cn' + canGet = False + canList = False + canUpdate = False + requiredUrlAttrs = ['group_id'] + requiredCreateAttrs = ['cn', 'group_access', 'provider'] + + +class GroupLdapSyncLinkManager(BaseManager): + obj_cls = GroupLdapSyncLink + + class GroupMember(GitlabObject): _url = '/groups/%(group_id)s/members' canGet = 'from_list' @@ -807,7 +821,8 @@ class Group(GitlabObject): ('accessrequests', GroupAccessRequestManager, [('group_id', 'id')]), ('members', GroupMemberManager, [('group_id', 'id')]), ('projects', GroupProjectManager, [('group_id', 'id')]), - ('issues', GroupIssueManager, [('group_id', 'id')]) + ('issues', GroupIssueManager, [('group_id', 'id')]), + ('ldaplinks', GroupLdapSyncLinkManager, [('group_id', 'id')]), ] GUEST_ACCESS = gitlab.GUEST_ACCESS From 6005163127156ed586d6c0e1bd1466fa055ba60a Mon Sep 17 00:00:00 2001 From: Leo Antunes Date: Mon, 19 Sep 2016 16:06:25 +0200 Subject: [PATCH 3/3] test against gitlab EE --- tools/build_test_env.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/build_test_env.sh b/tools/build_test_env.sh index 7881c1826..ff01e103b 100755 --- a/tools/build_test_env.sh +++ b/tools/build_test_env.sh @@ -75,7 +75,7 @@ cleanup() { } try docker run --name gitlab-test --detach --publish 8080:80 \ - --publish 2222:22 gpocentek/test-python-gitlab:latest >/dev/null + --publish 2222:22 costela/test-python-gitlab:latest >/dev/null LOGIN='root' PASSWORD='5iveL!fe' @@ -100,7 +100,7 @@ while :; do curl -s http://localhost:8080/users/sign_in 2>/dev/null \ | grep -q "GitLab Community Edition" && break I=$((I+5)) - [ "$I" -lt 120 ] || fatal "timed out" + [ "$I" -lt 300 ] || fatal "timed out" done sleep 5