Пример #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))
Пример #2
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))
Пример #3
0
 def test_matchesHostIP(self):
     """
     A "hostname,ip" formatted line will match both the host and the IP.
     """
     self.entry = PlainEntry.fromString(self.hostIPLine)
     self.assertEqual(True, self.entry.matchesHost("198.49.126.131"))
     self.test_matchesHost()
Пример #4
0
 def test_matchesHostIP(self):
     """
     A "hostname,ip" formatted line will match both the host and the IP.
     """
     self.entry = PlainEntry.fromString(self.hostIPLine)
     self.assertEqual(True, self.entry.matchesHost("198.49.126.131"))
     self.test_matchesHost()
Пример #5
0
 def test_toString(self):
     """
     L{PlainEntry.toString} generates the serialized OpenSSL format string
     for the entry, sans newline.
     """
     self.assertEqual(self.entry.toString(), self.plaintextLine.rstrip("\n"))
     multiHostEntry = PlainEntry.fromString(self.hostIPLine)
     self.assertEqual(multiHostEntry.toString(), self.hostIPLine.rstrip("\n"))
Пример #6
0
 def test_toString(self):
     """
     L{PlainEntry.toString} generates the serialized OpenSSL format string
     for the entry, sans newline.
     """
     self.assertEqual(self.entry.toString(), self.plaintextLine.rstrip("\n"))
     multiHostEntry = PlainEntry.fromString(self.hostIPLine)
     self.assertEqual(multiHostEntry.toString(),
                      self.hostIPLine.rstrip("\n"))
Пример #7
0
 def setUp(self):
     """
     Set 'entry' to a sample plain-text entry with sampleKey as its key.
     """
     self.entry = PlainEntry.fromString(self.plaintextLine)
Пример #8
0
 def setUp(self):
     """
     Set 'entry' to a sample plain-text entry with sampleKey as its key.
     """
     self.entry = PlainEntry.fromString(self.plaintextLine)