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

test: improve test for urlencoded user:pass #968

Merged
merged 1 commit into from
Oct 9, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions plumbing/transport/common_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package transport

import (
"fmt"
"net/url"
"testing"

Expand Down Expand Up @@ -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 = "[email protected]"
e.Password = " !\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"
url, err := url.Parse(e.String())
user := "[email protected]"
pass := " !\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"
e, err := NewEndpoint(fmt.Sprintf(
"http://%s:%[email protected]/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://[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")
}

func (s *SuiteCommon) TestNewEndpointInvalidURL(c *C) {
Expand Down