test(auth): lab7 verify rehash, shared limits and session expiry and measure login cost

This commit is contained in:
Голиков Maximillian Антон
2026-11-29 14:32:11 +03:00
parent a907161087
commit b34427c34f
4 changed files with 196 additions and 0 deletions
@@ -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)
}
}
}