Beispiel #1
0
func (s *updateAuthKeysSuite) TestIdempotent(c *gc.C) {
	err := upgrades.UpdateAuthorizedKeysForSystemIdentity(s.ctx)
	c.Assert(err, jc.ErrorIsNil)

	err = upgrades.UpdateAuthorizedKeysForSystemIdentity(s.ctx)
	c.Assert(err, jc.ErrorIsNil)

	s.assertHasPublicKeyInAuth(c, s.systemIdentity)
}
Beispiel #2
0
func (s *updateAuthKeysSuite) TestReplacesWrongKey(c *gc.C) {
	// Put a wrong key in there.
	_, publicKey, err := ssh.GenerateKey(config.JujuSystemKey)
	c.Assert(err, jc.ErrorIsNil)
	keys := testing.FakeAuthKeys + "\n" + publicKey
	err = s.State.UpdateEnvironConfig(map[string]interface{}{
		"authorized-keys": keys,
	}, nil, nil)
	c.Assert(err, jc.ErrorIsNil)

	err = upgrades.UpdateAuthorizedKeysForSystemIdentity(s.ctx)
	c.Assert(err, jc.ErrorIsNil)

	s.assertHasPublicKeyInAuth(c, s.systemIdentity)
}