Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
545ce67f44 |
@@ -29,17 +29,19 @@ func TestRequestBodyLimit(t *testing.T) {
|
|||||||
announced bool
|
announced bool
|
||||||
want int
|
want int
|
||||||
action string
|
action string
|
||||||
// reachesApp is whether the app sees the request at all.
|
// refusedBeforeApp is a refusal before anything reaches the app.
|
||||||
reachesApp bool
|
// A body over the limit with no length given has already partly
|
||||||
|
// reached the app when it is refused.
|
||||||
|
refusedBeforeApp bool
|
||||||
}{
|
}{
|
||||||
{"announced, over the limit", 2 * sizeLimit, true,
|
{"announced, over the limit", 2 * sizeLimit, true,
|
||||||
http.StatusRequestEntityTooLarge, requestlog.ActionTooLarge, false},
|
|
||||||
{"announced, at the limit", sizeLimit, true,
|
|
||||||
http.StatusOK, requestlog.ActionForward, true},
|
|
||||||
{"not announced, over the limit", 4 * sizeLimit, false,
|
|
||||||
http.StatusRequestEntityTooLarge, requestlog.ActionTooLarge, true},
|
http.StatusRequestEntityTooLarge, requestlog.ActionTooLarge, true},
|
||||||
|
{"announced, at the limit", sizeLimit, true,
|
||||||
|
http.StatusOK, requestlog.ActionForward, false},
|
||||||
|
{"not announced, over the limit", 4 * sizeLimit, false,
|
||||||
|
http.StatusRequestEntityTooLarge, requestlog.ActionTooLarge, false},
|
||||||
{"not announced, at the limit", sizeLimit, false,
|
{"not announced, at the limit", sizeLimit, false,
|
||||||
http.StatusOK, requestlog.ActionForward, true},
|
http.StatusOK, requestlog.ActionForward, false},
|
||||||
} {
|
} {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
@@ -64,8 +66,8 @@ func TestRequestBodyLimit(t *testing.T) {
|
|||||||
tc.want)
|
tc.want)
|
||||||
wantLine(t, out.requestLine(t), tc.want, tc.action)
|
wantLine(t, out.requestLine(t), tc.want, tc.action)
|
||||||
|
|
||||||
if (calls.Load() > 0) != tc.reachesApp {
|
if tc.refusedBeforeApp && calls.Load() != 0 {
|
||||||
t.Errorf("the app was called %d times", calls.Load())
|
t.Errorf("the app was called %d times, want never", calls.Load())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user