| 1 |
From: Maytham Alsudany <[email protected]> |
| 2 |
Date: Mon, 10 Jun 2024 17:18:46 +0800 |
| 3 |
Subject: Use explicit loopback IP instead of localhost |
| 4 |
|
| 5 |
Tests were failing because they were attempting to connect to a DNS server |
| 6 |
(which requires internet) and looking up "localhost". This patch changes out |
| 7 |
"localhost" for the more explicit "127.0.0.1" loopback IP. |
| 8 |
|
| 9 |
Forwarded: not-needed |
| 10 |
Last-Update: 2024-06-10 |
| 11 |
--- |
| 12 |
plumbing/transport/git/common_test.go | 4 ++-- |
| 13 |
plumbing/transport/ssh/internal/test/proxy_test.go | 8 ++++---- |
| 14 |
2 files changed, 6 insertions(+), 6 deletions(-) |
| 15 |
|
| 16 |
diff --git a/plumbing/transport/git/common_test.go b/plumbing/transport/git/common_test.go |
| 17 |
index 7216d5c..b66eb43 100644 |
| 18 |
--- a/plumbing/transport/git/common_test.go |
| 19 |
+++ b/plumbing/transport/git/common_test.go |
| 20 |
@@ -71,7 +71,7 @@ func (s *BaseSuite) StartDaemon(c *C) { |
| 21 |
} |
| 22 |
|
| 23 |
func (s *BaseSuite) newEndpoint(c *C, name string) *transport.Endpoint { |
| 24 |
- ep, err := transport.NewEndpoint(fmt.Sprintf("git://localhost:%d/%s", s.port, name)) |
| 25 |
+ ep, err := transport.NewEndpoint(fmt.Sprintf("git://127.0.0.1:%d/%s", s.port, name)) |
| 26 |
c.Assert(err, IsNil) |
| 27 |
|
| 28 |
return ep |
| 29 |
@@ -98,7 +98,7 @@ func (s *BaseSuite) TearDownTest(c *C) { |
| 30 |
} |
| 31 |
|
| 32 |
func freePort() (int, error) { |
| 33 |
- addr, err := net.ResolveTCPAddr("tcp", "localhost:0") |
| 34 |
+ addr, err := net.ResolveTCPAddr("tcp", "127.0.0.1:0") |
| 35 |
if err != nil { |
| 36 |
return 0, err |
| 37 |
} |
| 38 |
diff --git a/plumbing/transport/ssh/internal/test/proxy_test.go b/plumbing/transport/ssh/internal/test/proxy_test.go |
| 39 |
index b4da338..46a73ed 100644 |
| 40 |
--- a/plumbing/transport/ssh/internal/test/proxy_test.go |
| 41 |
+++ b/plumbing/transport/ssh/internal/test/proxy_test.go |
| 42 |
@@ -36,7 +36,7 @@ var socksProxiedRequests int32 |
| 43 |
// Its located in a separate package because golang caches the value |
| 44 |
// of proxy env vars leading to misleading/unexpected test results. |
| 45 |
func (s *ProxyEnvSuite) TestCommand(c *C) { |
| 46 |
- socksListener, err := net.Listen("tcp", "localhost:0") |
| 47 |
+ socksListener, err := net.Listen("tcp", "127.0.0.1:0") |
| 48 |
c.Assert(err, IsNil) |
| 49 |
|
| 50 |
socksServer, err := socks5.New(&socks5.Config{ |
| 51 |
@@ -46,11 +46,11 @@ func (s *ProxyEnvSuite) TestCommand(c *C) { |
| 52 |
go func() { |
| 53 |
socksServer.Serve(socksListener) |
| 54 |
}() |
| 55 |
- socksProxyAddr := fmt.Sprintf("socks5://localhost:%d", socksListener.Addr().(*net.TCPAddr).Port) |
| 56 |
+ socksProxyAddr := fmt.Sprintf("socks5://127.0.0.1:%d", socksListener.Addr().(*net.TCPAddr).Port) |
| 57 |
os.Setenv("ALL_PROXY", socksProxyAddr) |
| 58 |
defer os.Unsetenv("ALL_PROXY") |
| 59 |
|
| 60 |
- sshListener, err := net.Listen("tcp", "localhost:0") |
| 61 |
+ sshListener, err := net.Listen("tcp", "127.0.0.1:0") |
| 62 |
c.Assert(err, IsNil) |
| 63 |
sshServer := &ssh.Server{Handler: HandlerSSH} |
| 64 |
go func() { |
| 65 |
@@ -97,7 +97,7 @@ func (s *ProxyEnvSuite) prepareRepository(c *C, f *fixtures.Fixture, name string |
| 66 |
|
| 67 |
func (s *ProxyEnvSuite) newEndpoint(c *C, name string) *transport.Endpoint { |
| 68 |
ep, err := transport.NewEndpoint(fmt.Sprintf( |
| 69 |
- "ssh://git@localhost:%d/%s/%s", s.port, filepath.ToSlash(s.base), name, |
| 70 |
+ "ssh://[email protected]:%d/%s/%s", s.port, filepath.ToSlash(s.base), name, |
| 71 |
)) |
| 72 |
|
| 73 |
c.Assert(err, IsNil) |