-
Notifications
You must be signed in to change notification settings - Fork 324
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
Provide extractors to work with raw cookie data #144
Comments
Hi, It's fairly basic, you can use it to pull the cookie headers out and use them as variables for templating, but may serve for your use case. It won't be able to set multiple cookie headers at the same time though until #74 is resolved. Does that work? Thanks, |
@nitrocode ^ reply above |
Thank you for the quick reply @svanoort but I'm having trouble setting up the extractor. I read through your advanced guide but I wasn't able to find any examples that would work for me. I also found #70 and attempted the following to no avail.
How would I change my YAML file so I can extract |
Also tried
but my output still doesn't replace my $SetCookie with the correct cookie. |
Alright, well this is interesting. Change Test 1 to
Changed Test 2 to This caused the correct headers to be sent
But the response contained a different SESSID
Also tried changing Set-Cookie to Cookie in Test 2 which resulted in the same 401 failure. |
@nitrocode That's the correct syntax for the test, yes, and it should be "set-cookie"... but the test doesn't do anything to modify the response, that's coming straight from your server. So what I'm thinking is there's a missing piece here for server behavior. My guess is that the server is changing the session ID every time to prevent some form of attack, possibly session fixation (see http://stackoverflow.com/questions/14466595/apache-tomcat-7-changing-jsessionid-on-every-request). What happens with session IDs when run by curl in verbose mode? Does it stay static? Are you able to reuse the cookie JAR on multiple requests? (My guess is no, in this case.) |
@svanoort Thanks for all of your help! That seemed to shed some light on the situation. I changed my Set-Cookie to just cookie and I added my second test's body attribute to the url attribute. It says both tests are passing now. It would be nice as a feature request for a commandline switch to automatically save the cookie retrieved and used. What do you think? |
@nitrocode Hmm, I think I'd misread something here yesterday in the headers, but I'm glad you've got it working now! I have a better idea for how to do this than saving all cookies (which could introduce issues with what are supposed to be isolated tests): provide an extractor that will save all cookie data in a raw string format to a variable that can be used in header templating. How does that sound? An optional extension might be to just save a specific cookie element or elements. We've got a definite weakness in that area. What do you think? |
@svanoort yeah that sounds like a good starting point. Since the following tests require a cookie to perform the action intended, it would be good if the login test did not pass, it should exit from the entire YAML test because all of the tests following will fail. |
Yeah, it needs a failfast option I believe. That is a little tricker to do than it sounds though. |
@nitrocode Added an issue for failfast or setup/teardown - #146 |
Great, thanks |
I'm trying to do the following
Here is my YAML
Is there a way I can write an extractor that will extract the cookie from the first test and push it into the second test?
I got the underlying curl commands to work:
I could do this all in curl but I'd much rather use your YAML abstraction layer. Any advice on how to make my YAML connect to my API like I was able to using curl's cookie I/O?
The text was updated successfully, but these errors were encountered: