Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def like_page(locust):
params = LikePage()
page = random.choice(confluence_dataset["pages"])
page_id = page[0]
JSON_HEADERS['Origin'] = CONFLUENCE_SETTINGS.server_url
r = locust.client.get(f'/rest/likes/1.0/content/{page_id}/likes', headers=JSON_HEADERS, catch_response=True)
content = r.content.decode('utf-8')
like = fetch_by_re(params.like_re, content)
if like is None:
r = locust.client.post(f'/rest/likes/1.0/content/{page_id}/likes', headers=JSON_HEADERS, catch_response=True)
else:
r = locust.client.delete(f'/rest/likes/1.0/content/{page_id}/likes', catch_response=True)
content = r.content.decode('utf-8')
if 'likes' not in content:
logger.error(f"Could not set like to the page {page_id}: {content}")
assert 'likes' in r.content.decode('utf-8'), 'Could not set like to the page.'
def like_page(locust):
params = LikePage()
page = random.choice(confluence_dataset["pages"])
page_id = page[0]
JSON_HEADERS['Origin'] = CONFLUENCE_SETTINGS.server_url
r = locust.client.get(f'/rest/likes/1.0/content/{page_id}/likes', headers=JSON_HEADERS, catch_response=True)
content = r.content.decode('utf-8')
like = fetch_by_re(params.like_re, content)
if like is None:
r = locust.client.post(f'/rest/likes/1.0/content/{page_id}/likes', headers=JSON_HEADERS, catch_response=True)
else:
r = locust.client.delete(f'/rest/likes/1.0/content/{page_id}/likes', catch_response=True)
content = r.content.decode('utf-8')
if 'likes' not in content:
logger.error(f"Could not set like to the page {page_id}: {content}")
assert 'likes' in r.content.decode('utf-8'), 'Could not set like to the page.'