@@ -54,59 +54,55 @@ func Test_copyCookie(t *testing.T) {
56func Test_splitCookie(t *testing.T) {
56func Test_splitCookie(t *testing.T) {
57− testCases := map[string]struct {
57+ testCases := map[string]*http.Cookie{
61 "Short cookie name": {
58 "Short cookie name": {
62− Cookie: &http.Cookie{
63− Name: "short",
59+ Name: "short",
64− Value: strings.Repeat("v", 10000),
60+ Value: strings.Repeat("v", 10000),
66− ExpectedSizes: []int{4089, 4089, 1822},
68 "Long cookie name": {
62 "Long cookie name": {
69− Cookie: &http.Cookie{
70− Name: strings.Repeat("n", 251),
63+ Name: strings.Repeat("n", 251),
71− Value: strings.Repeat("a", 10000),
64+ Value: strings.Repeat("a", 10000),
73− ExpectedSizes: []int{3843, 3843, 2314},
75 "Max cookie name": {
66 "Max cookie name": {
76− Cookie: &http.Cookie{
77− Name: strings.Repeat("n", 256),
67+ Name: strings.Repeat("n", 256),
78− Value: strings.Repeat("a", 10000),
68+ Value: strings.Repeat("a", 10000),
80− ExpectedSizes: []int{3840, 3840, 2320},
82 "Suffix overflow cookie name": {
70 "Suffix overflow cookie name": {
83− Cookie: &http.Cookie{
84− Name: strings.Repeat("n", 255),
71+ Name: strings.Repeat("n", 255),
85− Value: strings.Repeat("a", 10000),
72+ Value: strings.Repeat("a", 10000),
87− ExpectedSizes: []int{3840, 3840, 2320},
74+ "Double digit suffix cookie name overflow": {
75+ Name: strings.Repeat("n", 253),
76+ Value: strings.Repeat("a", 50000),
89− "Double digit suffix cookie name results in different sizes": {
78+ "With short name and attributes": {
90− Cookie: &http.Cookie{
79+ Name: "short",
91− Name: strings.Repeat("n", 253),
92− Value: strings.Repeat("a", 50000),
80+ Value: strings.Repeat("v", 10000),
94− ExpectedSizes: []int{3841, 3841, 3841, 3841, 3841, 3841, 3841, 3841, 3841, 3841,
82+ Domain: "x.y.z",
95− 3840, 3840, 3840, 70},
83+ Secure: true,
85+ SameSite: http.SameSiteLaxMode,
97− "Double digit suffix overflow cookie name results in same sizes": {
87+ "With max length name and attributes": {
98− Cookie: &http.Cookie{
99− Name: strings.Repeat("n", 254),
88+ Name: strings.Repeat("n", 256),
100− Value: strings.Repeat("a", 50000),
89+ Value: strings.Repeat("v", 10000),
101− },
90+ Path: "/path",
102− ExpectedSizes: []int{3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840,
91+ Domain: "x.y.z",
103− 3840, 3840, 3840, 80},
92+ Secure: true,
94+ SameSite: http.SameSiteLaxMode,
106 for testName, tc := range testCases {
97 for testName, tc := range testCases {
107 t.Run(testName, func(t *testing.T) {
98 t.Run(testName, func(t *testing.T) {
99+ splitCookies := splitCookie(tc)
108− for i, cookie := range splitCookie(tc.Cookie) {
100+ for i, cookie := range splitCookies {
109− assert.Equal(t, tc.ExpectedSizes[i], len(cookie.Value))
101+ if i < len(splitCookies)-1 {
102+ assert.Equal(t, 4000, len(cookie.String()))
104+ assert.GreaterOrEqual(t, 4000, len(cookie.String()))