Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to add custom cookies in the cookie manager #178

Open
andy-tarr opened this issue Mar 10, 2023 · 2 comments
Open

Add support to add custom cookies in the cookie manager #178

andy-tarr opened this issue Mar 10, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@andy-tarr
Copy link
Contributor

Add support to the cookie manager to create custom cookies

@rabelenda
Copy link
Contributor

Thank you Andy, that is a standing feature.

What do you think something like this:

testPlan(
        threadGroup(1, 1,
            httpCookies()
               .add(new Cookie("MyCookie", "val")
                 .domain("myservice.com")
                 .path("/users")
                 .secure(true)
                 .expires(Instant.now().plusSeconds(30))
               )
            httpSampler("http://myservice.com"),
        )
    ).run();

We could internally implement it with a jsr 223 sampler, and would have the advantage, over JMeter cookies manager way of setting cookies, that you can directly control at what point in test plan you actually want the cookies to be set. This would avoid cookies being set in requests which shouldn't (and may make the test plan behave in unexpected way) or require some workaround, like adding a controller, to limit the scope of the cookie manager to get a similar effect.

We could even in the future use same approach add methods to remove some particular cookie, or explicitly clear all cookies.

@rabelenda rabelenda added the enhancement New feature or request label Mar 13, 2023
@andy-tarr
Copy link
Contributor Author

I think this approach looks great

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants