MCPcopy
hub / github.com/gofiber/fiber / Test_Ctx_Cookie_Invalid

Function Test_Ctx_Cookie_Invalid

ctx_test.go:1583–1606  ·  view source on GitHub ↗

go test -run Test_Ctx_Cookie_Invalid

(t *testing.T)

Source from the content-addressed store, hash-verified

1581
1582// go test -run Test_Ctx_Cookie_Invalid
1583func Test_Ctx_Cookie_Invalid(t *testing.T) {
1584 t.Parallel()
1585 app := New()
1586
1587 cases := []*Cookie{
1588 {Name: "", Value: "a"}, // empty name
1589 {Name: "foo bar", Value: "a"}, // invalid char in name
1590 {Name: "n", Value: "bad\nval"}, // invalid value byte
1591 {Name: "d", Value: "b", Domain: "in valid"}, // invalid domain spaces
1592 {Name: "d", Value: "b", Domain: "example..com"}, // invalid domain dots
1593 {Name: "i", Value: "b", Domain: "2001:db8::1"}, // ipv6 not allowed
1594 {Name: "p", Value: "b", Path: "\x00"}, // invalid path byte
1595 {Name: "e", Value: "b", Expires: time.Date(1500, 1, 1, 0, 0, 0, 0, time.UTC)}, // invalid expires
1596 // Note: Partitioned without Secure is auto-fixed (Secure=true set automatically per CHIPS spec)
1597 }
1598
1599 for _, invalid := range cases {
1600 c := app.AcquireCtx(&fasthttp.RequestCtx{})
1601 c.Res().Cookie(invalid)
1602 require.Empty(t, c.Res().Get(HeaderSetCookie))
1603 c.Response().Header.Reset()
1604 app.ReleaseCtx(c)
1605 }
1606}
1607
1608// go test -run Test_Ctx_Cookie_DefaultPath
1609func Test_Ctx_Cookie_DefaultPath(t *testing.T) {

Callers

nothing calls this directly

Calls 8

AcquireCtxMethod · 0.80
ReleaseCtxMethod · 0.80
NewFunction · 0.70
CookieMethod · 0.65
ResMethod · 0.65
GetMethod · 0.65
ResetMethod · 0.65
ResponseMethod · 0.65

Tested by

no test coverage detected