2015-02-12 16:38:52 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net"
|
|
|
|
"os/exec"
|
|
|
|
"strings"
|
2015-04-18 16:46:47 +00:00
|
|
|
|
2017-01-05 11:38:34 +00:00
|
|
|
icmd "github.com/docker/docker/pkg/testutil/cmd"
|
2016-12-30 17:23:00 +00:00
|
|
|
"github.com/docker/docker/integration-cli/checker"
|
2015-04-18 16:46:47 +00:00
|
|
|
"github.com/go-check/check"
|
2015-02-12 16:38:52 +00:00
|
|
|
)
|
|
|
|
|
[nit] integration-cli: obey Go's naming convention
No substantial code change.
- Api --> API
- Cli --> CLI
- Http, Https --> HTTP, HTTPS
- Id --> ID
- Uid,Gid,Pid --> UID,PID,PID
- Ipam --> IPAM
- Tls --> TLS (TestDaemonNoTlsCliTlsVerifyWithEnv --> TestDaemonTLSVerifyIssue13964)
Didn't touch in this commit:
- Git: because it is officially "Git": https://git-scm.com/
- Tar: because it is officially "Tar": https://www.gnu.org/software/tar/
- Cpu, Nat, Mac, Ipc, Shm: for keeping a consistency with existing production code (not changable, for compatibility)
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2016-09-28 01:50:12 +00:00
|
|
|
func (s *DockerSuite) TestCLIProxyDisableProxyUnixSock(c *check.C) {
|
2017-01-05 11:38:34 +00:00
|
|
|
testRequires(c, DaemonIsLinux, SameHostDaemon)
|
2015-02-12 16:38:52 +00:00
|
|
|
|
2017-01-05 11:38:34 +00:00
|
|
|
icmd.RunCmd(icm.Cmd{
|
|
|
|
Command: []string{dockerBinary, "info"},
|
|
|
|
Env: appendBaseEnv(false, "HTTP_PROXY=http://127.0.0.1:9999"),
|
|
|
|
}).Assert(c, icmd.Success)
|
2015-02-12 16:38:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Can't use localhost here since go has a special case to not use proxy if connecting to localhost
|
2015-04-11 17:31:34 +00:00
|
|
|
// See https://golang.org/pkg/net/http/#ProxyFromEnvironment
|
[nit] integration-cli: obey Go's naming convention
No substantial code change.
- Api --> API
- Cli --> CLI
- Http, Https --> HTTP, HTTPS
- Id --> ID
- Uid,Gid,Pid --> UID,PID,PID
- Ipam --> IPAM
- Tls --> TLS (TestDaemonNoTlsCliTlsVerifyWithEnv --> TestDaemonTLSVerifyIssue13964)
Didn't touch in this commit:
- Git: because it is officially "Git": https://git-scm.com/
- Tar: because it is officially "Tar": https://www.gnu.org/software/tar/
- Cpu, Nat, Mac, Ipc, Shm: for keeping a consistency with existing production code (not changable, for compatibility)
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2016-09-28 01:50:12 +00:00
|
|
|
func (s *DockerDaemonSuite) TestCLIProxyProxyTCPSock(c *check.C) {
|
2015-04-18 16:46:47 +00:00
|
|
|
testRequires(c, SameHostDaemon)
|
2015-02-12 16:38:52 +00:00
|
|
|
// get the IP to use to connect since we can't use localhost
|
|
|
|
addrs, err := net.InterfaceAddrs()
|
2015-10-09 03:11:05 +00:00
|
|
|
c.Assert(err, checker.IsNil)
|
2015-02-12 16:38:52 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-09 06:53:56 +00:00
|
|
|
c.Assert(ip, checker.Not(checker.Equals), "")
|
|
|
|
|
2016-12-09 22:20:14 +00:00
|
|
|
s.d.Start(c, "-H", "tcp://"+ip+":2375")
|
2017-01-05 11:38:34 +00:00
|
|
|
|
|
|
|
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})
|
2015-02-12 16:38:52 +00:00
|
|
|
// Test with no_proxy
|
2017-01-05 11:38:34 +00:00
|
|
|
icmd.RunCommand(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)
|
2015-02-12 16:38:52 +00:00
|
|
|
}
|