Trouble Authenticating


I’ve recorded a simulation of me logging into my application and adding a note to an account, but the simulation never succeeds in adding a note to the account. I believe it isn’t authenticating, since the log shows it getting a 403 error on the post request to the login URL before it goes on, so I think when it continues on it is just getting the login page over and over for it’s various requests, since it isn’t authorized. The application is a Java application with a collection of JSP and JSF web pages and uses form based authentication. Since Gatling supports cookies, I think it should be able to login, as all it needs is the JSESSIONID cookie to have a session and the ARRAfinity cookie to get back to the right server in the cluster for its session. I’m doing a regex check against the response body to pullout the CSRF token and use it. I was already getting the 403 before adding the CSRF check. Here’s what I have in my simulation where I’m trying to login and getting a 403, in case someone sees what I’m doing wrong:

val scn = scenario(“RecordedSimulation”)
.formParam(“j_username”, “manager0”)
.formParam(“j_password”, “redacted”)
.formParam(“ANTI_CSRF_TOKEN”, “$csrfToken”)
.formParam(“actionCommand”, “doLogin”)
.formParam(“action”, “postAuthLoad”)
.formParam(“source”, “welcome”)
.formParam(“application”, “Admin”)
.formParam(“ANTI_CSRF_TOKEN”, “$csrfToken”),
… more simulation steps below

If anyone sees what’s wrong, any help would be greatly appreciated. I’ld like to use Gatling to loadtest my app, but obviously can’t if it isn’t getting past the
the login screen. When I run it with five users, it comes back in the summary with:,304,201,202,203,204,205,206,207,208,209), b 5 (100.0%) ut actually found 403

The 403 is always on the step where it posts to the login controller, but then afterwards everything else looks like it worked and it is making requests fine. It

even has different times for different page requests and acts like it’s following expected redirects, but I assume it isn’t hitting the application, since it didn’t
get authenticated. After all, it never manages to post the note that I posted when I recorded the simulation, so it seems obvious that it isn’t hitting the
internal webpages…

Oh, I forgot to mention my version. I’m running Gatling 3.0.0-SNAPSHOT. I switched to it from the release version to fix the too large strings bug when using the recorder.

Best thing to do is enable debug log and inspect the HTTP Request/Response and see if the http post params/headers/cookies compares with what you see in browser developer console → network while you perform the same exact step.

In your project go to /src/test/resources/logback-test.xml and uncomment line and run this with one user. Never enable this while running an actual stress test though!

Good luck.