Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def view_page_tree():
tree_request_id = locust.storage['tree_request_id'].replace('&', '&')
ancestors = locust.storage['ancestors']
root_page_id = locust.storage['root_page_id']
viewed_page_id = locust.storage['page_id']
space_key = locust.storage['space_key']
r = ''
# Page has parent
if locust.storage['has_no_root'] == 'false':
request = f"{tree_request_id}&hasRoot=true&pageId={root_page_id}&treeId=0&startDepth=0&mobile=false" \
f"&{ancestors}treePageId={viewed_page_id}&_={timestamp_int()}"
r = locust.client.get(f'{request}', catch_response=True)
# Page does not have parent
elif locust.storage['has_no_root'] == 'true':
request = f"{tree_request_id}&hasRoot=false&spaceKey={space_key}&treeId=0&startDepth=0&mobile=false" \
f"&{ancestors}treePageId={viewed_page_id}&_={timestamp_int()}"
r = locust.client.get(f'{request}', catch_response=True)
content = r.content.decode('utf-8')
if 'plugin_pagetree_children_span' not in content or 'plugin_pagetree_children_list' not in content:
logger.error(f'Could not view page tree: {content}')
assert 'plugin_pagetree_children_span' in content and 'plugin_pagetree_children_list' in content, \
'Could not view page tree.'
locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("975"),
TEXT_HEADERS, catch_response=True)
locust.client.get('/plugins/servlet/notifications-miniview', catch_response=True)
locust.client.get(f'/rest/watch-button/1.0/watchState/{content_id}?_={timestamp_int()}', catch_response=True)
locust.client.get(f'/rest/likes/1.0/content/{content_id}/likes?commentLikes=true&_={timestamp_int()}',
catch_response=True)
locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("995"),
TEXT_HEADERS, catch_response=True)
locust.client.get(f'/rest/highlighting/1.0/panel-items?pageId={content_id}&_={timestamp_int()}',
catch_response=True)
locust.client.get(f'/rest/inlinecomments/1.0/comments?containerId={content_id}&_={timestamp_int()}',
catch_response=True)
locust.client.get(f'/s/en_GB/{build_number}/{keyboard_hash}/_/images/icons/profilepics/add_profile_pic.svg',
catch_response=True)
locust.client.get('/rest/helptips/1.0/tips', catch_response=True)
locust.client.get(f'/rest/mywork/latest/status/notification/count?pageid={content_id}&_={timestamp_int()}',
catch_response=True)
locust.client.get(f'/plugins/editor-loader/editor.action?parentPageId=&pageId={content_id}'
f'&spaceKey={parsed_space_key}&atl_after_login_redirect={created_blog_title}'
f'&timeout=12000&_={timestamp_int()}', catch_response=True)
locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("1030"),
TEXT_HEADERS, catch_response=True)
locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("1035"),
TEXT_HEADERS, catch_response=True)
heartbeat_activity_body = {"dataType": "json",
"contentId": content_id,
"draftType": "blogpost",
"spaceKey": parsed_space_key,
"atl_token": atl_token
}
r = locust.client.post('/json/startheartbeatactivity.action', heartbeat_activity_body,
assignee = fetch_by_re(params.issue_assigneee_reporter_pattern, content, group_no=2)
reporter = fetch_by_re(params.issue_reporter_pattern, content)
if not (f' Edit Issue: [{issue_key}]' in content):
logger.error(f'{params.err_message_issue_not_found} - {issue_id}, {issue_key}: {content}')
assert f' Edit Issue: [{issue_key}]' in content, \
params.err_message_issue_not_found
logger.locust_info(f"{params.action_name}: Editing issue {issue_key}")
locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("705"),
TEXT_HEADERS, catch_response=True)
locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("710"),
TEXT_HEADERS, catch_response=True)
locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("720"),
TEXT_HEADERS, catch_response=True)
locust.client.get(f'/rest/internal/2/user/mention/search?issueKey={issue_key}'
f'&projectKey={project_key}&maxResults=10&_={timestamp_int()}', catch_response=True)
edit_body = f'id={issue_id}&summary={generate_random_string(15)}&issueType={issue_type}&priority={priority}' \
f'&dueDate=""&assignee={assignee}&reporter={reporter}&environment=""' \
f'&description={generate_random_string(500)}&timetracking_originalestimate=""' \
f'&timetracking_remainingestimate=""&isCreateIssue=""&hasWorkStarted=""&dnd-dropzone=""' \
f'&comment=""&commentLevel=""&atl_token={atl_token}&Update=Update'
locust.storage['edit_issue_body'] = edit_body
locust.storage['atl_token'] = atl_token
edit_issue_open_editor()
locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("1175"),
TEXT_HEADERS, catch_response=True)
locust.client.get(f'/rest/jira-metadata/1.0/metadata/aggregate?pageId={edit_page_id}&_={timestamp_int()}',
catch_response=True)
locust.client.get(f'/rest/likes/1.0/content/{edit_page_id}/likes?commentLikes=true&_={timestamp_int()}',
catch_response=True)
locust.client.get(f'/rest/highlighting/1.0/panel-items?pageId={edit_page_id}&_={timestamp_int()}',
catch_response=True)
locust.client.get(f'/rest/mywork/latest/status/notification/count?pageId={edit_page_id}&_={timestamp_int()}',
catch_response=True)
locust.client.get(f'/plugins/editor-loader/editor.action?parentPageId={edit_parent_page_id}'
f'&pageId={edit_page_id}&spaceKey={space_key}&atl_after_login_redirect=/pages/viewpage.action'
f'&timeout=12000&_={timestamp_int()}', catch_response=True)
locust.client.get(f'/rest/inlinecomments/1.0/comments?containerId={content_id}&_={timestamp_int()}',
catch_response=True)
locust.client.get(f'/rest/watch-button/1.0/watchState/{edit_page_id}?_={timestamp_int()}',
catch_response=True)
locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("1215"),
TEXT_HEADERS, catch_response=True)
locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("1220"),
TEXT_HEADERS, catch_response=True)
locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("1225"),
TEXT_HEADERS, catch_response=True)
locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("1230"),
TEXT_HEADERS, catch_response=True)
assert f'currentViewConfig\"{{\"id\":{board_id}', 'Could not open board'
locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("1000"),
TEXT_HEADERS, catch_response=True)
locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("1005"),
TEXT_HEADERS, catch_response=True)
locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("1010"),
TEXT_HEADERS, catch_response=True)
locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("1015"),
TEXT_HEADERS, catch_response=True)
locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("1020"),
TEXT_HEADERS, catch_response=True)
if project_key:
locust.client.get(f'/rest/api/2/project/{project_key}?_={timestamp_int()}', catch_response=True)
locust.client.get(f'/rest/greenhopper/1.0/xboard/toolSections?mode=work&rapidViewId={board_id}'
f'&selectedProjectKey={project_key}&_={timestamp_int()}', catch_response=True)
locust.client.get(f'/rest/greenhopper/1.0/xboard/work/allData.json?rapidViewId={board_id}'
f'&selectedProjectKey={project_key}&_={timestamp_int()}', catch_response=True)
if view_backlog:
locust.client.get(f'/rest/inline-create/1.0/context/bootstrap?query='
f'project%20%3D%20{project_key}%20ORDER%20BY%20Rank%20ASC&&_={timestamp_int()}',
catch_response=True)
else:
locust.client.get(f'/rest/greenhopper/1.0/xboard/toolSections?mode=work&rapidViewId={board_id}'
f'&_={timestamp_int()}', catch_response=True)
locust.client.get(f'/rest/greenhopper/1.0/xboard/work/allData.json?rapidViewId={board_id}'
f'&selectedProjectKey={project_key}', catch_response=True)
locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("1025"),
TEXT_HEADERS, catch_response=True)
locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("1030"),
TEXT_HEADERS, catch_response=True)
heartbeat_activity_body = {"dataType": "json",
"contentId": edit_content_id,
"draftType": "page",
"spaceKey": edit_space_key,
"atl_token": edit_atl_token
}
locust.client.post('/json/startheartbeatactivity.action', heartbeat_activity_body,
TEXT_HEADERS, catch_response=True)
expand = 'history.createdBy.status%2Chistory.contributors.publishers.users.status' \
'%2Cchildren.comment.version.by.status'
locust.client.get(f'/rest/api/content/{edit_page_id}?expand={expand}&_={timestamp_int()}',
catch_response=True)
locust.client.get(f'/rest/emoticons/1.0/_={timestamp_int()}', catch_response=True)
locust.client.post('/json/startheartbeatactivity.action', heartbeat_activity_body,
TEXT_HEADERS, catch_response=True)
locust.client.get(f'/rest/ui/1.0/content/{edit_page_id}/labels?_={timestamp_int()}', catch_response=True)
locust.client.get('/rest/mywork/latest/status/notification/count', catch_response=True)
locust.client.post('/json/startheartbeatactivity.action', heartbeat_activity_body,
TEXT_HEADERS, catch_response=True)
locust.client.get(f'/rest/likes/1.0/content/{parsed_page_id}/likes?commentLikes=true&_={timestamp_int()}',
catch_response=True)
locust.client.get(f'/rest/highlighting/1.0/panel-items?pageId={parsed_page_id}&_={timestamp_int()}',
catch_response=True)
locust.client.get(f'/rest/mywork/latest/status/notification/count?pageId={parsed_page_id}&_={timestamp_int()}',
catch_response=True)
r = locust.client.get(f'/rest/inlinecomments/1.0/comments?containerId={parsed_page_id}&_={timestamp_int()}',
catch_response=True)
content = r.content.decode('utf-8')
if 'authorDisplayName' not in content and '[]' not in content:
logger.error(f'Could not open comments for page {parsed_page_id}: {content}')
assert 'authorDisplayName' in content or '[]' in content, 'Could not open comments for page.'
locust.client.get(f'/plugins/editor-loader/editor.action?parentPageId={parent_page_id}&pageId={parsed_page_id}'
f'&spaceKey={space_key}&atl_after_login_redirect=/pages/viewpage.action'
f'&timeout=12000&_={timestamp_int()}', catch_response=True)
locust.client.get(f'/rest/watch-button/1.0/watchState/{parsed_page_id}?_={timestamp_int()}',
catch_response=True)
locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("145"),
TEXT_HEADERS, catch_response=True)
locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("150"),
TEXT_HEADERS, catch_response=True)
locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("155"),
TEXT_HEADERS, catch_response=True)
locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("160"),
TEXT_HEADERS, catch_response=True)
locust.client.get(f'/rest/likes/1.0/content/{create_page_id}/likes?commentLikes=true&_={timestamp_int()}',
catch_response=True)
locust.client.get(f'/rest/inlinecomments/1.0/comments?containerId={create_page_id}&_={timestamp_int()}',
catch_response=True)
locust.client.get(f'/rest/mywork/latest/status/notification/count?pageid={create_page_id}&_={timestamp_int()}',
catch_response=True)
locust.client.get(f'/rest/highlighting/1.0/panel-items?pageId={create_page_id}&_={timestamp_int()}',
catch_response=True)
locust.client.get(f'/rest/watch-button/1.0/watchState/{create_page_id}?_={timestamp_int()}',
catch_response=True)
locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("830"),
TEXT_HEADERS, catch_response=True)
locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("835"),
TEXT_HEADERS, catch_response=True)
r = locust.client.get(f'/plugins/editor-loader/editor.action?parentPageId={parent_page_id}'
f'&pageId={create_page_id}&spaceKey={space_key}'
f'&atl_after_login_redirect={page_title}&timeout=12000&_={timestamp_int()}',
catch_response=True)
content = r.content.decode('utf-8')
if page_title not in content:
logger.error(f'Page editor load failed for page {page_title}: {content}')
assert page_title in content, 'Page editor load failed for page.'
locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("845"),
TEXT_HEADERS, catch_response=True)
locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("850"),
TEXT_HEADERS, catch_response=True)
locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("855"),
TEXT_HEADERS, catch_response=True)
locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("1000"),
TEXT_HEADERS, catch_response=True)
locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("1005"),
TEXT_HEADERS, catch_response=True)
locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("1010"),
TEXT_HEADERS, catch_response=True)
locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("1015"),
TEXT_HEADERS, catch_response=True)
locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("1020"),
TEXT_HEADERS, catch_response=True)
if project_key:
locust.client.get(f'/rest/api/2/project/{project_key}?_={timestamp_int()}', catch_response=True)
locust.client.get(f'/rest/greenhopper/1.0/xboard/toolSections?mode=work&rapidViewId={board_id}'
f'&selectedProjectKey={project_key}&_={timestamp_int()}', catch_response=True)
locust.client.get(f'/rest/greenhopper/1.0/xboard/work/allData.json?rapidViewId={board_id}'
f'&selectedProjectKey={project_key}&_={timestamp_int()}', catch_response=True)
if view_backlog:
locust.client.get(f'/rest/inline-create/1.0/context/bootstrap?query='
f'project%20%3D%20{project_key}%20ORDER%20BY%20Rank%20ASC&&_={timestamp_int()}',
catch_response=True)
else:
locust.client.get(f'/rest/greenhopper/1.0/xboard/toolSections?mode=work&rapidViewId={board_id}'
f'&_={timestamp_int()}', catch_response=True)
locust.client.get(f'/rest/greenhopper/1.0/xboard/work/allData.json?rapidViewId={board_id}'
f'&selectedProjectKey={project_key}', catch_response=True)
locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("1025"),
TEXT_HEADERS, catch_response=True)
locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("1030"),
TEXT_HEADERS, catch_response=True)
if view_backlog:
locust.client.get(f'/rest/greenhopper/1.0/rapidviewconfig/editmodel.json?rapidViewId={board_id}'
raise Exception('Please check server hostname in jira.yml file')
content = r.content.decode('utf-8')
locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("110"),
TEXT_HEADERS, catch_response=True)
locust.client.post("/plugins/servlet/gadgets/dashboard-diagnostics",
{"uri": f"{locust.client.base_url.lower()}/secure/Dashboard.jspa"},
TEXT_HEADERS, catch_response=True)
locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("120"),
TEXT_HEADERS, catch_response=True)
locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("125"),
TEXT_HEADERS, catch_response=True)
locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("130"),
TEXT_HEADERS, catch_response=True)
locust.client.get(f'/rest/activity-stream/1.0/preferences?_={timestamp_int()}', catch_response=True)
locust.client.get(f'/rest/gadget/1.0/issueTable/jql?num=10&tableContext=jira.table.cols.dashboard'
f'&addDefault=true&enableSorting=true&paging=true&showActions=true'
f'&jql=assignee+%3D+currentUser()+AND'
f'+resolution+%3D+unresolved+ORDER+BY+priority+DESC%2C+created+ASC'
f'&sortBy=&startIndex=0&_={timestamp_int()}', catch_response=True)
locust.client.get(f'/plugins/servlet/streams?maxResults=5&relativeLinks=true&_={timestamp_int()}',
catch_response=True)
# Assertions
token = fetch_by_re(params.atl_token_pattern, content)
if not (f'title="loggedInUser" value="{user[0]}">' in content):
logger.error(f'User {user[0]} authentication failed: {content}')
assert f'title="loggedInUser" value="{user[0]}">' in content, 'User authentication failed'
locust.user = user[0]
locust.atl_token = token
locust.storage = dict() # Define locust storage dict for getting cross-functional variables access
logger.locust_info(f"{params.action_name}: User {user[0]} logged in with atl_token: {token}")