Ejemplo n.º 1
0
def test_ssh_host_override_from_config(mock_file, mock_exists, dvc, config,
                                       expected_host):
    remote = SSHRemote(dvc, config)

    mock_exists.assert_called_with(SSHRemoteTree.ssh_config_filename())
    mock_file.assert_called_with(SSHRemoteTree.ssh_config_filename())
    assert remote.tree.path_info.host == expected_host
Ejemplo n.º 2
0
def test_hardlink_optimization(dvc, tmp_dir, ssh_server):
    port = ssh_server.test_creds["port"]
    user = ssh_server.test_creds["username"]

    config = {
        "url": SSHMocked.get_url(user, port),
        "port": port,
        "user": user,
        "keyfile": ssh_server.test_creds["key_filename"],
    }
    tree = SSHRemoteTree(dvc, config)

    from_info = tree.path_info / "empty"
    to_info = tree.path_info / "link"

    with tree.open(from_info, "wb"):
        pass

    if os.name == "nt":
        link_path = "c:" + to_info.path.replace("/", "\\")
    else:
        link_path = to_info.path

    tree.hardlink(from_info, to_info)
    assert not System.is_hardlink(link_path)
Ejemplo n.º 3
0
def test_hardlink_optimization(dvc, tmp_dir, ssh):
    tree = SSHRemoteTree(dvc, ssh.config)

    from_info = tree.path_info / "empty"
    to_info = tree.path_info / "link"

    with tree.open(from_info, "wb"):
        pass

    if os.name == "nt":
        link_path = "c:" + to_info.path.replace("/", "\\")
    else:
        link_path = to_info.path

    tree.hardlink(from_info, to_info)
    assert not System.is_hardlink(link_path)
Ejemplo n.º 4
0
def test_url(dvc):
    user = "******"
    host = "123.45.67.89"
    port = 1234
    path = "/path/to/dir"

    # URL ssh://[user@]host.xz[:port]/path
    url = f"ssh://{user}@{host}:{port}{path}"
    config = {"url": url}

    tree = SSHRemoteTree(dvc, config)
    assert tree.path_info == url

    # SCP-like URL ssh://[user@]host.xz:/absolute/path
    url = f"ssh://{user}@{host}:{path}"
    config = {"url": url}

    tree = SSHRemoteTree(dvc, config)
    assert tree.path_info == url
Ejemplo n.º 5
0
def test_ssh_user(mock_file, mock_exists, dvc, config, expected_user):
    tree = SSHRemoteTree(dvc, config)

    mock_exists.assert_called_with(SSHRemoteTree.ssh_config_filename())
    mock_file.assert_called_with(SSHRemoteTree.ssh_config_filename())
    assert tree.path_info.user == expected_user
Ejemplo n.º 6
0
def test_no_path(dvc):
    config = {"url": "ssh://127.0.0.1"}
    tree = SSHRemoteTree(dvc, config)
    assert tree.path_info.path == ""
Ejemplo n.º 7
0
def test_ssh_gss_auth(mock_file, mock_exists, dvc, config, expected_gss_auth):
    tree = SSHRemoteTree(dvc, config)

    mock_exists.assert_called_with(SSHRemoteTree.ssh_config_filename())
    mock_file.assert_called_with(SSHRemoteTree.ssh_config_filename())
    assert tree.gss_auth == expected_gss_auth
Ejemplo n.º 8
0
def test_ssh_keyfile(mock_file, mock_exists, dvc, config, expected_keyfile):
    tree = SSHRemoteTree(dvc, config)

    mock_exists.assert_called_with(SSHRemoteTree.ssh_config_filename())
    mock_file.assert_called_with(SSHRemoteTree.ssh_config_filename())
    assert tree.keyfile == expected_keyfile
Ejemplo n.º 9
0
def test_ssh_port(mock_file, mock_exists, dvc, config, expected_port):
    remote = SSHRemote(dvc, config)

    mock_exists.assert_called_with(SSHRemoteTree.ssh_config_filename())
    mock_file.assert_called_with(SSHRemoteTree.ssh_config_filename())
    assert remote.path_info.port == expected_port