File tree Expand file tree Collapse file tree 3 files changed +36
-3
lines changed Expand file tree Collapse file tree 3 files changed +36
-3
lines changed Original file line number Diff line number Diff line change 77### Added
88
99- Only apply rollbacks if experiment has progressed past the initial steady state hypothesis [ #168 ] ( 168 )
10+ - Allow to not verify certificates when connecting to a HTTPS endpoint using [ #163 ] ( 163 )
11+ self-signed certificate.
12+
13+ [ 168 ] : https://github.com/chaostoolkit/chaostoolkit-lib/issues/168
14+ [ 163 ] : https://github.com/chaostoolkit/chaostoolkit-lib/issues/163
1015
1116### Changed
1217
Original file line number Diff line number Diff line change @@ -69,8 +69,8 @@ def parse_experiment_from_http(response: requests.Response) -> Experiment:
6969 "only files with json, yaml or yml extensions are supported" )
7070
7171
72- def load_experiment (experiment_source : str ,
73- settings : Settings = None ) -> Experiment :
72+ def load_experiment (experiment_source : str , settings : Settings = None ,
73+ verify_tls : bool = True ) -> Experiment :
7474 """
7575 Load an experiment from the given source.
7676
@@ -90,6 +90,10 @@ def load_experiment(experiment_source: str,
9090 type: digest
9191 value: UIY
9292 ```
93+
94+ Set `verify_tls` to `False` if the source is a over a self-signed
95+ certificate HTTP endpoint to instruct the loader to not verify the
96+ certificates.
9397 """
9498 with controls (level = "loader" , context = experiment_source ) as control :
9599 if os .path .exists (experiment_source ):
@@ -117,7 +121,7 @@ def load_experiment(experiment_source: str,
117121 auth ["type" ], auth ["value" ])
118122 break
119123
120- r = requests .get (experiment_source , headers = headers )
124+ r = requests .get (experiment_source , headers = headers , verify = verify_tls )
121125 if r .status_code != 200 :
122126 raise InvalidSource (
123127 "Failed to fetch the experiment: {}" .format (r .text ))
Original file line number Diff line number Diff line change 77from chaoslib .exceptions import InvalidSource , InvalidExperiment
88from chaoslib .loader import load_experiment , parse_experiment_from_file
99from chaoslib .types import Settings
10+ import requests
1011
1112from fixtures import experiments
1213
@@ -121,3 +122,26 @@ def test_http_loads_fails_when_known_type():
121122 )
122123 with pytest .raises (InvalidExperiment ):
123124 load_experiment ('http://example.com/experiment.yaml' )
125+
126+
127+ def test_https_no_verification ():
128+ with requests_mock .mock () as m :
129+ m .get (
130+ 'https://example.com/experiment.yaml' , status_code = 200 ,
131+ headers = {"Content-Type" : "text/css" },
132+ text = "body {}"
133+ )
134+ with pytest .raises (InvalidExperiment ):
135+ load_experiment (
136+ 'https://example.com/experiment.yaml' , verify_tls = False )
137+
138+
139+ def test_https_with_verification ():
140+ with requests_mock .mock () as m :
141+ m .get (
142+ 'https://example.com/experiment.yaml' ,
143+ exc = requests .exceptions .SSLError
144+ )
145+ with pytest .raises (requests .exceptions .SSLError ):
146+ load_experiment (
147+ 'https://example.com/experiment.yaml' , verify_tls = True )
You can’t perform that action at this time.
0 commit comments