func (s *MachineSuite) TestMachineEnvironWorker(c *gc.C) { proxyDir := c.MkDir() s.agentSuite.PatchValue(&machineenvironmentworker.ProxyDirectory, proxyDir) s.agentSuite.PatchValue(&apt.ConfFile, filepath.Join(proxyDir, "juju-apt-proxy")) s.primeAgent(c, version.Current, state.JobHostUnits) // Make sure there are some proxy settings to write. proxySettings := proxy.Settings{ Http: "http proxy", Https: "https proxy", Ftp: "ftp proxy", } updateAttrs := config.ProxyConfigMap(proxySettings) err := s.State.UpdateEnvironConfig(updateAttrs, nil, nil) c.Assert(err, gc.IsNil) s.assertJobWithAPI(c, state.JobHostUnits, func(conf agent.Config, st *api.State) { for { select { case <-time.After(coretesting.LongWait): c.Fatalf("timeout while waiting for proxy settings to change") case <-time.After(10 * time.Millisecond): _, err := os.Stat(apt.ConfFile) if os.IsNotExist(err) { continue } c.Assert(err, gc.IsNil) return } } }) }
func (s *ConfigSuite) TestProxyConfigMap(c *gc.C) { s.addJujuFiles(c) cfg := newTestConfig(c, testing.Attrs{}) proxySettings := proxy.Settings{ Http: "http proxy", Https: "https proxy", Ftp: "ftp proxy", NoProxy: "no proxy", } cfg, err := cfg.Apply(config.ProxyConfigMap(proxySettings)) c.Assert(err, gc.IsNil) c.Assert(cfg.ProxySettings(), gc.DeepEquals, proxySettings) // Apt proxy and proxy differ by the content of the no-proxy values. proxySettings.NoProxy = "" c.Assert(cfg.AptProxySettings(), gc.DeepEquals, proxySettings) }