f6e697d2 |
package main
import (
"net"
"strings" |
e25352a4 |
"testing" |
dc944ea7 |
|
6345208b |
"gotest.tools/assert" |
38457285 |
"gotest.tools/icmd" |
f6e697d2 |
)
|
64a928a3 |
func (s *DockerSuite) TestCLIProxyDisableProxyUnixSock(c *testing.T) { |
43b15e92 |
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon) |
f6e697d2 |
|
303b1d20 |
icmd.RunCmd(icmd.Cmd{ |
87e3fcfe |
Command: []string{dockerBinary, "info"}, |
303b1d20 |
Env: appendBaseEnv(false, "HTTP_PROXY=http://127.0.0.1:9999"), |
87e3fcfe |
}).Assert(c, icmd.Success) |
f6e697d2 |
}
// Can't use localhost here since go has a special case to not use proxy if connecting to localhost |
ca37301d |
// See https://golang.org/pkg/net/http/#ProxyFromEnvironment |
64a928a3 |
func (s *DockerDaemonSuite) TestCLIProxyProxyTCPSock(c *testing.T) { |
f6e697d2 |
// get the IP to use to connect since we can't use localhost
addrs, err := net.InterfaceAddrs() |
6345208b |
assert.NilError(c, err) |
f6e697d2 |
var ip string
for _, addr := range addrs {
sAddr := addr.String()
if !strings.Contains(sAddr, "127.0.0.1") {
addrArr := strings.Split(sAddr, "/")
ip = addrArr[0]
break
}
}
|
6345208b |
assert.Assert(c, ip != "") |
1db16176 |
|
c502fb49 |
s.d.Start(c, "-H", "tcp://"+ip+":2375") |
87e3fcfe |
icmd.RunCmd(icmd.Cmd{
Command: []string{dockerBinary, "info"}, |
303b1d20 |
Env: []string{"DOCKER_HOST=tcp://" + ip + ":2375", "HTTP_PROXY=127.0.0.1:9999"},
}).Assert(c, icmd.Expected{Error: "exit status 1", ExitCode: 1}) |
f6e697d2 |
// Test with no_proxy |
303b1d20 |
icmd.RunCmd(icmd.Cmd{ |
87e3fcfe |
Command: []string{dockerBinary, "info"}, |
303b1d20 |
Env: []string{"DOCKER_HOST=tcp://" + ip + ":2375", "HTTP_PROXY=127.0.0.1:9999", "NO_PROXY=" + ip}, |
87e3fcfe |
}).Assert(c, icmd.Success) |
f6e697d2 |
} |