How to use the locustio.common_utils.generate_random_string 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
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()
github atlassian / dc-app-performance-toolkit / app / locustio / jira / requests_params.py View on Github external
def prepare_issue_body(issue_body_dict: dict, user):
        description = f"Locust description {generate_random_string(20)}"
        summary = f"Locust summary {generate_random_string(10)}"
        environment = f'Locust environment {generate_random_string(10)}'
        duedate = ""
        reporter = user
        timetracking_originalestimate = ""
        timetracking_remainingestimate = ""
        is_create_issue = "true"
        has_work_started = ""
        project_id = issue_body_dict['project_id']
        atl_token = issue_body_dict['atl_token']
        form_token = issue_body_dict['form_token']
        issue_type = issue_body_dict['issue_type']
        resolution_done = issue_body_dict['resolution_done']
        fields_to_retain = issue_body_dict['fields_to_retain']
        custom_fields_to_retain = issue_body_dict['custom_fields_to_retain']
github atlassian / dc-app-performance-toolkit / app / locustio / jira / requests_params.py View on Github external
def prepare_issue_body(issue_body_dict: dict, user):
        description = f"Locust description {generate_random_string(20)}"
        summary = f"Locust summary {generate_random_string(10)}"
        environment = f'Locust environment {generate_random_string(10)}'
        duedate = ""
        reporter = user
        timetracking_originalestimate = ""
        timetracking_remainingestimate = ""
        is_create_issue = "true"
        has_work_started = ""
        project_id = issue_body_dict['project_id']
        atl_token = issue_body_dict['atl_token']
        form_token = issue_body_dict['form_token']
        issue_type = issue_body_dict['issue_type']
        resolution_done = issue_body_dict['resolution_done']
        fields_to_retain = issue_body_dict['fields_to_retain']
        custom_fields_to_retain = issue_body_dict['custom_fields_to_retain']

        request_body = f"pid={project_id}&issuetype={issue_type}&atl_token={atl_token}&formToken={form_token}" \
github atlassian / dc-app-performance-toolkit / app / locustio / confluence / http_actions.py View on Github external
def search_cql():
        r = locust.client.get(f"/rest/api/search?cql=siteSearch~'{generate_random_string(3, only_letters=True)}'"
                              f"&start=0&limit=20", catch_response=True)
        if '{"results":[' not in r.content.decode('utf-8'):
            logger.locust_info(r.content.decode('utf-8'))
        content = r.content.decode('utf-8')
        if 'results' not in content:
            logger.error(f"Search cql failed: {content}")
        assert 'results' in content, "Search cql failed."
        locust.client.get('/rest/mywork/latest/status/notification/count', catch_response=True)
github atlassian / dc-app-performance-toolkit / app / locustio / confluence / http_actions.py View on Github external
def comment_page(locust):
    page = random.choice(confluence_dataset["pages"])
    page_id = page[0]
    comment = f'<p>{generate_random_string(length=15, only_letters=True)}</p>'
    uid = str(uuid.uuid4())
    r = locust.client.post(f'/rest/tinymce/1/content/{page_id}/comment?actions=true',
                           params={'html': comment, 'watch': True, 'uuid': uid}, headers=NO_TOKEN_HEADERS,
                           catch_response=True)
    content = r.content.decode('utf-8')
    if not('reply-comment' in content and 'edit-comment' in content):
        logger.error(f'Could not add comment: {content}')
    assert 'reply-comment' in content and 'edit-comment' in content, 'Could not add comment.'
github atlassian / dc-app-performance-toolkit / app / locustio / confluence / http_actions.py View on Github external
def create_page():
        draft_name = f"{generate_random_string(10, only_letters=True)}"
        content_id = locust.storage['content_id']
        atl_token = locust.storage['atl_token']
        create_page_body = {
                            "status": "current",
                            "title": f"Test Performance JMeter {draft_name}",
                            "space": {"key": f"{space_key}"},
                            "body": {
                              "storage": {
                                "value": f"Test Performance Create Page Content {draft_name}",
                                "representation": "storage",
                                "content": {
                                  "id": f"{content_id}"
                                }
                              }
                            },
                            "id": f"{content_id}",
github atlassian / dc-app-performance-toolkit / app / locustio / confluence / http_actions.py View on Github external
def edit_page():
        locust.storage['draft_name'] = f"{generate_random_string(10, only_letters=True)}"
        edit_parent_page_id = locust.storage['edit_parent_page_id']
        edit_page_id = locust.storage['edit_page_id']
        content_id = locust.storage['edit_content_id']
        edit_page_version = int(locust.storage['edit_page_version']) + 1
        edit_atl_token = locust.storage['atl_token']
        edit_page_body = dict()

        if edit_parent_page_id:
            edit_page_body = {
                  "status": "current",
                  "title": f"Test Performance Edit with locust {locust.storage['draft_name']}",
                  "space": {
                    "key": f"{space_key}"
                  },
                  "body": {
                    "storage": {
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()
github atlassian / dc-app-performance-toolkit / app / locustio / confluence / http_actions.py View on Github external
TEXT_HEADERS, catch_response=True)
        content = r.content.decode('utf-8')
        if atl_token not in content:
            logger.error(f'Token {atl_token} not found in content: {content}')
        assert atl_token in content, 'Token not found in content.'

        contributor_hash = fetch_by_re(params.contribution_hash, content)
        locust.storage['contributor_hash'] = contributor_hash

        r = locust.client.get(f'/rest/ui/1.0/content/{content_id}/labels', catch_response=True)
        content = r.content.decode('utf-8')
        if '"success":true' not in content:
            logger.error(f'Could not get labels for content {content_id}: {content}')
        assert '"success":true' in content, 'Could not get labels for content in blog editor.'

        draft_name = f"Performance Blog - {generate_random_string(10, only_letters=True)}"
        locust.storage['draft_name'] = draft_name
        locust.storage['parsed_space_key'] = parsed_space_key
        locust.storage['content_id'] = content_id
        locust.storage['atl_token'] = atl_token

        draft_body = {"draftId": content_id,
                      "pageId": "0",
                      "type": "blogpost",
                      "title": draft_name,
                      "spaceKey": parsed_space_key,
                      "content": "<p>test blog draft</p>",
                      "syncRev": "0.mcPCPtDvwoayMR7zvuQSbf8.27"}

        TEXT_HEADERS['Content-Type'] = 'application/json'
        r = locust.client.post('/rest/tinymce/1/drafts', json=draft_body, headers=TEXT_HEADERS, catch_response=True)
        content = r.content.decode('utf-8')