示例#1
0
    def test_add_host_key(self):
        """Testing FileSSHStorage.add_host_key"""
        storage = FileSSHStorage()
        storage.add_host_key('host1', self.key1)

        filename = storage.get_host_keys_filename()
        with open(filename, 'r') as fp:
            lines = fp.readlines()

        self.assertEqual(len(lines), 1)
        self.assertEqual(lines[0], 'host1 ssh-rsa %s\n' % self.key1_b64)
示例#2
0
    def test_add_host_key(self):
        """Testing FileSSHStorage.add_host_key"""
        storage = FileSSHStorage()
        storage.add_host_key('host1', self.key1)

        filename = storage.get_host_keys_filename()
        with open(filename, 'r') as fp:
            lines = fp.readlines()

        self.assertEqual(len(lines), 1)
        self.assertEqual(lines[0], 'host1 ssh-rsa %s\n' % self.key1_b64)
示例#3
0
    def test_replace_host_key(self):
        """Testing FileSSHStorage.replace_host_key"""
        storage = FileSSHStorage()
        storage.add_host_key('host1', self.key1)
        storage.replace_host_key('host1', self.key1, self.key2)

        filename = storage.get_host_keys_filename()
        fp = open(filename, 'r')
        lines = fp.readlines()
        fp.close()

        self.assertEqual(len(lines), 1)
        self.assertEqual(lines[0], 'host1 ssh-dss %s\n' % self.key2_b64)
示例#4
0
    def test_replace_host_key(self):
        """Testing FileSSHStorage.replace_host_key"""
        storage = FileSSHStorage()
        storage.add_host_key('host1', self.key1)
        storage.replace_host_key('host1', self.key1, self.key2)

        filename = storage.get_host_keys_filename()
        fp = open(filename, 'r')
        lines = fp.readlines()
        fp.close()

        self.assertEqual(len(lines), 1)
        self.assertEqual(lines[0], 'host1 ssh-dss %s\n' % self.key2_b64)
示例#5
0
    def test_replace_host_key(self):
        """Testing FileSSHStorage.replace_host_key"""
        storage = FileSSHStorage()
        storage.add_host_key('host1', test_keys.rsa_key)
        storage.replace_host_key('host1', test_keys.rsa_key, test_keys.dsa_key)

        filename = storage.get_host_keys_filename()

        with open(filename, 'r') as fp:
            lines = fp.readlines()

        self.assertEqual(len(lines), 1)
        self.assertEqual(lines[0],
                         'host1 ssh-dss %s\n' % test_keys.dsa_key_b64)