Accessing functions from http requests - Change expected status code dinamically


I ran into a problem with Gatling, and I hope you can help me.

The problem is, that I would like to test an api, which has several user roles with different permissions. According to the logged in user, I would like to change the expected http response code dinamically. (200 if the user has permission to the method, 403 if not)

Here is what I tried to to:

  1. First I get the user permissions with a http request.
  2. Then within each http request, I call a function, which supposed to return the appropriate status code, according to the downloaded permissions. For example:

.check(“staff”, “employee”, “getEmployeeList”)),

I guess, that it fails because the http requests val-s created when the simulation starts, and that time, the permissions are not downloaded yet. I also tried with lazy vals, but didn’t help.

My question is that, is there any way, to dinamically change the expected status code in the request?

Thanks in advance,
Balázs Komáromi

You have to pass a function: => NormalUser.prm.getStatus(“staff”, “employee”, “getEmployeeList”))


Thank you, it works like a charm now :slight_smile: