package domain import "testing" func TestCreatorPasswordHashRoundTrip(t *testing.T) { hash, err := HashCreatorPassword("a-long-enough-test-password") if err != nil { t.Fatal(err) } if !VerifyCreatorPassword(hash, "a-long-enough-test-password") { t.Fatal("hashed password was not accepted") } if VerifyCreatorPassword(hash, "wrong-password") { t.Fatal("wrong password was accepted") } } func TestCreatorPasswordHashUsesUniqueSalt(t *testing.T) { first, err := HashCreatorPassword("a-long-enough-test-password") if err != nil { t.Fatal(err) } second, err := HashCreatorPassword("a-long-enough-test-password") if err != nil { t.Fatal(err) } if first == second { t.Fatal("password hashes reused a salt") } } func TestCreatorPasswordHashRejectsShortPassword(t *testing.T) { if _, err := HashCreatorPassword("short"); err == nil { t.Fatal("short password was accepted") } }