You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@heyman I have created a test using the scenario of a user which should login, then get a list of orders from an API endpoint. My test will login and extract the authToken (verified by printing in console), but any subsequent requests get an error 'HTTP Error(u'401 Unauthorized for this url')'. Everything I've read suggests session persistence is built into the HttpLocust class. I have tried changing the order of the requests, combining them into a single task, etc. Can you provide some direction on this? Here's my code:
Note: I did try making the authToken global and changing the second request to 'self.client.get('/api/getOrdersEndpoint', {'auth_token': authToken}). I also tried extracting the cookies using response.cookies, then inserting into the second request in a similar fashion. These only got me a new error (get() allows only 2 parameters, 3 were supplied).
The text was updated successfully, but these errors were encountered:
I'm actually looking for an example of how to test endpoints behind OAuth2, as well. I'm very new to the tool, but I'm getting the 401 as well and it's not obvious how to get around it. Thanks!
@tiffanywilson: Locust persists cookies between requests, which is the most common way for web apps to keep track of users' sessions. However, if the web app that is being tested doesn't rely on cookies for sessions, the auth token must be provided in the way that the app expects.
@sweeneyb Very hard to say what might be causing it, but it's most likely not an issue with Locust.
Closing this issue, but feel free to re-open it if you have indications that there's some kind of bug or other issue in Locust.
@heyman I have created a test using the scenario of a user which should login, then get a list of orders from an API endpoint. My test will login and extract the authToken (verified by printing in console), but any subsequent requests get an error 'HTTP Error(u'401 Unauthorized for this url')'. Everything I've read suggests session persistence is built into the HttpLocust class. I have tried changing the order of the requests, combining them into a single task, etc. Can you provide some direction on this? Here's my code:
`from locust import HttpLocust, TaskSet, task
class UserBehavior(TaskSet):
class User(HttpLocust):
host = 'http://localhost:3000'
task_set = UserBehavior
min_wait = 5000
max_wait = 10000`
Note: I did try making the authToken global and changing the second request to 'self.client.get('/api/getOrdersEndpoint', {'auth_token': authToken}). I also tried extracting the cookies using response.cookies, then inserting into the second request in a similar fashion. These only got me a new error (get() allows only 2 parameters, 3 were supplied).
The text was updated successfully, but these errors were encountered: