Пример #1
0
func (s *AptSuite) TestAptProxyContentRoundtrip(c *gc.C) {
	proxySettings := proxy.Settings{
		Http:  "http://[email protected]",
		Https: "https://[email protected]",
		Ftp:   "ftp://[email protected]",
	}
	output := apt.ProxyContent(proxySettings)

	s.HookCommandOutput(&apt.CommandOutput, []byte(output), nil)

	detected, err := apt.DetectProxies()
	c.Assert(err, gc.IsNil)
	c.Assert(detected, gc.DeepEquals, proxySettings)
}
Пример #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(&apt.CommandOutput, []byte(output), nil)

	proxySettings, err := apt.DetectProxies()
	c.Assert(err, gc.IsNil)
	c.Assert(proxySettings, gc.DeepEquals, proxy.Settings{
		Http: "10.0.3.1:3142",
		Ftp:  "here-it-is",
	})
}
Пример #3
0
func (s *AptSuite) TestDetectAptProxyNone(c *gc.C) {
	_ = s.HookCommandOutput(&apt.CommandOutput, []byte{}, nil)
	proxySettings, err := apt.DetectProxies()
	c.Assert(err, gc.IsNil)
	c.Assert(proxySettings, gc.DeepEquals, proxy.Settings{})
}