summaryrefslogtreecommitdiff
path: root/fuzz.go
diff options
context:
space:
mode:
authorKamil Kisiel <kamil@kamilkisiel.net>2015-08-18 23:59:03 +0300
committerKamil Kisiel <kamil@kamilkisiel.net>2015-08-18 23:59:32 +0300
commit45e43d5d12f051fe5e9f538f0f237d58016b6866 (patch)
treeced0870978ee4136fef4ca3acf06ac8242494614 /fuzz.go
parent95995b243b00d085c7068909df0f833b343a3215 (diff)
Added fuzz testing facilities.
Diffstat (limited to 'fuzz.go')
-rw-r--r--fuzz.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/fuzz.go b/fuzz.go
new file mode 100644
index 0000000..e4d0534
--- /dev/null
+++ b/fuzz.go
@@ -0,0 +1,25 @@
+// +build gofuzz
+
+package securecookie
+
+var hashKey = []byte("very-secret12345")
+var blockKey = []byte("a-lot-secret1234")
+var s = New(hashKey, blockKey)
+
+type Cookie struct {
+ B bool
+ I int
+ S string
+}
+
+func Fuzz(data []byte) int {
+ datas := string(data)
+ var c Cookie
+ if err := s.Decode("fuzz", datas, &c); err != nil {
+ return 0
+ }
+ if _, err := s.Encode("fuzz", c); err != nil {
+ panic(err)
+ }
+ return 1
+}