gohorsejobs/backend/cmd/debug_user/main_test.go

25 lines
512 B
Go

package main
import (
"testing"
"golang.org/x/crypto/bcrypt"
)
func TestVerifyUserPassword(t *testing.T) {
password := "Admin@2025!"
hash, _ := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
valid, err := VerifyUserPassword(string(hash), password)
if err != nil {
t.Errorf("Unexpected error: %v", err)
}
if !valid {
t.Error("Expected password to be valid")
}
valid, _ = VerifyUserPassword(string(hash), "wrong")
if valid {
t.Error("Expected password to be invalid")
}
}