5824: gofmt
authorTom Clegg <tom@curoverse.com>
Fri, 2 Oct 2015 02:16:51 +0000 (22:16 -0400)
committerTom Clegg <tom@curoverse.com>
Sat, 17 Oct 2015 00:02:16 +0000 (20:02 -0400)
services/keep-web/handler.go
services/keep-web/handler_test.go
services/keep-web/server_test.go

index b39a941480d25e732ffed93c7a2a0683e06fc435..9751cd18132f3e1968a9d3b3cbf0022cd0ab0284 100644 (file)
@@ -21,9 +21,9 @@ import (
 type handler struct{}
 
 var (
-       clientPool      = arvadosclient.MakeClientPool()
-       trustAllContent = false
-       anonymousTokens []string
+       clientPool         = arvadosclient.MakeClientPool()
+       trustAllContent    = false
+       anonymousTokens    []string
        attachmentOnlyHost = ""
 )
 
index a64aeb5f79e645c03b0eca772ebc4e6d512e484b..9b5ab2a418b31f31a3758c2c6d8d26f53d2867ef 100644 (file)
@@ -16,7 +16,7 @@ import (
 
 var _ = check.Suite(&UnitSuite{})
 
-type UnitSuite struct {}
+type UnitSuite struct{}
 
 func mustParseURL(s string) *url.URL {
        r, err := url.Parse(s)
@@ -34,7 +34,7 @@ func (s *IntegrationSuite) TestVhost404(c *check.C) {
                resp := httptest.NewRecorder()
                req := &http.Request{
                        Method: "GET",
-                       URL: mustParseURL(testURL),
+                       URL:    mustParseURL(testURL),
                }
                (&handler{}).ServeHTTP(resp, req)
                c.Check(resp.Code, check.Equals, http.StatusNotFound)
@@ -52,7 +52,7 @@ func (s *IntegrationSuite) TestVhostViaAuthzHeader(c *check.C) {
        doVhostRequests(c, authzViaAuthzHeader)
 }
 func authzViaAuthzHeader(r *http.Request, tok string) int {
-       r.Header.Add("Authorization", "OAuth2 " + tok)
+       r.Header.Add("Authorization", "OAuth2 "+tok)
        return http.StatusUnauthorized
 }
 
@@ -61,7 +61,7 @@ func (s *IntegrationSuite) TestVhostViaCookieValue(c *check.C) {
 }
 func authzViaCookieValue(r *http.Request, tok string) int {
        r.AddCookie(&http.Cookie{
-               Name: "api_token",
+               Name:  "api_token",
                Value: auth.EncodeTokenCookie([]byte(tok)),
        })
        return http.StatusUnauthorized
@@ -120,8 +120,8 @@ func doVhostRequestsWithHostPath(c *check.C, authz authorizer, hostPath string)
                u := mustParseURL("http://" + hostPath)
                req := &http.Request{
                        Method: "GET",
-                       Host: u.Host,
-                       URL: u,
+                       Host:   u.Host,
+                       URL:    u,
                        Header: http.Header{},
                }
                failCode := authz(req, tok)
@@ -157,8 +157,8 @@ func doReq(req *http.Request) *httptest.ResponseRecorder {
        u, _ := req.URL.Parse(resp.Header().Get("Location"))
        req = &http.Request{
                Method: "GET",
-               Host: u.Host,
-               URL: u,
+               Host:   u.Host,
+               URL:    u,
                Header: http.Header{},
        }
        for _, c := range cookies {
@@ -169,8 +169,8 @@ func doReq(req *http.Request) *httptest.ResponseRecorder {
 
 func (s *IntegrationSuite) TestVhostRedirectQueryTokenToCookie(c *check.C) {
        s.testVhostRedirectTokenToCookie(c, "GET",
-               arvadostest.FooCollection + ".example.com/foo",
-               "?api_token=" + arvadostest.ActiveToken,
+               arvadostest.FooCollection+".example.com/foo",
+               "?api_token="+arvadostest.ActiveToken,
                "text/plain",
                "",
                http.StatusOK,
@@ -179,8 +179,8 @@ func (s *IntegrationSuite) TestVhostRedirectQueryTokenToCookie(c *check.C) {
 
 func (s *IntegrationSuite) TestVhostRedirectQueryTokenSingleOriginError(c *check.C) {
        s.testVhostRedirectTokenToCookie(c, "GET",
-               "example.com/c=" + arvadostest.FooCollection + "/foo",
-               "?api_token=" + arvadostest.ActiveToken,
+               "example.com/c="+arvadostest.FooCollection+"/foo",
+               "?api_token="+arvadostest.ActiveToken,
                "text/plain",
                "",
                http.StatusBadRequest,
@@ -193,8 +193,8 @@ func (s *IntegrationSuite) TestVhostRedirectQueryTokenTrustAllContent(c *check.C
        }(trustAllContent)
        trustAllContent = true
        s.testVhostRedirectTokenToCookie(c, "GET",
-               "example.com/c=" + arvadostest.FooCollection + "/foo",
-               "?api_token=" + arvadostest.ActiveToken,
+               "example.com/c="+arvadostest.FooCollection+"/foo",
+               "?api_token="+arvadostest.ActiveToken,
                "text/plain",
                "",
                http.StatusOK,
@@ -208,16 +208,16 @@ func (s *IntegrationSuite) TestVhostRedirectQueryTokenAttachmentOnlyHost(c *chec
        attachmentOnlyHost = "example.com:1234"
 
        s.testVhostRedirectTokenToCookie(c, "GET",
-               "example.com/c=" + arvadostest.FooCollection + "/foo",
-               "?api_token=" + arvadostest.ActiveToken,
+               "example.com/c="+arvadostest.FooCollection+"/foo",
+               "?api_token="+arvadostest.ActiveToken,
                "text/plain",
                "",
                http.StatusBadRequest,
        )
 
        resp := s.testVhostRedirectTokenToCookie(c, "GET",
-               "example.com:1234/c=" + arvadostest.FooCollection + "/foo",
-               "?api_token=" + arvadostest.ActiveToken,
+               "example.com:1234/c="+arvadostest.FooCollection+"/foo",
+               "?api_token="+arvadostest.ActiveToken,
                "text/plain",
                "",
                http.StatusOK,
@@ -227,7 +227,7 @@ func (s *IntegrationSuite) TestVhostRedirectQueryTokenAttachmentOnlyHost(c *chec
 
 func (s *IntegrationSuite) TestVhostRedirectPOSTFormTokenToCookie(c *check.C) {
        s.testVhostRedirectTokenToCookie(c, "POST",
-               arvadostest.FooCollection + ".example.com/foo",
+               arvadostest.FooCollection+".example.com/foo",
                "",
                "application/x-www-form-urlencoded",
                url.Values{"api_token": {arvadostest.ActiveToken}}.Encode(),
@@ -237,7 +237,7 @@ func (s *IntegrationSuite) TestVhostRedirectPOSTFormTokenToCookie(c *check.C) {
 
 func (s *IntegrationSuite) TestVhostRedirectPOSTFormTokenToCookie404(c *check.C) {
        s.testVhostRedirectTokenToCookie(c, "POST",
-               arvadostest.FooCollection + ".example.com/foo",
+               arvadostest.FooCollection+".example.com/foo",
                "",
                "application/x-www-form-urlencoded",
                url.Values{"api_token": {arvadostest.SpectatorToken}}.Encode(),
@@ -249,10 +249,10 @@ func (s *IntegrationSuite) testVhostRedirectTokenToCookie(c *check.C, method, ho
        u, _ := url.Parse(`http://` + hostPath + queryString)
        req := &http.Request{
                Method: method,
-               Host: u.Host,
-               URL: u,
+               Host:   u.Host,
+               URL:    u,
                Header: http.Header{"Content-Type": {contentType}},
-               Body: ioutil.NopCloser(strings.NewReader(body)),
+               Body:   ioutil.NopCloser(strings.NewReader(body)),
        }
 
        resp := httptest.NewRecorder()
@@ -261,14 +261,14 @@ func (s *IntegrationSuite) testVhostRedirectTokenToCookie(c *check.C, method, ho
                c.Assert(resp.Code, check.Equals, expectStatus)
                return resp
        }
-       c.Check(resp.Body.String(), check.Matches, `.*href="//` + regexp.QuoteMeta(html.EscapeString(hostPath)) + `".*`)
+       c.Check(resp.Body.String(), check.Matches, `.*href="//`+regexp.QuoteMeta(html.EscapeString(hostPath))+`".*`)
        cookies := (&http.Response{Header: resp.Header()}).Cookies()
 
        u, _ = u.Parse(resp.Header().Get("Location"))
        req = &http.Request{
                Method: "GET",
-               Host: u.Host,
-               URL: u,
+               Host:   u.Host,
+               URL:    u,
                Header: http.Header{},
        }
        for _, c := range cookies {
index fdbb50e79f6a42c329df6581ebdc7d7ea1dcee6e..740d243f7be7fbc8dff0de8fb247cde93b3098e2 100644 (file)
@@ -105,14 +105,14 @@ func (s *IntegrationSuite) test100BlockFile(c *check.C, blocksize int) {
        err = arv.Create("collections",
                map[string]interface{}{
                        "collection": map[string]interface{}{
-                               "name": fmt.Sprintf("testdata blocksize=%d", blocksize),
+                               "name":          fmt.Sprintf("testdata blocksize=%d", blocksize),
                                "manifest_text": mtext,
                        },
                }, &coll)
        c.Assert(err, check.Equals, nil)
        uuid := coll["uuid"].(string)
 
-       hdr, body, size := s.runCurl(c, arv.ApiToken, uuid + ".dl.example.com", "/testdata.bin")
+       hdr, body, size := s.runCurl(c, arv.ApiToken, uuid+".dl.example.com", "/testdata.bin")
        c.Check(hdr, check.Matches, `(?s)HTTP/1.1 200 OK\r\n.*`)
        c.Check(hdr, check.Matches, `(?si).*Content-length: `+fmt.Sprintf("%d00", blocksize)+`\r\n.*`)
        c.Check([]byte(body)[:1234], check.DeepEquals, testdata[:1234])
@@ -139,82 +139,82 @@ func (s *IntegrationSuite) Test200(c *check.C) {
        for _, spec := range []curlCase{
                // My collection
                {
-                       auth: arvadostest.ActiveToken,
-                       host: arvadostest.FooCollection + "--dl.example.com",
-                       path: "/foo",
+                       auth:    arvadostest.ActiveToken,
+                       host:    arvadostest.FooCollection + "--dl.example.com",
+                       path:    "/foo",
                        dataMD5: "acbd18db4cc2f85cedef654fccc4a4d8",
                },
                {
-                       host: strings.Replace(arvadostest.FooPdh, "+", "-", 1) + ".dl.example.com",
-                       path: "/t=" + arvadostest.ActiveToken + "/foo",
+                       host:    strings.Replace(arvadostest.FooPdh, "+", "-", 1) + ".dl.example.com",
+                       path:    "/t=" + arvadostest.ActiveToken + "/foo",
                        dataMD5: "acbd18db4cc2f85cedef654fccc4a4d8",
                },
                {
-                       path: "/c=" + arvadostest.FooPdh + "/t=" + arvadostest.ActiveToken + "/foo",
+                       path:    "/c=" + arvadostest.FooPdh + "/t=" + arvadostest.ActiveToken + "/foo",
                        dataMD5: "acbd18db4cc2f85cedef654fccc4a4d8",
                },
                {
-                       path: "/c=" + strings.Replace(arvadostest.FooPdh, "+", "-", 1) + "/t=" + arvadostest.ActiveToken + "/_/foo",
+                       path:    "/c=" + strings.Replace(arvadostest.FooPdh, "+", "-", 1) + "/t=" + arvadostest.ActiveToken + "/_/foo",
                        dataMD5: "acbd18db4cc2f85cedef654fccc4a4d8",
                },
                {
-                       path: "/collections/download/" + arvadostest.FooCollection + "/" + arvadostest.ActiveToken + "/foo",
+                       path:    "/collections/download/" + arvadostest.FooCollection + "/" + arvadostest.ActiveToken + "/foo",
                        dataMD5: "acbd18db4cc2f85cedef654fccc4a4d8",
                },
                {
-                       auth: "tokensobogus",
-                       path: "/collections/download/" + arvadostest.FooCollection + "/" + arvadostest.ActiveToken + "/foo",
+                       auth:    "tokensobogus",
+                       path:    "/collections/download/" + arvadostest.FooCollection + "/" + arvadostest.ActiveToken + "/foo",
                        dataMD5: "acbd18db4cc2f85cedef654fccc4a4d8",
                },
                {
-                       auth: arvadostest.ActiveToken,
-                       path: "/collections/download/" + arvadostest.FooCollection + "/" + arvadostest.ActiveToken + "/foo",
+                       auth:    arvadostest.ActiveToken,
+                       path:    "/collections/download/" + arvadostest.FooCollection + "/" + arvadostest.ActiveToken + "/foo",
                        dataMD5: "acbd18db4cc2f85cedef654fccc4a4d8",
                },
                {
-                       auth: arvadostest.AnonymousToken,
-                       path: "/collections/download/" + arvadostest.FooCollection + "/" + arvadostest.ActiveToken + "/foo",
+                       auth:    arvadostest.AnonymousToken,
+                       path:    "/collections/download/" + arvadostest.FooCollection + "/" + arvadostest.ActiveToken + "/foo",
                        dataMD5: "acbd18db4cc2f85cedef654fccc4a4d8",
                },
 
                // Anonymously accessible user agreement
                {
-                       path: "/c=" + arvadostest.HelloWorldCollection + "/Hello%20world.txt",
+                       path:    "/c=" + arvadostest.HelloWorldCollection + "/Hello%20world.txt",
                        dataMD5: "f0ef7081e1539ac00ef5b761b4fb01b3",
                },
                {
-                       host: arvadostest.HelloWorldCollection + ".dl.example.com",
-                       path: "/Hello%20world.txt",
+                       host:    arvadostest.HelloWorldCollection + ".dl.example.com",
+                       path:    "/Hello%20world.txt",
                        dataMD5: "f0ef7081e1539ac00ef5b761b4fb01b3",
                },
                {
-                       host: arvadostest.HelloWorldCollection + ".dl.example.com",
-                       path: "/_/Hello%20world.txt",
+                       host:    arvadostest.HelloWorldCollection + ".dl.example.com",
+                       path:    "/_/Hello%20world.txt",
                        dataMD5: "f0ef7081e1539ac00ef5b761b4fb01b3",
                },
                {
-                       path: "/collections/" + arvadostest.HelloWorldCollection + "/Hello%20world.txt",
+                       path:    "/collections/" + arvadostest.HelloWorldCollection + "/Hello%20world.txt",
                        dataMD5: "f0ef7081e1539ac00ef5b761b4fb01b3",
                },
                {
-                       auth: arvadostest.ActiveToken,
-                       path: "/collections/" + arvadostest.HelloWorldCollection + "/Hello%20world.txt",
+                       auth:    arvadostest.ActiveToken,
+                       path:    "/collections/" + arvadostest.HelloWorldCollection + "/Hello%20world.txt",
                        dataMD5: "f0ef7081e1539ac00ef5b761b4fb01b3",
                },
                {
-                       auth: arvadostest.SpectatorToken,
-                       path: "/collections/" + arvadostest.HelloWorldCollection + "/Hello%20world.txt",
+                       auth:    arvadostest.SpectatorToken,
+                       path:    "/collections/" + arvadostest.HelloWorldCollection + "/Hello%20world.txt",
                        dataMD5: "f0ef7081e1539ac00ef5b761b4fb01b3",
                },
                {
-                       auth: arvadostest.SpectatorToken,
-                       host: arvadostest.HelloWorldCollection + "--dl.example.com",
-                       path: "/Hello%20world.txt",
+                       auth:    arvadostest.SpectatorToken,
+                       host:    arvadostest.HelloWorldCollection + "--dl.example.com",
+                       path:    "/Hello%20world.txt",
                        dataMD5: "f0ef7081e1539ac00ef5b761b4fb01b3",
                },
                {
-                       auth: arvadostest.SpectatorToken,
-                       path: "/collections/download/" + arvadostest.HelloWorldCollection + "/" + arvadostest.SpectatorToken + "/Hello%20world.txt",
+                       auth:    arvadostest.SpectatorToken,
+                       path:    "/collections/download/" + arvadostest.HelloWorldCollection + "/" + arvadostest.SpectatorToken + "/Hello%20world.txt",
                        dataMD5: "f0ef7081e1539ac00ef5b761b4fb01b3",
                },
        } {
@@ -238,7 +238,7 @@ func (s *IntegrationSuite) Test200(c *check.C) {
 func (s *IntegrationSuite) runCurl(c *check.C, token, host, uri string, args ...string) (hdr, bodyPart string, bodySize int64) {
        curlArgs := []string{"--silent", "--show-error", "--include"}
        testHost, testPort, _ := net.SplitHostPort(s.testServer.Addr)
-       curlArgs = append(curlArgs, "--resolve", host + ":" + testPort + ":" + testHost)
+       curlArgs = append(curlArgs, "--resolve", host+":"+testPort+":"+testHost)
        if token != "" {
                curlArgs = append(curlArgs, "-H", "Authorization: OAuth2 "+token)
        }