13493: Test OPTIONS method.
authorTom Clegg <tclegg@veritasgenetics.com>
Tue, 10 Jul 2018 19:54:22 +0000 (15:54 -0400)
committerTom Clegg <tclegg@veritasgenetics.com>
Tue, 10 Jul 2018 19:54:22 +0000 (15:54 -0400)
API: Return empty body for OPTIONS requests.

Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tclegg@veritasgenetics.com>

lib/controller/federation_test.go
services/api/app/controllers/static_controller.rb

index 72f4259c989f71854228c4f497709d398140b10b..268209280eaea8c5357e8550db1d3673e1d1baba 100644 (file)
@@ -170,6 +170,23 @@ func (s *FederationSuite) TestGetRemoteWorkflow(c *check.C) {
        c.Check(wf.OwnerUUID, check.Equals, arvadostest.ActiveUserUUID)
 }
 
+func (s *FederationSuite) TestOptionsMethod(c *check.C) {
+       req := httptest.NewRequest("OPTIONS", "/arvados/v1/workflows/"+arvadostest.WorkflowWithDefinitionYAMLUUID, nil)
+       req.Header.Set("Origin", "https://example.com")
+       resp := s.testRequest(req)
+       c.Check(resp.StatusCode, check.Equals, http.StatusOK)
+       body, err := ioutil.ReadAll(resp.Body)
+       c.Check(err, check.IsNil)
+       c.Check(string(body), check.Equals, "")
+       c.Check(resp.Header.Get("Access-Control-Allow-Origin"), check.Equals, "*")
+       for _, hdr := range []string{"Authorization", "Content-Type"} {
+               c.Check(resp.Header.Get("Access-Control-Allow-Headers"), check.Matches, ".*"+hdr+".*")
+       }
+       for _, method := range []string{"GET", "HEAD", "PUT", "POST", "DELETE"} {
+               c.Check(resp.Header.Get("Access-Control-Allow-Methods"), check.Matches, ".*"+method+".*")
+       }
+}
+
 func (s *FederationSuite) TestRemoteWithTokenInQuery(c *check.C) {
        req := httptest.NewRequest("GET", "/arvados/v1/workflows/"+strings.Replace(arvadostest.WorkflowWithDefinitionYAMLUUID, "zzzzz-", "zmock-", 1)+"?api_token="+arvadostest.ActiveToken, nil)
        s.testRequest(req)
index 594dc436297224463f860fe3d74cb9d718e02bdf..f0992c18314ac22bc60034855a204ab3aedce796 100644 (file)
@@ -25,7 +25,7 @@ class StaticController < ApplicationController
   end
 
   def empty
-    render text: "-"
+    render text: ""
   end
 
 end