http/webdav: support specifying certs in ssl (#6142)

This commit is contained in:
Saugat Pachhai
2021-06-10 02:24:56 +03:00
committed by GitHub
parent 57c728269d
commit 5012494213
4 changed files with 29 additions and 2 deletions
+2 -1
View File
@@ -93,7 +93,7 @@ HTTP_COMMON = {
"user": str,
"password": str,
"ask_password": Bool,
"ssl_verify": Bool,
"ssl_verify": Any(Bool, str),
"method": str,
}
WEBDAV_COMMON = {
@@ -104,6 +104,7 @@ WEBDAV_COMMON = {
"cert_path": str,
"key_path": str,
"timeout": Coerce(int),
"ssl_verify": Any(Bool, str),
}
SCHEMA = {
+4 -1
View File
@@ -31,7 +31,10 @@ class WebDAVFileSystem(FSSpecWrapper): # pylint:disable=abstract-method
key_path = config.get("key_path", None)
cert = cert_path if not key_path else (cert_path, key_path)
self.fs_args.update({"base_url": config["url"], "cert": cert})
ssl_verify = config.get("ssl_verify", True)
self.fs_args.update(
{"base_url": config["url"], "cert": cert, "verify": ssl_verify}
)
self.prefix = config.get("prefix", "")
@staticmethod
+12
View File
@@ -106,6 +106,18 @@ def test_ssl_verify_disable(dvc):
assert fs._session.verify is False
def test_ssl_verify_custom_cert(dvc):
config = {
"url": "http://example.com/",
"path_info": "file.html",
"ssl_verify": "/path/to/custom/cabundle.pem",
}
fs = HTTPFileSystem(**config)
assert fs._session.verify == "/path/to/custom/cabundle.pem"
def test_http_method(dvc):
from requests.auth import HTTPBasicAuth
+11
View File
@@ -16,3 +16,14 @@ def test_password(dvc):
config = {"url": url, "user": user, "password": password}
fs = WebDAVFileSystem(**config)
assert fs.password == password
def test_ssl_verify_custom_cert(dvc):
config = {
"url": "http://example.com/",
"path_info": "file.html",
"ssl_verify": "/path/to/custom/cabundle.pem",
}
fs = WebDAVFileSystem(**config)
assert fs.fs_args["verify"] == "/path/to/custom/cabundle.pem"