0

I am trying to carry out a test as like it explained here: JMeter Alter HTTP Headers During Test.

Quote from above :

I'm attempting to test an HTTP service with JMeter. The HTTP service requires authentication through a simple bearer token mechanism. I'm trying to proceed as follows:

  • POST authentication request Store token as a variable
  • Set Authorization HTTP header to stored variable
  • Request protected resource(s)
  • Evaluate performance

When the POST occurs, I am not able to capture the bearer token. Its a header.

I tried the solution provided by Dmitri on that issue Or as Bennet tried with RegEx Extractor and HTTPs Manager.

I think I am doing something silly not to able to extract the token. Any thoughts how to extract the token?

Community
  • 1
  • 1
lpt
  • 931
  • 16
  • 35

1 Answers1

0

Most likely your Regular Expression Extractor configuration is not correct, by default it:

  • uses response body as a source therefore you need to switch it to look into response headers (red rectangle)
  • looks up in main sample only, if your header is set after redirect it won't be processed (amber rectangle)

    Example configuration:

    Regular Expression Extractor for Headers

You can double check ${bearer} variable value using Debug Sampler and View Results Tree listener combination.

Dmitri T
  • 159,985
  • 5
  • 83
  • 133
  • tried all the options, still unable to extract the token. While debugging dont see bearer token anywhere. I am sure I am missing something really simple thing. – lpt Jan 20 '17 at 16:03
  • Update your question with screenshots of: View Results Tree listener on "Sample Result" tab showing the "bearer" header value you want to extract. 2. Regular Expression Extractor. Let me know via comment once done so I could take a look. – Dmitri T Jan 20 '17 at 16:10
  • exactly that is what I am missing. I do not see bearer header. But for some reason when I do 'POST' method, it expects the bearer token as a request header. To summarize the app: user inputs log in credentials > bearer token is generated> this bearer token can be used throughout the test and then it expires. I do not see the bearer token in header (Jmeter). However if I run that in fiddler or firebug I can see it as the response header. Not exactly sure why it behaves different in Jmeter vs Firebug's Net. – lpt Jan 20 '17 at 16:21
  • In that case I believe [How to Run Performance Tests on OAuth Secured Apps with JMeter](https://www.blazemeter.com/blog/how-run-performance-tests-oauth-secured-apps-jmeter) article will help – Dmitri T Jan 20 '17 at 19:13
  • tried that from your earlier advice on other ticket. It did not work. I am super surprised on this issue. I am sure I am missing something very small. IT cant be this hard. – lpt Jan 20 '17 at 20:54
  • So finally got this wrapped up. Steps taken were to use regular expression extractor and json extractor. – lpt Jan 24 '17 at 18:47