Skip to content

Commit 933b38b

Browse files
ceacheStephenSorriaux
authored andcommitted
fix(tests): Disable JAAS isInitiator for Server
Satisfy new Hound style/lint checks Upgrade to latest 3.5.6/3.4.14 Zookeeper releases.
1 parent d7bed55 commit 933b38b

File tree

5 files changed

+56
-55
lines changed

5 files changed

+56
-55
lines changed

.travis.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,35 +20,35 @@ matrix:
2020
- python: '2.7'
2121
env: ZOOKEEPER_VERSION=3.4.14 TOX_VENV=py27
2222
- python: '2.7'
23-
env: ZOOKEEPER_VERSION=3.5.5 ZOOKEEPER_PREFIX="apache-" ZOOKEEPER_SUFFIX="-bin" ZOOKEEPER_LIB="lib" TOX_VENV=py27
23+
env: ZOOKEEPER_VERSION=3.5.6 ZOOKEEPER_PREFIX="apache-" ZOOKEEPER_SUFFIX="-bin" ZOOKEEPER_LIB="lib" TOX_VENV=py27
2424
- python: '2.7'
2525
env: ZOOKEEPER_VERSION=3.4.14 TOX_VENV=py27-gevent
2626
- python: '2.7'
27-
env: ZOOKEEPER_VERSION=3.5.5 ZOOKEEPER_PREFIX="apache-" ZOOKEEPER_SUFFIX="-bin" ZOOKEEPER_LIB="lib" TOX_VENV=py27-gevent
27+
env: ZOOKEEPER_VERSION=3.5.6 ZOOKEEPER_PREFIX="apache-" ZOOKEEPER_SUFFIX="-bin" ZOOKEEPER_LIB="lib" TOX_VENV=py27-gevent
2828
- python: '2.7'
2929
env: ZOOKEEPER_VERSION=3.4.14 TOX_VENV=py27-eventlet
3030
- python: '2.7'
31-
env: ZOOKEEPER_VERSION=3.5.5 ZOOKEEPER_PREFIX="apache-" ZOOKEEPER_SUFFIX="-bin" ZOOKEEPER_LIB="lib" TOX_VENV=py27-eventlet
31+
env: ZOOKEEPER_VERSION=3.5.6 ZOOKEEPER_PREFIX="apache-" ZOOKEEPER_SUFFIX="-bin" ZOOKEEPER_LIB="lib" TOX_VENV=py27-eventlet
3232
- python: '3.6'
3333
env: ZOOKEEPER_VERSION=3.4.14 TOX_VENV=py36
3434
- python: '3.6'
3535
env: ZOOKEEPER_VERSION=3.4.14 TOX_VENV=py36-sasl
3636
- python: '3.6'
37-
env: ZOOKEEPER_VERSION=3.5.5 ZOOKEEPER_PREFIX="apache-" ZOOKEEPER_SUFFIX="-bin" ZOOKEEPER_LIB="lib" TOX_VENV=py36
37+
env: ZOOKEEPER_VERSION=3.5.6 ZOOKEEPER_PREFIX="apache-" ZOOKEEPER_SUFFIX="-bin" ZOOKEEPER_LIB="lib" TOX_VENV=py36
3838
- python: '3.6'
39-
env: ZOOKEEPER_VERSION=3.5.5 ZOOKEEPER_PREFIX="apache-" ZOOKEEPER_SUFFIX="-bin" ZOOKEEPER_LIB="lib" TOX_VENV=py36-sasl
39+
env: ZOOKEEPER_VERSION=3.5.6 ZOOKEEPER_PREFIX="apache-" ZOOKEEPER_SUFFIX="-bin" ZOOKEEPER_LIB="lib" TOX_VENV=py36-sasl
4040
- python: '3.7'
4141
env: ZOOKEEPER_VERSION=3.4.14 TOX_VENV=py37
4242
- python: '3.7'
4343
env: ZOOKEEPER_VERSION=3.4.14 TOX_VENV=py37-sasl
4444
- python: '3.7'
45-
env: ZOOKEEPER_VERSION=3.5.5 ZOOKEEPER_PREFIX="apache-" ZOOKEEPER_SUFFIX="-bin" ZOOKEEPER_LIB="lib" TOX_VENV=py37 DEPLOY=true
45+
env: ZOOKEEPER_VERSION=3.5.6 ZOOKEEPER_PREFIX="apache-" ZOOKEEPER_SUFFIX="-bin" ZOOKEEPER_LIB="lib" TOX_VENV=py37 DEPLOY=true
4646
- python: '3.7'
47-
env: ZOOKEEPER_VERSION=3.5.5 ZOOKEEPER_PREFIX="apache-" ZOOKEEPER_SUFFIX="-bin" ZOOKEEPER_LIB="lib" TOX_VENV=py37-sasl
47+
env: ZOOKEEPER_VERSION=3.5.6 ZOOKEEPER_PREFIX="apache-" ZOOKEEPER_SUFFIX="-bin" ZOOKEEPER_LIB="lib" TOX_VENV=py37-sasl
4848
- python: pypy
4949
env: ZOOKEEPER_VERSION=3.4.14 TOX_VENV=pypy
5050
- python: 'pypy'
51-
env: ZOOKEEPER_VERSION=3.5.5 ZOOKEEPER_PREFIX="apache-" ZOOKEEPER_SUFFIX="-bin" ZOOKEEPER_LIB="lib" TOX_VENV=pypy
51+
env: ZOOKEEPER_VERSION=3.5.6 ZOOKEEPER_PREFIX="apache-" ZOOKEEPER_SUFFIX="-bin" ZOOKEEPER_LIB="lib" TOX_VENV=pypy
5252
notifications:
5353
email: false
5454
install:

ensure-zookeeper-env.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -e
44

55
HERE=`pwd`
66
ZOO_BASE_DIR="$HERE/zookeeper"
7-
ZOOKEEPER_VERSION=${ZOOKEEPER_VERSION:-3.4.13}
7+
ZOOKEEPER_VERSION=${ZOOKEEPER_VERSION:-3.4.14}
88
ZOOKEEPER_PATH="$ZOO_BASE_DIR/$ZOOKEEPER_VERSION"
99
ZOOKEEPER_PREFIX=${ZOOKEEPER_PREFIX}
1010
ZOOKEEPER_SUFFIX=${ZOOKEEPER_SUFFIX}

kazoo/testing/common.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class ManagedZooKeeper(object):
7575
Hudson/Buildbot context, to ensure more test robustness."""
7676

7777
def __init__(self, software_path, server_info, peers=(), classpath=None,
78-
configuration_entries=[], java_system_properties=[],
78+
configuration_entries=(), java_system_properties=(),
7979
jaas_config=None):
8080
"""Define the ZooKeeper test instance.
8181
@@ -182,7 +182,7 @@ def run(self):
182182

183183
# JAAS configuration for SASL authentication
184184
"-Djava.security.auth.login.config=%s" % jaas_config_path,
185-
] + self.java_system_properties + [
185+
] + list(self.java_system_properties) + [
186186
"org.apache.zookeeper.server.quorum.QuorumPeerMain",
187187
config_path,
188188
]
@@ -273,8 +273,8 @@ class ZookeeperCluster(object):
273273

274274
def __init__(self, install_path=None, classpath=None,
275275
size=3, port_offset=20000, observer_start_id=-1,
276-
configuration_entries=[],
277-
java_system_properties=[],
276+
configuration_entries=(),
277+
java_system_properties=(),
278278
jaas_config=None):
279279
self._install_path = install_path
280280
self._classpath = classpath

kazoo/testing/harness.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ def get_global_cluster():
9393
Server {
9494
com.sun.security.auth.module.Krb5LoginModule required
9595
debug=true
96+
isInitiator=false
9697
useKeyTab=true
9798
keyTab="%s"
9899
storeKey=true

kazoo/tests/test_sasl.py

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,13 @@
1313

1414

1515
class TestLegacySASLDigestAuthentication(KazooTestHarness):
16-
1716
def setUp(self):
1817
try:
1918
import puresasl # NOQA
2019
except ImportError:
21-
raise SkipTest('PureSASL not available.')
20+
raise SkipTest("PureSASL not available.")
2221

23-
os.environ['ZOOKEEPER_JAAS_AUTH'] = 'digest'
22+
os.environ["ZOOKEEPER_JAAS_AUTH"] = "digest"
2423
self.setup_zookeeper()
2524

2625
if TRAVIS_ZK_VERSION:
@@ -39,36 +38,35 @@ def test_connect_sasl_auth(self):
3938
username = "jaasuser"
4039
password = "jaas_password"
4140

42-
acl = make_acl('sasl', credential=username, all=True)
41+
acl = make_acl("sasl", credential=username, all=True)
4342

4443
sasl_auth = "%s:%s" % (username, password)
45-
client = self._get_client(auth_data=[('sasl', sasl_auth)])
44+
client = self._get_client(auth_data=[("sasl", sasl_auth)])
4645

4746
client.start()
4847
try:
49-
client.create('/1', acl=(acl,))
48+
client.create("/1", acl=(acl,))
5049
# give ZK a chance to copy data to other node
5150
time.sleep(0.1)
5251
self.assertRaises(NoAuthError, self.client.get, "/1")
5352
finally:
54-
client.delete('/1')
53+
client.delete("/1")
5554
client.stop()
5655
client.close()
5756

5857
def test_invalid_sasl_auth(self):
59-
client = self._get_client(auth_data=[('sasl', 'baduser:badpassword')])
58+
client = self._get_client(auth_data=[("sasl", "baduser:badpassword")])
6059
self.assertRaises(AuthFailedError, client.start)
6160

6261

6362
class TestSASLDigestAuthentication(KazooTestHarness):
64-
6563
def setUp(self):
6664
try:
6765
import puresasl # NOQA
6866
except ImportError:
69-
raise SkipTest('PureSASL not available.')
67+
raise SkipTest("PureSASL not available.")
7068

71-
os.environ['ZOOKEEPER_JAAS_AUTH'] = 'digest'
69+
os.environ["ZOOKEEPER_JAAS_AUTH"] = "digest"
7270
self.setup_zookeeper()
7371

7472
if TRAVIS_ZK_VERSION:
@@ -87,48 +85,51 @@ def test_connect_sasl_auth(self):
8785
username = "jaasuser"
8886
password = "jaas_password"
8987

90-
acl = make_acl('sasl', credential=username, all=True)
88+
acl = make_acl("sasl", credential=username, all=True)
9189

9290
client = self._get_client(
93-
sasl_options={'mechanism': 'DIGEST-MD5',
94-
'username': username,
95-
'password': password}
91+
sasl_options={
92+
"mechanism": "DIGEST-MD5",
93+
"username": username,
94+
"password": password,
95+
}
9696
)
9797
client.start()
9898
try:
99-
client.create('/1', acl=(acl,))
99+
client.create("/1", acl=(acl,))
100100
# give ZK a chance to copy data to other node
101101
time.sleep(0.1)
102102
self.assertRaises(NoAuthError, self.client.get, "/1")
103103
finally:
104-
client.delete('/1')
104+
client.delete("/1")
105105
client.stop()
106106
client.close()
107107

108108
def test_invalid_sasl_auth(self):
109109
client = self._get_client(
110-
sasl_options={'mechanism': 'DIGEST-MD5',
111-
'username': 'baduser',
112-
'password': 'badpassword'}
110+
sasl_options={
111+
"mechanism": "DIGEST-MD5",
112+
"username": "baduser",
113+
"password": "badpassword",
114+
}
113115
)
114116
self.assertRaises(AuthFailedError, client.start)
115117

116118

117119
class TestSASLGSSAPIAuthentication(KazooTestHarness):
118-
119120
def setUp(self):
120121
try:
121122
import puresasl # NOQA
122123
except ImportError:
123-
raise SkipTest('PureSASL not available.')
124+
raise SkipTest("PureSASL not available.")
124125
try:
125126
import kerberos # NOQA
126127
except ImportError:
127-
raise SkipTest('Kerberos support not available.')
128-
if not os.environ.get('KRB5_TEST_ENV'):
129-
raise SkipTest('Test Kerberos environ not setup.')
128+
raise SkipTest("Kerberos support not available.")
129+
if not os.environ.get("KRB5_TEST_ENV"):
130+
raise SkipTest("Test Kerberos environ not setup.")
130131

131-
os.environ['ZOOKEEPER_JAAS_AUTH'] = 'gssapi'
132+
os.environ["ZOOKEEPER_JAAS_AUTH"] = "gssapi"
132133
self.setup_zookeeper()
133134

134135
if TRAVIS_ZK_VERSION:
@@ -147,40 +148,39 @@ def test_connect_gssapi_auth(self):
147148
# Ensure we have a client ticket
148149
subprocess.check_call(
149150
[
150-
'kinit',
151-
'-kt', os.path.expandvars('${KRB5_TEST_ENV}/client.keytab'),
152-
'client'
151+
"kinit",
152+
"-kt",
153+
os.path.expandvars("${KRB5_TEST_ENV}/client.keytab"),
154+
"client",
153155
]
154156
)
155157

156-
acl = make_acl('sasl', credential='[email protected]', all=True)
158+
acl = make_acl("sasl", credential="[email protected]", all=True)
157159

158-
client = self._get_client(
159-
sasl_options={'mechanism': 'GSSAPI'}
160-
)
160+
client = self._get_client(sasl_options={"mechanism": "GSSAPI"})
161161
client.start()
162162
try:
163-
client.create('/1', acl=(acl,))
163+
client.create("/1", acl=(acl,))
164164
# give ZK a chance to copy data to other node
165165
time.sleep(0.1)
166166
self.assertRaises(NoAuthError, self.client.get, "/1")
167167
finally:
168-
client.delete('/1')
168+
client.delete("/1")
169169
client.stop()
170170
client.close()
171171

172172
def test_invalid_gssapi_auth(self):
173173
# Request a post-datated ticket, so that it is currently invalid.
174174
subprocess.check_call(
175175
[
176-
'kinit',
177-
'-kt', os.path.expandvars('${KRB5_TEST_ENV}/client.keytab'),
178-
'-s', '30min',
179-
'client'
176+
"kinit",
177+
"-kt",
178+
os.path.expandvars("${KRB5_TEST_ENV}/client.keytab"),
179+
"-s",
180+
"30min",
181+
"client",
180182
]
181183
)
182184

183-
client = self._get_client(
184-
sasl_options={'mechanism': 'GSSAPI'}
185-
)
185+
client = self._get_client(sasl_options={"mechanism": "GSSAPI"})
186186
self.assertRaises(AuthFailedError, client.start)

0 commit comments

Comments
 (0)