summaryrefslogtreecommitdiff
path: root/app/utilities_test.go
blob: 7037b2fa24bb6d5e5f0a978882967916ad560907 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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.")
	}
}