'Locust cannot maintain Session in HTTPS
I have a Locustfile in which I perform authentication, like so:
def on_start(self):
response = self.client.get('/login-page/url')
csrftoken = response.cookies['csrftoken']
credentials = {
"username":"username",
"password":"password"
}
self.client.post("/login-page/url'", data=credentials, headers={'X-CSRFToken':csrftoken})
Since Locust suports cookies, in all subsequent requests/tasks I should have my "user" logged in.
My Locustfile is basically made of tasks like this one:
@task
def some-task(self):
with self.client.get("/some/path", allow_redirects=False, catch_response=True) as response:
if response.status_code == 302:
response.failure("You were redirected")
Here, after the request is sent I check for errors using the status code. If it's 302 that means the user was redirected because the authentication failed.
All tasks are running without errors ("Fail" column in the GUI) except in one of my websites which uses HTTPS.
I tried changing to HTTP, with the same site, and the tasks worked again.
I looked through Locust's docs and in SO but until now no proper answers. I'd really like to know why this happens and how can I overcome this.
Thank you.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
