Skip to content

HTTP

This task performs a HTTP request to a specified endpoint.

This is useful if the scenario is using a non-HTTP user or a request to a URL other than the one under testing is needed, e.g. for testdata.

Step implementations

Arguments

  • direction RequestDirection - only RequestDirection.FROM is implemented

  • endpoint str - URL to perform GET request from

  • name str - name used in locust statistics

Authentication

To enable authentication for HttpClientTask the auth context tree has to be correctly set. This is done by using step_setup_set_context_variable where the branches are prefixed with <host>/, e.g.:

And value for variable "foobar" is "none"
And value for variable "url" is "https://www.example.com/api/test"
And set context variable "www.example.com/auth.user.username" to "bob"
And set context variable "www.example.com/auth.user.password" to "password"
And set context variable "www.example.com/auth.user.redirect_uri" to "/authenticated"
And set context variable "www.example.com/auth.provider" to "https://login.example.com/oauth2"
And set context variable "www.example.com/auth.client.id" to "aaaa-bbbb-cccc-dddd"

Then get from "https://{{ url }}" with name "authenticated-get" and save response payload in "foobar"

This will make any requests towards www.example.com to get a token from http://login.example.com/oauth2 and use it in any requests towards www.example.com.

For more details, see Azure Active Directory.