mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
59e55dcdd0
goimports -w \ -- "./integration-cli/daemon" "./pkg/discovery" "./pkg/discovery/file" "./pkg/discovery/kv" "./pkg/discovery/memory" "./pkg/discovery/nodes" "./integration-cli" \ && \ gofmt -w -s \ -- "./integration-cli/daemon" "./pkg/discovery" "./pkg/discovery/file" "./pkg/discovery/kv" "./pkg/discovery/memory" "./pkg/discovery/nodes" "./integration-cli" Signed-off-by: Tibor Vass <tibor@docker.com>
50 lines
1.4 KiB
Go
50 lines
1.4 KiB
Go
package main
|
|
|
|
import (
|
|
"net"
|
|
"strings"
|
|
"testing"
|
|
|
|
"gotest.tools/assert"
|
|
"gotest.tools/icmd"
|
|
)
|
|
|
|
func (s *DockerSuite) TestCLIProxyDisableProxyUnixSock(c *testing.T) {
|
|
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon)
|
|
|
|
icmd.RunCmd(icmd.Cmd{
|
|
Command: []string{dockerBinary, "info"},
|
|
Env: appendBaseEnv(false, "HTTP_PROXY=http://127.0.0.1:9999"),
|
|
}).Assert(c, icmd.Success)
|
|
}
|
|
|
|
// Can't use localhost here since go has a special case to not use proxy if connecting to localhost
|
|
// See https://golang.org/pkg/net/http/#ProxyFromEnvironment
|
|
func (s *DockerDaemonSuite) TestCLIProxyProxyTCPSock(c *testing.T) {
|
|
// get the IP to use to connect since we can't use localhost
|
|
addrs, err := net.InterfaceAddrs()
|
|
assert.NilError(c, err)
|
|
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
|
|
}
|
|
}
|
|
|
|
assert.Assert(c, ip != "")
|
|
|
|
s.d.Start(c, "-H", "tcp://"+ip+":2375")
|
|
|
|
icmd.RunCmd(icmd.Cmd{
|
|
Command: []string{dockerBinary, "info"},
|
|
Env: []string{"DOCKER_HOST=tcp://" + ip + ":2375", "HTTP_PROXY=127.0.0.1:9999"},
|
|
}).Assert(c, icmd.Expected{Error: "exit status 1", ExitCode: 1})
|
|
// Test with no_proxy
|
|
icmd.RunCmd(icmd.Cmd{
|
|
Command: []string{dockerBinary, "info"},
|
|
Env: []string{"DOCKER_HOST=tcp://" + ip + ":2375", "HTTP_PROXY=127.0.0.1:9999", "NO_PROXY=" + ip},
|
|
}).Assert(c, icmd.Success)
|
|
}
|