def test_local_channel(): with tempfile.TemporaryDirectory() as script_dir: script_dir = tempfile.mkdtemp() p = LocalProvider(channel=LocalChannel(), launcher=SingleNodeLauncher(debug=False)) p.script_dir = script_dir _run_tests(p)
def test_ssh_channel(): with tempfile.TemporaryDirectory() as config_dir: sshd_thread, priv_key, server_port = _start_sshd(config_dir) try: with tempfile.TemporaryDirectory() as remote_script_dir: # The SSH library fails to add the new host key to the file if the file does not # already exist, so create it here. pathlib.Path( '{}/known.hosts'.format(config_dir)).touch(mode=0o600) script_dir = tempfile.mkdtemp() p = LocalProvider(channel=SSHChannel( '127.0.0.1', port=server_port, script_dir=remote_script_dir, host_keys_filename='{}/known.hosts'.format(config_dir), key_filename=priv_key), launcher=SingleNodeLauncher(debug=False)) p.script_dir = script_dir _run_tests(p) finally: _stop_sshd(sshd_thread)