def process_role(args): role = load_entity(Role(), args) print(args.entity + ' ' + args.operation) if not args.name: print("error --name required for entity role") return False elif args.operation == ADD: constraint = load_entity(Constraint(), args) role.constraint = constraint admin.add_role(role) elif args.operation == UPDATE: constraint = load_entity(Constraint(), args) role.constraint = constraint admin.update_role(role) elif args.operation == DELETE: admin.delete_role(role) elif args.operation == READ: print_role(review.read_role(role), role.name) pass elif args.operation == SEARCH: role.name += '*' roles = review.find_roles(role) if len(roles) > 0: for idx, rle in enumerate(roles): print_role(rle, role.name + ':' + str(idx)) else: print_ln('No matching records found matching filter: ' + role.name) else: print('process_role failed, invalid operation=' + args.operation) return False return True
def test_search_roles(self): """ Test the role search by name in ldap """ print_ln('test search roles by name') try: rle = Role(name = 'oam*') rList = roledao.search(rle) for idx, entity in enumerate(rList) : print_role(entity, "Role[" + str(idx+1) + "]:") except Exception as e: self.fail('role search failed, exception=' + e.msg)
def test_create_roles(self): """ Test the role create """ print_ln('test create roles') rls = role_test_data.get_test_roles('py-test', 10) for rle in rls: try: rle = roledao.create(rle) print_role(rle, "Role Create") except Exception as e: self.fail('role create failed, exception=' + e.msg)
def test07_add_role(self): """ Test the add role method """ print_ln('test_add_role') rles = role_test_data.get_test_roles('py-role', 10) for rle in rles: try: entity = admin.add_role(rle) print_role(entity, "Add Role") except Exception as e: self.fail('test_add_role failed, exception=' + e.msg)
def test_update_roles(self): """ Test the role update """ print_ln('test update roles') rls = role_test_data.get_test_roles('py-test', 10) for rle in rls: rle.description += '-updated' try: rle = roledao.update(rle) print_role(rle, "Role Update") except Exception as e: self.fail('role update failed, exception=' + e.msg)