Ejemplo n.º 1
0
func (s *AptSuite) TestAptProxyContentRoundtrip(c *gc.C) {
	proxy := osenv.ProxySettings{
		Http:  "http://[email protected]",
		Https: "https://[email protected]",
		Ftp:   "ftp://[email protected]",
	}
	output := utils.AptProxyContent(proxy)

	s.HookCommandOutput(&utils.AptCommandOutput, []byte(output), nil)

	detected, err := utils.DetectAptProxies()
	c.Assert(err, gc.IsNil)
	c.Assert(detected, gc.DeepEquals, proxy)
}
Ejemplo n.º 2
0
func (s *AptSuite) TestDetectAptProxyPartial(c *gc.C) {
	const output = `CommandLine::AsString "apt-config dump";
Acquire::http::Proxy  "10.0.3.1:3142";
Acquire::ftp::Proxy "here-it-is";
Acquire::magic::Proxy "none";
`
	_ = s.HookCommandOutput(&utils.AptCommandOutput, []byte(output), nil)

	proxy, err := utils.DetectAptProxies()
	c.Assert(err, gc.IsNil)
	c.Assert(proxy, gc.DeepEquals, osenv.ProxySettings{
		Http: "10.0.3.1:3142",
		Ftp:  "here-it-is",
	})
}
Ejemplo n.º 3
0
func (s *AptSuite) TestDetectAptProxyNone(c *gc.C) {
	_ = s.HookCommandOutput(&utils.AptCommandOutput, []byte{}, nil)
	proxy, err := utils.DetectAptProxies()
	c.Assert(err, gc.IsNil)
	c.Assert(proxy, gc.DeepEquals, osenv.ProxySettings{})
}