-
-
Notifications
You must be signed in to change notification settings - Fork 34
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
Keep cookies in store #556
Conversation
testdata/book/cookie.yml
Outdated
/cookies: | ||
get: | ||
headers: | ||
Cookie: "{{ cookies['httpbin.org'][0].Raw }};" |
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.
Hosts change from environment to environment, so we may need the ability to identify them.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
keyMap[c.Name] = c | ||
} | ||
|
||
d[httpStoreCookieKey] = keyMap |
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.
If there is no SetCookie in the response header, should I explicitly set an empty slice?
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 don't think empty slice is necessary because it doesn't become panic even if it is nil, but I thought it would be better to have empty map set.
Line 131 in 867ca0c
store := map[string]any{} |
Lines 155 to 157 in 867ca0c
s.steps = []map[string]any{} | |
s.stepMapKeys = []string{} | |
s.stepMap = map[string]map[string]any{} |
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.
Fixed this
9d2c60c
[]*http.Cookie{&cookie5}, | ||
map[string]map[string]*http.Cookie{ | ||
// Expire | ||
"example.com": {}, |
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.
Once all cookies are deleted, should I also delete the domain key itself?
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.
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.
Thank you for looking into this!
Gives me more confidence in these specs.
This comment has been minimized.
This comment has been minimized.
&& current.res.cookies[vars.cookie.key].Name == vars.cookie.key | ||
&& current.res.cookies[vars.cookie.key].Value == uuid |
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.
When accessing the cookie of a step, the domain key is not needed because the domain of the request is obvious.
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.
Great!!!
/cookies: | ||
get: | ||
headers: | ||
Cookie: "{{ cookies[url('${HTTPBIN_END_POINT:-https://httpbin.org/}').Host][vars.cookie.key].Raw }};" |
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 would like to consider addressing this in the following Issue as it is a redundant description
#555
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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.
GREAT!!!
I have one modification request, but it is basically LGTM!
keyMap[c.Name] = c | ||
} | ||
|
||
d[httpStoreCookieKey] = keyMap |
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 don't think empty slice is necessary because it doesn't become panic even if it is nil, but I thought it would be better to have empty map set.
Line 131 in 867ca0c
store := map[string]any{} |
Lines 155 to 157 in 867ca0c
s.steps = []map[string]any{} | |
s.stepMapKeys = []string{} | |
s.stepMap = map[string]map[string]any{} |
keyMap = make(map[string]*http.Cookie) | ||
} | ||
if !cookie.Expires.IsZero() && cookie.Expires.Before(time.Now()) { | ||
// Remove expired cookie |
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.
Great!
[]*http.Cookie{&cookie5}, | ||
map[string]map[string]*http.Cookie{ | ||
// Expire | ||
"example.com": {}, |
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.
&& current.res.cookies[vars.cookie.key].Name == vars.cookie.key | ||
&& current.res.cookies[vars.cookie.key].Value == uuid |
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.
Great!!!
testdata/book/cookie.yml
Outdated
body: null | ||
test: | | ||
current.res.status == 200 | ||
&& current.res.body.cookies[vars.cookie.key] == uuid |
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.
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.
Code Metrics Report
Details | | main (867ca0c) | #556 (0ebb0af) | +/- |
|---------------------|----------------|----------------|--------|
+ | Coverage | 69.1% | 69.3% | +0.2% |
| Files | 48 | 49 | +1 |
| Lines | 5010 | 5043 | +33 |
+ | Covered | 3461 | 3493 | +32 |
+ | Code to Test Ratio | 1:0.7 | 1:0.7 | +0.0 |
| Code | 10032 | 10093 | +61 |
+ | Test | 6544 | 6816 | +272 |
+ | Test Execution Time | 4m48s | 2m36s | -2m12s | Code coverage of files in pull request scope (75.8% → 76.2%)
Reported by octocov |
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.
LGTM!
I would like to consider including it in the README in phase 2 |
refs #548