1
// Copyright 2013 Canonical Ltd.
2
// Licensed under the AGPLv3, see LICENCE file for details.
7
gc "launchpad.net/gocheck"
9
"launchpad.net/juju-core/juju/osenv"
10
"launchpad.net/juju-core/testing/testbase"
13
type proxySuite struct {
17
var _ = gc.Suite(&proxySuite{})
19
func (s *proxySuite) TestDetectNoSettings(c *gc.C) {
20
// Patch all of the environment variables we check out just in case the
22
s.PatchEnvironment("http_proxy", "")
23
s.PatchEnvironment("HTTP_PROXY", "")
24
s.PatchEnvironment("https_proxy", "")
25
s.PatchEnvironment("HTTPS_PROXY", "")
26
s.PatchEnvironment("ftp_proxy", "")
27
s.PatchEnvironment("FTP_PROXY", "")
29
proxies := osenv.DetectProxies()
31
c.Assert(proxies, gc.DeepEquals, osenv.ProxySettings{})
34
func (s *proxySuite) TestDetectPrimary(c *gc.C) {
35
// Patch all of the environment variables we check out just in case the
37
s.PatchEnvironment("http_proxy", "http://user@10.0.0.1")
38
s.PatchEnvironment("HTTP_PROXY", "")
39
s.PatchEnvironment("https_proxy", "https://user@10.0.0.1")
40
s.PatchEnvironment("HTTPS_PROXY", "")
41
s.PatchEnvironment("ftp_proxy", "ftp://user@10.0.0.1")
42
s.PatchEnvironment("FTP_PROXY", "")
44
proxies := osenv.DetectProxies()
46
c.Assert(proxies, gc.DeepEquals, osenv.ProxySettings{
47
Http: "http://user@10.0.0.1",
48
Https: "https://user@10.0.0.1",
49
Ftp: "ftp://user@10.0.0.1",
53
func (s *proxySuite) TestDetectFallback(c *gc.C) {
54
// Patch all of the environment variables we check out just in case the
56
s.PatchEnvironment("http_proxy", "")
57
s.PatchEnvironment("HTTP_PROXY", "http://user@10.0.0.2")
58
s.PatchEnvironment("https_proxy", "")
59
s.PatchEnvironment("HTTPS_PROXY", "https://user@10.0.0.2")
60
s.PatchEnvironment("ftp_proxy", "")
61
s.PatchEnvironment("FTP_PROXY", "ftp://user@10.0.0.2")
63
proxies := osenv.DetectProxies()
65
c.Assert(proxies, gc.DeepEquals, osenv.ProxySettings{
66
Http: "http://user@10.0.0.2",
67
Https: "https://user@10.0.0.2",
68
Ftp: "ftp://user@10.0.0.2",
72
func (s *proxySuite) TestDetectPrimaryPreference(c *gc.C) {
73
// Patch all of the environment variables we check out just in case the
75
s.PatchEnvironment("http_proxy", "http://user@10.0.0.1")
76
s.PatchEnvironment("https_proxy", "https://user@10.0.0.1")
77
s.PatchEnvironment("ftp_proxy", "ftp://user@10.0.0.1")
78
s.PatchEnvironment("HTTP_PROXY", "http://user@10.0.0.2")
79
s.PatchEnvironment("HTTPS_PROXY", "https://user@10.0.0.2")
80
s.PatchEnvironment("FTP_PROXY", "ftp://user@10.0.0.2")
82
proxies := osenv.DetectProxies()
84
c.Assert(proxies, gc.DeepEquals, osenv.ProxySettings{
85
Http: "http://user@10.0.0.1",
86
Https: "https://user@10.0.0.1",
87
Ftp: "ftp://user@10.0.0.1",