def testDelUserDontExists(self): inv = Backend(cfg, cherrypy.log, 'test', attr, 'uid') try: inv.del_user('test') inv.del_user('test') except UserDoesntExist: return else: raise AssertionError("expected an exception")
def testAddUser(self): try: inv.del_user(u'test☭') except: pass inv = Backend(cfg, cherrypy.log, 'test', attr, 'uid') user = { 'uid': u'test☭', 'sn': 'test', 'cn': 'test', 'userPassword': '******', 'uidNumber': '42', 'gidNumber': '42', 'homeDirectory': '/home/test/' } inv.add_user(user) inv.del_user(u'test☭')
def testGetGroups(self): inv = Backend(cfg, cherrypy.log, 'test', attr, 'uid') inv.add_user(default_user) inv.add_to_groups('default_user', default_groups) ret = inv.get_groups('default_user') expected = Set(default_groups) assert ret == expected
def testSearchUser(self): inv = Backend(cfg, cherrypy.log, 'test', attr, 'uid') inv.add_user(default_user) inv.add_user(default_user2) ret = inv.search('default') expected = ['default_user', 'default_user2'] assert Set(ret.keys()) == Set(expected)
def testModifyUser(self): inv = Backend(cfg, cherrypy.log, 'test', attr, 'uid') user = { 'uid': u'test☭', 'sn': 'test', 'cn': 'test', 'userPassword': '******', 'uidNumber': '42', 'gidNumber': '42', 'homeDirectory': '/home/test/' } inv.add_user(user) inv.set_attrs(u'test☭', { 'gecos': 'test2', 'homeDirectory': '/home/test/' }) inv.del_user(u'test☭')
def testModifyUser(self): inv = Backend(cfg, cherrypy.log, 'test', attr, 'uid') user = { 'uid': u'test☭', 'sn': 'test', 'cn': 'test', 'userPassword': '******', 'uidNumber': '42', 'gidNumber': '42', 'homeDirectory': '/home/test/' } inv.add_user(user) inv.set_attrs(u'test☭', {'gecos': 'test2', 'homeDirectory': '/home/test/'}) inv.del_user(u'test☭')
def testAddUserDuplicate(self): inv = Backend(cfg, cherrypy.log, 'test', attr, 'uid') user = { 'uid': 'test', 'sn': 'test', 'cn': 'test', 'uidNumber': '42', 'userPassword': '******', 'gidNumber': '42', 'homeDirectory': '/home/test/' } try: inv.add_user(user) inv.add_user(user) except UserAlreadyExists: inv.del_user('test') return else: inv.del_user('test') raise AssertionError("expected an exception")
def testNominal(self): inv = Backend(cfg, cherrypy.log, 'test', attr, 'uid') return True
def testAuthFailure(self): inv = Backend(cfg, cherrypy.log, 'test', attr, 'uid') res = inv.auth('notauser', 'password') or inv.auth('default_user', 'notapassword') assert res == False
def testAuthSuccess(self): inv = Backend(cfg, cherrypy.log, 'test', attr, 'uid') ret = inv.auth('admin', 'admin') assert ret == True
def testAuthFailure(self): inv = Backend(cfg, cherrypy.log, 'test', attr, 'uid') res = inv.auth('notauser', 'password') or inv.auth( 'default_user', 'notapassword') assert res == False