waf: test the request_bytes of a ban added through the endpoint
check / check (push) Failing after 18m9s
check / check (push) Failing after 18m9s
No test read the request_bytes of an own endpoint's log line, so removing the counting in logOwnEndpoint went unnoticed. The test checks that a ban to add is logged with its body's bytes, and that the health endpoint, which reads no body, logs 0. Model: opus-5-5
This commit is contained in:
1 parent
e84156ef04
commit
b7e7557047
1 file changed
+33
@@ -333,6 +333,39 @@ func TestBanToAddThatCannotBeReadIsRefused(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestBanToAddIsLoggedWithTheBytesOfItsBody(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
s, _, _ := startWithClock(
|
||||
t,
|
||||
"",
|
||||
map[string]string{adminToken: adminSecret},
|
||||
)
|
||||
|
||||
s.admin(http.MethodPost, waf.BansPath, banOtherClient, http.StatusOK)
|
||||
|
||||
line := s.out.endedLines(t, s.sent)[s.sent-1]
|
||||
if line.RequestBytes != int64(len(banOtherClient)) {
|
||||
t.Errorf(
|
||||
"the ban to add was logged with request_bytes %d, want %d",
|
||||
line.RequestBytes,
|
||||
len(banOtherClient),
|
||||
)
|
||||
}
|
||||
|
||||
// The health endpoint reads none of a body sent to it.
|
||||
s.ownEndpointRequest("", http.MethodGet, waf.HealthPath, "ok",
|
||||
http.StatusOK)
|
||||
|
||||
line = s.out.endedLines(t, s.sent)[s.sent-1]
|
||||
if line.RequestBytes != 0 {
|
||||
t.Errorf(
|
||||
"the health request was logged with request_bytes %d, want 0",
|
||||
line.RequestBytes,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
func TestClientEndpointShowsTheClientAndItsBans(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
Reference in new issue
Block a user