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