diff options
author | Charles-Henri de Boysson <ceache@users.noreply.github.com> | 2020-02-06 23:41:42 -0500 |
---|---|---|
committer | Stephen SORRIAUX <stephen.sorriaux@gmail.com> | 2020-02-23 11:58:28 +0100 |
commit | 933b38b5506d84e05ed6f6c5c8c208a3367400da (patch) | |
tree | 68a3f7b229f304d4988837d97377dae60ae29a40 | |
parent | d7bed550fee1b861eb2ee81cc685e6d08ee35c34 (diff) | |
download | kazoo-933b38b5506d84e05ed6f6c5c8c208a3367400da.tar.gz |
fix(tests): Disable JAAS isInitiator for Server
Satisfy new Hound style/lint checks
Upgrade to latest 3.5.6/3.4.14 Zookeeper releases.
-rw-r--r-- | .travis.yml | 16 | ||||
-rwxr-xr-x | ensure-zookeeper-env.sh | 2 | ||||
-rw-r--r-- | kazoo/testing/common.py | 8 | ||||
-rw-r--r-- | kazoo/testing/harness.py | 1 | ||||
-rw-r--r-- | kazoo/tests/test_sasl.py | 84 |
5 files changed, 56 insertions, 55 deletions
diff --git a/.travis.yml b/.travis.yml index ef6ef66..85f105b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,35 +20,35 @@ matrix: - python: '2.7' env: ZOOKEEPER_VERSION=3.4.14 TOX_VENV=py27 - python: '2.7' - env: ZOOKEEPER_VERSION=3.5.5 ZOOKEEPER_PREFIX="apache-" ZOOKEEPER_SUFFIX="-bin" ZOOKEEPER_LIB="lib" TOX_VENV=py27 + env: ZOOKEEPER_VERSION=3.5.6 ZOOKEEPER_PREFIX="apache-" ZOOKEEPER_SUFFIX="-bin" ZOOKEEPER_LIB="lib" TOX_VENV=py27 - python: '2.7' env: ZOOKEEPER_VERSION=3.4.14 TOX_VENV=py27-gevent - python: '2.7' - env: ZOOKEEPER_VERSION=3.5.5 ZOOKEEPER_PREFIX="apache-" ZOOKEEPER_SUFFIX="-bin" ZOOKEEPER_LIB="lib" TOX_VENV=py27-gevent + env: ZOOKEEPER_VERSION=3.5.6 ZOOKEEPER_PREFIX="apache-" ZOOKEEPER_SUFFIX="-bin" ZOOKEEPER_LIB="lib" TOX_VENV=py27-gevent - python: '2.7' env: ZOOKEEPER_VERSION=3.4.14 TOX_VENV=py27-eventlet - python: '2.7' - env: ZOOKEEPER_VERSION=3.5.5 ZOOKEEPER_PREFIX="apache-" ZOOKEEPER_SUFFIX="-bin" ZOOKEEPER_LIB="lib" TOX_VENV=py27-eventlet + env: ZOOKEEPER_VERSION=3.5.6 ZOOKEEPER_PREFIX="apache-" ZOOKEEPER_SUFFIX="-bin" ZOOKEEPER_LIB="lib" TOX_VENV=py27-eventlet - python: '3.6' env: ZOOKEEPER_VERSION=3.4.14 TOX_VENV=py36 - python: '3.6' env: ZOOKEEPER_VERSION=3.4.14 TOX_VENV=py36-sasl - python: '3.6' - env: ZOOKEEPER_VERSION=3.5.5 ZOOKEEPER_PREFIX="apache-" ZOOKEEPER_SUFFIX="-bin" ZOOKEEPER_LIB="lib" TOX_VENV=py36 + env: ZOOKEEPER_VERSION=3.5.6 ZOOKEEPER_PREFIX="apache-" ZOOKEEPER_SUFFIX="-bin" ZOOKEEPER_LIB="lib" TOX_VENV=py36 - python: '3.6' - env: ZOOKEEPER_VERSION=3.5.5 ZOOKEEPER_PREFIX="apache-" ZOOKEEPER_SUFFIX="-bin" ZOOKEEPER_LIB="lib" TOX_VENV=py36-sasl + env: ZOOKEEPER_VERSION=3.5.6 ZOOKEEPER_PREFIX="apache-" ZOOKEEPER_SUFFIX="-bin" ZOOKEEPER_LIB="lib" TOX_VENV=py36-sasl - python: '3.7' env: ZOOKEEPER_VERSION=3.4.14 TOX_VENV=py37 - python: '3.7' env: ZOOKEEPER_VERSION=3.4.14 TOX_VENV=py37-sasl - python: '3.7' - env: ZOOKEEPER_VERSION=3.5.5 ZOOKEEPER_PREFIX="apache-" ZOOKEEPER_SUFFIX="-bin" ZOOKEEPER_LIB="lib" TOX_VENV=py37 DEPLOY=true + env: ZOOKEEPER_VERSION=3.5.6 ZOOKEEPER_PREFIX="apache-" ZOOKEEPER_SUFFIX="-bin" ZOOKEEPER_LIB="lib" TOX_VENV=py37 DEPLOY=true - python: '3.7' - env: ZOOKEEPER_VERSION=3.5.5 ZOOKEEPER_PREFIX="apache-" ZOOKEEPER_SUFFIX="-bin" ZOOKEEPER_LIB="lib" TOX_VENV=py37-sasl + env: ZOOKEEPER_VERSION=3.5.6 ZOOKEEPER_PREFIX="apache-" ZOOKEEPER_SUFFIX="-bin" ZOOKEEPER_LIB="lib" TOX_VENV=py37-sasl - python: pypy env: ZOOKEEPER_VERSION=3.4.14 TOX_VENV=pypy - python: 'pypy' - env: ZOOKEEPER_VERSION=3.5.5 ZOOKEEPER_PREFIX="apache-" ZOOKEEPER_SUFFIX="-bin" ZOOKEEPER_LIB="lib" TOX_VENV=pypy + env: ZOOKEEPER_VERSION=3.5.6 ZOOKEEPER_PREFIX="apache-" ZOOKEEPER_SUFFIX="-bin" ZOOKEEPER_LIB="lib" TOX_VENV=pypy notifications: email: false install: diff --git a/ensure-zookeeper-env.sh b/ensure-zookeeper-env.sh index 17cbc58..151b60a 100755 --- a/ensure-zookeeper-env.sh +++ b/ensure-zookeeper-env.sh @@ -4,7 +4,7 @@ set -e HERE=`pwd` ZOO_BASE_DIR="$HERE/zookeeper" -ZOOKEEPER_VERSION=${ZOOKEEPER_VERSION:-3.4.13} +ZOOKEEPER_VERSION=${ZOOKEEPER_VERSION:-3.4.14} ZOOKEEPER_PATH="$ZOO_BASE_DIR/$ZOOKEEPER_VERSION" ZOOKEEPER_PREFIX=${ZOOKEEPER_PREFIX} ZOOKEEPER_SUFFIX=${ZOOKEEPER_SUFFIX} diff --git a/kazoo/testing/common.py b/kazoo/testing/common.py index c8005df..9cf0ff0 100644 --- a/kazoo/testing/common.py +++ b/kazoo/testing/common.py @@ -75,7 +75,7 @@ class ManagedZooKeeper(object): Hudson/Buildbot context, to ensure more test robustness.""" def __init__(self, software_path, server_info, peers=(), classpath=None, - configuration_entries=[], java_system_properties=[], + configuration_entries=(), java_system_properties=(), jaas_config=None): """Define the ZooKeeper test instance. @@ -182,7 +182,7 @@ log4j.appender.ROLLINGFILE.File=""" + to_java_compatible_path( # NOQA # JAAS configuration for SASL authentication "-Djava.security.auth.login.config=%s" % jaas_config_path, - ] + self.java_system_properties + [ + ] + list(self.java_system_properties) + [ "org.apache.zookeeper.server.quorum.QuorumPeerMain", config_path, ] @@ -273,8 +273,8 @@ class ZookeeperCluster(object): def __init__(self, install_path=None, classpath=None, size=3, port_offset=20000, observer_start_id=-1, - configuration_entries=[], - java_system_properties=[], + configuration_entries=(), + java_system_properties=(), jaas_config=None): self._install_path = install_path self._classpath = classpath diff --git a/kazoo/testing/harness.py b/kazoo/testing/harness.py index 6cb5cb1..ce8748a 100644 --- a/kazoo/testing/harness.py +++ b/kazoo/testing/harness.py @@ -93,6 +93,7 @@ Server { Server { com.sun.security.auth.module.Krb5LoginModule required debug=true + isInitiator=false useKeyTab=true keyTab="%s" storeKey=true diff --git a/kazoo/tests/test_sasl.py b/kazoo/tests/test_sasl.py index 08839b6..635b7c4 100644 --- a/kazoo/tests/test_sasl.py +++ b/kazoo/tests/test_sasl.py @@ -13,14 +13,13 @@ from kazoo.tests.util import TRAVIS_ZK_VERSION class TestLegacySASLDigestAuthentication(KazooTestHarness): - def setUp(self): try: import puresasl # NOQA except ImportError: - raise SkipTest('PureSASL not available.') + raise SkipTest("PureSASL not available.") - os.environ['ZOOKEEPER_JAAS_AUTH'] = 'digest' + os.environ["ZOOKEEPER_JAAS_AUTH"] = "digest" self.setup_zookeeper() if TRAVIS_ZK_VERSION: @@ -39,36 +38,35 @@ class TestLegacySASLDigestAuthentication(KazooTestHarness): username = "jaasuser" password = "jaas_password" - acl = make_acl('sasl', credential=username, all=True) + acl = make_acl("sasl", credential=username, all=True) sasl_auth = "%s:%s" % (username, password) - client = self._get_client(auth_data=[('sasl', sasl_auth)]) + client = self._get_client(auth_data=[("sasl", sasl_auth)]) client.start() try: - client.create('/1', acl=(acl,)) + client.create("/1", acl=(acl,)) # give ZK a chance to copy data to other node time.sleep(0.1) self.assertRaises(NoAuthError, self.client.get, "/1") finally: - client.delete('/1') + client.delete("/1") client.stop() client.close() def test_invalid_sasl_auth(self): - client = self._get_client(auth_data=[('sasl', 'baduser:badpassword')]) + client = self._get_client(auth_data=[("sasl", "baduser:badpassword")]) self.assertRaises(AuthFailedError, client.start) class TestSASLDigestAuthentication(KazooTestHarness): - def setUp(self): try: import puresasl # NOQA except ImportError: - raise SkipTest('PureSASL not available.') + raise SkipTest("PureSASL not available.") - os.environ['ZOOKEEPER_JAAS_AUTH'] = 'digest' + os.environ["ZOOKEEPER_JAAS_AUTH"] = "digest" self.setup_zookeeper() if TRAVIS_ZK_VERSION: @@ -87,48 +85,51 @@ class TestSASLDigestAuthentication(KazooTestHarness): username = "jaasuser" password = "jaas_password" - acl = make_acl('sasl', credential=username, all=True) + acl = make_acl("sasl", credential=username, all=True) client = self._get_client( - sasl_options={'mechanism': 'DIGEST-MD5', - 'username': username, - 'password': password} + sasl_options={ + "mechanism": "DIGEST-MD5", + "username": username, + "password": password, + } ) client.start() try: - client.create('/1', acl=(acl,)) + client.create("/1", acl=(acl,)) # give ZK a chance to copy data to other node time.sleep(0.1) self.assertRaises(NoAuthError, self.client.get, "/1") finally: - client.delete('/1') + client.delete("/1") client.stop() client.close() def test_invalid_sasl_auth(self): client = self._get_client( - sasl_options={'mechanism': 'DIGEST-MD5', - 'username': 'baduser', - 'password': 'badpassword'} + sasl_options={ + "mechanism": "DIGEST-MD5", + "username": "baduser", + "password": "badpassword", + } ) self.assertRaises(AuthFailedError, client.start) class TestSASLGSSAPIAuthentication(KazooTestHarness): - def setUp(self): try: import puresasl # NOQA except ImportError: - raise SkipTest('PureSASL not available.') + raise SkipTest("PureSASL not available.") try: import kerberos # NOQA except ImportError: - raise SkipTest('Kerberos support not available.') - if not os.environ.get('KRB5_TEST_ENV'): - raise SkipTest('Test Kerberos environ not setup.') + raise SkipTest("Kerberos support not available.") + if not os.environ.get("KRB5_TEST_ENV"): + raise SkipTest("Test Kerberos environ not setup.") - os.environ['ZOOKEEPER_JAAS_AUTH'] = 'gssapi' + os.environ["ZOOKEEPER_JAAS_AUTH"] = "gssapi" self.setup_zookeeper() if TRAVIS_ZK_VERSION: @@ -147,25 +148,24 @@ class TestSASLGSSAPIAuthentication(KazooTestHarness): # Ensure we have a client ticket subprocess.check_call( [ - 'kinit', - '-kt', os.path.expandvars('${KRB5_TEST_ENV}/client.keytab'), - 'client' + "kinit", + "-kt", + os.path.expandvars("${KRB5_TEST_ENV}/client.keytab"), + "client", ] ) - acl = make_acl('sasl', credential='client@KAZOOTEST.ORG', all=True) + acl = make_acl("sasl", credential="client@KAZOOTEST.ORG", all=True) - client = self._get_client( - sasl_options={'mechanism': 'GSSAPI'} - ) + client = self._get_client(sasl_options={"mechanism": "GSSAPI"}) client.start() try: - client.create('/1', acl=(acl,)) + client.create("/1", acl=(acl,)) # give ZK a chance to copy data to other node time.sleep(0.1) self.assertRaises(NoAuthError, self.client.get, "/1") finally: - client.delete('/1') + client.delete("/1") client.stop() client.close() @@ -173,14 +173,14 @@ class TestSASLGSSAPIAuthentication(KazooTestHarness): # Request a post-datated ticket, so that it is currently invalid. subprocess.check_call( [ - 'kinit', - '-kt', os.path.expandvars('${KRB5_TEST_ENV}/client.keytab'), - '-s', '30min', - 'client' + "kinit", + "-kt", + os.path.expandvars("${KRB5_TEST_ENV}/client.keytab"), + "-s", + "30min", + "client", ] ) - client = self._get_client( - sasl_options={'mechanism': 'GSSAPI'} - ) + client = self._get_client(sasl_options={"mechanism": "GSSAPI"}) self.assertRaises(AuthFailedError, client.start) |