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