Example #1
0
def __create_test_perm(name, number, op):
    label = name + '-' + str(number)
    return Perm(obj_name=label,
                op_name=op,
                obj_id=str(number),
                description=label + ' Object.' + op,
                abstract_name=label + '.' + op,
                type='test',
                props=['name1:value1', 'name2:value2'])
Example #2
0
 def test_search_perms(self):
     """
     Test the perm search by obj_name and op_name in ldap
     """
     print_ln('test search perms by objNm')        
     try:
         prm = Perm(obj_name = "TOB*", op_name = "TOP*")
         pList = permdao.search(prm)
         for idx, entity in enumerate(pList) :            
             print_entity (entity, "Perm[" + str(idx+1) + "]:", 1)
     except Exception as e:
         self.fail('perm search failed, exception=' + str(e))
Example #3
0
 def test_delete_perms(self):
     """
     Test the perm delete
     """
     print_ln('test delete perms')
     
     try:
         pList = permdao.search(Perm(obj_name='py-test*', op_name='*'))
         for perm in pList:                       
             entity = permdao.delete(perm)
             print_ln("Delete perm obj=" + perm.obj_name + ', op=' + perm.op_name + ', id=' + perm.obj_id)
     except Exception as e:
         self.fail('perm delete failed, exception=' + str(e))
Example #4
0
    def test_delete_perm(self):
        """
        Test the perm delete object method
        """
        print_ln('test_delete_perm')

        try:
            pList = review_mgr.find_perms(Perm(obj_name='py-obj*',
                                               op_name='*'))
            for perm in pList:
                entity = admin_mgr.delete_perm(perm)
                print_ln("Delete Perm obj name=" + entity.obj_name + ', op=' +
                         entity.op_name + ', id=' + entity.obj_id)
        except Exception as e:
            self.fail('test_delete_perm failed, exception=' + str(e))
Example #5
0
    def test_perm_roles(self):
        """
        Test the perm roles method
        """
        print_ln('test_perm_roles')

        try:
            pList = review_mgr.find_perms(Perm(obj_name='py-obj*',
                                               op_name='*'))
            for perm in pList:
                print_ln("Role Perm obj name=" + perm.obj_name + ', op=' +
                         perm.op_name + ', id=' + perm.obj_id)
                rList = review_mgr.perm_roles(perm)
                for role in rList:
                    print_ln("Assigned role=" + role, 1)
        except Exception as e:
            self.fail('test_perm_roles failed, exception=' + str(e))
Example #6
0
    def test_perm_users(self):
        """
        Test the perm users method
        """
        print_ln('test_perm_users')

        try:
            pList = review_mgr.find_perms(Perm(obj_name='py-obj*',
                                               op_name='*'))
            for perm in pList:
                print_ln("Perm obj name=" + perm.obj_name + ', op=' +
                         perm.op_name + ', id=' + perm.obj_id)
                uList = review_mgr.perm_users(perm)
                for user in uList:
                    print_ln("Assigned user=" + user.uid, 1)
        except Exception as e:
            self.fail('test_perm_users failed, exception=' + str(e))
Example #7
0
    def test_revoke(self):
        """
        Test the revoke method
        """
        print_ln('test_revoke')

        try:
            pList = review_mgr.find_perms(Perm(obj_name='py-obj*',
                                               op_name='*'))
            rles = role_test_data.get_test_roles('py-role', 10)
            for perm in pList:
                for rle in rles:
                    admin_mgr.revoke(perm, rle)
                    print_ln("Revoke Perm obj name=" + perm.obj_name +
                             ', op=' + perm.op_name + ', id=' + perm.obj_id +
                             ', Role=' + rle.name)
        except Exception as e:
            pass
Example #8
0
def __unload(entry):
    entity = Perm()
    entity.dn = ldaphelper.get_dn(entry)

    entity.internal_id = ldaphelper.get_attr_val(
        entry[ATTRIBUTES][global_ids.INTERNAL_ID])
    entity.obj_id = ldaphelper.get_attr_val(entry[ATTRIBUTES][OBJ_ID])
    entity.obj_name = ldaphelper.get_attr_val(entry[ATTRIBUTES][OBJ_NM])
    entity.op_name = ldaphelper.get_attr_val(entry[ATTRIBUTES][OP_NM])
    entity.abstract_name = ldaphelper.get_attr_val(
        entry[ATTRIBUTES][PERM_NAME])
    entity.type = ldaphelper.get_attr_val(entry[ATTRIBUTES][TYPE])
    entity.description = ldaphelper.get_one_attr_val(
        entry[ATTRIBUTES][global_ids.DESC])
    # Get the multi-occurring attrs:
    entity.users = ldaphelper.get_list(entry[ATTRIBUTES][USERS])
    entity.roles = ldaphelper.get_list(entry[ATTRIBUTES][ROLES])
    entity.props = ldaphelper.get_list(entry[ATTRIBUTES][global_ids.PROPS])
    return entity