Reproduce cookie refresh bugs, validate fixes #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Per bitly#115, @jehiah noted that he encountered a cookie refresh
bug whereby an empty cookie value was being set when --cookie-refresh was
enabled. I was able to ascertain by studying the code that if the original
cookie has expired, the "refresh" case would still be triggered, causing an
empty cookie to be set.
TestProcessCookieFailIfRefreshSetAndCookieExpired reproduces the bug when the
ok &&
component of theok && p.CookieRefresh != time.Duration(0)
expression within ProcessCookie() is removed. The bug is confirmed fixed when
the
ok &&
component is reinstated.At the same time, it's now apparent that the effective cookie expiration
period was always one week prior to @jehiah's changes, thanks to the timestamp
in validateCookie() being compared against the hardcoded value
time.Duration(24)*7*time.Hour*-1
. TestProcessCookieFailIfCookieExpiredconfirms that @jehiah's changes solves this problem as well.
I also took the liberty to add a comment to the timestamp comparison in
validateCookie(), since it took effort to remind myself how it was supposed to
work.