Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 'tcp+tls' protocol not being accepted #20109

Merged
merged 1 commit into from
Feb 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/urlutil/urlutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var (
validPrefixes = map[string][]string{
"url": {"http://", "https://"},
"git": {"git://", "github.com/", "git@"},
"transport": {"tcp://", "udp://", "unix://"},
"transport": {"tcp://", "tcp+tls://", "udp://", "unix://"},
}
urlPathWithFragmentSuffix = regexp.MustCompile(".git(?:#.+)?$")
)
Expand All @@ -35,7 +35,7 @@ func IsGitTransport(str string) bool {
return IsURL(str) || strings.HasPrefix(str, "git://") || strings.HasPrefix(str, "git@")
}

// IsTransportURL returns true if the provided str is a transport (tcp, udp, unix) URL.
// IsTransportURL returns true if the provided str is a transport (tcp, tcp+tls, udp, unix) URL.
func IsTransportURL(str string) bool {
return checkURL(str, "transport")
}
Expand Down
14 changes: 14 additions & 0 deletions pkg/urlutil/urlutil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ var (
invalidGitUrls = []string{
"http://github.com/docker/docker.git:#branch",
}
transportUrls = []string{
"tcp://example.com",
"tcp+tls://example.com",
"udp://example.com",
"unix:///example",
}
)

func TestValidGitTransport(t *testing.T) {
Expand Down Expand Up @@ -53,3 +59,11 @@ func TestIsGIT(t *testing.T) {
}
}
}

func TestIsTransport(t *testing.T) {
for _, url := range transportUrls {
if IsTransportURL(url) == false {
t.Fatalf("%q should be detected as valid Transport url", url)
}
}
}