Hello.
I have k test users, I want to use for a load test scenario. To access the application under test, a bearer token must first be acquired from a provider. I do not want to bombard the provider with requests over and over.
I tried the following in Java to retrieve a token, if a user does not yet have one.
doIf(session -> needsToken(session.get("user")))
.then(
exec(http("Login").post(AUTHORITY_URL)
.formParamMap(session -> body(session.get("user")))
.check(status().is(200))
.check(jsonPath("$.id_token").transformWithSession((token, session) -> {
if(token ==null || token.isBlank())
return false;
else if(session.get("user") instanceof User user){
user.setIdToken(token);
return true;
}
else return false;
}).shouldBe(true)
)
));
That plan however does not work. It still makes many requests to the authority provider.
The User class
public class User {
private String username;
private String password;
private transient AtomicReference<String> idToken = new AtomicReference<>("");
...
}
Any help appreciated.