mirror of
https://github.com/nais/wonderwall.git
synced 2026-02-14 17:49:54 +00:00
refactor(cookie): set expires to epoch zero time on deletion
This commit is contained in:
@@ -43,7 +43,7 @@ func (in Cookie) Decrypt(crypter crypto.Crypter) (string, error) {
|
||||
}
|
||||
|
||||
func Clear(w http.ResponseWriter, name string, opts Options) {
|
||||
expires := time.Now().Add(-7 * 24 * time.Hour)
|
||||
expires := time.Unix(0, 0)
|
||||
maxAge := -1
|
||||
|
||||
cookie := &http.Cookie{
|
||||
|
||||
@@ -52,11 +52,9 @@ func TestClear(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
shouldExpireBefore := time.Now().Add(-7 * 24 * time.Hour)
|
||||
|
||||
assert.NotNil(t, result)
|
||||
assert.True(t, result.Expires.Before(time.Now()))
|
||||
assert.True(t, result.Expires.Before(shouldExpireBefore))
|
||||
assert.True(t, result.Expires.Equal(time.Unix(0, 0)))
|
||||
assert.Equal(t, -1, result.MaxAge)
|
||||
assert.True(t, result.HttpOnly)
|
||||
assert.Equal(t, name, result.Name)
|
||||
|
||||
Reference in New Issue
Block a user