X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/b6d7efab2c4bffa3fabd55b166e44cca8ac1391f..d3c60bd8a33f6b23611155e836a783ab236a76b8:/lib/controller/router/router_test.go diff --git a/lib/controller/router/router_test.go b/lib/controller/router/router_test.go index 4cabe70f16..0330ec4252 100644 --- a/lib/controller/router/router_test.go +++ b/lib/controller/router/router_test.go @@ -38,8 +38,8 @@ type RouterSuite struct { func (s *RouterSuite) SetUpTest(c *check.C) { s.stub = arvadostest.APIStub{} s.rtr = &router{ - mux: mux.NewRouter(), - fed: &s.stub, + mux: mux.NewRouter(), + backend: &s.stub, } s.rtr.addRoutes() } @@ -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)) + 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 @@ -273,7 +301,7 @@ func (s *RouterIntegrationSuite) TestContainerLock(c *check.C) { c.Check(rr.Code, check.Equals, http.StatusOK) c.Check(jresp["uuid"], check.HasLen, 27) c.Check(jresp["state"], check.Equals, "Locked") - _, rr, jresp = doRequest(c, s.rtr, token, "POST", "/arvados/v1/containers/"+uuid+"/lock", nil, nil) + _, rr, _ = doRequest(c, s.rtr, token, "POST", "/arvados/v1/containers/"+uuid+"/lock", nil, nil) c.Check(rr.Code, check.Equals, http.StatusUnprocessableEntity) c.Check(rr.Body.String(), check.Not(check.Matches), `.*"uuid":.*`) _, rr, jresp = doRequest(c, s.rtr, token, "POST", "/arvados/v1/containers/"+uuid+"/unlock", nil, nil)