Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ofek committed Aug 27, 2020
1 parent 5e9c3fb commit d6f2cee
Show file tree
Hide file tree
Showing 15 changed files with 45 additions and 22 deletions.
6 changes: 5 additions & 1 deletion cisco_aci/tests/test_cisco.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ def test_recover_from_expired_token(aggregator, api_kwargs):
@pytest.mark.parametrize(
'extra_config, expected_http_kwargs',
[
pytest.param({'pwd': 'foobar'}, {'auth': (common.USERNAME, 'foobar'), 'verify': True}, id='new auth config'),
pytest.param(
{'pwd': 'foobar'},
{'auth': (common.USERNAME.encode('utf-8'), b'foobar'), 'verify': True},
id='new auth config',
),
pytest.param({'ssl_verify': True}, {'verify': True}, id='legacy ssl verify config True'),
pytest.param({'ssl_verify': False}, {'verify': False}, id='legacy ssl verify config False'),
],
Expand Down
4 changes: 2 additions & 2 deletions couch/tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
(
"legacy auth config",
{'user': 'legacy_foo', 'password': 'legacy_bar'},
{'auth': ('legacy_foo', 'legacy_bar')},
{'auth': (b'legacy_foo', b'legacy_bar')},
),
("new auth config", {'username': 'new_foo', 'password': 'new_bar'}, {'auth': ('new_foo', 'new_bar')}),
("new auth config", {'username': 'new_foo', 'password': 'new_bar'}, {'auth': (b'new_foo', b'new_bar')}),
("timeout", {'timeout': 17}, {'timeout': (17, 17)}),
],
)
Expand Down
8 changes: 6 additions & 2 deletions couchbase/tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,13 @@ def test__get_query_monitoring_data():
(
"new auth config",
{'username': 'new_foo', 'password': 'bar', 'tls_verify': False},
{'auth': ('new_foo', 'bar'), 'verify': False},
{'auth': (b'new_foo', b'bar'), 'verify': False},
),
(
"legacy config",
{'user': 'new_foo', 'ssl_verify': False},
{'auth': (b'new_foo', b'password'), 'verify': False},
),
("legacy config", {'user': 'new_foo', 'ssl_verify': False}, {'auth': ('new_foo', 'password'), 'verify': False}),
],
)
def test_config(test_case, extra_config, expected_http_kwargs):
Expand Down
2 changes: 1 addition & 1 deletion envoy/tests/test_envoy.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def test_unknown():
@pytest.mark.parametrize(
'test_case, extra_config, expected_http_kwargs',
[
("new auth config", {'username': 'new_foo', 'password': 'new_bar'}, {'auth': ('new_foo', 'new_bar')}),
("new auth config", {'username': 'new_foo', 'password': 'new_bar'}, {'auth': (b'new_foo', b'new_bar')}),
("legacy ssl config True", {'verify_ssl': True}, {'verify': True}),
("legacy ssl config False", {'verify_ssl': False}, {'verify': False}),
("legacy ssl config unset", {}, {'verify': True}),
Expand Down
4 changes: 2 additions & 2 deletions etcd/tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def test_followers(aggregator):
@pytest.mark.parametrize(
'test_case, extra_config, expected_http_kwargs',
[
("new auth config", {'username': 'new_foo', 'password': 'new_bar'}, {'auth': ('new_foo', 'new_bar')}),
("new auth config", {'username': 'new_foo', 'password': 'new_bar'}, {'auth': (b'new_foo', b'new_bar')}),
("legacy ssl config True", {'ssl_cert_validation': True}, {'verify': True}),
("legacy ssl config False", {'ssl_cert_validation': False}, {'verify': False}),
("legacy ssl config unset", {}, {'verify': False}),
Expand All @@ -163,7 +163,7 @@ def test_config_legacy(legacy_instance, test_case, extra_config, expected_http_k
@pytest.mark.parametrize(
'test_case, extra_config, expected_http_kwargs',
[
("new auth config", {'username': 'new_foo', 'password': 'new_bar'}, {'auth': ('new_foo', 'new_bar')}),
("new auth config", {'username': 'new_foo', 'password': 'new_bar'}, {'auth': (b'new_foo', b'new_bar')}),
("legacy ssl config True", {'ssl_verify': True}, {'verify': True}),
("legacy ssl config False", {'ssl_verify': False}, {'verify': False}),
("legacy ssl config unset", {}, {'verify': False}),
Expand Down
5 changes: 4 additions & 1 deletion hdfs_datanode/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ def requests_auth_mock(*args, **kwargs):
assert 'auth' in kwargs, "Error, missing authentication"

# Make sure we've got the correct username and password
assert kwargs['auth'] == (TEST_USERNAME, TEST_PASSWORD), "Incorrect username or password"
assert kwargs['auth'] == (
TEST_USERNAME.encode('utf-8'),
TEST_PASSWORD.encode('utf-8'),
), "Incorrect username or password"

# Return mocked request.get(...)
return requests_get_mock(*args, **kwargs)
5 changes: 4 additions & 1 deletion hdfs_namenode/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ def requests_auth_mock(*args, **kwargs):
assert 'auth' in kwargs, "Error, missing authentication"

# Make sure we've got the correct username and password
assert kwargs['auth'] == (TEST_USERNAME, TEST_PASSWORD), "Incorrect username or password"
assert kwargs['auth'] == (
TEST_USERNAME.encode('utf-8'),
TEST_PASSWORD.encode('utf-8'),
), "Incorrect username or password"

# Return mocked request.get(...)
return requests_get_mock(*args, **kwargs)
5 changes: 4 additions & 1 deletion mapreduce/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,10 @@ def requests_auth_mock(*args, **kwargs):
assert 'auth' in kwargs, "Error, missing authentication"

# Make sure we've got the correct username and password
assert kwargs['auth'] == (TEST_USERNAME, TEST_PASSWORD), "Incorrect username or password"
assert kwargs['auth'] == (
TEST_USERNAME.encode('utf-8'),
TEST_PASSWORD.encode('utf-8'),
), "Incorrect username or password"

# Return mocked request.get(...)
return requests_get_mock(*args, **kwargs)
4 changes: 2 additions & 2 deletions marathon/tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,15 @@ def test_get_instance_config(check):
"new config",
{},
{'timeout': 5, 'username': 'foo', 'password': 'bar', 'tls_verify': False},
{'timeout': 5, 'auth': ('foo', 'bar'), 'verify': False},
{'timeout': 5, 'auth': (b'foo', b'bar'), 'verify': False},
),
("connect_timeout", {'default_timeout': 5}, {'connect_timeout': 2}, {'timeout': (5.0, 2.0)}),
("read_timeout", {}, {'timeout': 7, 'read_timeout': 3}, {'timeout': (3.0, 7.0)}),
(
"legacy config",
{'default_timeout': 3},
{'user': 'foo', 'password': 'bar', 'disable_ssl_validation': True},
{'timeout': 3, 'auth': ('foo', 'bar'), 'verify': False},
{'timeout': 3, 'auth': (b'foo', b'bar'), 'verify': False},
),
("default config", {}, {}, {'verify': True}),
],
Expand Down
4 changes: 2 additions & 2 deletions nginx/tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ def test_nest_payload(check):
(
"legacy auth config",
{'user': 'legacy_foo', 'password': 'legacy_bar'},
{'auth': ('legacy_foo', 'legacy_bar')},
{'auth': (b'legacy_foo', b'legacy_bar')},
),
("new auth config", {'username': 'new_foo', 'password': 'new_bar'}, {'auth': ('new_foo', 'new_bar')}),
("new auth config", {'username': 'new_foo', 'password': 'new_bar'}, {'auth': (b'new_foo', b'new_bar')}),
("legacy ssl config True", {'ssl_validation': True}, {'verify': True}),
("legacy ssl config False", {'ssl_validation': False}, {'verify': False}),
],
Expand Down
4 changes: 2 additions & 2 deletions php_fpm/tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ def test_backoff_success(check, instance, aggregator, payload):
@pytest.mark.parametrize(
'test_case, extra_config, expected_http_kwargs',
[
("old auth config", {'user': 'old_foo', 'password': 'new_bar'}, {'auth': ('old_foo', 'new_bar')}),
("new auth config", {'username': 'new_foo', 'password': 'new_bar'}, {'auth': ('new_foo', 'new_bar')}),
("old auth config", {'user': 'old_foo', 'password': 'new_bar'}, {'auth': (b'old_foo', b'new_bar')}),
("new auth config", {'username': 'new_foo', 'password': 'new_bar'}, {'auth': (b'new_foo', b'new_bar')}),
("legacy ssl config True", {'disable_ssl_validation': False}, {'verify': True}),
("legacy ssl config False", {'disable_ssl_validation': True}, {'verify': False}),
("legacy ssl config unset", {}, {'verify': True}),
Expand Down
4 changes: 2 additions & 2 deletions rabbitmq/tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ def test_get_stats_empty_exchanges(mock__get_object_data, instance, check, aggre
(
"legacy auth config",
{'rabbitmq_user': 'legacy_foo', 'rabbitmq_pass': 'legacy_bar'},
{'auth': ('legacy_foo', 'legacy_bar')},
{'auth': (b'legacy_foo', b'legacy_bar')},
),
("new auth config", {'username': 'new_foo', 'password': 'new_bar'}, {'auth': ('new_foo', 'new_bar')}),
("new auth config", {'username': 'new_foo', 'password': 'new_bar'}, {'auth': (b'new_foo', b'new_bar')}),
("legacy ssl config True", {'ssl_verify': True}, {'verify': True}),
("legacy ssl config False", {'ssl_verify': False}, {'verify': False}),
],
Expand Down
5 changes: 4 additions & 1 deletion spark/tests/test_spark.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,10 @@ def yarn_requests_auth_mock(*args, **kwargs):
assert 'auth' in kwargs, "Error, missing authentication"

# Make sure we've got the correct username and password
assert kwargs['auth'] == (TEST_USERNAME, TEST_PASSWORD), "Incorrect username or password"
assert kwargs['auth'] == (
TEST_USERNAME.encode('utf-8'),
TEST_PASSWORD.encode('utf-8'),
), "Incorrect username or password"

# Return mocked request.get(...)
return yarn_requests_get_mock(*args, **kwargs)
Expand Down
2 changes: 1 addition & 1 deletion squid/tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def test_legacy_username_password(instance, auth_config):

g.assert_called_with(
'http://host:port/squid-internal-mgr/counters',
auth=('datadog_user', 'datadog_pass'),
auth=(b'datadog_user', b'datadog_pass'),
cert=mock.ANY,
headers=mock.ANY,
proxies=mock.ANY,
Expand Down
5 changes: 4 additions & 1 deletion yarn/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ def requests_auth_get(*args, **kwargs):
assert 'auth' in kwargs, 'Missing "auth" argument in requests.get(...) call'

# Make sure we've got the correct username and password
assert kwargs['auth'] == (TEST_USERNAME, TEST_PASSWORD), "Incorrect username or password in requests.get"
assert kwargs['auth'] == (
TEST_USERNAME.encode('utf-8'),
TEST_PASSWORD.encode('utf-8'),
), "Incorrect username or password in requests.get"

# Return mocked request.get(...)
return requests_get_mock(*args, **kwargs)
Expand Down

0 comments on commit d6f2cee

Please sign in to comment.