aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/transport/http/common_test.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2018-06-11 10:26:30 +0200
committerGitHub <noreply@github.com>2018-06-11 10:26:30 +0200
commit0710c6cb710a0cdab04ab7f61cc62e23cfcacbee (patch)
tree38ca4ef4d3320aeebed55b5154926bf23dd5b3c4 /plumbing/transport/http/common_test.go
parente7cf6d22593c8fcdd393b0da9d922c670b61a199 (diff)
parentbf6190841e8b6cd3a216bc056e5b71c73e18c410 (diff)
downloadgo-git-0710c6cb710a0cdab04ab7f61cc62e23cfcacbee.tar.gz
Merge pull request #859 from ebilling/fix-858/token-authentication
plumbing/transport: http, Adds token authentication support [Fixes #858]
Diffstat (limited to 'plumbing/transport/http/common_test.go')
-rw-r--r--plumbing/transport/http/common_test.go13
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)