mirror of
https://github.com/lukaszraczylo/traefikoidc.git
synced 2026-10-12 04:04:26 +00:00
Security/correctness fixes: - fail-open token validation preserved with lenient-audience; access token that fails verification and has no ID token to corroborate now fails closed - token_manager blacklist-expiry: fix impossible tautology (x>24h && x<24h) - constant-time OAuth state compare; clear state/nonce/code_verifier on callback token-exchange failure to prevent replay of half-failed flows - StopAllTasks gated on last-instance close - background-task panic recovery; remove task-registry counter leak - circuit breaker half-open: release probe slot; CB + per-session outcome recorded once per refresh operation, not once per waiter - Redis connection pool: handle nil receive when pool closed concurrently - FileStore: atomic temp-write + rename - errors_recovery health-check data race -> atomic Test-isolation / hardening: - reset helpers for Once-pinned global cache manager and transport pool - coverage: utils 70->93% (redirect URL security contract); fuzz targets for bearer parsers; concurrent ServeHTTP race tests for the shared request path Dead-code removal (verified orphaned, build+suite green): internal/providers (30 files, 0 importers), internal/compat, internal/features, input_validation. Verified: govulncheck, go mod tidy, yaegi-validate, cross-compile (darwin+ linux), golangci-lint (new-from-rev clean), 3x full race+shuffle green.
36 lines
1.1 KiB
Go
36 lines
1.1 KiB
Go
package traefikoidc
|
|
|
|
import (
|
|
"sync/atomic"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
// TestReview_BackgroundTaskRecoversFromPanic verifies that a panicking
|
|
// background task function is recovered and the periodic loop keeps running.
|
|
// Previously a panic in taskFunc unwound the goroutine, permanently killing
|
|
// the background task (metadata refresh, autocleanup, memory monitor) with no
|
|
// log. An unrecovered panic here would crash the whole test binary.
|
|
func TestReview_BackgroundTaskRecoversFromPanic(t *testing.T) {
|
|
ResetGlobalTaskRegistry()
|
|
defer ResetGlobalTaskRegistry()
|
|
|
|
var runCount int32
|
|
logger := newNoOpLogger()
|
|
task := NewBackgroundTask("review-recover-task", 40*time.Millisecond, func() {
|
|
n := atomic.AddInt32(&runCount, 1)
|
|
if n == 1 {
|
|
panic("review: first run panics")
|
|
}
|
|
}, logger)
|
|
task.Start()
|
|
defer task.Stop()
|
|
|
|
// Give the task time to run several intervals past the initial panic.
|
|
time.Sleep(GetTestDuration(250 * time.Millisecond))
|
|
|
|
if got := atomic.LoadInt32(&runCount); got < 2 {
|
|
t.Fatalf("Background task should have recovered and continued running after the panic; runCount=%d", got)
|
|
}
|
|
}
|