Files
persist/encrypt_test.go
George Suntres ec429adb87 Initial commit
2026-03-29 12:31:04 -04:00

41 lines
610 B
Go

package persist
import (
"testing"
)
func TestUser_EncryptPassword(t *testing.T) {
u := &User{
Password: "1234",
}
encrypted := u.EncryptPassword()
if u.Password != encrypted {
t.Fatal("Failed to encrypt password")
}
}
func TestUser_CheckPassword(t *testing.T) {
u := &User{
Password: "1234",
}
u.EncryptPassword()
if !u.CheckPassword("1234") {
t.Fatal("Failed to check password")
}
}
func TestUser_CheckPassword_FalsePositive(t *testing.T) {
u := &User{
Password: "1234",
}
u.EncryptPassword()
if u.CheckPassword("!234") {
t.Fatal("Should have not accepted password")
}
}