* include custom auth header for webdav

* Revert "include custom auth header for webdav"

This reverts commit d2f2b2889b6bcf0429e4a28076f709a04642ae3a.

* include custom auth header for dvc webdav, ran unit tests

* update dvc-webdav version
This commit is contained in:
frederik-sandfort
2023-02-02 16:36:11 +05:45
committed by GitHub
parent 49a27f4140
commit 18fa1a0272
3 changed files with 44 additions and 1 deletions
+1
View File
@@ -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),
+1 -1
View File
@@ -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"]
+42
View File
@@ -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,