test(auth): lab7 verify rehash, shared limits and session expiry and measure login cost
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
package service
|
||||
|
||||
import "testing"
|
||||
|
||||
func BenchmarkLoginArgon2id(b *testing.B) {
|
||||
hasher := NewArgon2idHasher()
|
||||
const password = "test-only-benchmark"
|
||||
encoded, err := hasher.Hash(password)
|
||||
if err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
b.ReportAllocs()
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
ok, err := hasher.Verify(password, encoded)
|
||||
if err != nil || !ok {
|
||||
b.Fatal("проверка пароля не прошла", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user