本文整理汇总了Golang中github.com/juju/juju/apiserver/keymanager.NewKeyManagerAPI函数的典型用法代码示例。如果您正苦于以下问题:Golang NewKeyManagerAPI函数的具体用法?Golang NewKeyManagerAPI怎么用?Golang NewKeyManagerAPI使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewKeyManagerAPI函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestNewKeyManagerAPIAcceptsEnvironManager
func (s *keyManagerSuite) TestNewKeyManagerAPIAcceptsEnvironManager(c *gc.C) {
anAuthoriser := s.authoriser
anAuthoriser.EnvironManager = true
endPoint, err := keymanager.NewKeyManagerAPI(s.State, s.resources, anAuthoriser)
c.Assert(err, jc.ErrorIsNil)
c.Assert(endPoint, gc.NotNil)
}
示例2: TestAddJujuSystemKey
func (s *keyManagerSuite) TestAddJujuSystemKey(c *gc.C) {
anAuthoriser := s.authoriser
anAuthoriser.EnvironManager = true
anAuthoriser.Tag = names.NewMachineTag("0")
var err error
s.keymanager, err = keymanager.NewKeyManagerAPI(s.State, s.resources, anAuthoriser)
c.Assert(err, jc.ErrorIsNil)
key1 := sshtesting.ValidKeyOne.Key + " [email protected]"
key2 := sshtesting.ValidKeyTwo.Key
initialKeys := []string{key1, key2}
s.setAuthorisedKeys(c, strings.Join(initialKeys, "\n"))
newKey := sshtesting.ValidKeyThree.Key + " juju-system-key"
args := params.ModifyUserSSHKeys{
User: "juju-system-key",
Keys: []string{newKey},
}
results, err := s.keymanager.AddKeys(args)
c.Assert(err, jc.ErrorIsNil)
c.Assert(results, gc.DeepEquals, params.ErrorResults{
Results: []params.ErrorResult{
{Error: nil},
},
})
s.assertEnvironKeys(c, append(initialKeys, newKey))
}
示例3: TestNewKeyManagerAPIRefusesNonEnvironManager
func (s *keyManagerSuite) TestNewKeyManagerAPIRefusesNonEnvironManager(c *gc.C) {
anAuthoriser := s.authoriser
anAuthoriser.Tag = names.NewMachineTag("99")
anAuthoriser.EnvironManager = false
endPoint, err := keymanager.NewKeyManagerAPI(s.State, s.resources, anAuthoriser)
c.Assert(endPoint, gc.IsNil)
c.Assert(err, gc.ErrorMatches, "permission denied")
}
示例4: SetUpTest
func (s *keyManagerSuite) SetUpTest(c *gc.C) {
s.JujuConnSuite.SetUpTest(c)
s.resources = common.NewResources()
s.AddCleanup(func(_ *gc.C) { s.resources.StopAll() })
s.authoriser = apiservertesting.FakeAuthorizer{
Tag: s.AdminUserTag(c),
}
var err error
s.keymanager, err = keymanager.NewKeyManagerAPI(s.State, s.resources, s.authoriser)
c.Assert(err, gc.IsNil)
}
示例5: TestAddJujuSystemKeyNotMachine
func (s *keyManagerSuite) TestAddJujuSystemKeyNotMachine(c *gc.C) {
anAuthoriser := s.authoriser
anAuthoriser.EnvironManager = true
anAuthoriser.Tag = names.NewUnitTag("wordpress/0")
var err error
s.keymanager, err = keymanager.NewKeyManagerAPI(s.State, s.resources, anAuthoriser)
c.Assert(err, gc.IsNil)
key1 := sshtesting.ValidKeyOne.Key
s.setAuthorisedKeys(c, key1)
newKey := sshtesting.ValidKeyThree.Key + " juju-system-key"
args := params.ModifyUserSSHKeys{
User: "juju-system-key",
Keys: []string{newKey},
}
_, err = s.keymanager.AddKeys(args)
c.Assert(err, gc.ErrorMatches, "permission denied")
s.assertEnvironKeys(c, []string{key1})
}
示例6: TestNewKeyManagerAPIAcceptsClient
func (s *keyManagerSuite) TestNewKeyManagerAPIAcceptsClient(c *gc.C) {
endPoint, err := keymanager.NewKeyManagerAPI(s.State, s.resources, s.authoriser)
c.Assert(err, jc.ErrorIsNil)
c.Assert(endPoint, gc.NotNil)
}