예제 #1
0
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
	}
}
예제 #2
0
// 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")
}
예제 #3
0
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`)

}
예제 #4
0
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".*`)
}