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 2ab9dcdb authored by Rob Carleski's avatar Rob Carleski 🇮🇸
Browse files

Add new members lists to group_data.

- group_data['members']
- group_data['memberGroups']
- group_data['expandedMembers']
parent 3d7b589c
......@@ -7,6 +7,7 @@ import time
from urllib.parse import quote
from requests.packages.urllib3.util.retry import Retry
from requests.adapters import HTTPAdapter
from ldap3.utils.dn import parse_dn
class Client:
......@@ -152,7 +153,7 @@ class Client:
if item['naming'].lower() == name.lower():
return item['dn'].lower()
elif item['group']:
hname = re.sub('[\._]', ' ', name).lower()
hname = re.sub(r'[\._]', ' ', name).lower()
if item['displayName'].lower() == hname:
return item['dn'].lower()
else:
......@@ -230,6 +231,33 @@ class Client:
if r.status_code == requests.codes.ok:
if 'umichgroup' in r.json()['group'][0]['objectClass']:
self.group_data = r.json()['group'][0]
self.group_data['members'] = []
self.group_data['memberGroups'] = []
self.group_data['expandedMembers'] = []
print('gronp')
subclient = Client({
'client_id': self.client_id,
'secret': self.secret
})
if isinstance(self.group_data['memberDn'], list):
for member in self.group_data['memberDn']:
self.group_data['members'].append(
parse_dn(member)[0][1]
)
self.group_data['expandedMembers'].append(
parse_dn(member)[0][1]
)
if isinstance(self.group_data['memberGroupDn'], list):
for member in self.group_data['memberGroupDn']:
self.group_data['memberGroups'].append(
parse_dn(member)[0][1]
)
subclient.fetch_group(member)
for m in subclient.group_data['expandedMembers']:
if m not in self.group_data['expandedMembers']:
self.group_data['expandedMembers'].append(
m
)
else:
raise ValueError('{} is not a group. Got [{}]'.format(
name,
......@@ -361,7 +389,7 @@ class Client:
name = self._validate_name(name)
endpoint = self.call_url + '/reserve'
data = {
'name': re.sub('[\._]', ' ', name)
'name': re.sub(r'[\._]', ' ', name)
}
for x in range(int(self.retries)):
......
......@@ -29,6 +29,7 @@ setup(
packages=find_packages(),
install_requires=[
'requests',
'ldap3',
],
setup_requires=[
'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