Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Commit 80afdec

Browse files
authored
Merge pull request #968 from smola/improve-test-weird-userpass
test: improve test for urlencoded user:pass
2 parents 1fdd36c + 37f80c6 commit 80afdec

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

plumbing/transport/common_test.go

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package transport
22

33
import (
4+
"fmt"
45
"net/url"
56
"testing"
67

@@ -155,12 +156,21 @@ func (s *SuiteCommon) TestNewEndpointFileURL(c *C) {
155156
}
156157

157158
func (s *SuiteCommon) TestValidEndpoint(c *C) {
158-
e, err := NewEndpoint("http://github.com/user/repository.git")
159-
e.User = "[email protected]"
160-
e.Password = " !\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"
161-
url, err := url.Parse(e.String())
159+
160+
pass := " !\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"
161+
e, err := NewEndpoint(fmt.Sprintf(
162+
"http://%s:%[email protected]/user/repository.git",
163+
url.PathEscape(user),
164+
url.PathEscape(pass),
165+
))
162166
c.Assert(err, IsNil)
163-
c.Assert(url, NotNil)
167+
c.Assert(e, NotNil)
168+
c.Assert(e.User, Equals, user)
169+
c.Assert(e.Password, Equals, pass)
170+
c.Assert(e.Host, Equals, "github.com")
171+
c.Assert(e.Path, Equals, "/user/repository.git")
172+
173+
c.Assert(e.String(), Equals, "http://[email protected]:%20%21%22%23$%25&%27%28%29%2A+%2C-.%2F:%3B%3C=%3E%3F@%5B%5C%5D%5E_%60%7B%7C%[email protected]/user/repository.git")
164174
}
165175

166176
func (s *SuiteCommon) TestNewEndpointInvalidURL(c *C) {

0 commit comments

Comments
 (0)