diff --git a/dvc/config_schema.py b/dvc/config_schema.py index b5ee185a8..a5c077d3c 100644 --- a/dvc/config_schema.py +++ b/dvc/config_schema.py @@ -106,6 +106,7 @@ WEBDAV_COMMON = { "password": str, "ask_password": Bool, "token": str, + "custom_auth_header": str, "cert_path": str, "key_path": str, "timeout": Coerce(int), diff --git a/pyproject.toml b/pyproject.toml index 04141ff9f..555606219 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -78,7 +78,7 @@ oss = ["dvc-oss==2.19.0"] s3 = ["dvc-s3==2.21.0"] ssh = ["dvc-ssh==2.21.0"] ssh_gssapi = ["dvc-ssh[gssapi]==2.21.0"] -webdav = ["dvc-webdav==2.19.0"] +webdav = ["dvc-webdav==2.19.1"] webhdfs = ["dvc-webhdfs==2.19.0"] webhdfs_kerberos = ["dvc-webhdfs[kerberos]==2.19.0"] terraform = ["tpi[ssh]>=2.1.0"] diff --git a/tests/unit/remote/test_webdav.py b/tests/unit/remote/test_webdav.py index cd8c188e3..416556793 100644 --- a/tests/unit/remote/test_webdav.py +++ b/tests/unit/remote/test_webdav.py @@ -9,6 +9,7 @@ url = "webdav://example.com/public.php/webdav" user = "username" password = "password" token = "4MgjsNM5aSJjxIKM" +custom_auth_header = "Custom-Header" def test_common(): @@ -23,6 +24,7 @@ def test_common(): password=None, ask_password=False, token=None, + custom_auth_header=None, ) assert issubset( { @@ -87,6 +89,46 @@ def test_ask_password(mocker): ask_password_mocked.assert_called_once_with(host, user) +def test_custom_auth_header(): + config = { + "url": url, + "custom_auth_header": custom_auth_header, + "password": password, + } + fs = WebDAVFileSystem(**config) + assert issubset( + {"headers": {custom_auth_header: password}, "auth": None}, + fs.fs_args, + ) + + +def test_ask_password_custom_auth_header(mocker): + ask_password_mocked = mocker.patch( + "dvc_webdav.ask_password", return_value="pass" + ) + host = "host" + + # it should not ask for password as password is set + config = { + "url": url, + "custom_auth_header": custom_auth_header, + "password": password, + "ask_password": True, + "host": host, + } + fs = WebDAVFileSystem(**config) + assert issubset( + {"headers": {custom_auth_header: password}, "auth": None}, fs.fs_args + ) + + config.pop("password") + fs = WebDAVFileSystem(**config) + assert issubset( + {"headers": {custom_auth_header: "pass"}, "auth": None}, fs.fs_args + ) + ask_password_mocked.assert_called_once_with(host, custom_auth_header) + + def test_ssl_verify_custom_cert(): config = { "url": url,