forked from mtusi2026/mtusi2026lab4
S3-вложения и сверка Postgresql с MinIO
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
package password
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestArgon2idRoundTrip(t *testing.T) {
|
||||
p := Params{Time: 1, Memory: 8, Threads: 1}
|
||||
encoded, err := p.Hash("correct-horse-1")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if encoded == "correct-horse-1" || len(encoded) < 20 {
|
||||
t.Fatalf("hash is not a PHC string: %s", encoded)
|
||||
}
|
||||
if !Verify("correct-horse-1", encoded) {
|
||||
t.Fatal("matching password rejected")
|
||||
}
|
||||
if Verify("other-password-1", encoded) {
|
||||
t.Fatal("wrong password accepted")
|
||||
}
|
||||
if Verify("correct-horse-1", "sha256:deadbeef") {
|
||||
t.Fatal("non-argon string accepted")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user