Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix http invert without explicit default #4277

Merged
merged 1 commit into from
Aug 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion datadog_checks_base/datadog_checks/base/utils/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,13 @@ def __init__(self, instance, init_config, remapper=None, logger=None):
if field in instance:
continue

# Invert default booleans if need be
default = default_fields[field]
if data.get('invert'):
default = not default

# Get value, with a possible default
value = instance.get(remapped_field, data.get('default', default_fields[field]))
value = instance.get(remapped_field, data.get('default', default))

# Invert booleans if need be
if data.get('invert'):
Expand Down
8 changes: 8 additions & 0 deletions datadog_checks_base/tests/test_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,14 @@ def test_invert(self):

assert http.options['verify'] is True

def test_invert_without_explicit_default(self):
instance = {}
init_config = {}
remapper = {'disable_ssl_validation': {'name': 'tls_verify', 'invert': True}}
http = RequestsWrapper(instance, init_config, remapper)

assert http.options['verify'] is True

def test_standard_override(self):
instance = {'disable_ssl_validation': True, 'tls_verify': False}
init_config = {}
Expand Down