diff options
Diffstat (limited to 'app/utilities_test.go')
| -rw-r--r-- | app/utilities_test.go | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/app/utilities_test.go b/app/utilities_test.go new file mode 100644 index 0000000..7037b2f --- /dev/null +++ b/app/utilities_test.go @@ -0,0 +1,33 @@ +package main + +import ( + "testing" +) + +func TestMd5Hash(t *testing.T) { + hash := "f9d08276bc85d30d578e8883f3c7e843" + testHash := Md5Hash("md5hash") + + if hash != testHash { + t.Fatal("Expected %s as hash. Got %s.", hash, testHash) + } +} + +func TestRandomKey(t *testing.T) { + key := RandomKey() + if len(key) != 40 { + t.Fatal("Expected a key with length of 40. Got %s.", key) + } +} + +func TestPassword(t *testing.T) { + + testHash, err := HashPassword("password") + if err != nil { + t.Fatal("Hashing password failed.") + } + verify := VerifyPassword("password", testHash) + if !verify { + t.Fatal("Verifying password failed.") + } +} |
