Skip to content

Commit

Permalink
add cookie text test
Browse files Browse the repository at this point in the history
  • Loading branch information
chmike committed Mar 11, 2022
1 parent 8896786 commit bbe157e
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions securecookie_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,28 @@ func TestGorillaValueLen(t *testing.T) {
fmt.Println("Gorilla value:", c.Value, "len:", len(c.Value))
}

func TestCookieText(t *testing.T) {
key := MustGenerateRandomKey()
loginCookie, err := New("login", key, Params{
Path: "/", // cookie received only when URL starts with this path
Domain: "www.example.com", // cookie received only when URL domain matches this one
MaxAge: 15 * 24 * 3600, // cookie becomes invalid after 15 days
HTTPOnly: true, // disallow access by remote javascript code
Secure: true, // cookie received only with HTTPS, never with HTTP
SameSite: Strict, // cookie only for same site
})
if err != nil {
t.Fatalf("unexpected error: %s", err)
}
var recorder = httptest.NewRecorder()
if err := loginCookie.SetValue(recorder, []byte{}); err != nil {
t.Fatal("unexpected error:", err)
}
hdr := recorder.Header()
t.Error(hdr.Get("Set-Cookie"))

}

var buf1 = make([]byte, 512)
var buf2 = make([]byte, 512)
var val = []byte("some value")
Expand Down

0 comments on commit bbe157e

Please sign in to comment.