aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/transport/ssh/common_test.go
diff options
context:
space:
mode:
authorAnand Francis Joseph <anjoseph@redhat.com>2023-11-02 22:48:52 +0530
committerAnand Francis Joseph <anjoseph@redhat.com>2023-11-02 22:48:52 +0530
commit501e9ad99aa3d18b7711d8cea94e0e9b68883b6b (patch)
tree32097c3bc4bfa6327b71bc5627eea8efd9bc7678 /plumbing/transport/ssh/common_test.go
parent6252084d6fd3173aceeecd6765722ae844ddb266 (diff)
downloadgo-git-501e9ad99aa3d18b7711d8cea94e0e9b68883b6b.tar.gz
plumbing: transport/ssh, Fix nil pointer dereference caused when an unreachable proxy server is set. Fixes #900
Signed-off-by: Anand Francis Joseph <anjoseph@redhat.com>
Diffstat (limited to 'plumbing/transport/ssh/common_test.go')
-rw-r--r--plumbing/transport/ssh/common_test.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/plumbing/transport/ssh/common_test.go b/plumbing/transport/ssh/common_test.go
index 496e82d..4cc2a06 100644
--- a/plumbing/transport/ssh/common_test.go
+++ b/plumbing/transport/ssh/common_test.go
@@ -172,6 +172,28 @@ func (s *SuiteCommon) TestIssue70(c *C) {
c.Assert(err, IsNil)
}
+/*
+Given, an endpoint to a git server with a socks5 proxy URL,
+When, the socks5 proxy server is not reachable,
+Then, there should not be any panic and an error with appropriate message should be returned.
+Related issue : https://github.com/go-git/go-git/pull/900
+*/
+func (s *SuiteCommon) TestInvalidSocks5Proxy(c *C) {
+ ep, err := transport.NewEndpoint("git@github.com:foo/bar.git")
+ c.Assert(err, IsNil)
+ ep.Proxy.URL = "socks5://127.0.0.1:1080"
+
+ auth, err := NewPublicKeys("foo", testdata.PEMBytes["rsa"], "")
+ c.Assert(err, IsNil)
+ c.Assert(auth, NotNil)
+
+ ps, err := DefaultClient.NewUploadPackSession(ep, auth)
+ //Since the proxy server is not running, we expect an error.
+ c.Assert(ps, IsNil)
+ c.Assert(err, NotNil)
+ c.Assert(err, ErrorMatches, "socks connect .* dial tcp 127.0.0.1:1080: .*")
+}
+
type mockSSHConfig struct {
Values map[string]map[string]string
}