FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
docker/integration-cli/docker_cli_proxy_test.go at master · Eagle-X/docker · GitHub
Eagle-X
/
docker
Public
forked from
moby/moby
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
docker
/
integration-cli
/
docker_cli_proxy_test.go
Copy path
More file actions
More file actions
Latest commit
History
History
History
53 lines (44 loc) · 1.62 KB
Breadcrumbs
docker
/
integration-cli
/
docker_cli_proxy_test.go
Copy path
File metadata and controls
53 lines (44 loc) · 1.62 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package
main
import
(
"net"
"os/exec"
"strings"
"github.com/docker/docker/pkg/integration/checker"
"github.com/go-check/check"
)
func
(
s
*
DockerSuite
)
TestCliProxyDisableProxyUnixSock
(
c
*
check.
C
) {
testRequires
(
c
,
DaemonIsLinux
)
testRequires
(
c
,
SameHostDaemon
)
// test is valid when DOCKER_HOST=unix://..
cmd
:=
exec
.
Command
(
dockerBinary
,
"info"
)
cmd
.
Env
=
appendBaseEnv
([]
string
{
"HTTP_PROXY=http://127.0.0.1:9999"
})
out
,
_
,
err
:=
runCommandWithOutput
(
cmd
)
c
.
Assert
(
err
,
checker
.
IsNil
,
check
.
Commentf
(
"%v"
,
out
))
}
// 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
*
check.
C
) {
testRequires
(
c
,
SameHostDaemon
)
// get the IP to use to connect since we can't use localhost
addrs
,
err
:=
net
.
InterfaceAddrs
()
c
.
Assert
(
err
,
checker
.
IsNil
)
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
}
}
c
.
Assert
(
ip
,
checker
.
Not
(
checker
.
Equals
),
""
)
err
=
s
.
d
.
Start
(
"-H"
,
"tcp://"
+
ip
+
":2375"
)
c
.
Assert
(
err
,
checker
.
IsNil
)
cmd
:=
exec
.
Command
(
dockerBinary
,
"info"
)
cmd
.
Env
=
[]
string
{
"DOCKER_HOST=tcp://"
+
ip
+
":2375"
,
"HTTP_PROXY=127.0.0.1:9999"
}
out
,
_
,
err
:=
runCommandWithOutput
(
cmd
)
c
.
Assert
(
err
,
checker
.
NotNil
,
check
.
Commentf
(
"%v"
,
out
))
// Test with no_proxy
cmd
.
Env
=
append
(
cmd
.
Env
,
"NO_PROXY="
+
ip
)
out
,
_
,
err
=
runCommandWithOutput
(
exec
.
Command
(
dockerBinary
,
"info"
))
c
.
Assert
(
err
,
checker
.
IsNil
,
check
.
Commentf
(
"%v"
,
out
))
}
Back
|
FazBrowse Home
|
New Git URL