mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
http/webdav: support specifying certs in ssl (#6142)
This commit is contained in:
@@ -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
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user