diff options
author | Paulo Gomes <pjbgf@linux.com> | 2023-11-02 18:52:46 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-02 18:52:46 +0000 |
commit | 22585738b4b13797f241a04b9cb6b48b31056aac (patch) | |
tree | 32097c3bc4bfa6327b71bc5627eea8efd9bc7678 /plumbing/transport/ssh/common_test.go | |
parent | 6252084d6fd3173aceeecd6765722ae844ddb266 (diff) | |
parent | 501e9ad99aa3d18b7711d8cea94e0e9b68883b6b (diff) | |
download | go-git-22585738b4b13797f241a04b9cb6b48b31056aac.tar.gz |
Merge pull request #901 from anandf/fix_ssh_proxy_nil_dereference
plumbing: transport/ssh, Fix nil pointer dereference caused when an unreachable proxy server is set. Fixes #900
Diffstat (limited to 'plumbing/transport/ssh/common_test.go')
-rw-r--r-- | plumbing/transport/ssh/common_test.go | 22 |
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 } |