Add tests for auth, rate limiting, security, and util

This commit is contained in:
root
2026-03-24 13:46:44 +01:00
parent d9de02f08d
commit 7b1293bb6f
4 changed files with 208 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
package security
import "testing"
func TestHashAndCheckPassword(t *testing.T) {
pw := "correct horse battery staple"
hash, err := HashPassword(pw)
if err != nil {
t.Fatalf("HashPassword returned error: %v", err)
}
if hash == "" {
t.Fatalf("expected non-empty hash")
}
if !CheckPassword(pw, hash) {
t.Fatalf("expected CheckPassword to succeed for correct password")
}
if CheckPassword("wrong", hash) {
t.Fatalf("expected CheckPassword to fail for wrong password")
}
}