My testing website generates JWT token both in UI framework designed from angular CSS and backend APIs also generate JWT token which expires in 1 hour. I have to do a performance test for this website using Jmeter. What should be the prerequisites I have to take with both backend and frontend team. Because while recording the test of frontend and running in JMeter on every alternate request it generates either 403 or 401 response
1 Answer
As per How do JSON Web Tokens work? article:
Whenever the user wants to access a protected route or resource, the user agent should send the JWT, typically in the Authorization header using the Bearer schema. The content of the header should look like the following:
Authorization: Bearer <token>
So you should design your test plan as follows:
- Open login page
- Perform login
- Extract JWT token using a suitable JMeter Post-Processor and save it into a JMeter Variable
- Add a HTTP Header Manager and configure it to send Authorization header with the value of
Bearer ${JMeter Variable holding the token here}