Ejemplo n.º 1
0
func (s *upgraderSuite) TestToolsForAgent(c *gc.C) {
	cur := version.Current
	agent := params.Entity{Tag: s.rawMachine.Tag()}

	// The machine must have its existing tools set before we query for the
	// next tools. This is so that we can grab Arch and Series without
	// having to pass it in again
	err := s.rawMachine.SetAgentVersion(version.Current)
	c.Assert(err, gc.IsNil)

	args := params.Entities{Entities: []params.Entity{agent}}
	results, err := s.upgrader.Tools(args)
	c.Assert(err, gc.IsNil)
	assertTools := func() {
		c.Check(results.Results, gc.HasLen, 1)
		c.Assert(results.Results[0].Error, gc.IsNil)
		agentTools := results.Results[0].Tools
		c.Check(agentTools.URL, gc.Not(gc.Equals), "")
		c.Check(agentTools.Version, gc.DeepEquals, cur)
	}
	assertTools()
	c.Check(results.Results[0].DisableSSLHostnameVerification, jc.IsFalse)

	envtesting.SetSSLHostnameVerification(c, s.State, false)

	results, err = s.upgrader.Tools(args)
	c.Assert(err, gc.IsNil)
	assertTools()
	c.Check(results.Results[0].DisableSSLHostnameVerification, jc.IsTrue)
}
Ejemplo n.º 2
0
func (s *charmSuite) TestArchiveURL(c *gc.C) {
	archiveURL, hostnameVerification, err := s.apiCharm.ArchiveURL()
	c.Assert(err, gc.IsNil)
	c.Assert(archiveURL, gc.DeepEquals, s.wordpressCharm.BundleURL())
	c.Assert(hostnameVerification, gc.Equals, utils.VerifySSLHostnames)

	envtesting.SetSSLHostnameVerification(c, s.State, false)

	archiveURL, hostnameVerification, err = s.apiCharm.ArchiveURL()
	c.Assert(err, gc.IsNil)
	c.Assert(archiveURL, gc.DeepEquals, s.wordpressCharm.BundleURL())
	c.Assert(hostnameVerification, gc.Equals, utils.NoVerifySSLHostnames)
}
Ejemplo n.º 3
0
func (s *uniterSuite) TestCharmArchiveURL(c *gc.C) {
	dummyCharm := s.AddTestingCharm(c, "dummy")

	args := params.CharmURLs{URLs: []params.CharmURL{
		{URL: "something-invalid"},
		{URL: s.wpCharm.String()},
		{URL: dummyCharm.String()},
	}}
	result, err := s.uniter.CharmArchiveURL(args)
	c.Assert(err, gc.IsNil)
	c.Assert(result, gc.DeepEquals, params.CharmArchiveURLResults{
		Results: []params.CharmArchiveURLResult{
			{Error: apiservertesting.ErrUnauthorized},
			{
				Result: s.wpCharm.BundleURL().String(),
				DisableSSLHostnameVerification: false,
			},
			{
				Result: dummyCharm.BundleURL().String(),
				DisableSSLHostnameVerification: false,
			},
		},
	})

	envtesting.SetSSLHostnameVerification(c, s.State, false)

	result, err = s.uniter.CharmArchiveURL(args)
	c.Assert(err, gc.IsNil)
	c.Assert(result, gc.DeepEquals, params.CharmArchiveURLResults{
		Results: []params.CharmArchiveURLResult{
			{Error: apiservertesting.ErrUnauthorized},
			{
				Result: s.wpCharm.BundleURL().String(),
				DisableSSLHostnameVerification: true,
			},
			{
				Result: dummyCharm.BundleURL().String(),
				DisableSSLHostnameVerification: true,
			},
		},
	})
}
Ejemplo n.º 4
0
func (s *machineUpgraderSuite) TestTools(c *gc.C) {
	cur := version.Current
	curTools := &tools.Tools{Version: cur, URL: ""}
	curTools.Version.Minor++
	s.rawMachine.SetAgentVersion(cur)
	// Upgrader.Tools returns the *desired* set of tools, not the currently
	// running set. We want to be upgraded to cur.Version
	stateTools, hostnameVerification, err := s.st.Tools(s.rawMachine.Tag())
	c.Assert(err, gc.IsNil)
	c.Assert(stateTools.Version, gc.Equals, cur)
	c.Assert(stateTools.URL, gc.Not(gc.Equals), "")
	c.Assert(hostnameVerification, gc.Equals, utils.VerifySSLHostnames)

	envtesting.SetSSLHostnameVerification(c, s.State, false)

	stateTools, hostnameVerification, err = s.st.Tools(s.rawMachine.Tag())
	c.Assert(err, gc.IsNil)
	c.Assert(stateTools.Version, gc.Equals, cur)
	c.Assert(stateTools.URL, gc.Not(gc.Equals), "")
	c.Assert(hostnameVerification, gc.Equals, utils.NoVerifySSLHostnames)
}