func (s *macaroonLoginSuite) TestsFailToObtainDischargeLogin(c *gc.C) { s.DischargerLogin = func() string { return "" } cmd := modelcmd.NewModelCommandBase(s.store, s.controllerName, s.accountName, s.modelName) _, err := cmd.NewAPIRoot() c.Assert(err, gc.ErrorMatches, "connecting with cached addresses: cannot get discharge.*") }
func (s *macaroonLoginSuite) TestsUnknownUserLogin(c *gc.C) { s.DischargerLogin = func() string { return "testUnknown@nowhere" } cmd := modelcmd.NewModelCommandBase(s.store, s.controllerName, s.accountName, s.modelName) _, err := cmd.NewAPIRoot() c.Assert(err, gc.ErrorMatches, "connecting with cached addresses: invalid entity name or password \\(unauthorized access\\)") }
func (s *macaroonLoginSuite) TestsSuccessfulLogin(c *gc.C) { s.DischargerLogin = func() string { return testUser } cmd := modelcmd.NewModelCommandBase(s.store, s.controllerName, s.accountName, s.modelName) _, err := cmd.NewAPIRoot() c.Assert(err, jc.ErrorIsNil) }
func (s *macaroonLoginSuite) TestsSuccessfulLogin(c *gc.C) { s.DischargerLogin = func() string { return testUser } cmd := envcmd.NewEnvCommandBase(s.envName, nil, nil) _, err := cmd.NewAPIRoot() c.Assert(err, jc.ErrorIsNil) }
func (s *macaroonLoginSuite) TestsUnknownUserLogin(c *gc.C) { s.DischargerLogin = func() string { return "testUnknown@nowhere" } cmd := envcmd.NewEnvCommandBase(s.envName, nil, nil) _, err := cmd.NewAPIRoot() // TODO(rog) is this really the right error here? c.Assert(err, gc.ErrorMatches, `environment "`+s.envName+`" not found`) }
func (s *macaroonLoginSuite) TestsFailToObtainDischargeLogin(c *gc.C) { s.DischargerLogin = func() string { return "" } cmd := modelcmd.NewModelCommandBase(s.envName, nil, nil) _, err := cmd.NewAPIRoot() // TODO(rog) is this really the right error here? c.Assert(err, gc.ErrorMatches, `model "`+s.envName+`" not found`) }
// NewAddRelationCommand returns a command to add a relation between 2 services. func NewAddRelationCommand() cmd.Command { cmd := &addRelationCommand{} cmd.newAPIFunc = func() (ApplicationAddRelationAPI, error) { root, err := cmd.NewAPIRoot() if err != nil { return nil, errors.Trace(err) } return application.NewClient(root), nil } return modelcmd.Wrap(cmd) }