Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e001f1c830 |
@@ -62,6 +62,26 @@ func TestAllowNetsSkipEveryCheckButTheSizeLimit(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRequestFromAllowNetsIsNotCounted(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
app := startApp(t, func(http.ResponseWriter, *http.Request) {})
|
||||
addr, out := startProxy(t, app.URL, map[string]string{
|
||||
trustedProxies: trustLocalhost,
|
||||
allowNets: listedAddr,
|
||||
rateLimitPerMinute: "1",
|
||||
})
|
||||
|
||||
// listedAddr's requests are not counted, so the first request from
|
||||
// unlistedAddr is within the limit of one a minute.
|
||||
wantAnswers(t, addr, out, []sentRequest{
|
||||
{listedAddr, http.StatusOK, requestlog.ActionForward},
|
||||
{listedAddr, http.StatusOK, requestlog.ActionForward},
|
||||
{unlistedAddr, http.StatusOK, requestlog.ActionForward},
|
||||
{unlistedAddr, http.StatusTooManyRequests, requestlog.ActionRateLimited},
|
||||
})
|
||||
}
|
||||
|
||||
func TestDenyNetsRefuseBeforeTheLookupAndTheBody(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -149,8 +169,9 @@ type sentRequest struct {
|
||||
action string
|
||||
}
|
||||
|
||||
// wantAnswers sends requests to smallwebwaf at addr in turn, as the first
|
||||
// it is sent, and checks each one's answer and log line.
|
||||
// wantAnswers sends requests to smallwebwaf at addr one after another and
|
||||
// checks each one's answer and log line. They must be the first requests
|
||||
// smallwebwaf is sent, since the log lines are matched to them in order.
|
||||
func wantAnswers(t *testing.T, addr string, out *output, requests []sentRequest) {
|
||||
t.Helper()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user