func (s *AuthorisedKeysKeysSuite) TestReplaceKeepsUnrecognised(c *gc.C) { writeAuthKeysFile(c, []string{sshtesting.ValidKeyOne.Key, "invalid-key"}) anotherKey := sshtesting.ValidKeyTwo.Key + " anotheruser@host" err := ssh.ReplaceKeys(testSSHUser, anotherKey) c.Assert(err, jc.ErrorIsNil) actual, err := ssh.ReadAuthorisedKeys(testSSHUser) c.Assert(err, jc.ErrorIsNil) c.Assert(actual, gc.DeepEquals, []string{"invalid-key", anotherKey}) }
func (s *AuthorisedKeysKeysSuite) TestDeleteKeysKeepsUnrecognised(c *gc.C) { firstKey := sshtesting.ValidKeyOne.Key + " user@host" writeAuthKeysFile(c, []string{firstKey, sshtesting.ValidKeyTwo.Key, "invalid-key"}) err := ssh.DeleteKeys(testSSHUser, "user@host") c.Assert(err, jc.ErrorIsNil) actual, err := ssh.ReadAuthorisedKeys(testSSHUser) c.Assert(err, jc.ErrorIsNil) c.Assert(actual, gc.DeepEquals, []string{"invalid-key", sshtesting.ValidKeyTwo.Key}) }