How to use the locustio.common_utils.TEXT_HEADERS function in locustio

To help you get started, we’ve selected a few locustio examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github atlassian / dc-app-performance-toolkit / app / locustio / jira / http_actions.py View on Github external
def login_and_view_dashboard(locust):
    params = Login()

    user = random.choice(jira_dataset["users"])
    body = params.login_body
    body['os_username'] = user[0]
    body['os_password'] = user[1]

    locust.client.post('/login.jsp', body, TEXT_HEADERS, catch_response=True)
    r = locust.client.get('/', catch_response=True)
    if not r.content:
        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)
github atlassian / dc-app-performance-toolkit / app / locustio / confluence / http_actions.py View on Github external
def login_and_view_dashboard(locust):
    params = Login()

    user = random.choice(confluence_dataset["users"])
    username = user[0]
    password = user[1]

    login_body = params.login_body
    login_body['os_username'] = username
    login_body['os_password'] = password
    locust.client.post('/dologin.action', login_body, TEXT_HEADERS, catch_response=True)
    r = locust.client.get('/', catch_response=True)
    content = r.content.decode('utf-8')
    if 'Log Out' not in content:
        logger.error(f'Login with {username}, {password} failed: {content}')
    assert 'Log Out' in content, 'User authentication failed.'
    logger.locust_info(f'User {username} is successfully logged in')
    keyboard_hash = fetch_by_re(params.keyboard_hash_re, content)
    build_number = fetch_by_re(params.build_number_re, content)
    locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("010"),
                       TEXT_HEADERS, catch_response=True)
    locust.client.get('/rest/mywork/latest/status/notification/count', catch_response=True)
    locust.client.get(f'/rest/shortcuts/latest/shortcuts/{build_number}/{keyboard_hash}', catch_response=True)
    locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("025"),
                       TEXT_HEADERS, catch_response=True)
    locust.client.get(f'/rest/experimental/search?cql=type=space%20and%20space.type=favourite%20order%20by%20favourite'
                      f'%20desc&expand=space.icon&limit=100&_={timestamp_int()}', catch_response=True)
github atlassian / dc-app-performance-toolkit / app / locustio / jira / http_actions.py View on Github external
def add_comment_open_comment():
        r = locust.client.get(f'/secure/AddComment!default.jspa?id={issue_id}', catch_response=True)
        content = r.content.decode('utf-8')
        token = fetch_by_re(params.atl_token_pattern, content)
        form_token = fetch_by_re(params.form_token_pattern, content)
        if not (f'Add Comment: {issue_key}' in content):
            logger.error(f'Could not open comment in the {issue_key} issue: {content}')
        assert f'Add Comment: {issue_key}' in content, 'Could not open comment in the issue'

        locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("805"),
                           TEXT_HEADERS, catch_response=True)
        locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("810"),
                           TEXT_HEADERS, catch_response=True)
        locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("820"),
                           TEXT_HEADERS, catch_response=True)
        locust.client.get(f'/rest/internal/2/user/mention/search?issueKey={issue_key}&projectKey={project_key}'
                          f'&maxResults=10&_={timestamp_int()}', catch_response=True)
        locust.storage['token'] = token
        locust.storage['form_token'] = form_token
    add_comment_open_comment()
github atlassian / dc-app-performance-toolkit / app / locustio / confluence / http_actions.py View on Github external
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)
github atlassian / dc-app-performance-toolkit / app / locustio / confluence / http_actions.py View on Github external
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)
github atlassian / dc-app-performance-toolkit / app / locustio / confluence / http_actions.py View on Github external
"representation": "storage",
                                  "content": {
                                    "id": f"{content_id}"
                                  }
                                }
                              },
                              "id": f"{content_id}",
                              "type": "page",
                              "version": {
                                "number": f"{edit_page_version}"
                              }
                            }
        TEXT_HEADERS['Content-Type'] = 'application/json'
        TEXT_HEADERS['X-Requested-With'] = 'XMLHttpRequest'
        r = locust.client.put(f'/rest/api/content/{content_id}?status=draft', json=edit_page_body,
                              headers=TEXT_HEADERS, catch_response=True)
        content = r.content.decode('utf-8')

        if 'history' not in content:
            logger.info(f'Could not edit page. Response content: {content}')
        if 'history' not in content:
            logger.error(f'User {locust.user} could not edit page {content_id}, '
                         f'parent page id: {edit_parent_page_id}: {content}')
        assert 'history' in content, \
               'User could not edit page.'

        r = locust.client.get(f'/pages/viewpage.action?pageId={edit_page_id}', catch_response=True)
        content = r.content.decode('utf-8')
        if not('last-modified' in content and 'Created by' in content):
            logger.error(f"Could not open page {edit_page_id}: {content}")
        assert 'last-modified' in content and 'Created by' in content, "Could not open page to edit."
github atlassian / dc-app-performance-toolkit / app / locustio / jira / http_actions.py View on Github external
url = f'/secure/RapidBoard.jspa?rapidView={board_id}&view=planning'
    else:
        url = f'/secure/RapidBoard.jspa?rapidView={board_id}'

    r = locust.client.get(url, catch_response=True)
    content = r.content.decode('utf-8')
    project_key = fetch_by_re(params.project_key_pattern, content)
    project_id = fetch_by_re(params.project_id_pattern, content)
    project_plan = fetch_by_re(params.project_plan_pattern, content, group_no=2)
    if project_plan:
        project_plan = project_plan.replace('\\', '')
    logger.locust_info(f"{params.action_name}: key = {project_key}, id = {project_id}, plan = {project_plan}")
    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:
github atlassian / dc-app-performance-toolkit / app / locustio / jira / http_actions.py View on Github external
def add_comment_save_comment():
        r = locust.client.post(f'/secure/AddComment.jspa?atl_token={locust.storage["token"]}',
                               params={"id": {issue_id}, "formToken": locust.storage["form_token"],
                                       "dnd-dropzone": None, "comment": generate_random_string(20),
                                       "commentLevel": None, "atl_token": locust.storage["token"],
                                       "Add": "Add"}, headers=TEXT_HEADERS, catch_response=True)
        content = r.content.decode('utf-8')
        if not (f'' in content):
            logger.error(f'Could not save comment: {content}')
        assert f'' in content, 'Could not save comment'
    add_comment_save_comment()