github.com/michael-k/docker@v1.7.0-rc2/integration-cli/docker_api_test.go (about) 1 package main 2 3 import ( 4 "net/http" 5 "net/http/httputil" 6 "time" 7 8 "github.com/go-check/check" 9 ) 10 11 func (s *DockerSuite) TestApiOptionsRoute(c *check.C) { 12 status, _, err := sockRequest("OPTIONS", "/", nil) 13 c.Assert(status, check.Equals, http.StatusOK) 14 c.Assert(err, check.IsNil) 15 } 16 17 func (s *DockerSuite) TestApiGetEnabledCors(c *check.C) { 18 res, body, err := sockRequestRaw("GET", "/version", nil, "") 19 body.Close() 20 c.Assert(err, check.IsNil) 21 c.Assert(res.StatusCode, check.Equals, http.StatusOK) 22 // TODO: @runcom incomplete tests, why old integration tests had this headers 23 // and here none of the headers below are in the response? 24 //c.Log(res.Header) 25 //c.Assert(res.Header.Get("Access-Control-Allow-Origin"), check.Equals, "*") 26 //c.Assert(res.Header.Get("Access-Control-Allow-Headers"), check.Equals, "Origin, X-Requested-With, Content-Type, Accept, X-Registry-Auth") 27 } 28 29 func (s *DockerSuite) TestVersionStatusCode(c *check.C) { 30 conn, err := sockConn(time.Duration(10 * time.Second)) 31 c.Assert(err, check.IsNil) 32 33 client := httputil.NewClientConn(conn, nil) 34 defer client.Close() 35 36 req, err := http.NewRequest("GET", "/v999.0/version", nil) 37 c.Assert(err, check.IsNil) 38 req.Header.Set("User-Agent", "Docker-Client/999.0") 39 40 res, err := client.Do(req) 41 c.Assert(res.StatusCode, check.Equals, http.StatusBadRequest) 42 }