Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
bharat-rajani committed Apr 25, 2024
1 parent a5d8b51 commit 48890fd
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
4 changes: 0 additions & 4 deletions .gitignore
@@ -1,5 +1 @@
coverage.coverprofile

# IDE Metadata
.idea
.vscode
1 change: 1 addition & 0 deletions cookie_go111_test.go
Expand Up @@ -17,6 +17,7 @@ func TestNewCookieFromOptionsSameSite(t *testing.T) {
{http.SameSiteDefaultMode},
{http.SameSiteLaxMode},
{http.SameSiteStrictMode},
{http.SameSiteNoneMode},
}
for i, v := range tests {
options := &Options{
Expand Down
8 changes: 4 additions & 4 deletions sessions_test.go
Expand Up @@ -40,8 +40,8 @@ func TestFlashes(t *testing.T) {

store := NewCookieStore([]byte("secret-key"))

if store.Options.SameSite != http.SameSiteLaxMode {
t.Fatalf("cookie store error: default same site is not set to Lax")
if store.Options.SameSite != http.SameSiteNoneMode {
t.Fatalf("cookie store error: default same site is not set to None")
}

// Round 1 ----------------------------------------------------------------
Expand Down Expand Up @@ -72,8 +72,8 @@ func TestFlashes(t *testing.T) {
t.Fatal("No cookies. Header:", hdr)
}

if !strings.Contains(cookies[0], "SameSite=Lax") {
t.Fatal("Set-Cookie does not contains SameSite=Lax, cookie string:", cookies[0])
if !strings.Contains(cookies[0], "SameSite=None") || !strings.Contains(cookies[0], "Secure") {
t.Fatal("Set-Cookie does not contains SameSite=None with Secure, cookie string:", cookies[0])
}

if _, err = store.Get(req, "session:key"); err.Error() != "sessions: invalid character in cookie name: session:key" {
Expand Down
3 changes: 2 additions & 1 deletion store.go
Expand Up @@ -56,7 +56,8 @@ func NewCookieStore(keyPairs ...[]byte) *CookieStore {
Options: &Options{
Path: "/",
MaxAge: 86400 * 30,
SameSite: http.SameSiteLaxMode,
SameSite: http.SameSiteNoneMode,
Secure: true,
},
}

Expand Down

0 comments on commit 48890fd

Please sign in to comment.