check / check (push) Failing after 14m44s
`smallwebwaf` with no command now prints the commands and exits with status 2. The image runs rproxy, or servewaf with SMALLWEBWAF_COMMAND=servewaf. The passing-on code, its settings and its log fields and metric go. internal/proxy keeps the checks, answers, reports and own endpoints; its tests run through the real rproxy. The documents describe the pair. Judgement call: clients.json keeps token_refused, since state files refuse unknown fields. Deviation: script/gitea-requests sets SWWAF_LOG_REQUEST_HEADERS, to label requests. Partially verified: make example-app and make gitea-requests never built the image, as Ubuntu's snapshot service answered 5xx. Model: opus-5-5
41 lines
1.1 KiB
Go
41 lines
1.1 KiB
Go
package proxy_test
|
|
|
|
import (
|
|
"net/http"
|
|
"testing"
|
|
|
|
"sneak.berlin/go/smallwebwaf/internal/proxy"
|
|
"sneak.berlin/go/smallwebwaf/internal/requestlog"
|
|
)
|
|
|
|
func TestHealthEndpointCountsTowardNoLimit(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
// With a limit of one request a minute, any request counted before
|
|
// the last one would have it refused.
|
|
s, _, _ := startWithClock(t, "", map[string]string{rateLimitPerMinute: "1"})
|
|
|
|
const (
|
|
healthChecks = 3
|
|
contentType = "text/plain; charset=utf-8"
|
|
)
|
|
|
|
for range healthChecks {
|
|
got := s.adminRequest("", http.MethodGet, proxy.HealthPath, "", http.StatusOK)
|
|
|
|
if string(got.body) != "ok\n" || got.header.Get("Content-Type") != contentType {
|
|
t.Errorf("health endpoint answered %q with Content-Type %q, want ok "+
|
|
"with %q", got.body, got.header.Get("Content-Type"), contentType)
|
|
}
|
|
}
|
|
|
|
s.get(client, http.StatusOK, requestlog.ActionForward)
|
|
|
|
for _, line := range s.out.endedLines(t, healthChecks)[:healthChecks] {
|
|
if line.ResponseContentType != contentType {
|
|
t.Errorf("health check's log line has response_content_type %q, "+
|
|
"want %q", line.ResponseContentType, contentType)
|
|
}
|
|
}
|
|
}
|