0
votes

I have extracted the JWT token from the User login controller Rest API(taken endpoints from swagger) and my test plan looks like this

test plan

TEstplan.

As you can see in the images in login request it takes the header of Breakdown Configuration and it doesn't take authorization token value pass as a JSON object in Bearer ${token} although I have extracted it in JSON extractor and debug sampler shows it.

I have also used the once only controller but it doesn't solve the issue. Please help in the nested Header Manager and how to use it correctly. Even I have used Bean Shell processor under my GETALL Bd-config request and pass the command:

import org.apache.jmeter.protocol.http.control.Header;

sampler.getHeaderManager().add(new Header("Authorization","Bearer " + vars.get("token"))); 

But it doesnt solve the issue. Please guide. My jwt token expiration time is 1 hour

1
could you show the "Request Body" - Adnan

1 Answers

0
votes

Your test configuration is wrong, JMeter's Post-Processors obey JMeter Scoping Rules therefore your Extract token post-processor is being sequentially applied to:

  1. Login
  2. Debug Sampler - (ka-boom, here the token gets replaced by blank value)
  3. GetAll bd-config

The solution will be putting these Extract id and Extract token as the children of the Login request

enter image description here

This way the token and the id will be extracted from the Login and remain until next iteration not being overwritten by the Debug Sampler