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

Reproduce cookie refresh bugs, validate fixes #1

Merged
merged 1 commit into from
Jun 23, 2015

Conversation

mbland
Copy link

@mbland mbland commented Jun 23, 2015

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 the ok && 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. TestProcessCookieFailIfCookieExpired
confirms 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.

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 the `ok && 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`. TestProcessCookieFailIfCookieExpired
confirms 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.
@mbland mbland force-pushed the cookie_renew_115 branch from 747387a to 21f67c7 Compare June 23, 2015 11:04
jehiah added a commit that referenced this pull request Jun 23, 2015
Reproduce cookie refresh bugs, validate fixes
@jehiah jehiah merged commit afa45ff into jehiah:cookie_renew_115 Jun 23, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants