"""Test case for function writing the known_hosts file"""
def setUp(self):
- self.tmpfile = tempfile.NamedTemporaryFile()
+ testutils.GanetiTestCase.setUp(self)
+ self.tmpfile = self._CreateTempFile()
def test(self):
cfg = mocks.FakeConfig()
- sstore = mocks.FakeSStore()
- ssh.WriteKnownHostsFile(cfg, sstore, self.tmpfile.name)
- self.assertFileContent(self.tmpfile.name,
- "%s ssh-rsa %s\n" % (sstore.GetClusterName(),
+ ssh.WriteKnownHostsFile(cfg, self.tmpfile)
+ self.assertFileContent(self.tmpfile,
+ "%s ssh-rsa %s\n" % (cfg.GetClusterName(),
mocks.FAKE_CLUSTER_KEY))
+ def testFormatParamikoFingerprintCorrect(self):
+ self.assertEqual(ssh.FormatParamikoFingerprint("C0Ffee"), "c0:ff:ee")
+
+ def testFormatParamikoFingerprintNotDividableByTwo(self):
+ self.assertRaises(AssertionError, ssh.FormatParamikoFingerprint, "C0Ffe")
+
if __name__ == '__main__':
- unittest.main()
+ testutils.GanetiTestProgram()