Note: The default ITS GitLab runner is a shared resource and is subject to slowdowns during heavy usage.
You can run your own GitLab runner that is dedicated just to your group if you need to avoid processing delays.

Commit 20a3599d authored by Rob Carleski's avatar Rob Carleski 🇮🇸
Browse files

Add new members list to group_data.

parent 3d7b589c
...@@ -7,6 +7,7 @@ import time ...@@ -7,6 +7,7 @@ import time
from urllib.parse import quote from urllib.parse import quote
from requests.packages.urllib3.util.retry import Retry from requests.packages.urllib3.util.retry import Retry
from requests.adapters import HTTPAdapter from requests.adapters import HTTPAdapter
from ldap3.utils.dn import parse_dn
class Client: class Client:
...@@ -152,7 +153,7 @@ class Client: ...@@ -152,7 +153,7 @@ class Client:
if item['naming'].lower() == name.lower(): if item['naming'].lower() == name.lower():
return item['dn'].lower() return item['dn'].lower()
elif item['group']: elif item['group']:
hname = re.sub('[\._]', ' ', name).lower() hname = re.sub(r'[\._]', ' ', name).lower()
if item['displayName'].lower() == hname: if item['displayName'].lower() == hname:
return item['dn'].lower() return item['dn'].lower()
else: else:
...@@ -230,6 +231,17 @@ class Client: ...@@ -230,6 +231,17 @@ class Client:
if r.status_code == requests.codes.ok: if r.status_code == requests.codes.ok:
if 'umichgroup' in r.json()['group'][0]['objectClass']: if 'umichgroup' in r.json()['group'][0]['objectClass']:
self.group_data = r.json()['group'][0] self.group_data = r.json()['group'][0]
self.group_data['members'] = []
if isinstance(self.group_data['memberDn'], list):
for member in self.group_data['memberDn']:
  • If you like, you can do for member in self.group_data['memberDn'] or []: instead of checking whether it's a list first.

    Or if you really wanted to golf it:

    self.group_data['members'].extend([parse_dn(x)[0][1] for x in self.group_data['memberDn'] or []])
Please register or sign in to reply
self.group_data['members'].append(
parse_dn(member)[0][1]
)
if isinstance(self.group_data['memberGroupDn'], list):
for member in self.group_data['memberGroupDn']:
self.group_data['members'].append(
parse_dn(member)[0][1]
)
else: else:
raise ValueError('{} is not a group. Got [{}]'.format( raise ValueError('{} is not a group. Got [{}]'.format(
name, name,
...@@ -361,7 +373,7 @@ class Client: ...@@ -361,7 +373,7 @@ class Client:
name = self._validate_name(name) name = self._validate_name(name)
endpoint = self.call_url + '/reserve' endpoint = self.call_url + '/reserve'
data = { data = {
'name': re.sub('[\._]', ' ', name) 'name': re.sub(r'[\._]', ' ', name)
} }
for x in range(int(self.retries)): for x in range(int(self.retries)):
......
...@@ -29,6 +29,7 @@ setup( ...@@ -29,6 +29,7 @@ setup(
packages=find_packages(), packages=find_packages(),
install_requires=[ install_requires=[
'requests', 'requests',
'ldap3',
], ],
setup_requires=[ setup_requires=[
'pytest-runner', 'pytest-runner',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment