Files

28 lines
661 B
Go

package auth
import "testing"
func TestPasswordPolicy(t *testing.T) {
for _, value := range []string{"short", "alllowercase123", "ALLUPPERCASE123"} {
if validatePassword(value) == nil {
t.Fatalf("expected %q to fail policy", value)
}
}
if err := validatePassword("Bell-Safe-2026"); err != nil {
t.Fatalf("valid password rejected: %v", err)
}
}
func TestPasswordHashRoundTrip(t *testing.T) {
hash, err := hashPassword("Bell-Safe-2026")
if err != nil {
t.Fatal(err)
}
if !passwordMatches(hash, "Bell-Safe-2026") {
t.Fatal("password did not match")
}
if passwordMatches(hash, "Wrong-Safe-2026") {
t.Fatal("wrong password matched")
}
}