mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-18 23:10:14 +01:00
Feature/http ssl verify configuration (#4547)
* add test for http ssl_verify configuration * add ssl_verify flag to HTTPTree
This commit is contained in:
@@ -118,6 +118,7 @@ HTTP_COMMON = {
|
||||
"user": str,
|
||||
"password": str,
|
||||
"ask_password": Bool,
|
||||
"ssl_verify": Bool,
|
||||
}
|
||||
WEBDAV_COMMON = {
|
||||
"user": str,
|
||||
|
||||
@@ -53,6 +53,7 @@ class HTTPTree(BaseTree): # pylint:disable=abstract-method
|
||||
self.password = config.get("password", None)
|
||||
self.ask_password = config.get("ask_password", False)
|
||||
self.headers = {}
|
||||
self.ssl_verify = config.get("ssl_verify", True)
|
||||
|
||||
def _auth_method(self, path_info=None):
|
||||
from requests.auth import HTTPBasicAuth, HTTPDigestAuth
|
||||
@@ -81,6 +82,8 @@ class HTTPTree(BaseTree): # pylint:disable=abstract-method
|
||||
|
||||
session = requests.Session()
|
||||
|
||||
session.verify = self.ssl_verify
|
||||
|
||||
retries = Retry(
|
||||
total=self.SESSION_RETRIES,
|
||||
backoff_factor=self.SESSION_BACKOFF_FACTOR,
|
||||
|
||||
@@ -80,3 +80,26 @@ def test_custom_auth_method(dvc):
|
||||
assert tree._auth_method() is None
|
||||
assert header in tree.headers
|
||||
assert tree.headers[header] == password
|
||||
|
||||
|
||||
def test_ssl_verify_is_enabled_by_default(dvc):
|
||||
config = {
|
||||
"url": "http://example.com/",
|
||||
"path_info": "file.html",
|
||||
}
|
||||
|
||||
tree = HTTPTree(dvc, config)
|
||||
|
||||
assert tree._session.verify is True
|
||||
|
||||
|
||||
def test_ssl_verify_disable(dvc):
|
||||
config = {
|
||||
"url": "http://example.com/",
|
||||
"path_info": "file.html",
|
||||
"ssl_verify": False,
|
||||
}
|
||||
|
||||
tree = HTTPTree(dvc, config)
|
||||
|
||||
assert tree._session.verify is False
|
||||
|
||||
Reference in New Issue
Block a user