Add tests for auth, rate limiting, security, and util
This commit is contained in:
22
internal/security/password_test.go
Normal file
22
internal/security/password_test.go
Normal 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")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user