package authpw import "testing" func TestHashVerifiesOnlyTheSamePassword(t *testing.T) { encoded, err := Hash("correct-horse-battery") if err != nil { t.Fatal(err) } if !Verify("correct-horse-battery", encoded) { t.Fatal("same password rejected") } if Verify("correct-horse-batteries", encoded) { t.Fatal("other password accepted") } if Verify("correct-horse-battery", "sha256:nope") { t.Fatal("foreign encoding accepted") } }