Files
mtusi2026lab2/internal/authpw/password_test.go
T
Quzzqq cbb92b7aef
Application / application (pull_request) Canceled after 0s
Skeleton contracts / contracts (pull_request) Canceled after 0s
2 lab
2026-10-23 16:31:42 +03:00

20 lines
446 B
Go

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")
}
}