diff options
Diffstat (limited to 'user_test.go')
| -rw-r--r-- | user_test.go | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/user_test.go b/user_test.go new file mode 100644 index 0000000..3c2bc74 --- /dev/null +++ b/user_test.go @@ -0,0 +1,46 @@ +package main + +import ( + "testing" +) + +func TestHashPassword(t *testing.T) { + vU := VirtualUser{} + vU.Password = "md5hash" + vU.Password = vU.HashPassword() + if vU.Password != "f9d08276bc85d30d578e8883f3c7e843" { + t.Fatal("Expected 'f9d08276bc85d30d578e8883f3c7e843' as hash. Got %s.", vU.Password) + } +} + +func TestAuthUser(t *testing.T) { + vU := VirtualUser{Email: "test@example.com", Password: "password"} + if !vU.AuthUser() { + t.Fatal("Authentification failed.") + } + vU.Password = "Password" + if vU.AuthUser() { + t.Fatal("Authentification succeeded with wrong password.") + } +} + +func TestUpdatePassword(t *testing.T) { + vU := VirtualUser{Email: "test@example.com", Password: "password"} + if vU.UpdatePassword(vU.Password) { + t.Fatal("Update password even when both passwords be equal.") + } + if vU.UpdatePassword("") { + t.Fatal("Update password even with empty password.") + } + if !vU.UpdatePassword("Password") { + t.Fatal("Updating password failed.") + } + +} + +func TestCreateAlias(t *testing.T) { + //vA := VirtualAlias(Source: "") +} + +func TestAliasExists(t *testing.T) { +} |
