diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2017-11-21 11:44:21 +0100 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2017-11-21 11:44:21 +0100 |
commit | 2f51048cd2599d61d49085dc8ed2d51fe6dadd17 (patch) | |
tree | a08a49d64718262d455ec5f754aac4b4f9b94dab /plumbing/transport/http | |
parent | 97fb5e93083fbe4ea02078312ae2cbca3b145ab1 (diff) | |
download | go-git-2f51048cd2599d61d49085dc8ed2d51fe6dadd17.tar.gz |
transport: made public all the fields and standardize AuthMethod
Signed-off-by: Máximo Cuadros <mcuadros@gmail.com>
Diffstat (limited to 'plumbing/transport/http')
-rw-r--r-- | plumbing/transport/http/common.go | 15 | ||||
-rw-r--r-- | plumbing/transport/http/common_test.go | 2 |
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:*******") |