fix(lib): properly clear out test cookie (#522)
Closes #520 For some reason, Chrome and Firefox are very picky over what they use to match cookies that need to be deleted. Listen to me for my tale of woe: The basic problem here is that cookies were an early hack added on the side of the HTTP spec and they're basically impossible to upgrade or change because who knows what relies on the exact behavior cookies use. As a result, cookies don't just match by name, but by every setting that exists on them. You can also have two cookies with the same name but different values. This spec is a nightmare lol. Even more fun: browsers will make up values for cookies if they aren't set, meaning that getting a challenge token at `/docs` is semantically different than a challenge token you got from `/`. This PR fixes this issue by explicitly setting the "make sure cookie support is working" cookie's path to `/`, meaning that it will always be sent. Additionally, cookies are expired by setting the expiry time to one minute in the past. Hopefully this will fix it. I'm testing this locally and it seems to work fine. Signed-off-by: Xe Iaso <me@xeiaso.net>
This commit is contained in:
parent
e31e1ca5e7
commit
a6045d6698
4 changed files with 54 additions and 33 deletions
|
|
@ -11,7 +11,7 @@ func TestClearCookie(t *testing.T) {
|
|||
srv := spawnAnubis(t, Options{})
|
||||
rw := httptest.NewRecorder()
|
||||
|
||||
srv.ClearCookie(rw, srv.cookieName)
|
||||
srv.ClearCookie(rw, srv.cookieName, "/")
|
||||
|
||||
resp := rw.Result()
|
||||
|
||||
|
|
@ -36,7 +36,7 @@ func TestClearCookieWithDomain(t *testing.T) {
|
|||
srv := spawnAnubis(t, Options{CookieDomain: "techaro.lol"})
|
||||
rw := httptest.NewRecorder()
|
||||
|
||||
srv.ClearCookie(rw, srv.cookieName)
|
||||
srv.ClearCookie(rw, srv.cookieName, "/")
|
||||
|
||||
resp := rw.Result()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue