class LdapPermissionStoreTestCase(unittest.TestCase): def setUp(self): self.env = EnvironmentStub(default_data=True) self.env.config.set('ldap', 'enable', 'true') self.env.config.set('ldap', 'basedn', 'dc=example,dc=org') self.env.config.set('ldap', 'host', 'xebian') self.env.config.set('ldap', 'store_bind', 'true') self.env.config.set('ldap', 'bind_user', 'trac') self.env.config.set('ldap', 'bind_passwd', 'Trac') self.env.config.set('ldap', 'permfilter', 'objectclass=groupofnames') self.action1 = 'FILE_VIEW' self.action2 = 'TICKET_CREATE' #def test_userPermissions(self): # ps = LdapPermissionStore(self.env) # perms = ps.get_user_permissions('@users') # action = 'MILESTONE_VIEW' # self.assertEqual(perms.has_key(action), True) # self.assertEqual(perms[action], True) def test_store(self): self.ps = LdapPermissionStore(self.env) self.ps.grant_permission('@users', self.action1) self.ps.grant_permission('@users', self.action2) perms = self.ps.get_user_permissions('@users') self.assertEqual(perms.has_key(self.action1), True) self.assertEqual(perms[self.action1], True) self.assertEqual(perms.has_key(self.action2), True) self.assertEqual(perms[self.action2], True) self.ps = LdapPermissionStore(self.env) perms = self.ps.get_all_permissions() for perm in perms: print perm, "\n" self.ps.revoke_permission('@users', self.action1) perms = self.ps.get_user_permissions('@users') self.assertEqual(perms.has_key(self.action1), False) self.ps.revoke_permission('@users', self.action2) perms = self.ps.get_user_permissions('@users') self.assertEqual(perms.has_key(self.action2), False)
class LdapPermissionStoreTestCase(unittest.TestCase): def setUp(self): self.env = EnvironmentStub(default_data=True) self.env.config.set('ldap', 'enable', 'true') self.env.config.set('ldap', 'basedn', 'dc=example,dc=org') self.env.config.set('ldap', 'host', 'localhost') self.env.config.set('ldap', 'store_bind', 'true') self.env.config.set('ldap', 'bind_user', 'uid=trac,dc=example,dc=org') self.env.config.set('ldap', 'bind_passwd', 'Trac') self.env.config.set('ldap', 'permfilter', 'objectclass=groupofnames') self.action1 = 'FILE_VIEW' self.action2 = 'TICKET_CREATE' #def test_userPermissions(self): # ps = LdapPermissionStore(self.env) # perms = ps.get_user_permissions('@users') # action = 'MILESTONE_VIEW' # self.assertEqual(perms.has_key(action), True) # self.assertEqual(perms[action], True) def test_store(self): self.ps = LdapPermissionStore(self.env) self.ps.grant_permission('@users', self.action1) self.ps.grant_permission('@users', self.action2) perms = self.ps.get_user_permissions('@users') self.assertEqual(perms.has_key(self.action1), True) self.assertEqual(perms[self.action1], True) self.assertEqual(perms.has_key(self.action2), True) self.assertEqual(perms[self.action2], True) self.ps = LdapPermissionStore(self.env) perms = self.ps.get_all_permissions() for perm in perms: print perm, "\n" self.ps.revoke_permission('@users', self.action1) perms = self.ps.get_user_permissions('@users') self.assertEqual(perms.has_key(self.action1), False) self.ps.revoke_permission('@users', self.action2) perms = self.ps.get_user_permissions('@users') self.assertEqual(perms.has_key(self.action2), False)
def test_store(self): self.ps = LdapPermissionStore(self.env) self.ps.grant_permission('@users', self.action1) self.ps.grant_permission('@users', self.action2) perms = self.ps.get_user_permissions('@users') self.assertEqual(perms.has_key(self.action1), True) self.assertEqual(perms[self.action1], True) self.assertEqual(perms.has_key(self.action2), True) self.assertEqual(perms[self.action2], True) self.ps = LdapPermissionStore(self.env) perms = self.ps.get_all_permissions() for perm in perms: print perm, "\n" self.ps.revoke_permission('@users', self.action1) perms = self.ps.get_user_permissions('@users') self.assertEqual(perms.has_key(self.action1), False) self.ps.revoke_permission('@users', self.action2) perms = self.ps.get_user_permissions('@users') self.assertEqual(perms.has_key(self.action2), False)