Exemple #1
0
    def test_no_host_key(self):
        # Disable logging to avoid output during test
        logging.disable(logging.ERROR)

        with self.assertRaises(paramiko.SSHException):
            with SshTransport(machine='localhost', timeout=30, 
                              load_system_host_keys = False):
                pass

        # Reset logging level
        logging.disable(logging.NOTSET)
Exemple #2
0
 def test_auto_add_policy(self):
     with SshTransport(machine='localhost',
                       timeout=30,
                       load_system_host_keys=True,
                       key_policy='AutoAddPolicy'):
         pass
Exemple #3
0
 def test_invalid_param(self):
     with self.assertRaises(ValueError):
         SshTransport(machine='localhost', invalid_param=True)
Exemple #4
0
 def test_closed_connection_sftp(self):
     with self.assertRaises(
             aiida.transport.transport.TransportInternalError):
         t = SshTransport(machine='localhost')
         t.listdir()
Exemple #5
0
 def test_closed_connection_ssh(self):
     with self.assertRaises(
             aiida.transport.transport.TransportInternalError):
         t = SshTransport(machine='localhost')
         t._exec_command_internal('ls')
Exemple #6
0
###########################################################################
"""
Test ssh plugin on localhost
"""
import unittest
import logging

import aiida.transport
import aiida.transport.transport
import paramiko
from aiida.transport.plugins.ssh import SshTransport

# This will be used by test_all_plugins

plugin_transport = SshTransport(machine='localhost',
                                timeout=30,
                                load_system_host_keys=True,
                                key_policy='AutoAddPolicy')


class TestBasicConnection(unittest.TestCase):
    """
    Test basic connections.
    """
    def test_closed_connection_ssh(self):
        with self.assertRaises(
                aiida.transport.transport.TransportInternalError):
            t = SshTransport(machine='localhost')
            t._exec_command_internal('ls')

    def test_closed_connection_sftp(self):
        with self.assertRaises(