2411: Remove golang<1.4 shim.
authorTom Clegg <tom@curoverse.com>
Wed, 28 Jun 2017 19:38:36 +0000 (15:38 -0400)
committerTom Clegg <tom@curoverse.com>
Wed, 28 Jun 2017 20:27:56 +0000 (16:27 -0400)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@curoverse.com>

sdk/go/auth/auth.go
sdk/go/auth/basic_auth_go13.go [deleted file]
sdk/go/auth/basic_auth_go14.go [deleted file]
sdk/go/auth/basic_auth_test.go [deleted file]

index 9c2a759f60ebe9acd11dd52574b7dc66f42fe7cc..730989b3a371ebcb2874784bbd76f668c22a6db2 100644 (file)
@@ -45,7 +45,7 @@ func (a *Credentials) LoadTokensFromHTTPRequest(r *http.Request) {
 
        // Load base64-encoded token from "Authorization: Basic ..."
        // header (typically used by git via credential helper)
-       if _, password, ok := BasicAuth(r); ok {
+       if _, password, ok := r.BasicAuth(); ok {
                a.Tokens = append(a.Tokens, password)
        }
 
diff --git a/sdk/go/auth/basic_auth_go13.go b/sdk/go/auth/basic_auth_go13.go
deleted file mode 100644 (file)
index 7108ded..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright (C) The Arvados Authors. All rights reserved.
-//
-// SPDX-License-Identifier: Apache-2.0
-
-// +build !go1.4
-
-package auth
-
-import (
-       "encoding/base64"
-       "net/http"
-       "strings"
-)
-
-func BasicAuth(r *http.Request) (username, password string, ok bool) {
-       tokens := strings.SplitN(r.Header.Get("Authorization"), " ", 2)
-       if len(tokens) != 2 || tokens[0] != "Basic" {
-               return "", "", false
-       }
-
-       decoded, err := base64.StdEncoding.DecodeString(tokens[1])
-       if err != nil {
-               return "", "", false
-       }
-
-       userAndPass := strings.SplitN(string(decoded), ":", 2)
-       if len(userAndPass) != 2 {
-               return "", "", false
-       }
-
-       return userAndPass[0], userAndPass[1], true
-}
diff --git a/sdk/go/auth/basic_auth_go14.go b/sdk/go/auth/basic_auth_go14.go
deleted file mode 100644 (file)
index bfb430b..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright (C) The Arvados Authors. All rights reserved.
-//
-// SPDX-License-Identifier: Apache-2.0
-
-// +build go1.4
-
-package auth
-
-import (
-       "net/http"
-)
-
-func BasicAuth(r *http.Request) (username, password string, ok bool) {
-       return r.BasicAuth()
-}
diff --git a/sdk/go/auth/basic_auth_test.go b/sdk/go/auth/basic_auth_test.go
deleted file mode 100644 (file)
index 83b737e..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright (C) The Arvados Authors. All rights reserved.
-//
-// SPDX-License-Identifier: Apache-2.0
-
-package auth
-
-import (
-       "net/http"
-       "testing"
-)
-
-type basicAuthTestCase struct {
-       hdr  string
-       user string
-       pass string
-       ok   bool
-}
-
-func TestBasicAuth(t *testing.T) {
-       tests := []basicAuthTestCase{
-               {"Basic Zm9vOmJhcg==", "foo", "bar", true},
-               {"Bogus Zm9vOmJhcg==", "", "", false},
-               {"Zm9vOmJhcg==", "", "", false},
-               {"Basic", "", "", false},
-               {"", "", "", false},
-       }
-       for _, test := range tests {
-               if u, p, ok := BasicAuth(&http.Request{Header: map[string][]string{
-                       "Authorization": {test.hdr},
-               }}); u != test.user || p != test.pass || ok != test.ok {
-                       t.Error("got:", u, p, ok, "expected:", test.user, test.pass, test.ok, "from:", test.hdr)
-               }
-       }
-}