Skip to content

Commit

Permalink
Add test for global request body size limit
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrickTaibel committed May 24, 2022
1 parent e2bb656 commit b57f3a3
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions gateway/proxy_muxer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"net/http/httptest"
"reflect"
"strconv"
"strings"
"sync/atomic"
"testing"

Expand Down Expand Up @@ -310,3 +311,19 @@ func TestHandle404(t *testing.T) {
{Path: "/nonexisting", Code: http.StatusNotFound, BodyMatch: http.StatusText(http.StatusNotFound)},
}...)
}

func TestRequestBodyLimit(t *testing.T) {
ts := StartTest(func(globalConf *config.Config) {
globalConf.HttpServerOptions.MaxRequestBodySize = 1024
})
defer ts.Close()

ts.Gw.BuildAndLoadAPI(func(spec *APISpec) {
spec.UseKeylessAccess = true
})

_, _ = ts.Run(t, []test.TestCase{
{Path: "/sample/", Method: "POST", Data: strings.Repeat("a", 1024), Code: http.StatusOK},
{Path: "/sample/", Method: "POST", Data: strings.Repeat("a", 1025), Code: http.StatusRequestEntityTooLarge},
}...)
}

0 comments on commit b57f3a3

Please sign in to comment.