Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cookie.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ func newCookieFromOptions(name, value string, options *Options) *http.Cookie {
MaxAge: options.MaxAge,
Secure: options.Secure,
HttpOnly: options.HttpOnly,
Partitioned: options.Partitioned,
}

}
1 change: 1 addition & 0 deletions cookie_go111.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ func newCookieFromOptions(name, value string, options *Options) *http.Cookie {
Secure: options.Secure,
HttpOnly: options.HttpOnly,
SameSite: options.SameSite,
Partitioned: options.Partitioned,
}

}
20 changes: 13 additions & 7 deletions cookie_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ func TestNewCookieFromOptions(t *testing.T) {
maxAge int
secure bool
httpOnly bool
partitioned bool
}{
{"", "bar", "/foo/bar", "foo.example.com", 3600, true, true},
{"foo", "", "/foo/bar", "foo.example.com", 3600, true, true},
{"foo", "bar", "", "foo.example.com", 3600, true, true},
{"foo", "bar", "/foo/bar", "", 3600, true, true},
{"foo", "bar", "/foo/bar", "foo.example.com", 0, true, true},
{"foo", "bar", "/foo/bar", "foo.example.com", 3600, false, true},
{"foo", "bar", "/foo/bar", "foo.example.com", 3600, true, false},
{"", "bar", "/foo/bar", "foo.example.com", 3600, true, true, true},
{"foo", "", "/foo/bar", "foo.example.com", 3600, true, true, true},
{"foo", "bar", "", "foo.example.com", 3600, true, true, true},
{"foo", "bar", "/foo/bar", "", 3600, true, true, true},
{"foo", "bar", "/foo/bar", "foo.example.com", 0, true, true, true},
{"foo", "bar", "/foo/bar", "foo.example.com", 3600, false, true, true},
{"foo", "bar", "/foo/bar", "foo.example.com", 3600, true, false, true},
{"foo", "bar", "/foo/bar", "foo.example.com", 3600, true, true, false},
}
for i, v := range tests {
options := &Options{
Expand All @@ -30,6 +32,7 @@ func TestNewCookieFromOptions(t *testing.T) {
MaxAge: v.maxAge,
Secure: v.secure,
HttpOnly: v.httpOnly,
Partitioned: v.partitioned,
}
cookie := newCookieFromOptions(v.name, v.value, options)
if cookie.Name != v.name {
Expand All @@ -53,5 +56,8 @@ func TestNewCookieFromOptions(t *testing.T) {
if cookie.HttpOnly != v.httpOnly {
t.Fatalf("%v: bad cookie httpOnly: got %v, want %v", i+1, cookie.HttpOnly, v.httpOnly)
}
if cookie.Partitioned != v.partitioned {
t.Fatalf("%v: bad cookie partitioned: got %v, want %v", i+1, cookie.Partitioned, v.partitioned)
}
}
}
1 change: 1 addition & 0 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ type Options struct {
MaxAge int
Secure bool
HttpOnly bool
Partitioned bool
}
1 change: 1 addition & 0 deletions options_go111.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type Options struct {
MaxAge int
Secure bool
HttpOnly bool
Partitioned bool
// Defaults to http.SameSiteDefaultMode
SameSite http.SameSite
}
1 change: 1 addition & 0 deletions vendor/github.com/gorilla/securecookie/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.