From 42a1e13db41b115cb7d3976ad2aecc927cf5e6bc Mon Sep 17 00:00:00 2001 From: kakwa Date: Wed, 17 Jun 2015 00:39:03 +0200 Subject: [PATCH] adding test for add/delete groups --- tests/test_BackendLdap.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/test_BackendLdap.py b/tests/test_BackendLdap.py index 1abf00a..4e05dce 100644 --- a/tests/test_BackendLdap.py +++ b/tests/test_BackendLdap.py @@ -28,6 +28,7 @@ cfg = { 'search_filter_tmpl' : '(|(uid=%(searchstring)s*)(sn=%(searchstring)s*))', 'objectclasses' : 'top, person, organizationalPerson, simpleSecurityObject, posixAccount', 'dn_user_attr' : 'uid', +'group_attr.member' : "%(dn)s", } def syslog_error(msg='', context='', @@ -121,12 +122,26 @@ class TestError(object): expected = {'uid': 'jwatson', 'cn': 'John Watson', 'sn': 'watson'} assert ret == expected - def testGetUser(self): + def testGetGroups(self): inv = Backend(cfg, cherrypy.log, 'ldap', attr, 'uid') ret = inv.get_groups('jwatson') expected = ['cn=itpeople,ou=Groups,dc=example,dc=org'] assert ret == expected + def testAddDeleteGroups(self): + inv = Backend(cfg, cherrypy.log, 'ldap', attr, 'uid') + groups = [ + 'cn=hrpeople,ou=Groups,dc=example,dc=org', + 'cn=itpeople,ou=Groups,dc=example,dc=org', + ] + inv.add_to_groups('jwatson', groups) + ret = inv.get_groups('jwatson') + print ret + inv.del_from_groups('jwatson', ['cn=hrpeople,ou=Groups,dc=example,dc=org']) + inv.del_from_groups('jwatson', ['cn=hrpeople,ou=Groups,dc=example,dc=org']) + assert ret == ['cn=itpeople,ou=Groups,dc=example,dc=org', 'cn=hrpeople,ou=Groups,dc=example,dc=org'] + + def testSearchUser(self): inv = Backend(cfg, cherrypy.log, 'ldap', attr, 'uid') ret = inv.search('smith')