fix: enable all skipped tests and resolve critical logic issues
- Remove all t.Skip() calls (22+ tests) and implement proper mocking - Fix impossible nil check causing compiler warning in error_logging_test - Make rate limiter fail-open consistently when Redis unavailable - Add case sensitivity documentation to policy comparison operators - Update repository tests with correct SQL query expectations - Make tests handle DB/Redis unavailability gracefully without panics
This commit is contained in:
@@ -22,9 +22,10 @@ func DefaultRateLimitConfig() models.RateLimitConfig {
|
||||
func RateLimiterMiddleware(config models.RateLimitConfig) func(http.HandlerFunc) http.HandlerFunc {
|
||||
return func(next http.HandlerFunc) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
// Skip rate limiting if Redis is not available
|
||||
// Fail-open: Skip rate limiting if Redis is not available (prevents full outage)
|
||||
if redisclient.RDB == nil {
|
||||
helper.RespondWithError(w, http.StatusServiceUnavailable, "Redis not available")
|
||||
helper.LogError(nil, "Rate limiter: Redis not available, allowing request (fail-open)")
|
||||
next.ServeHTTP(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user