diff options
author | Eric Billingsley <eric@calculi.com> | 2018-06-08 15:19:12 -0700 |
---|---|---|
committer | Eric Billingsley <eric@calculi.com> | 2018-06-08 15:19:12 -0700 |
commit | bf6190841e8b6cd3a216bc056e5b71c73e18c410 (patch) | |
tree | 8e5a48002cf8aa1d0cdb4bac838b1af15f34d1e3 /plumbing/transport/http/common_test.go | |
parent | b23570073eaee3489e5e3d666f22ba5cbeb53243 (diff) | |
download | go-git-bf6190841e8b6cd3a216bc056e5b71c73e18c410.tar.gz |
plumbing/transport: http, Adds token authentication support [Fixes #858]
Signed-off-by: Eric Billingsley <ebilling@babrains.com>
Diffstat (limited to 'plumbing/transport/http/common_test.go')
-rw-r--r-- | plumbing/transport/http/common_test.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/plumbing/transport/http/common_test.go b/plumbing/transport/http/common_test.go index 8d57996..71eede4 100644 --- a/plumbing/transport/http/common_test.go +++ b/plumbing/transport/http/common_test.go @@ -54,6 +54,19 @@ func (s *ClientSuite) TestNewBasicAuth(c *C) { c.Assert(a.String(), Equals, "http-basic-auth - foo:*******") } +func (s *ClientSuite) TestNewTokenAuth(c *C) { + a := &TokenAuth{"OAUTH-TOKEN-TEXT"} + + c.Assert(a.Name(), Equals, "http-token-auth") + c.Assert(a.String(), Equals, "http-token-auth - *******") + + // Check header is set correctly + req, err := http.NewRequest("GET", "https://github.com/git-fixtures/basic", nil) + c.Assert(err, Equals, nil) + a.setAuth(req) + c.Assert(req.Header.Get("Authorization"), Equals, "Bearer OAUTH-TOKEN-TEXT") +} + func (s *ClientSuite) TestNewErrOK(c *C) { res := &http.Response{StatusCode: http.StatusOK} err := NewErr(res) |