Beispiel #1
0
func (s *verifyStorageSuite) TestVerifyStorageFails(c *C) {
	defer testing.MakeFakeHome(c, existingEnv, "existing").Restore()

	environ, err := environs.NewFromName("test")
	c.Assert(err, IsNil)
	storage := environ.Storage()
	someError := errors.Unauthorizedf("you shall not pass")
	dummy.Poison(storage, "bootstrap-verify", someError)
	err = environs.VerifyStorage(storage)
	c.Assert(err, Equals, environs.VerifyStorageError)
}
Beispiel #2
0
func (s *checkEnvironmentSuite) TestCheckEnvironment(c *C) {
	defer testing.MakeFakeHome(c, checkEnv, "existing").Restore()

	environ, err := environs.NewFromName("test")
	c.Assert(err, IsNil)

	// VerifyStorage is sufficient for our tests and much simpler
	// than Bootstrap which calls it.
	storage := environ.Storage()
	err = environs.VerifyStorage(storage)
	c.Assert(err, IsNil)
	err = environs.CheckEnvironment(environ)
	c.Assert(err, IsNil)
}
Beispiel #3
0
func (s *verifyStorageSuite) TestVerifyStorage(c *C) {
	defer testing.MakeFakeHome(c, existingEnv, "existing").Restore()

	environ, err := environs.NewFromName("test")
	c.Assert(err, IsNil)
	storage := environ.Storage()
	err = environs.VerifyStorage(storage)
	c.Assert(err, IsNil)
	reader, err := storage.Get("bootstrap-verify")
	c.Assert(err, IsNil)
	defer reader.Close()
	contents, err := ioutil.ReadAll(reader)
	c.Assert(err, IsNil)
	c.Check(string(contents), Equals,
		"juju-core storage writing verified: ok\n")
}
Beispiel #4
0
func (s *checkEnvironmentSuite) TestCheckEnvironmentGetFails(c *C) {
	defer testing.MakeFakeHome(c, checkEnv, "existing").Restore()

	environ, err := environs.NewFromName("test")
	c.Assert(err, IsNil)

	// VerifyStorage is sufficient for our tests and much simpler
	// than Bootstrap which calls it.
	storage := environ.Storage()
	err = environs.VerifyStorage(storage)
	c.Assert(err, IsNil)

	// When fetching the verification file from storage fails,
	// we get an InvalidEnvironmentError.
	someError := errors.Unauthorizedf("you shall not pass")
	dummy.Poison(storage, "bootstrap-verify", someError)
	err = environs.CheckEnvironment(environ)
	c.Assert(err, Equals, someError)
}
Beispiel #5
0
func (s *checkEnvironmentSuite) TestCheckEnvironmentFileNotFound(c *C) {
	defer testing.MakeFakeHome(c, checkEnv, "existing").Restore()

	environ, err := environs.NewFromName("test")
	c.Assert(err, IsNil)

	// VerifyStorage is sufficient for our tests and much simpler
	// than Bootstrap which calls it.
	storage := environ.Storage()
	err = environs.VerifyStorage(storage)
	c.Assert(err, IsNil)

	// When the bootstrap-verify file does not exist, it still believes
	// the environment is a juju-core one because earlier versions
	// did not create that file.
	err = storage.Remove("bootstrap-verify")
	c.Assert(err, IsNil)
	err = environs.CheckEnvironment(environ)
	c.Assert(err, IsNil)
}