func (s *MachineEnvironmentWatcherSuite) updateConfig(c *gc.C) (osenv.ProxySettings, osenv.ProxySettings) {

	proxySettings := osenv.ProxySettings{
		Http:    "http proxy",
		Https:   "https proxy",
		Ftp:     "ftp proxy",
		NoProxy: "no proxy",
	attrs := map[string]interface{}{}
	for k, v := range config.ProxyConfigMap(proxySettings) {
		attrs[k] = v

	// We explicitly set apt proxy settings as well to show that it is the apt
	// settings that are used for the apt config, and not just the normal
	// proxy settings which is what we would get if we don't explicitly set
	// apt values.
	aptProxySettings := osenv.ProxySettings{
		Http:  "apt http proxy",
		Https: "apt https proxy",
		Ftp:   "apt ftp proxy",
	for k, v := range config.AptProxyConfigMap(aptProxySettings) {
		attrs[k] = v

	err := s.State.UpdateEnvironConfig(attrs, nil, nil)
	c.Assert(err, gc.IsNil)

	return proxySettings, aptProxySettings
Beispiel #2
func (*ConfigSuite) TestAptProxyConfigMap(c *gc.C) {
	defer makeFakeHome(c).Restore()

	cfg := newTestConfig(c, testing.Attrs{})
	proxy := osenv.ProxySettings{
		Http:  "http proxy",
		Https: "https proxy",
		Ftp:   "ftp proxy",
	cfg, err := cfg.Apply(config.AptProxyConfigMap(proxy))
	c.Assert(err, gc.IsNil)
	// The default proxy settings should still be empty.
	c.Assert(cfg.ProxySettings(), gc.DeepEquals, osenv.ProxySettings{})
	c.Assert(cfg.AptProxySettings(), gc.DeepEquals, proxy)