Exemplo n.º 1
0
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.*")
}
Exemplo n.º 2
0
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\\)")
}
Exemplo n.º 3
0
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)
}
Exemplo n.º 4
0
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)
}
Exemplo n.º 5
0
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`)
}
Exemplo n.º 6
0
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`)
}
Exemplo n.º 7
0
// 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)
}