diff options
author | Andinus <andinus@nand.sh> | 2020-03-29 16:10:59 +0530 |
---|---|---|
committer | Andinus <andinus@nand.sh> | 2020-03-29 16:10:59 +0530 |
commit | a6826055bf4e6a23f80da047ccfe4509a209f3a6 (patch) | |
tree | f2bb2bec35ee5e61cb42f4edffb04368a0f8ba60 /password/hash_test.go | |
parent | 7b95d6b80dd2d1efb26f7c515383abd4f0dc9d42 (diff) | |
download | perseus-a6826055bf4e6a23f80da047ccfe4509a209f3a6.tar.gz |
Initial perseus rewrite
Diffstat (limited to 'password/hash_test.go')
-rw-r--r-- | password/hash_test.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/password/hash_test.go b/password/hash_test.go new file mode 100644 index 0000000..4f37393 --- /dev/null +++ b/password/hash_test.go @@ -0,0 +1,34 @@ +package password + +import "testing" + +// TestHash tests the Hash function. +func TestHash(t *testing.T) { + var err error + passhash := make(map[string]string) + + // We generate random hashes with Hash, random string is + // generate by RandStr func. + for i := 1; i <= 8; i++ { + p := RandStr(8) + passhash[p], err = Hash(p) + + // Here we test if the hashPass func runs sucessfully. + if err != nil { + t.Errorf("Hash func failed for password: %s", + p) + } + } + + // Here we are testing if the hashPass func returns correct + // hashes. We assume that checkPass func returns correct + // values. + for p, h := range passhash { + err = Check(p, h) + if err != nil { + t.Errorf("password: %s, hash: %s didn't match.", + p, h) + } + } + +} |