-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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 (#24772)
- Loading branch information
1 parent
1bad05d
commit 64cc691
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")) | ||
} |