def test_raise_error_for_bad_project(): """ will raise JiraProxyError when project does not exist """ jp = JiraProxy(GOOD_VANILLA_SERVER_CONFIG) with py.test.raises(JiraProxyError) as excinfo: issue_key = jp.getPermissions(BAD_PROJECT_KEY_1) actualErrorMessage = excErrorMessage(excinfo) assert 'Could not find project for identifier:' in actualErrorMessage
def test_get_permissions_associated_with_project_name(): """ will return permissions for a user for a project identified by project name """ jp = JiraProxy(GOOD_VANILLA_SERVER_CONFIG) permissions = jp.getPermissions(PROJECT_NAME_1) assert permissions is not None assert len(permissions) > 3 assert 'EDIT_ISSUE' in permissions assert 'CREATE_ISSUE' in permissions assert 'RESOLVE_ISSUE' in permissions
def test_get_permissions_associated_with_project_key(): """ will return permissions for a user in a project """ jp = JiraProxy(GOOD_VANILLA_SERVER_CONFIG) permissions = jp.getPermissions(PROJECT_KEY_1) assert permissions is not None assert len(permissions) > 3 assert 'EDIT_ISSUE' in permissions assert 'CREATE_ISSUE' in permissions assert 'RESOLVE_ISSUE' in permissions
def main(args): config = REG_USER_CONFIG jira = JiraProxy(config) permissions = jira.getPermissions(PROJECT_KEY) permission_keys = sorted(permissions.keys()) #each permission value has id, key, name, description, and havePermission attributes have_permissions = [ key for key, perm in permissions.items() if perm['havePermission'] ] lack_permissions = [ key for key, perm in permissions.items() if not perm['havePermission'] ] #have_permissions = permissions.collect{|name, permission| permission} # .select{|p| p['havePermission']} #lack_permissions = permissions.collect{|name, permission| permission} # .select{|p| !p['havePermission']} print("") print(f"In {config['url']} the login user {config['user']} \n" f"HAS these permissions for the project: {PROJECT_KEY}") for perm_key in permission_keys: if perm_key in have_permissions: perm_name = permissions[perm_key]['name'] print(f"{perm_key:<32.32} {perm_name}") print("\n\n") print(f"In {config['url']} the login user {config['user']} \n" f"LACKS these permissions for the project: {PROJECT_KEY}") for perm_key in permission_keys: if perm_key in lack_permissions: perm_name = permissions[perm_key]['name'] print(f"{perm_key:<32.32} {perm_name}") print("")