mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-12-02 23:10:25 +01:00
webdav: bring back support for user in url (#6155)
Also added some optimizations, and merged Webdavs into the same file.
This commit is contained in:
@@ -1,29 +1,51 @@
|
||||
from dvc.fs.webdav import WebDAVFileSystem
|
||||
import pytest
|
||||
|
||||
from dvc.fs import get_cloud_fs
|
||||
from dvc.fs.webdav import WebDAVFileSystem, WebDAVSFileSystem
|
||||
|
||||
# Test configuration
|
||||
url = "webdavs://example.com/public.php/webdav"
|
||||
url = "webdav://example.com/public.php/webdav"
|
||||
user = "username"
|
||||
userurl = f"webdavs://{user}@example.com/public.php/webdav"
|
||||
userurl = f"webdav://{user}@example.com/public.php/webdav"
|
||||
password = "password"
|
||||
https_url = "webdavs://example.com/public.php/webdav"
|
||||
|
||||
|
||||
def test_user(dvc):
|
||||
def test_user():
|
||||
fs = WebDAVFileSystem(url=url, user=user)
|
||||
assert fs.user == user
|
||||
|
||||
|
||||
def test_password(dvc):
|
||||
def test_password():
|
||||
config = {"url": url, "user": user, "password": password}
|
||||
fs = WebDAVFileSystem(**config)
|
||||
assert fs.password == password
|
||||
|
||||
|
||||
def test_ssl_verify_custom_cert(dvc):
|
||||
def test_ssl_verify_custom_cert():
|
||||
config = {
|
||||
"url": "http://example.com/",
|
||||
"path_info": "file.html",
|
||||
"url": url,
|
||||
"ssl_verify": "/path/to/custom/cabundle.pem",
|
||||
}
|
||||
|
||||
fs = WebDAVFileSystem(**config)
|
||||
assert fs.fs_args["verify"] == "/path/to/custom/cabundle.pem"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"base_url, fs_cls",
|
||||
[(url, WebDAVFileSystem), (https_url, WebDAVSFileSystem)],
|
||||
)
|
||||
def test_remote_with_jobs(dvc, base_url, fs_cls):
|
||||
remote_config = {"url": base_url, "user": user}
|
||||
|
||||
dvc.config["remote"]["dav"] = remote_config
|
||||
cls, config, _ = get_cloud_fs(dvc, name="dav")
|
||||
assert config["user"] == user
|
||||
assert cls is fs_cls
|
||||
|
||||
# config from remote takes priority
|
||||
remote_config.update({"user": "admin"})
|
||||
cls, config, _ = get_cloud_fs(dvc, name="dav")
|
||||
assert config["user"] == "admin"
|
||||
assert cls is fs_cls
|
||||
|
||||
Reference in New Issue
Block a user