X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/8eda8735d7a36f3752f1d426cad1fb0002b30cca..be28c5f528a93ee32eef4c1dc2d0872cb718b29f:/lib/controller/federation_test.go diff --git a/lib/controller/federation_test.go b/lib/controller/federation_test.go index d0bff84eaf..6a9ad8c15f 100644 --- a/lib/controller/federation_test.go +++ b/lib/controller/federation_test.go @@ -64,6 +64,7 @@ func (s *FederationSuite) SetUpTest(c *check.C) { cluster.TLS.Insecure = true cluster.API.MaxItemsPerResponse = 1000 cluster.API.MaxRequestAmplification = 4 + cluster.API.RequestTimeout = arvados.Duration(5 * time.Minute) arvadostest.SetServiceURL(&cluster.Services.RailsAPI, "http://localhost:1/") arvadostest.SetServiceURL(&cluster.Services.Controller, "http://localhost:/") s.testHandler = &Handler{Cluster: cluster} @@ -586,6 +587,21 @@ func (s *FederationSuite) TestUpdateRemoteContainerRequest(c *check.C) { setPri(1) // Reset fixture so side effect doesn't break other tests. } +func (s *FederationSuite) TestCreateContainerRequestBadToken(c *check.C) { + defer s.localServiceReturns404(c).Close() + // pass cluster_id via query parameter, this allows arvados-controller + // to avoid parsing the body + req := httptest.NewRequest("POST", "/arvados/v1/container_requests?cluster_id=zzzzz", + strings.NewReader(`{"container_request":{}}`)) + req.Header.Set("Authorization", "Bearer abcdefg") + req.Header.Set("Content-type", "application/json") + resp := s.testRequest(req).Result() + c.Check(resp.StatusCode, check.Equals, http.StatusForbidden) + var e map[string][]string + c.Check(json.NewDecoder(resp.Body).Decode(&e), check.IsNil) + c.Check(e["errors"], check.DeepEquals, []string{"invalid API token"}) +} + func (s *FederationSuite) TestCreateRemoteContainerRequest(c *check.C) { defer s.localServiceReturns404(c).Close() // pass cluster_id via query parameter, this allows arvados-controller