Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c6070bf792 |
@@ -62,26 +62,6 @@ 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) {
|
func TestDenyNetsRefuseBeforeTheLookupAndTheBody(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
@@ -169,9 +149,8 @@ type sentRequest struct {
|
|||||||
action string
|
action string
|
||||||
}
|
}
|
||||||
|
|
||||||
// wantAnswers sends requests to smallwebwaf at addr one after another and
|
// wantAnswers sends requests to smallwebwaf at addr in turn, as the first
|
||||||
// checks each one's answer and log line. They must be the first requests
|
// it is sent, and checks each one's answer and log line.
|
||||||
// smallwebwaf is sent, since the log lines are matched to them in order.
|
|
||||||
func wantAnswers(t *testing.T, addr string, out *output, requests []sentRequest) {
|
func wantAnswers(t *testing.T, addr string, out *output, requests []sentRequest) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user