mirror of
https://github.com/lukaszraczylo/traefikoidc.git
synced 2026-10-18 04:47:28 +00:00
Seven findings are fixed. Each fix has a regression test. - Compare X-Forwarded-Host and the serving host case-insensitively, so a case variant cannot widen the session cookie Domain. - Reject a future iat on the opaque introspection path. - Serve the cached parsed JWKS inside the signature-refresh cooldown. - Release the half-open circuit slot when a probe panics. - Cap requests that wait for provider initialisation at 512. Extra requests receive 503 with Retry-After. - Cap cookie deletion headers at 32 cookie names per response. - Cap front-channel sid markers at 1000, so unauthenticated requests cannot evict backchannel or jti replay markers.
41 lines
1.0 KiB
Go
41 lines
1.0 KiB
Go
package recovery
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestCircuitBreaker_PanickingProbeReleasesHalfOpenSlot(t *testing.T) {
|
|
cb := NewCircuitBreaker(CircuitBreakerConfig{
|
|
FailureThreshold: 1,
|
|
SuccessThreshold: 1,
|
|
Timeout: 20 * time.Millisecond,
|
|
MaxRequests: 1,
|
|
}, &mockLogger{})
|
|
|
|
_ = cb.ExecuteWithContext(context.Background(), func() error { return errors.New("fail") })
|
|
time.Sleep(40 * time.Millisecond)
|
|
|
|
func() {
|
|
defer func() {
|
|
if recover() == nil {
|
|
t.Error("panic must still propagate to the caller")
|
|
}
|
|
}()
|
|
_ = cb.ExecuteWithContext(context.Background(), func() error { panic("boom") })
|
|
}()
|
|
|
|
if cb.GetState() != CircuitBreakerOpen {
|
|
t.Fatalf("state after panicking probe = %s, want open", cb.GetState())
|
|
}
|
|
time.Sleep(40 * time.Millisecond)
|
|
if err := cb.ExecuteWithContext(context.Background(), func() error { return nil }); err != nil {
|
|
t.Fatalf("probe after next timeout rejected: %v", err)
|
|
}
|
|
if cb.GetState() != CircuitBreakerClosed {
|
|
t.Fatalf("state = %s, want closed", cb.GetState())
|
|
}
|
|
}
|