Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how can I send https request with locust when I already have been authentication.. #966

Closed
turgayh opened this issue Feb 20, 2019 · 3 comments

Comments

@turgayh
Copy link

turgayh commented Feb 20, 2019

Description of issue / feature request

Hi .. I'm working about load testing and I'm beginner.

İ want to get request a page that protected (login required)..

My code

from locust import HttpLocust, TaskSet, task

class WebsiteTasks(TaskSet):
    def on_start(self):
        self.login()
    def login(self):
        response = self.client.get("/admin/")
        csrftoken = response.cookies['csrftoken']
        response = self.client.post("/admin/", 
                                    {"username": "hakantrg",
                                     "password": "123456"},
                                    headers={"X-CSRFToken": csrftoken})
        #self.client.get('/polls', cookies=response.cookies)
        #print(response.cookies)
        return response
    @task
    def user_workflow(self):
        self.login()
        self.index()
        self.about()

    def index(self):
        self.client.get("/")
        
    def about(self):
        self.client.get('/polls', cookies=self.locust.client.cookies.get_dict())
    #@task


class WebsiteUser(HttpLocust):
    task_set = WebsiteTasks
    host = "http://localhost:8000"
    min_wait = 5000
    max_wait = 15000

Expected behavior

I try to success request .

Actual behavior

# fails | Method | Name | Type
-- | -- | -- | --
7 | GET | / | HTTPError('404 Client Error: Not Found for url: http://localhost:8000/',)
7 | GET | /polls | HTTPError('404 Client Error: Not Found for url: http://localhost:8000/accounts/login/?next=/polls/',)

Environment settings (for bug reports)

  • OS:Wİndows 10
  • Python version:3.5
  • Locust version: 0.9.0

Steps to reproduce (for bug reports)

TBD - example code appreciated

@cgoldberg
Copy link
Member

The details will depend on your application under test.

closing.. this is a general question, not a bug/issue.

@anm237
Copy link

anm237 commented Nov 22, 2020

My application accepts only HTTPS traffic. While load testing, I faced this error on the console.

"HTTPError('404 Client Error: Not Found for url: https://[MY_ENDPOINT_URL]/healthcheck')"

Is this because locust tries to send an HTTP request to the application endpoint and it is getting rejected

@heyman
Copy link
Member

heyman commented Nov 23, 2020

@anm237 No, that doesn't sounds like it's related to HTTPS. The HTTPError exception does not imply that plain HTTP is used. It sounds like the URL you're requesting returns a 404 Not Found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants