X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/6cfcb064bc3f330f8857fdc57124fb59a1e3ca16..d2a55e74eadd28effb16f60d8d9cbe9bbedef14c:/lib/controller/router/router_test.go diff --git a/lib/controller/router/router_test.go b/lib/controller/router/router_test.go index 5700f01e2f..639d2a28b4 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() } @@ -47,6 +47,7 @@ func (s *RouterSuite) SetUpTest(c *check.C) { func (s *RouterSuite) TestOptions(c *check.C) { token := arvadostest.ActiveToken for _, trial := range []struct { + comment string // unparsed -- only used to help match test failures to trials method string path string header http.Header @@ -120,6 +121,32 @@ func (s *RouterSuite) TestOptions(c *check.C) { shouldCall: "CollectionList", withOptions: arvados.ListOptions{Limit: 123, Offset: 456, IncludeTrash: true, IncludeOldVersions: true}, }, + { + comment: "form-encoded expression filter in query string", + method: "GET", + path: "/arvados/v1/collections?filters=[%22(foo25M 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 +330,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) @@ -286,6 +343,12 @@ func (s *RouterIntegrationSuite) TestContainerLock(c *check.C) { c.Check(jresp["uuid"], check.IsNil) } +func (s *RouterIntegrationSuite) TestWritableBy(c *check.C) { + _, rr, jresp := doRequest(c, s.rtr, arvadostest.ActiveTokenV2, "GET", `/arvados/v1/users/`+arvadostest.ActiveUserUUID, nil, nil) + c.Check(rr.Code, check.Equals, http.StatusOK) + c.Check(jresp["writable_by"], check.DeepEquals, []interface{}{"zzzzz-tpzed-000000000000000", "zzzzz-tpzed-xurymjxw79nv3jz", "zzzzz-j7d0g-48foin4vonvc2at"}) +} + func (s *RouterIntegrationSuite) TestFullTimestampsInResponse(c *check.C) { uuid := arvadostest.CollectionReplicationDesired2Confirmed2UUID token := arvadostest.ActiveTokenV2