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

#1211 Standard delete Cookie behaviour does not work in Karate #1316

Merged
merged 2 commits into from
Oct 11, 2020
Merged

#1211 Standard delete Cookie behaviour does not work in Karate #1316

merged 2 commits into from
Oct 11, 2020

Conversation

chaudharydeepak
Copy link
Contributor

#1211 Standard delete Cookie behaviour does not work in Karate

We delete cookies by setting expiration from max-age. If cookie is getting expired via set-cookie header, modified code to include this while adding the cookie.

@chaudharydeepak
Copy link
Contributor Author

chaudharydeepak commented Oct 11, 2020

@ptrthomas - this possibly is the fix to delete cookies -

  1. For Apache http client - while preparing the cookies for cookiestore, we set expiration based on max-age.

  2. Additionally I noticed - seems if someone is removing cookie via set-cookie header, these cookies were not accounted for - included logic to read from header for set-cookie, then prepare the cookie and add to response.

Please let me know for any feedback -

included test cases as following -
@apache @mock-servlet-todo
Scenario: manually expire cookie by setting max-age to 0.
Given path 'search', 'cookies'
And cookie foo = {value:'bar', max-age:'0', path:'/search'}
And param domain = '.abc.com'
When method get
Then status 200
And match response == []

@apache @mock-servlet-todo
Scenario: max-age is -1, cookie should persist.
Given path 'search', 'cookies'
And cookie foo = {value:'bar', max-age:'-1', path:'/search'}
And param domain = '.abc.com'
When method get
Then status 200
And match response[0] contains { name: 'foo', value: 'bar', domain: '.abc.com' }

Copy link
Member

@ptrthomas ptrthomas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and you had a question on how to check for what was sent - here is an example: https://github.com/intuit/karate/blob/master/karate-demo/src/test/java/demo/encoding/encoding.feature#L60

just FYI - there is configure setting in karate to convert all header names to lower-case, not on by default, example: https://github.com/intuit/karate/blob/master/karate-demo/src/test/java/demo/headers/content-type.feature

@ptrthomas
Copy link
Member

@chaudharydeepak LGTM - were you planning any more changes ?

@chaudharydeepak
Copy link
Contributor Author

@ptrthomas - no, I think we good, Thank you.

@ptrthomas ptrthomas merged commit 9db1465 into karatelabs:develop Oct 11, 2020
@chaudharydeepak
Copy link
Contributor Author

@ptrthomas - Thank you for sharing this!

@chaudharydeepak
Copy link
Contributor Author

@ptrthomas - quick update - I went ahead and filled the google form. Thank you for this amazing opportunity to collaborate!

@chaudharydeepak FYI: https://medium.com/intuit-engineering/develop-with-intuit-for-hacktoberfest-2020-8f29b70ff2b4
image

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants