Jmeter - authorization header is missing

I have a pretty simple jmeter script for our site. As part of the flow through the site, I use our API to update the user application.

The API uses OAuth authentication, which I'm familiar with using my own proprietary testing tool.

First, I get an authentication token through a call to our authorization endpoint. This returns a bit of JSON as follows:

{"access_token":"a really long auth token string"}

In my script, I use regex to capture this token string. As part of investigating this issue, I used Debug PostProcessor to verify that I am getting the correct string, and I am doing it. It is saved as the 'authToken' variable.

In the next step in the script, I add the header through the HTTP header manager, for example:

Imgur

I know this header is correct, since we have many examples of it in our API tests.

The relevant part of the script looks like this:

Imgur


Each time I run the script, the step using the token / header returns 401 unauthorized.

I tested the actual URL and title in the Chrome plugin and the call works as expected.

There is no evidence in the View Results Tree listener that the authorization header is set at all. I tried hard-coded authentication token, but without joy - it is still not part of the request.

In the result tree, the query looks like this:

POST <correct URL>

POST data:{"id":"<item id>"}

Cookie Data: SessionProxyFilter_SessionId=<stuff>; sessionToken=<stuff>

Request Headers:
Content-Length: 52
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36       (KHTML, like Gecko) Chrome/43.0.2357.124 Safari/537.36
Connection: keep-alive
Content-Type: application/json

Imgur

There are also no redirects in the result tree.

I tried the solutions here and here , but none of them worked.

, , , , , script jmeter. , , .

+4
1

, . "" "HttpClient4".

+3

Source: https://habr.com/ru/post/1625349/


All Articles