Skip to content

Commit

Permalink
feat(flag): allow disabling SSL verification
Browse files Browse the repository at this point in the history
Coveralls Enterprise instances often use self-signed certificates.
  • Loading branch information
nickmerwin authored and TheKevJames committed Jun 2, 2019
1 parent 749b97f commit 2e3b5c6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion coveralls/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ def wear(self, dry_run=False):
return {}

endpoint = '{}/api/v1/jobs'.format(self._coveralls_host.rstrip('/'))
response = requests.post(endpoint, files={'json_file': json_string})
verify = not bool(os.environ.get('COVERALLS_SKIP_SSL_VERIFY'))
response = requests.post(endpoint, files={'json_file': json_string},
verify=verify)
try:
response.raise_for_status()
return response.json()
Expand Down
8 changes: 5 additions & 3 deletions tests/api/wear_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,16 @@ def test_no_coverage(self, report_files, mock_requests):

@mock.patch.dict(
os.environ,
{'COVERALLS_HOST': 'https://coveralls.my-enterprise.info'}, clear=True)
{'COVERALLS_HOST': 'https://coveralls.my-enterprise.info',
'COVERALLS_SKIP_SSL_VERIFY': '1'}, clear=True)
def test_coveralls_host_env_var_overrides_api_url(self, mock_requests):
coveralls.Coveralls(repo_token='xxx').wear(dry_run=False)
mock_requests.post.assert_called_once_with(
'https://coveralls.my-enterprise.info/api/v1/jobs', files=mock.ANY)
'https://coveralls.my-enterprise.info/api/v1/jobs',
files=mock.ANY, verify=False)

@mock.patch.dict(os.environ, {}, clear=True)
def test_api_call_uses_default_host_if_no_env_var_set(self, mock_requests):
coveralls.Coveralls(repo_token='xxx').wear(dry_run=False)
mock_requests.post.assert_called_once_with(
'https://coveralls.io/api/v1/jobs', files=mock.ANY)
'https://coveralls.io/api/v1/jobs', files=mock.ANY, verify=True)

0 comments on commit 2e3b5c6

Please sign in to comment.