X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/615e280721c4be51556e2c31b4baffa69dd0d6d8..b8b6fb68a54f0f81d8ad6a75cad2650179108d66:/lib/controller/router/router_test.go diff --git a/lib/controller/router/router_test.go b/lib/controller/router/router_test.go index 18fff7c9cc..0330ec4252 100644 --- a/lib/controller/router/router_test.go +++ b/lib/controller/router/router_test.go @@ -169,7 +169,7 @@ func (s *RouterIntegrationSuite) SetUpTest(c *check.C) { cluster.TLS.Insecure = true arvadostest.SetServiceURL(&cluster.Services.RailsAPI, "https://"+os.Getenv("ARVADOS_TEST_API_HOST")) url, _ := url.Parse("https://" + os.Getenv("ARVADOS_TEST_API_HOST")) - s.rtr = New(rpc.NewConn("zzzzz", url, true, rpc.PassthroughTokenProvider), nil) + s.rtr = New(rpc.NewConn("zzzzz", url, true, rpc.PassthroughTokenProvider), Config{}) } func (s *RouterIntegrationSuite) TearDownSuite(c *check.C) { @@ -226,6 +226,34 @@ func (s *RouterIntegrationSuite) TestCollectionResponses(c *check.C) { c.Check(jresp["kind"], check.Equals, "arvados#collection") } +func (s *RouterIntegrationSuite) TestMaxRequestSize(c *check.C) { + token := arvadostest.ActiveTokenV2 + for _, maxRequestSize := range []int{ + // Ensure 5M limit is enforced. + 5000000, + // Ensure 50M limit is enforced, and that a >25M body + // is accepted even though the default Go request size + // limit is 10M. + 50000000, + } { + s.rtr.config.MaxRequestSize = maxRequestSize + okstr := "a" + for len(okstr) < maxRequestSize/2 { + okstr = okstr + okstr + } + + hdr := http.Header{"Content-Type": {"application/x-www-form-urlencoded"}} + + body := bytes.NewBufferString(url.Values{"foo_bar": {okstr}}.Encode()) + _, rr, _ := doRequest(c, s.rtr, token, "POST", `/arvados/v1/collections`, hdr, body) + c.Check(rr.Code, check.Equals, http.StatusOK) + + body = bytes.NewBufferString(url.Values{"foo_bar": {okstr + okstr}}.Encode()) + _, rr, _ = doRequest(c, s.rtr, token, "POST", `/arvados/v1/collections`, hdr, body) + c.Check(rr.Code, check.Equals, http.StatusRequestEntityTooLarge) + } +} + func (s *RouterIntegrationSuite) TestContainerList(c *check.C) { token := arvadostest.ActiveTokenV2