Valijon
Valijon

Reputation: 13103

Jmeter make request with logged session

I need to test my REST service with jMeter. I need to login first and then call REST services several times.

!!Http Cookie Manager does not work as expected!!

The problem:

HTTP Request to login - Here I need to get JSESSIONID

POST http://localhost:8080/xxx/index.faces

POST data:
form-login=form-login&j_username=xxx&j_password=yyy

[no cookies] - ???

Cabeceras de petición:
Connection: keep-alive
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0
Content-Type: application/x-www-form-urlencoded
Content-Length: 76
Host: localhost:8080

On browser it returns:

JSESSIONID=E9A3BC9C290549F32EB278133337450A; Path=/xxx/; HttpOnly

HTTP Cookie Manager - It is supposed to save cookies

HTTP Request to REST - Fails, cause JSESSIONID is not set

GET http://localhost:8080/xxx/rest/yyy/list

[no cookies]

Cabeceras de petición:
Connection: keep-alive
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0
Host: localhost:8080

jmeter configuration

Upvotes: 0

Views: 1732

Answers (3)

Valijon
Valijon

Reputation: 13103

Finally, I've figured out why is not working. Cookie Manager works perfectly. Login page actually expects javax.faces.ViewState id in order to pass jmeter request into login provider. Once, I've resolved it (), javax.faces.ViewState becomes stateless and let me login succesfully. Thanks for help enter image description here

Upvotes: 1

JusMe
JusMe

Reputation: 288

Add an HTTP Header Manager to the request and add JSESSIONID as the name and ${COOKIE__JSESSIONID} as the value in the "Headers Stored in Header Manager" section.

This will pass the value of JSESSIONID from the cookie to the HTTP Request Headers.

Upvotes: 0

Imlus
Imlus

Reputation: 57

Did you put the cookie manager before the request?

Upvotes: 0

Related Questions