aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2018-10-09 06:32:14 +0200
committerGitHub <noreply@github.com>2018-10-09 06:32:14 +0200
commit80afdec53d1bb2e8cc018896e6850858c6dd768a (patch)
treee5f1141c28d4508420c8c50c48fc7b3b4907ce14
parent1fdd36c814746efdf199392135696cfde7287b44 (diff)
parent37f80c63cc19d8f224d7c5eb0338594b9cef3838 (diff)
downloadgo-git-80afdec53d1bb2e8cc018896e6850858c6dd768a.tar.gz
Merge pull request #968 from smola/improve-test-weird-userpass
test: improve test for urlencoded user:pass
-rw-r--r--plumbing/transport/common_test.go20
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) {