-
-
Notifications
You must be signed in to change notification settings - Fork 29
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
Adds "remove cookie" function to request module #57
Changes from 3 commits
3bb074c
eb1ca94
fff137f
c2ad48f
d471e09
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -450,3 +450,40 @@ pub fn set_req_cookies_test() { | |
|> request.get_header("cookie") | ||
|> should.equal(Ok("k1=v1; k2=v2")) | ||
} | ||
|
||
pub fn remove_cookie_from_request_test() { | ||
let req = | ||
request.new() | ||
|> request.set_cookie("FIRST_COOKIE", "first") | ||
|> request.set_cookie("SECOND_COOKIE", "second") | ||
|> request.set_cookie("THIRD_COOKIE", "third") | ||
|
||
req | ||
|> request.get_header("cookie") | ||
|> should.be_ok | ||
|> should.equal( | ||
"FIRST_COOKIE=first; SECOND_COOKIE=second; THIRD_COOKIE=third", | ||
) | ||
|
||
let modified_req = | ||
req | ||
|> request.remove_cookie("SECOND_COOKIE") | ||
|
||
modified_req | ||
|> request.get_header("cookie") | ||
|> should.be_ok | ||
|> should.equal("FIRST_COOKIE=first; THIRD_COOKIE=third") | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we have a test to check that if you try and remove "SECOND" it won't remove "SECOND_COOKIE" please 🙏 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, good catch that was a bug. I had to rework the function a tiny bit to fix it. Update pushed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you |
||
|
||
pub fn only_remove_matching_cookies_test() { | ||
request.new() | ||
|> request.set_cookie("FIRST_COOKIE", "first") | ||
|> request.set_cookie("SECOND_COOKIE", "second") | ||
|> request.set_cookie("THIRD_COOKIE", "third") | ||
|> request.remove_cookie("SECOND") | ||
|> request.get_header("cookie") | ||
|> should.be_ok | ||
|> should.equal( | ||
"FIRST_COOKIE=first; SECOND_COOKIE=second; THIRD_COOKIE=third", | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this was for debugging?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, It slipped through 😅