X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/9833a2b9be1a722bd9aad08baf48ca072bde7ca7..f6a29cc714dd3409f865ceb799a886dd0b5d8152:/lib/controller/router/router_test.go diff --git a/lib/controller/router/router_test.go b/lib/controller/router/router_test.go index 18fff7c9cc..11b090a214 100644 --- a/lib/controller/router/router_test.go +++ b/lib/controller/router/router_test.go @@ -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 @@ -91,6 +92,12 @@ func (s *RouterSuite) TestOptions(c *check.C) { shouldCall: "CollectionList", withOptions: arvados.ListOptions{Limit: -1}, }, + { + method: "GET", + path: "/arvados/v1/api_client_authorizations", + shouldCall: "APIClientAuthorizationList", + withOptions: arvados.ListOptions{Limit: -1}, + }, { method: "GET", path: "/arvados/v1/collections?limit=123&offset=456&include_trash=true&include_old_versions=1", @@ -120,6 +127,38 @@ 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 @@ -316,10 +385,10 @@ func (s *RouterIntegrationSuite) TestFullTimestampsInResponse(c *check.C) { func (s *RouterIntegrationSuite) TestSelectParam(c *check.C) { uuid := arvadostest.QueuedContainerUUID token := arvadostest.ActiveTokenV2 + // GET for _, sel := range [][]string{ {"uuid", "command"}, {"uuid", "command", "uuid"}, - {"", "command", "uuid"}, } { j, err := json.Marshal(sel) c.Assert(err, check.IsNil) @@ -327,14 +396,32 @@ func (s *RouterIntegrationSuite) TestSelectParam(c *check.C) { c.Check(rr.Code, check.Equals, http.StatusOK) c.Check(resp["kind"], check.Equals, "arvados#container") - c.Check(resp["etag"], check.FitsTypeOf, "") - c.Check(resp["etag"], check.Not(check.Equals), "") c.Check(resp["uuid"], check.HasLen, 27) c.Check(resp["command"], check.HasLen, 2) c.Check(resp["mounts"], check.IsNil) _, hasMounts := resp["mounts"] c.Check(hasMounts, check.Equals, false) } + // POST & PUT + uuid = arvadostest.FooCollection + j, err := json.Marshal([]string{"uuid", "description"}) + c.Assert(err, check.IsNil) + for _, method := range []string{"PUT", "POST"} { + desc := "Today is " + time.Now().String() + reqBody := "{\"description\":\"" + desc + "\"}" + var resp map[string]interface{} + var rr *httptest.ResponseRecorder + if method == "PUT" { + _, rr, resp = doRequest(c, s.rtr, token, method, "/arvados/v1/collections/"+uuid+"?select="+string(j), nil, bytes.NewReader([]byte(reqBody))) + } else { + _, rr, resp = doRequest(c, s.rtr, token, method, "/arvados/v1/collections?select="+string(j), nil, bytes.NewReader([]byte(reqBody))) + } + c.Check(rr.Code, check.Equals, http.StatusOK) + c.Check(resp["kind"], check.Equals, "arvados#collection") + c.Check(resp["uuid"], check.HasLen, 27) + c.Check(resp["description"], check.Equals, desc) + c.Check(resp["manifest_text"], check.IsNil) + } } func (s *RouterIntegrationSuite) TestHEAD(c *check.C) {