aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/transport/http
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2017-11-21 11:56:57 +0100
committerGitHub <noreply@github.com>2017-11-21 11:56:57 +0100
commitb08cc8dc5450981530af3e6f6ad1159ae8ea8705 (patch)
treea08a49d64718262d455ec5f754aac4b4f9b94dab /plumbing/transport/http
parent97fb5e93083fbe4ea02078312ae2cbca3b145ab1 (diff)
parent2f51048cd2599d61d49085dc8ed2d51fe6dadd17 (diff)
downloadgo-git-b08cc8dc5450981530af3e6f6ad1159ae8ea8705.tar.gz
Merge pull request #649 from mcuadros/auth
transport: made public all the fields and standardized AuthMethod
Diffstat (limited to 'plumbing/transport/http')
-rw-r--r--plumbing/transport/http/common.go15
-rw-r--r--plumbing/transport/http/common_test.go2
2 files changed, 6 insertions, 11 deletions
diff --git a/plumbing/transport/http/common.go b/plumbing/transport/http/common.go
index 95103f7..10a267a 100644
--- a/plumbing/transport/http/common.go
+++ b/plumbing/transport/http/common.go
@@ -151,17 +151,12 @@ func basicAuthFromEndpoint(ep *transport.Endpoint) *BasicAuth {
return nil
}
- return NewBasicAuth(u, ep.Password)
+ return &BasicAuth{u, ep.Password}
}
// BasicAuth represent a HTTP basic auth
type BasicAuth struct {
- username, password string
-}
-
-// NewBasicAuth returns a basicAuth base on the given user and password
-func NewBasicAuth(username, password string) *BasicAuth {
- return &BasicAuth{username, password}
+ Username, Password string
}
func (a *BasicAuth) setAuth(r *http.Request) {
@@ -169,7 +164,7 @@ func (a *BasicAuth) setAuth(r *http.Request) {
return
}
- r.SetBasicAuth(a.username, a.password)
+ r.SetBasicAuth(a.Username, a.Password)
}
// Name is name of the auth
@@ -179,11 +174,11 @@ func (a *BasicAuth) Name() string {
func (a *BasicAuth) String() string {
masked := "*******"
- if a.password == "" {
+ if a.Password == "" {
masked = "<empty>"
}
- return fmt.Sprintf("%s - %s:%s", a.Name(), a.username, masked)
+ return fmt.Sprintf("%s - %s:%s", a.Name(), a.Username, masked)
}
// Err is a dedicated error to return errors based on status code
diff --git a/plumbing/transport/http/common_test.go b/plumbing/transport/http/common_test.go
index bd1bec3..c2c0d3e 100644
--- a/plumbing/transport/http/common_test.go
+++ b/plumbing/transport/http/common_test.go
@@ -49,7 +49,7 @@ func (s *UploadPackSuite) TestNewClient(c *C) {
}
func (s *ClientSuite) TestNewBasicAuth(c *C) {
- a := NewBasicAuth("foo", "qux")
+ a := &BasicAuth{"foo", "qux"}
c.Assert(a.Name(), Equals, "http-basic-auth")
c.Assert(a.String(), Equals, "http-basic-auth - foo:*******")