first commit
This commit is contained in:
34
services/auth/password_test.go
Normal file
34
services/auth/password_test.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestHashPassword(t *testing.T) {
|
||||
hash, err := HashPassword("password")
|
||||
if err != nil {
|
||||
t.Errorf("error hashing password: %v", err)
|
||||
}
|
||||
|
||||
if hash == "" {
|
||||
t.Error("expected hash to be not empty")
|
||||
}
|
||||
|
||||
if hash == "password" {
|
||||
t.Error("expected hash to be different from password")
|
||||
}
|
||||
}
|
||||
|
||||
func TestComparePasswords(t *testing.T) {
|
||||
hash, err := HashPassword("password")
|
||||
if err != nil {
|
||||
t.Errorf("error hashing password: %v", err)
|
||||
}
|
||||
|
||||
if !ComparePasswords(hash, []byte("password")) {
|
||||
t.Errorf("expected password to match hash")
|
||||
}
|
||||
if ComparePasswords(hash, []byte("notpassword")) {
|
||||
t.Errorf("expected password to not match hash")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user