mirror of
https://github.com/kakwa/ldapcherry
synced 2024-11-22 09:24:21 +01:00
fix unit tests + add graph method
* fix unit tests on roles (adding mandatory description) * adding a method to get roles graph in json
This commit is contained in:
parent
9b803008bc
commit
a62c5a64ac
@ -10,6 +10,7 @@
|
||||
import sys
|
||||
import re
|
||||
import traceback
|
||||
import json
|
||||
import logging
|
||||
import logging.handlers
|
||||
from operator import itemgetter
|
||||
@ -463,14 +464,26 @@ class LdapCherry(object):
|
||||
@cherrypy.expose
|
||||
def delete(self, **params):
|
||||
""" remove user page """
|
||||
self._check_auth(must_admin=True, is_admin=is_admin)
|
||||
self._check_auth(must_admin=True)
|
||||
is_admin = self._check_admin()
|
||||
pass
|
||||
|
||||
@cherrypy.expose
|
||||
def graph(self, **params):
|
||||
""" remove user page """
|
||||
self._check_auth(must_admin=True)
|
||||
is_admin = self._check_admin()
|
||||
graph={}
|
||||
for r in self.roles.graph:
|
||||
s = list(self.roles.graph[r]['sub_roles'])
|
||||
p = list(self.roles.graph[r]['parent_roles'])
|
||||
graph[r] = { 'sub_roles': s, 'parent_roles': p}
|
||||
return json.dumps(graph, separators=(',',':'))
|
||||
|
||||
@cherrypy.expose
|
||||
def modify(self, **params):
|
||||
""" modify user page """
|
||||
self._check_auth(must_admin=True, is_admin=is_admin)
|
||||
self._check_auth(must_admin=True)
|
||||
is_admin = self._check_admin()
|
||||
pass
|
||||
|
||||
|
@ -3,6 +3,7 @@ users:
|
||||
ad: [Domain Users]
|
||||
ldap: ['cn=users,ou=group,dc=example,dc=com']
|
||||
display_name: Simple Users
|
||||
description: description
|
||||
subroles:
|
||||
admin-lv2:
|
||||
LC_admins: true
|
||||
@ -10,6 +11,7 @@ users:
|
||||
ad: [Domain Users]
|
||||
ldap: ['cn=nagios admins,ou=group,dc=example,dc=com']
|
||||
display_name: Administrators Level 2
|
||||
description: description
|
||||
subroles:
|
||||
admin-lv3:
|
||||
backends_groups:
|
||||
@ -17,10 +19,12 @@ users:
|
||||
ldap: ['cn=dns admins,ou=group,dc=example,dc=com', 'cn=nagios admins,ou=group,dc=example,dc=com',
|
||||
'cn=puppet admins,ou=group,dc=example,dc=com',]
|
||||
display_name: Administrators Level 3
|
||||
description: description
|
||||
subroles: {}
|
||||
developpers:
|
||||
backends_groups:
|
||||
ad: [Domain Users]
|
||||
ldap: ['cn=developpers,ou=group,dc=example,dc=com']
|
||||
display_name: Developpers
|
||||
description: description
|
||||
subroles: {}
|
||||
|
@ -1,5 +1,6 @@
|
||||
admin-lv3:
|
||||
display_name: Administrators Level 3
|
||||
description: description
|
||||
backends_groups:
|
||||
ldap:
|
||||
- cn=dns admins,ou=group,dc=example,dc=com
|
||||
@ -13,6 +14,7 @@ admin-lv3:
|
||||
|
||||
admin-lv2:
|
||||
display_name: Administrators Level 2
|
||||
description: description
|
||||
LC_admins: True
|
||||
backends_groups:
|
||||
ldap:
|
||||
@ -23,6 +25,7 @@ admin-lv2:
|
||||
|
||||
developpers:
|
||||
display_name: Developpers
|
||||
description: description
|
||||
backends_groups:
|
||||
ldap:
|
||||
- cn=developpers,ou=group,dc=example,dc=com
|
||||
@ -32,6 +35,7 @@ developpers:
|
||||
|
||||
users:
|
||||
display_name: Simple Users
|
||||
description: description
|
||||
backends_groups:
|
||||
ldap:
|
||||
- cn=users,ou=group,dc=example,dc=com
|
||||
|
@ -1,6 +1,7 @@
|
||||
admin -lv3:
|
||||
display_name: Administrators Level 3
|
||||
LC_admins: True
|
||||
description: description
|
||||
backends_groups:
|
||||
ldap:
|
||||
- cn=dns admins,ou=group,dc=example,dc=com
|
||||
@ -14,6 +15,7 @@ admin -lv3:
|
||||
|
||||
admin -lv2:
|
||||
display_name: Administrators Level 2
|
||||
description: description
|
||||
backends_groups:
|
||||
ldap:
|
||||
- cn=nagios admins,ou=group,dc=example,dc=com
|
||||
@ -23,6 +25,7 @@ admin -lv2:
|
||||
|
||||
developpers:
|
||||
display_name: Developpers
|
||||
description: description
|
||||
backends_groups:
|
||||
ldap:
|
||||
- cn=developpers,ou=group,dc=example,dc=com
|
||||
@ -32,6 +35,7 @@ developpers:
|
||||
|
||||
users:
|
||||
display_name: Simple Users
|
||||
description: description
|
||||
backends_groups:
|
||||
ldap:
|
||||
- cn=users,ou=group,dc=example,dc=com
|
||||
@ -40,6 +44,7 @@ users:
|
||||
|
||||
users2:
|
||||
display_name: Simple Users 2
|
||||
description: description
|
||||
backends_groups:
|
||||
ldap:
|
||||
- cn=users,ou=group,dc=example,dc=com
|
||||
|
@ -1,5 +1,6 @@
|
||||
admin -lv3:
|
||||
display_name: Administrators Level 3
|
||||
description: description
|
||||
LC_admins: True
|
||||
backends_groups:
|
||||
ldap:
|
||||
@ -14,6 +15,7 @@ admin -lv3:
|
||||
|
||||
admin -lv3:
|
||||
display_name: Administrators Level 2
|
||||
description: description
|
||||
backends_groups:
|
||||
ldap:
|
||||
- cn=nagios admins,ou=group,dc=example,dc=com
|
||||
@ -23,6 +25,7 @@ admin -lv3:
|
||||
|
||||
developpers:
|
||||
display_name: Developpers
|
||||
description: description
|
||||
backends_groups:
|
||||
ldap:
|
||||
- cn=developpers,ou=group,dc=example,dc=com
|
||||
@ -32,6 +35,7 @@ developpers:
|
||||
|
||||
users:
|
||||
display_name: Simple Users
|
||||
description: description
|
||||
backends_groups:
|
||||
ldap:
|
||||
- cn=users,ou=group,dc=example,dc=com
|
||||
|
@ -1,5 +1,6 @@
|
||||
admin-lv3:
|
||||
display_name: Administrators Level 3
|
||||
description: description
|
||||
LC_admins: True
|
||||
backends_groups:
|
||||
ldap:
|
||||
@ -14,9 +15,11 @@ admin-lv3:
|
||||
|
||||
admin-lv2:
|
||||
display_name: Administrators Level 2
|
||||
description: description
|
||||
|
||||
developpers:
|
||||
display_name: Developpers
|
||||
description: description
|
||||
backends_groups:
|
||||
ldap:
|
||||
- cn=developpers,ou=group,dc=example,dc=com
|
||||
@ -26,6 +29,7 @@ developpers:
|
||||
|
||||
users:
|
||||
display_name: Simple Users
|
||||
description: description
|
||||
backends_groups:
|
||||
ldap:
|
||||
- cn=users,ou=group,dc=example,dc=com
|
||||
|
@ -1,6 +1,7 @@
|
||||
admin-lv3:
|
||||
display_name: Administrators Level 3
|
||||
LC_admins: True
|
||||
description: description
|
||||
backends_groups:
|
||||
ldap:
|
||||
- cn=dns admins,ou=group,dc=example,dc=com
|
||||
@ -13,6 +14,7 @@ admin-lv3:
|
||||
- Domain Controllers
|
||||
|
||||
admin-lv2:
|
||||
description: description
|
||||
backends_groups:
|
||||
ldap:
|
||||
- cn=nagios admins,ou=group,dc=example,dc=com
|
||||
@ -22,6 +24,7 @@ admin-lv2:
|
||||
|
||||
developpers:
|
||||
display_name: Developpers
|
||||
description: description
|
||||
backends_groups:
|
||||
ldap:
|
||||
- cn=developpers,ou=group,dc=example,dc=com
|
||||
@ -31,6 +34,7 @@ developpers:
|
||||
|
||||
users:
|
||||
display_name: Simple Users
|
||||
description: description
|
||||
backends_groups:
|
||||
ldap:
|
||||
- cn=users,ou=group,dc=example,dc=com
|
||||
|
@ -78,7 +78,7 @@ class TestError(object):
|
||||
|
||||
def testNested(self):
|
||||
inv = Roles('./tests/cfg/nested.yml')
|
||||
expected = {'developpers': {'backends_groups': {'ad': ['Domain Users'], 'ldap': ['cn=developpers,ou=group,dc=example,dc=com', 'cn=users,ou=group,dc=example,dc=com']}, 'display_name': 'Developpers'}, 'admin-lv3': {'backends_groups': {'ad': ['Domain Users', 'Administrators', 'Domain Controllers'], 'ldap': ['cn=nagios admins,ou=group,dc=example,dc=com', 'cn=users,ou=group,dc=example,dc=com', 'cn=puppet admins,ou=group,dc=example,dc=com', 'cn=dns admins,ou=group,dc=example,dc=com']}, 'display_name': 'Administrators Level 3'}, 'admin-lv2': {'backends_groups': {'ad': ['Domain Users'], 'ldap': ['cn=nagios admins,ou=group,dc=example,dc=com', 'cn=users,ou=group,dc=example,dc=com']}, 'display_name': 'Administrators Level 2', 'LC_admins': True}, 'users': {'backends_groups': {'ad': ['Domain Users'], 'ldap': ['cn=users,ou=group,dc=example,dc=com']}, 'display_name': 'Simple Users'}}
|
||||
expected = {'developpers': {'backends_groups': {'ad': ['Domain Users'], 'ldap': ['cn=developpers,ou=group,dc=example,dc=com', 'cn=users,ou=group,dc=example,dc=com']}, 'display_name': 'Developpers', 'description': 'description'}, 'admin-lv3': {'backends_groups': {'ad': ['Domain Users', 'Administrators', 'Domain Controllers'], 'ldap': ['cn=nagios admins,ou=group,dc=example,dc=com', 'cn=users,ou=group,dc=example,dc=com', 'cn=puppet admins,ou=group,dc=example,dc=com', 'cn=dns admins,ou=group,dc=example,dc=com']}, 'display_name': 'Administrators Level 3', 'description': 'description'}, 'admin-lv2': {'backends_groups': {'ad': ['Domain Users'], 'ldap': ['cn=nagios admins,ou=group,dc=example,dc=com', 'cn=users,ou=group,dc=example,dc=com']}, 'display_name': 'Administrators Level 2', 'description': 'description', 'LC_admins': True}, 'users': {'backends_groups': {'ad': ['Domain Users'], 'ldap': ['cn=users,ou=group,dc=example,dc=com']}, 'display_name': 'Simple Users', 'description': 'description'}}
|
||||
assert expected == inv.flatten
|
||||
|
||||
def testGetGroupMissingRole(self):
|
||||
|
Loading…
Reference in New Issue
Block a user