diff options
author | Santiago M. Mola <santi@mola.io> | 2018-09-27 09:27:48 +0200 |
---|---|---|
committer | Santiago M. Mola <santi@mola.io> | 2018-09-27 09:29:21 +0200 |
commit | 37f80c63cc19d8f224d7c5eb0338594b9cef3838 (patch) | |
tree | e5f1141c28d4508420c8c50c48fc7b3b4907ce14 | |
parent | 1fdd36c814746efdf199392135696cfde7287b44 (diff) | |
download | go-git-37f80c63cc19d8f224d7c5eb0338594b9cef3838.tar.gz |
test: improve test for urlencoded user:pass
Signed-off-by: Santiago M. Mola <santi@mola.io>
-rw-r--r-- | plumbing/transport/common_test.go | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/plumbing/transport/common_test.go b/plumbing/transport/common_test.go index 17f62a6..65ed5b9 100644 --- a/plumbing/transport/common_test.go +++ b/plumbing/transport/common_test.go @@ -1,6 +1,7 @@ package transport import ( + "fmt" "net/url" "testing" @@ -155,12 +156,21 @@ func (s *SuiteCommon) TestNewEndpointFileURL(c *C) { } func (s *SuiteCommon) TestValidEndpoint(c *C) { - e, err := NewEndpoint("http://github.com/user/repository.git") - e.User = "person@mail.com" - e.Password = " !\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~" - url, err := url.Parse(e.String()) + user := "person@mail.com" + pass := " !\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~" + e, err := NewEndpoint(fmt.Sprintf( + "http://%s:%s@github.com/user/repository.git", + url.PathEscape(user), + url.PathEscape(pass), + )) c.Assert(err, IsNil) - c.Assert(url, NotNil) + c.Assert(e, NotNil) + c.Assert(e.User, Equals, user) + c.Assert(e.Password, Equals, pass) + c.Assert(e.Host, Equals, "github.com") + c.Assert(e.Path, Equals, "/user/repository.git") + + c.Assert(e.String(), Equals, "http://person@mail.com:%20%21%22%23$%25&%27%28%29%2A+%2C-.%2F:%3B%3C=%3E%3F@%5B%5C%5D%5E_%60%7B%7C%7D~@github.com/user/repository.git") } func (s *SuiteCommon) TestNewEndpointInvalidURL(c *C) { |