Brandon Hawkinson
Brandon Hawkinson

Reputation: 117

JMeter Custom Authentication

We currently employ a non-standard authentication method and provide that in our authorization header for requests.

Due to this, we're at a bind with using a software such as JMeter. I've done some digging but we have no experience in this area.

What would be the best way to move forward with this?

Upvotes: 2

Views: 227

Answers (2)

Dmitri T
Dmitri T

Reputation: 168002

There are several workarounds:

  1. You can use a real browser driven by the WebDriver Sampler, once you have the authentication context you can extract it and add the header to JMeter's HTTP Request samplers using HTTP Header Manager
  2. The custom client code can be implemented in JMeter in the appropriate JSR223 Test Element, you can even re-use JavaScript code but be aware that you won't be able to use Navigator object or anything else connected with the browser.
  3. If you don't to load-test the authentication routine itself and want to focus solely on the application you can hard-code a test header which will be accepted by the application and use the aforementioned HTTP Header Manager to supply this token

Upvotes: 2

UBIK LOAD PACK
UBIK LOAD PACK

Reputation: 34516

The approach to do that is to use JSR223 Sampler with Groovy.

JMeter exposes:

You'll get a value using:

vars["varName"]

and store new variable using:

vars.put("newVarName", newVarThatYouComputeInGroovy);

You can then use the variables as:

${newVarName}

If you need to use content from a Request/ Response you can use extractors and export them to variables:

Upvotes: 1

Related Questions