Skip to content

Commit

Permalink
Simplified unit tests for the bug fix
Browse files Browse the repository at this point in the history
Signed-off-by: Anand Francis Joseph <anjoseph@redhat.com>
  • Loading branch information
anandf committed Nov 1, 2023
1 parent 651c00d commit a856e2e
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions plumbing/transport/ssh/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,27 +173,21 @@ func (s *SuiteCommon) TestIssue70(c *C) {
}

/*
Given, a default git client with proxy URL set,
When, connecting to a git server using a socks5 proxy that is not reachable,
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) {
uploadPack := &UploadPackSuite{
opts: []ssh.Option{
ssh.HostKeyPEM(testdata.PEMBytes["ed25519"]),
},
}
uploadPack.SetUpSuite(c)
// Use the default client, which does not have a host key callback
uploadPack.Client = DefaultClient
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)
auth.HostKeyCallback = stdssh.InsecureIgnoreHostKey()
ep := uploadPack.newEndpoint(c, "bar.git")
ep.Proxy.URL = "socks5://127.0.0.1:1080"
ps, err := uploadPack.Client.NewUploadPackSession(ep, auth)

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)
Expand Down

0 comments on commit a856e2e

Please sign in to comment.