Get all groups
This commit is contained in:
parent
6d14ed9246
commit
b46b4fa01e
|
@ -31,7 +31,21 @@ def get_group_by_cn(client, cn):
|
|||
return group
|
||||
|
||||
|
||||
# TODO: get_all_groups -> [group_dicts]
|
||||
def get_all_groups(client):
|
||||
log.info("Searching all the groups")
|
||||
dn = 'ou=Groups,{}'.format(client.base_dn)
|
||||
|
||||
log.debug("Search dn: {}".format(dn))
|
||||
|
||||
response_id = client.connection.search(
|
||||
dn, '(objectclass=groupOfNames)',
|
||||
search_scope='SUBTREE',
|
||||
attributes=[ALL_ATTRIBUTES]
|
||||
)
|
||||
|
||||
response = get_response(client, response_id)
|
||||
groups = [make_group_dict(client, entry) for entry in response]
|
||||
return groups
|
||||
|
||||
|
||||
def add_group_member(client, group, user):
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from phi.ldap.user import get_user_by_uid, get_all_users, \
|
||||
add_user, delete_user_by_uid, delete_user
|
||||
|
||||
from phi.ldap.group import add_group_member, get_group_by_cn
|
||||
from phi.ldap.group import add_group_member, get_group_by_cn, get_all_groups
|
||||
|
||||
|
||||
def test_connection(ldap_client):
|
||||
|
@ -60,6 +60,13 @@ def test_failing_delete_user(ldap_client):
|
|||
assert False
|
||||
|
||||
|
||||
def test_get_all_groups(ldap_client):
|
||||
groups = get_all_groups(ldap_client)
|
||||
|
||||
cns = [g['cn'] for g in groups]
|
||||
assert 'WikiUsers' in cns
|
||||
|
||||
|
||||
def test_add_to_group(ldap_client):
|
||||
client = ldap_client
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user