Addcookie withDomain method is not accepting the string expression

String expressions are not accepted in .withDomain method to add cookie; Can we support this in Gatling Java?

Example:
exec(addCookie(Cookie(“auth”, “#{bearerToken}”).withDomain(“#{authorizationCookieDomain}”).withSecure(false).withPath(“/”)))

indeed, it currently accept only a static value.
Then, could you please explain your use case? I fail to see one.

  • bearerToken = “SomeValue”

authorizationCookieDomain = “SomeValue”

exec(addCookie(Cookie(“auth”, “#{bearerToken}”).withDomain( “#{authorizationCookieDomain}”).withSecure(false).withPath(“/”)))

Cookie(“auth”, “#{bearerToken}”) - this works

withDomain(“#{authorizationCookieDomain}”) - this is not working because unlike Cookie there is no Expressions.toStringExpression() in withDomain method,

The ask is can we implement Expressions.toStringExpression() in withDomain method so that we can pass the stringExpression ?*

No, that’s what you’re trying to code, not your use case.
Why do you need dynamic cookie domain, instead of a simple static one?

I can’t provide a static value ; we have centralized code base and the value will differ based on projects and environment; and using variable without expression is working ; it would be great if we support string expression as well

So, you can compute this value once for the whole simulation at runtime.
static value is not literal value. (static in this context was opposed to session value)
You can provide a usual string value that you compute yourself.

Cheers!

1 Like

That’s how we are handling it currently. And we are not impacted due to this. I just brought this up cuz it would be nice to support string expressions as well . In most of the method Gatling supports it.

Sincerely, we won’t create another place to maintain if there is no use case for that.
Usually, either it is produced by the user (as you) with a standard String or http client retrieve a Cookie (with its domain) from a request.

Without use case, why implementing something?

Cheers!

1 Like