plaidshirt
plaidshirt

Reputation: 5671

Optional HTTP basic authentication in JMeter

I have a request, which can be used on an endpoint with and without authentication too, but response is different in these cases. I send request to path like /MyService?wsdl. I tried to use HTTP Authorization Manager added it to HTTP Request element with whole url to this service, but it isn't working. I am sure, that username and password are correct. How is it possible to debug authentication process?

Upvotes: 0

Views: 1475

Answers (2)

Dmitri T
Dmitri T

Reputation: 168002

  1. HTTP Authorisation Manager respects JMeter's Scoping Rules so make sure it is located either on the same level as HTTP Request sampler or add it as a child of this sampler (in the latter case it will be applied to this sampler only)
  2. Configure it as follows:

    • Base URL: protocol followed by IP address or hostname of the application under test
    • Username: your username
    • Password: your password
    • Mechanism: BASIC_DIGEST

      enter image description here

  3. Assuming everything goes well you should see Authorization header added to your request

    JMeter HTTP Authorisation Manager

See How to Use HTTP Basic Authentication in JMeter article for more details.


Alternative solution is adding HTTP Header Manager and configuring it to send Authorisation header with the value of ${__base64Encode(username:password,)}

JMeter Header Manager for basic auth

This approach assumes having __Base64Encode function installed, you can obtain it as a part of Custom JMeter Functions bundle using JMeter Plugins Manager

JMeter Plugins Manager - install custom functions

Upvotes: 1

Jerome L
Jerome L

Reputation: 637

I suggest to use Fiddler which is a Web Debugging Proxy to send requests from JMeter through it. You can configure HTTP Request to use a proxy.

Make sure the Authorization: Basic ... header is sent within the request.

The HTTP Authorization Manager should be placed at the root of the thread group. You can then specify the full request path associated to each authorization.

Upvotes: 0

Related Questions