From 20592295fa2b819dc0899488dd6c685731e0b9cf Mon Sep 17 00:00:00 2001 From: Ofek Lev Date: Thu, 27 Aug 2020 14:36:44 -0400 Subject: [PATCH] fix tests --- cisco_aci/tests/test_cisco.py | 6 +++++- couch/tests/test_unit.py | 4 ++-- couchbase/tests/test_unit.py | 4 ++-- envoy/tests/test_envoy.py | 2 +- etcd/tests/test_integration.py | 2 +- hdfs_datanode/tests/conftest.py | 4 +++- hdfs_namenode/tests/conftest.py | 4 +++- mapreduce/tests/conftest.py | 4 +++- marathon/tests/test_unit.py | 4 ++-- nginx/tests/test_unit.py | 4 ++-- php_fpm/tests/test_unit.py | 4 ++-- rabbitmq/tests/test_unit.py | 4 ++-- spark/tests/test_spark.py | 4 +++- squid/tests/test_unit.py | 2 +- yarn/tests/conftest.py | 4 +++- 15 files changed, 35 insertions(+), 21 deletions(-) diff --git a/cisco_aci/tests/test_cisco.py b/cisco_aci/tests/test_cisco.py index 5d2f03c625acb2..6d78cf27cd176c 100644 --- a/cisco_aci/tests/test_cisco.py +++ b/cisco_aci/tests/test_cisco.py @@ -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'), ], diff --git a/couch/tests/test_unit.py b/couch/tests/test_unit.py index 2740e566d5d928..5b7e3a47ca5c38 100644 --- a/couch/tests/test_unit.py +++ b/couch/tests/test_unit.py @@ -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)}), ], ) diff --git a/couchbase/tests/test_unit.py b/couchbase/tests/test_unit.py index 547aab560d28f1..a5d5231b66e91f 100644 --- a/couchbase/tests/test_unit.py +++ b/couchbase/tests/test_unit.py @@ -67,9 +67,9 @@ 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': ('new_foo', 'password'), 'verify': False}), + ("legacy config", {'user': 'new_foo', 'ssl_verify': False}, {'auth': (b'new_foo', b'password'), 'verify': False}), ], ) def test_config(test_case, extra_config, expected_http_kwargs): diff --git a/envoy/tests/test_envoy.py b/envoy/tests/test_envoy.py index 22163d4dd8e84a..8994acb5078028 100644 --- a/envoy/tests/test_envoy.py +++ b/envoy/tests/test_envoy.py @@ -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}), diff --git a/etcd/tests/test_integration.py b/etcd/tests/test_integration.py index 3efc642a4dd8bc..113ce63fe335c6 100644 --- a/etcd/tests/test_integration.py +++ b/etcd/tests/test_integration.py @@ -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}), diff --git a/hdfs_datanode/tests/conftest.py b/hdfs_datanode/tests/conftest.py index 12a717418191ae..0542a63653e02b 100644 --- a/hdfs_datanode/tests/conftest.py +++ b/hdfs_datanode/tests/conftest.py @@ -84,7 +84,9 @@ 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) diff --git a/hdfs_namenode/tests/conftest.py b/hdfs_namenode/tests/conftest.py index 3ecedec8d4817a..b2a463e148a504 100644 --- a/hdfs_namenode/tests/conftest.py +++ b/hdfs_namenode/tests/conftest.py @@ -88,7 +88,9 @@ 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) diff --git a/mapreduce/tests/conftest.py b/mapreduce/tests/conftest.py index 380f33dfabe439..988d763be01898 100644 --- a/mapreduce/tests/conftest.py +++ b/mapreduce/tests/conftest.py @@ -129,7 +129,9 @@ 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) diff --git a/marathon/tests/test_unit.py b/marathon/tests/test_unit.py index a5cf35ba1074ca..82f86ee660f7aa 100644 --- a/marathon/tests/test_unit.py +++ b/marathon/tests/test_unit.py @@ -89,7 +89,7 @@ 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)}), @@ -97,7 +97,7 @@ def test_get_instance_config(check): "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}), ], diff --git a/nginx/tests/test_unit.py b/nginx/tests/test_unit.py index 3940552e3b37b0..fb8c89ce38a207 100644 --- a/nginx/tests/test_unit.py +++ b/nginx/tests/test_unit.py @@ -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}), ], diff --git a/php_fpm/tests/test_unit.py b/php_fpm/tests/test_unit.py index f6398295c19971..914a10fca3a157 100644 --- a/php_fpm/tests/test_unit.py +++ b/php_fpm/tests/test_unit.py @@ -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}), diff --git a/rabbitmq/tests/test_unit.py b/rabbitmq/tests/test_unit.py index 56d7cd05d2bffc..d666dd4874abba 100644 --- a/rabbitmq/tests/test_unit.py +++ b/rabbitmq/tests/test_unit.py @@ -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}), ], diff --git a/spark/tests/test_spark.py b/spark/tests/test_spark.py index 5b738f174d069b..ccaa80b3a335e4 100644 --- a/spark/tests/test_spark.py +++ b/spark/tests/test_spark.py @@ -214,7 +214,9 @@ 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) diff --git a/squid/tests/test_unit.py b/squid/tests/test_unit.py index e3f87221d77754..365532ae22079d 100644 --- a/squid/tests/test_unit.py +++ b/squid/tests/test_unit.py @@ -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, diff --git a/yarn/tests/conftest.py b/yarn/tests/conftest.py index 5fa8aefaba8f7b..d8521f071b3349 100644 --- a/yarn/tests/conftest.py +++ b/yarn/tests/conftest.py @@ -59,7 +59,9 @@ 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)