aboutsummaryrefslogtreecommitdiff
path: root/fuzz
diff options
context:
space:
mode:
authorKamil Kisiel <kamil@kamilkisiel.net>2015-04-26 06:19:44 +0300
committerKamil Kisiel <kamil@kamilkisiel.net>2015-04-26 06:19:44 +0300
commit61f92ce7006cce1337c6eb66c2fccbde43621d60 (patch)
tree1b5ec93ed450b6464e27f3bfeb791152dcd757eb /fuzz
parentab638a3cc27c77beedde96fd004f6c65b7d35211 (diff)
Add fuzz test for go-fuzzfuzz
Diffstat (limited to 'fuzz')
-rw-r--r--fuzz/fuzz.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/fuzz/fuzz.go b/fuzz/fuzz.go
new file mode 100644
index 0000000..4b0963c
--- /dev/null
+++ b/fuzz/fuzz.go
@@ -0,0 +1,23 @@
+package fuzz
+
+import "github.com/gorilla/securecookie"
+
+var hashKey = []byte("very-secret12345")
+var blockKey = []byte("a-lot-secret1234")
+var s = securecookie.New(hashKey, blockKey)
+
+func Fuzz(data []byte) int {
+ var m int
+ err := s.Decode("fuzz", string(data), &m)
+ if err != nil {
+ return 0
+ }
+ encoded, err := s.Encode("fuzz", m)
+ if err != nil {
+ panic(err)
+ }
+ if encoded != string(data) {
+ panic("not the same")
+ }
+ return 1
+}