Пример #1
0
func (s *grantSuite) SetUpTest(c *gc.C) {
	s.grantRevokeSuite.SetUpTest(c)
	s.cmdFactory = func(fake *fakeGrantRevokeAPI) cmd.Command {
		c, _ := model.NewGrantCommandForTest(fake, s.store)
		return c
	}
}
Пример #2
0
// TestInitGrantAddModel checks that both the documented 'add-model' access and
// the backwards-compatible 'addmodel' work to grant the AddModel permission.
func (s *grantSuite) TestInitGrantAddModel(c *gc.C) {
	wrappedCmd, grantCmd := model.NewGrantCommandForTest(s.fake, s.store)
	// The documented case, add-model.
	err := testing.InitCommand(wrappedCmd, []string{"bob", "add-model"})
	c.Check(err, jc.ErrorIsNil)

	// The backwards-compatible case, addmodel.
	err = testing.InitCommand(wrappedCmd, []string{"bob", "addmodel"})
	c.Check(err, jc.ErrorIsNil)
	c.Assert(grantCmd.Access, gc.Equals, "add-model")
}
Пример #3
0
func (s *grantSuite) TestInit(c *gc.C) {
	wrappedCmd, grantCmd := model.NewGrantCommandForTest(s.fake, s.store)
	err := testing.InitCommand(wrappedCmd, []string{})
	c.Assert(err, gc.ErrorMatches, "no user specified")

	err = testing.InitCommand(wrappedCmd, []string{"bob", "read", "model1", "model2"})
	c.Assert(err, jc.ErrorIsNil)

	c.Assert(grantCmd.User, gc.Equals, "bob")
	c.Assert(grantCmd.ModelNames, jc.DeepEquals, []string{"model1", "model2"})

	err = testing.InitCommand(wrappedCmd, []string{})
	c.Assert(err, gc.ErrorMatches, `no user specified`)
}