Skip to content

Commit bb1ed3f

Browse files
Merge pull request #1770 from atlassian/websudo-jira-locust-app-specific
added websudo for jira locust
2 parents 226f625 + 110fb97 commit bb1ed3f

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

app/extension/jira/extension_locust.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55

66

77
@jira_measure("locust_app_specific_action")
8-
# @run_as_specific_user(username='admin', password='admin') # run as specific user
8+
# WebSudo is a feature that enhances security by requiring administrators to re-authenticate before
9+
# accessing administrative functions within Atlassian applications.
10+
# do_websudo=True requires user administrative rights, otherwise requests fail.
11+
#@run_as_specific_user(username='admin', password='admin', do_websudo=False) # run as specific user
912
def app_specific_action(locust):
1013
r = locust.get('/app/get_endpoint', catch_response=True) # call app-specific GET endpoint
1114
content = r.content.decode('utf-8') # decode response content

app/locustio/common_utils.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -419,12 +419,9 @@ def do_confluence_login(locust, usr, pwd, do_websudo=False):
419419
}
420420
system_info_html = locust.post(url='/doauthenticate.action', data=auth_body,
421421
headers={'X-Atlassian-Token': 'no-check'}, catch_response=True)
422-
print(system_info_html.content.decode('utf-8'))
423422

424423

425-
426-
427-
def do_login_jira(locust, usr, pwd):
424+
def do_login_jira(locust, usr, pwd, do_websudo=False):
428425
locust.client.cookies.clear()
429426
body = LOGIN_BODY
430427
body['os_username'] = usr
@@ -468,6 +465,16 @@ def do_login_jira(locust, usr, pwd):
468465
token = fetch_by_re(locust.session_data_storage['token_pattern'], content)
469466
locust.session_data_storage["token"] = token
470467

468+
if do_websudo:
469+
auth_body = {
470+
'webSudoDestination': '/secure/admin/ViewSystemInfo.jspa',
471+
'webSudoIsPost': False,
472+
'webSudoPassword': pwd,
473+
'atl_token': locust.session_data_storage["token"]
474+
}
475+
system_info_html = locust.post(url='/secure/admin/WebSudoAuthenticate.jspa', data=auth_body,
476+
headers={'X-Atlassian-Token': 'no-check'}, catch_response=True)
477+
471478

472479
def run_as_specific_user(username=None, password=None, do_websudo=False):
473480
if not (username and password):
@@ -500,7 +507,7 @@ def wrapper(*args, **kwargs):
500507

501508
# send requests by the specific user
502509
if app == JIRA or (app == JSM and app_type == TYPE_AGENT):
503-
do_login_jira(locust, username, password)
510+
do_login_jira(locust, username, password, do_websudo)
504511
func(*args, **kwargs)
505512
do_login_jira(locust, session_user_name, session_user_password)
506513

0 commit comments

Comments
 (0)