def get_role(self, rolename): secClient1 = SecurityClient(base_url, username1, password1) try: secClient1.get_role(rolename) except Exception, exception: message = exception #"Role not found" raise AssertionError(message)
def create_role(self, rolename, roledisplayname, roledescription, issystemrole): secClient1 = SecurityClient(base_url, username1, password1, 'xml') try: secClient1.create_role(rolename, roledisplayname, roledescription, issystemrole) role1 = secClient1.get_role(rolename) role1name = str(role1.name) role1dispname = str(role1.displayName) role1desc = str(role1.description) systemrole = str(role1.systemRole) if systemrole == 'True': systemrole = 'true' else: systemrole = 'false' if role1name != rolename: message = "role name doesn't match" raise AssertionError(message) elif role1dispname != roledisplayname: message = "role display name doesn't match" raise AssertionError(message) elif role1desc != roledescription: message = "role description doesn't match" raise AssertionError(message) elif systemrole != issystemrole: message = "system role flag doesn't match" raise AssertionError(message) else: print "created role validated" except Exception, exception: message = exception #"Role not found" raise AssertionError(message)
def add_role_permission(self, rolename, permissionname): secClient1 = SecurityClient(base_url, username1, password1) try: secClient1.add_role_permission(rolename, permissionname) role1 = secClient1.get_role(rolename) role1permissions = role1.permissions role1permissionnames = str(role1permissions.name) if permissionname in role1permissionnames: print "permission '%s' added to role" % permissionname else: message = "permission '%s' not added to role" % permissionname raise AssertionError(message) except Exception, exception: message = exception #"Permission not added to role" raise AssertionError(message)
def update_role_and_expect_error(self, rolename, roledescription): secClient1 = SecurityClient(base_url, username1, password1) try: role1 = secClient1.get_role(rolename) role1name = str(role1.name) role1desc = str(role1.description) secClient1.update_role(rolename, roledescription) message = "role updated" raise AssertionError(message) except AssertionError: raise AssertionError(message) except Exception, exception: if role1name != rolename: message = "role name has been updated" raise AssertionError(message) elif role1desc != roledescription: message = "role description has been updated" raise AssertionError(message)