Esempio n. 1
0
 def test_hasLaterAddedKey(self):
     """
     L{KnownHostsFile.hasHostKey} returns C{True} when a key for the given
     hostname is present in the file, even if it is only added to the file
     after the L{KnownHostsFile} instance is initialized.
     """
     key = Key.fromString(sampleKey)
     entry = PlainEntry(["brandnew.example.com"], key.sshType(), key, "")
     hostsFile = self.loadSampleHostsFile()
     with hostsFile._savePath.open("a") as hostsFileObj:
         hostsFileObj.write(entry.toString() + "\n")
     self.assertEqual(True, hostsFile.hasHostKey("brandnew.example.com",
                                                 key))