0

I have the following Test Plan which consists of a /auth/login call and then another /user/getmydata call which requires the Authorization cookie set by the login call

enter image description here

The output of the /auth/login call shows that the Authorization cookie is returned

Response headers:
HTTP/1.1 200 
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Content-Type: application/json;charset=UTF-8
Date: Wed, 05 Apr 2017 18:53:49 GMT
Expires: 0
Pragma: no-cache
Server: nginx/1.10.1
Set-Cookie: Authorization=eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiI1OGU1MWU5Y2EwOWQyNDQxZTZiOTUyNDciLCJ0b2tlblR5cGUiOiJBQ0NFU1MiLCJ1c2VyU2VlZCI6IjEwN250aGUiLCJleHAiOjE0OTI2MjgwMjl9.CjsKvpkdiuWkhJcsfURV6DuKbp4jjqLGPZR26GizTdCu7XstRmS0WmLqwVRswUvfKcAI8bNjU5MqW6K2Z2PVfg
X-Application-Context: application:stg1-us-east-1:8080
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
Content-Length: 646
Connection: keep-alive

However the next /user/getmydata call does not show the cookie to be passed back in the request and the call therefore fails

GET https://somedomain.com/user/getmydata

GET data:


[no cookies]

Request Headers:
Connection: keep-alive
Content-Type: application/json
Accept: application/json
Content-Length: 0
Host: somedomain.com
User-Agent: Apache-HttpClient/4.5.2 (Java/1.8.0_121)

The debug logs show:

2017/04/05 15:44:42 DEBUG - jmeter.protocol.http.control.HC4CookieHandler: Received Cookie: Authorization=eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiI1OGU1MWU5Y2EwOWQyNDQxZTZiOTUyNDciLCJ0b2tlblR5cGUiOiJBQ0NFU1MiLCJ1c2VyU2VlZCI6IjEwN250aGUiLCJleHAiOjE0OTI2MzEwODJ9.vCf2Pl2BddEBDmCIuHzcSuE-cDL5p3AXkQHYjD-XRuQZ-7xOh0wrSoAhKiWsg18cYyY-y2RqcMQLQ73z4C1W-Q From: https://api-stg1.somedomain.com/auth/login 
2017/04/05 15:44:42 DEBUG - jmeter.protocol.http.control.CookieManager: Add cookie to store api-stg1.somedomain.com TRUE    /auth   FALSE   0   Authorization   eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiI1OGU1MWU5Y2EwOWQyNDQxZTZiOTUyNDciLCJ0b2tlblR5cGUiOiJBQ0NFU1MiLCJ1c2VyU2VlZCI6IjEwN250aGUiLCJleHAiOjE0OTI2MzEwODJ9.vCf2Pl2BddEBDmCIuHzcSuE-cDL5p3AXkQHYjD-XRuQZ-7xOh0wrSoAhKiWsg18cYyY-y2RqcMQLQ73z4C1W-Q 

2017/04/05 15:44:42 DEBUG - jmeter.protocol.http.control.HC4CookieHandler: Found 0 cookies for https://api-stg1.somedomain.com/user/getmydata  

What am I doing wrong?

Bernie Lenz
  • 1,967
  • 23
  • 45
  • http://stackoverflow.com/a/1390955/863489 – elecay Apr 05 '17 at 19:57
  • You have to add the Cookie Manager to the Thread Level. Please let me know if it is working for you. – NaveenKumar Namachivayam Apr 06 '17 at 02:12
  • Possible duplicate of [Session/cookie management in Apache JMeter](http://stackoverflow.com/questions/1389464/session-cookie-management-in-apache-jmeter) – timbre timbre Apr 06 '17 at 04:45
  • The Cookie Manager is part of the Thread Group so that's right. I did some more research and suspect the issue is with the cookie path of the Authorization Cookie. I suspect it should be / instead of /auth – Bernie Lenz Apr 06 '17 at 14:46

0 Answers0