check(status.is(302))) // Gives a 200 because by this point I have been redirected to Step_01 (But needs to give 302) Here I want to be redirected
By default, Gatling follows redirects, and checks are applied on landing page, so you’ll never see the 302
Sorry for replying on a old thread. I’m using 2.2.1 and haven’t disabled follow redirect. One of my request is automatically getting redirected and the other not. I’ve posted below the HTTP request, response & relevant code snippet. Please let me know what I’m doing incorrectly which is making the server respond with a 200 rather than 302. Framework used is JSF Primefaces.
Redirect works fine below (302 reported as success and then redirected GET request is executed properly)
HTTP request:
POST https://abc.com:443/pages/home.xhtml
headers=
Upgrade-Insecure-Requests: 1
Referer: https://abc.com/
Origin: https://abc.com
Connection: keep-alive
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8
Cache-Control: max-age=0
Accept-Language: en-US,en;q=0.8
Accept-Encoding: gzip, deflate
User-Agent: Gatling (Linux) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36
Content-Type: application/x-www-form-urlencoded
Cookie: JSESSIONID=otBT4pwIANyITwUM3bSYdA7M.undefined
Content-Length: 217
Host: abc.com
params=
j_idt41: j_idt41
javax.faces.ViewState: -8024050803110144760:-4638024640726524952
j_idt41:form-name: abcd
j_idt41:form-pass: abcd
j_idt41:login1: j_idt41:login1
showMessageToClient: j_idt41:showMessage
HTTP response:
status=
302 Moved Temporarily
headers=
Cache-Control: no-cache
Cache-Control: no-store
Content-Type: application/xhtml+xml
Expires: -1
Location: https://abc.com/protectedPages/KYC_Customer_Landing_Page.xhtml
Pragma: no-cache
Server: Apache
Vary: X-Forwarded-Proto
X-Frame-Options: SAMEORIGIN
Content-Length: 0
Connection: keep-alive
val headers_54 = Map(
“Accept” → “text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8”,
“Accept-Encoding” → “gzip, deflate”,
“Cache-Control” → “max-age=0”,
“Connection” → “keep-alive”,
“Origin” → “https://abc.com”,
“Referer” → “https://abc.com/”,
“Upgrade-Insecure-Requests” → “1”)
val land_page =
feed(userFeeder)
.exec(http(“request_54”)
.post(“/pages/home.xhtml”)
.headers(headers_54)
.formParam(“j_idt41”, “j_idt41”)
.formParam(“javax.faces.ViewState”, session => session.get(“viewstate”).as[String])
.formParam(“j_idt41:form-name”, “${username}”)
.formParam(“j_idt41:form-pass”, “${passwd}”)
.formParam(“j_idt41:login1”, “j_idt41:login1”)
.formParam(“showMessageToClient”, “j_idt41:showMessage”)
.check(regex(“”“ViewState:0” value=“(.*)” autocomplete"“”).saveAs(“viewstate”)))
Below I’m expecting a 302 but 200 is reported but works fine from browser
HTTP request:
POST https://abc.com:443/protectedPages/Dash.xhtml
headers=
Upgrade-Insecure-Requests: 1
Referer: https://abc.com/protectedPages/Dash.xhtml
Origin: https://abc.com
Connection: keep-alive
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8
Cache-Control: max-age=0
Content-type: application/x-www-form-urlencoded
Accept-Language: en-US,en;q=0.8
Accept-Encoding: gzip, deflate, br
User-Agent: Gatling (Linux) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36
Content-Type: application/x-www-form-urlencoded
Cookie: JSESSIONID=otBT4pwIANyITwUM3bSYdA7M.undefined
Content-Length: 116
Host: abc.com
params=
j_idt11: j_idt11
javax.faces.ViewState: -3781719762879616191:3768904276059911396
j_idt11:j_idt66: j_idt11:j_idt66
HTTP response:
status=
200 OK
headers=
Cache-Control: no-cache
Cache-Control: no-store
Content-Type: text/html;charset=UTF-8
Expires: -1
Pragma: no-cache
Server: Apache
Vary: X-Forwarded-Proto,Accept-Encoding
X-Frame-Options: SAMEORIGIN
Connection: keep-alive
Content-Encoding: gzip
val headers_282l = Map(
“Accept” → “text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8”,
“Accept-Encoding” → “gzip, deflate, br”,
“Cache-Control” → “max-age=0”,
“Connection” → “keep-alive”,
“Content-type” → “application/x-www-form-urlencoded”,
“Origin” → “https://abc.com”,
“Referer” → “https://abc.com/protectedPages/Dash.xhtml”,
“Upgrade-Insecure-Requests” → “1”)
val logout_from_dashboard = exec(http(“request_282l”)
.post(“/protectedPages/Dash.xhtml”)
.headers(headers_282l)
.formParam(“j_idt11”, “j_idt11”)
.formParam(“javax.faces.ViewState”, session => session.get(“viewstate”).as[String])
.formParam(“j_idt11:j_idt66”, “j_idt11:j_idt66”))