Skip to content

Commit b4c650b

Browse files
author
admin
committed
fix for common_utils
1 parent 0b8a9d6 commit b4c650b

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

app/locustio/common_utils.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@
8383

8484
JIRA_TOKEN_PATTERN = r'name="atlassian-token" content="(.+?)">'
8585
CONFLUENCE_TOKEN_PATTERN = r'"ajs-atl-token" content="(.+?)"'
86+
CONFLUENCE_KEYBOARD_HASH_RE = 'name=\"ajs-keyboardshortcut-hash\" content=\"(.*?)\">'
87+
CONFLUENCE_BUILD_NUMBER_RE = 'meta name=\"ajs-build-number\" content=\"(.*?)\"'
8688

8789
JIRA = 'jira'
8890
JSM = 'jsm'
@@ -389,6 +391,25 @@ def do_confluence_login(locust, usr, pwd):
389391
json=login_body,
390392
headers=headers,
391393
catch_response=True)
394+
r = locust.get(url='/', catch_response=True)
395+
content = r.content.decode('utf-8')
396+
397+
if 'Log Out' not in content:
398+
print(f'Login with {usr}, {pwd} failed: {content}')
399+
assert 'Log Out' in content, 'User authentication failed.'
400+
print(f'User {usr} is successfully logged in back')
401+
keyboard_hash = fetch_by_re(CONFLUENCE_KEYBOARD_HASH_RE, content)
402+
build_number = fetch_by_re(CONFLUENCE_BUILD_NUMBER_RE, content)
403+
token = fetch_by_re(locust.session_data_storage['token_pattern'], content)
404+
405+
# 20 index.action
406+
locust.get('/index.action', catch_response=True)
407+
408+
locust.session_data_storage['build_number'] = build_number
409+
locust.session_data_storage['keyboard_hash'] = keyboard_hash
410+
locust.session_data_storage['username'] = usr
411+
locust.session_data_storage['password'] = pwd
412+
locust.session_data_storage['token'] = token
392413

393414

394415
def do_login_jira(locust, usr, pwd):

0 commit comments

Comments
 (0)