mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-10-14 16:20:03 +00:00
ed78509f92
- Fix deadlock and race conditions in internal/alerts - Add comprehensive error path tests for internal/config - Fix 401 handling in internal/api - Fix Docker Swarm task filtering test logic
32 lines
733 B
Go
32 lines
733 B
Go
package auth
|
|
|
|
import (
|
|
"errors"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestHashPassword_Error(t *testing.T) {
|
|
// bcrypt has a max length limit (usually 72 bytes).
|
|
// Passing a very long password should trigger an error.
|
|
longPassword := strings.Repeat("A", 80)
|
|
_, err := HashPassword(longPassword)
|
|
if err == nil {
|
|
t.Error("HashPassword() expected error for long password, got nil")
|
|
}
|
|
}
|
|
|
|
func TestGenerateAPIToken_Error(t *testing.T) {
|
|
originalRandRead := randRead
|
|
defer func() { randRead = originalRandRead }()
|
|
|
|
randRead = func(b []byte) (n int, err error) {
|
|
return 0, errors.New("forced error")
|
|
}
|
|
|
|
_, err := GenerateAPIToken()
|
|
if err == nil {
|
|
t.Error("GenerateAPIToken() expected error when rand.Read fails, got nil")
|
|
}
|
|
}
|