func (s *revokeSuite) SetUpTest(c *gc.C) { s.grantRevokeSuite.SetUpTest(c) s.cmdFactory = func(fake *fakeGrantRevokeAPI) cmd.Command { c, _ := model.NewRevokeCommandForTest(fake, s.store) return c } }
// TestInitRevokeAddModel checks that both the documented 'add-model' access and // the backwards-compatible 'addmodel' work to revoke the AddModel permission. func (s *grantSuite) TestInitRevokeAddModel(c *gc.C) { wrappedCmd, revokeCmd := model.NewRevokeCommandForTest(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(revokeCmd.Access, gc.Equals, "add-model") }
func (s *revokeSuite) TestInit(c *gc.C) { wrappedCmd, revokeCmd := model.NewRevokeCommandForTest(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(revokeCmd.User, gc.Equals, "bob") c.Assert(revokeCmd.ModelNames, jc.DeepEquals, []string{"model1", "model2"}) err = testing.InitCommand(wrappedCmd, []string{}) c.Assert(err, gc.ErrorMatches, `no user specified`) }
func (s *grantSuite) TestControllerAccessForModel(c *gc.C) { wrappedCmd, _ := model.NewRevokeCommandForTest(s.fake, s.store) err := testing.InitCommand(wrappedCmd, []string{"bob", "superuser", "default"}) msg := strings.Replace(err.Error(), "\n", "", -1) c.Check(msg, gc.Matches, `You have specified a controller access permission "superuser".*`) }