mirror of
https://github.com/lukaszraczylo/traefik-llmgateway.git
synced 2026-12-06 11:03:52 +00:00
fix(security): audit run-4 fixes and run-3 leftovers (#26)
Corrects passthrough metering, the cost gate, credential redaction, reload drain, response headers and the discovery cap.
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package traefikllmgateway
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
// A reader unblocked by the watchdog's cancel must find the failure already recorded.
|
||||
func TestWatchdogFire_RecordsTimeoutBeforeCancel(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
cancelledAtRecord := make(chan bool, 1)
|
||||
rec := func(_ *http.Response, _ error) {
|
||||
time.Sleep(20 * time.Millisecond)
|
||||
cancelledAtRecord <- ctx.Err() != nil
|
||||
}
|
||||
wb := newWatchdogBody(io.NopCloser(strings.NewReader("")), cancel, time.Hour, "p1", rec)
|
||||
wb.fire()
|
||||
if <-cancelledAtRecord {
|
||||
t.Fatal("context was cancelled before onTimeout recorded the failure")
|
||||
}
|
||||
if ctx.Err() == nil {
|
||||
t.Fatal("context not cancelled after fire")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user