2 lab
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
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")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user