Skip to content

Commit

Permalink
chore: move cookie fuzz test to go 1.18 fuzzing (#1686)
Browse files Browse the repository at this point in the history
  • Loading branch information
nickajacks1 authored Jan 4, 2024
1 parent 868ee45 commit fec7681
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 25 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ tags
.vscode
.DS_Store
vendor/
testdata/fuzz
22 changes: 22 additions & 0 deletions cookie_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package fasthttp

import (
"bytes"
"strings"
"testing"
"time"
Expand All @@ -15,6 +16,27 @@ func TestCookiePanic(t *testing.T) {
}
}

func FuzzCookieParse(f *testing.F) {
inputs := []string{
`xxx=yyy`,
`xxx=yyy; expires=Tue, 10 Nov 2009 23:00:00 GMT; domain=foobar.com; path=/a/b`,
" \n\t\"",
}
for _, input := range inputs {
f.Add([]byte(input))
}
c := AcquireCookie()
defer ReleaseCookie(c)
f.Fuzz(func(t *testing.T, cookie []byte) {
_ = c.ParseBytes(cookie)

w := bytes.Buffer{}
if _, err := c.WriteTo(&w); err != nil {
t.Fatalf("unexpected error: %v", err)
}
})
}

func TestCookieValueWithEqualAndSpaceChars(t *testing.T) {
t.Parallel()

Expand Down
25 changes: 0 additions & 25 deletions fuzzit/cookie/cookie_fuzz.go

This file was deleted.

0 comments on commit fec7681

Please sign in to comment.