File: cookie_go111_test.go

package info (click to toggle)
golang-github-gorilla-sessions 1.2.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 160 kB
  • sloc: makefile: 2
file content (29 lines) | stat: -rw-r--r-- 614 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// +build go1.11

package sessions

import (
	"net/http"
	"testing"
)

// Test for setting SameSite field in new http.Cookie from name, value
// and options
func TestNewCookieFromOptionsSameSite(t *testing.T) {
	tests := []struct {
		sameSite http.SameSite
	}{
		{http.SameSiteDefaultMode},
		{http.SameSiteLaxMode},
		{http.SameSiteStrictMode},
	}
	for i, v := range tests {
		options := &Options{
			SameSite: v.sameSite,
		}
		cookie := newCookieFromOptions("", "", options)
		if cookie.SameSite != v.sameSite {
			t.Fatalf("%v: bad cookie sameSite: got %v, want %v", i+1, cookie.SameSite, v.sameSite)
		}
	}
}