aboutsummaryrefslogtreecommitdiff
path: root/securecookie_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'securecookie_test.go')
-rw-r--r--securecookie_test.go31
1 files changed, 27 insertions, 4 deletions
diff --git a/securecookie_test.go b/securecookie_test.go
index 241ff10..76368a9 100644
--- a/securecookie_test.go
+++ b/securecookie_test.go
@@ -101,7 +101,7 @@ func TestAuthentication(t *testing.T) {
}
}
-func TestEncription(t *testing.T) {
+func TestEncryption(t *testing.T) {
block, err := aes.NewCipher([]byte("1234567890123456"))
if err != nil {
t.Fatalf("Block could not be created")
@@ -121,18 +121,41 @@ func TestEncription(t *testing.T) {
}
}
-func TestSerialization(t *testing.T) {
+func TestGobSerialization(t *testing.T) {
var (
+ sz GobEncoder
serialized []byte
deserialized map[string]string
err error
)
for _, value := range testCookies {
- if serialized, err = serialize(value); err != nil {
+ if serialized, err = sz.Serialize(value); err != nil {
t.Error(err)
} else {
deserialized = make(map[string]string)
- if err = deserialize(serialized, &deserialized); err != nil {
+ if err = sz.Deserialize(serialized, &deserialized); err != nil {
+ t.Error(err)
+ }
+ if fmt.Sprintf("%v", deserialized) != fmt.Sprintf("%v", value) {
+ t.Errorf("Expected %v, got %v.", value, deserialized)
+ }
+ }
+ }
+}
+
+func TestJSONSerialization(t *testing.T) {
+ var (
+ sz JSONEncoder
+ serialized []byte
+ deserialized map[string]string
+ err error
+ )
+ for _, value := range testCookies {
+ if serialized, err = sz.Serialize(value); err != nil {
+ t.Error(err)
+ } else {
+ deserialized = make(map[string]string)
+ if err = sz.Deserialize(serialized, &deserialized); err != nil {
t.Error(err)
}
if fmt.Sprintf("%v", deserialized) != fmt.Sprintf("%v", value) {