1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
12 check "gopkg.in/check.v1"
15 var _ = check.Suite(&AuthHandlerSuite{})
17 type AuthHandlerSuite struct{}
19 func (s *AuthHandlerSuite) TestCORS(c *check.C) {
23 resp := httptest.NewRecorder()
28 "Access-Control-Request-Method": {"GET"},
31 h.ServeHTTP(resp, req)
32 c.Check(resp.Code, check.Equals, http.StatusOK)
33 c.Check(resp.Header().Get("Access-Control-Allow-Methods"), check.Equals, "GET, POST")
34 c.Check(resp.Header().Get("Access-Control-Allow-Headers"), check.Equals, "Authorization, Content-Type")
35 c.Check(resp.Header().Get("Access-Control-Allow-Origin"), check.Equals, "*")
36 c.Check(resp.Body.String(), check.Equals, "")
38 // CORS actual request. Bogus token and path ensure
39 // authHandler responds 4xx without calling our wrapped (nil)
41 u, err := url.Parse("git.zzzzz.arvadosapi.com/test")
42 c.Assert(err, check.Equals, nil)
43 resp = httptest.NewRecorder()
49 "Authorization": {"OAuth2 foobar"},
52 h.ServeHTTP(resp, req)
53 c.Check(resp.Header().Get("Access-Control-Allow-Origin"), check.Equals, "*")