package secret import "testing" func TestHashVerifyRoundTrip(t *testing.T) { h, err := Hash("correct horse") if err != nil { t.Fatal(err) } if !Verify(h, "correct horse") { t.Fatal("correct password rejected") } if Verify(h, "wrong horse") { t.Fatal("wrong password accepted") } } func TestVerifyRejectsJunkVerifier(t *testing.T) { for _, v := range []string{"", "x", "pbkdf2-sha256$1$a$b", "md5$1$a$b"} { if Verify(v, "anything") { t.Fatalf("verifier %q accepted", v) } } } func TestUserCodeShape(t *testing.T) { c := UserCode() if len(c) != 9 || c[4] != '-' { t.Fatalf("user code %q", c) } }