Skip to content

Commit 5764da0

Browse files
ztzgjeffwidman
authored andcommitted
fix(tests): specify -Dfile.encoding=UTF-8 when starting the ZK JVM
1 parent 0bb0659 commit 5764da0

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

kazoo/security.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,17 @@ class Permissions(object):
5959

6060

6161
def make_digest_acl_credential(username, password):
62-
"""Create a SHA1 digest credential"""
62+
"""Create a SHA1 digest credential.
63+
64+
.. note::
65+
66+
This function uses UTF-8 to encode non-ASCII codepoints,
67+
whereas ZooKeeper uses the "default locale" for decoding. It
68+
may be a good idea to start the JVM with `-Dfile.encoding=UTF-8`
69+
in non-UTF-8 locales.
70+
See: https://github.com/python-zk/kazoo/pull/584
71+
72+
"""
6373
credential = username.encode('utf-8') + b":" + password.encode('utf-8')
6474
cred_hash = b64encode(hashlib.sha1(credential).digest()).strip()
6575
return username + ":" + cred_hash.decode('utf-8')

kazoo/testing/common.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,12 @@ def run(self):
169169
"java",
170170
"-cp", self.classpath,
171171

172+
# make_digest_acl_credential assumes UTF-8, but ZK decodes
173+
# digest auth packets using the JVM's default "charset"--which
174+
# depends on the environment. Force it to use UTF-8 to avoid
175+
# test failures.
176+
"-Dfile.encoding=UTF-8",
177+
172178
# "-Dlog4j.debug",
173179
"-Dreadonlymode.enabled=true",
174180
"-Dzookeeper.log.dir=%s" % log_path,

0 commit comments

Comments
 (0)