forked from go-gitea/gitea
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix safari cookie session bug (go-gitea#24772)
Partically backport go-gitea#24330 Related: go-gitea#24176 Maybe fix go-gitea#24770 (cherry picked from commit 64cc691)
- Loading branch information
1 parent
b261f44
commit 9bc4887
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright 2023 The Gitea Authors. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package context | ||
|
||
import ( | ||
"net/http" | ||
"net/http/httptest" | ||
"testing" | ||
|
||
"code.gitea.io/gitea/modules/setting" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestRemoveSessionCookieHeader(t *testing.T) { | ||
w := httptest.NewRecorder() | ||
w.Header().Add("Set-Cookie", (&http.Cookie{Name: setting.SessionConfig.CookieName, Value: "foo"}).String()) | ||
w.Header().Add("Set-Cookie", (&http.Cookie{Name: "other", Value: "bar"}).String()) | ||
assert.Len(t, w.Header().Values("Set-Cookie"), 2) | ||
removeSessionCookieHeader(w) | ||
assert.Len(t, w.Header().Values("Set-Cookie"), 1) | ||
assert.Contains(t, "other=bar", w.Header().Get("Set-Cookie")) | ||
} |