diff options
author | Jenkins <jenkins@review.openstack.org> | 2014-09-15 22:24:58 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2014-09-15 22:24:58 +0000 |
commit | eabe46630d53bd430361c9d9253864e473c567e1 (patch) | |
tree | 5518c62914317dcbb623d544c493ea7ce9e878b6 | |
parent | 74ea4d994f08fd927dbcedb21c1447803041b928 (diff) | |
parent | 1131b5679fcf1492e5191defd9343b75b7091634 (diff) | |
download | oslo-incubator-eabe46630d53bd430361c9d9253864e473c567e1.tar.gz |
Merge "Enabled mask_password to handle byte code strings"2014.2
-rw-r--r-- | openstack/common/strutils.py | 7 | ||||
-rw-r--r-- | tests/unit/test_strutils.py | 4 |
2 files changed, 10 insertions, 1 deletions
diff --git a/openstack/common/strutils.py b/openstack/common/strutils.py index 12caaf4c..e1ff56f8 100644 --- a/openstack/common/strutils.py +++ b/openstack/common/strutils.py @@ -292,7 +292,12 @@ def mask_password(message, secret="***"): >>> mask_password("u'original_password' : u'aaaaa'") "u'original_password' : u'***'" """ - message = six.text_type(message) + try: + message = six.text_type(message) + except UnicodeDecodeError: + # NOTE(jecarey): Temporary fix to handle cases where message is a + # byte string. A better solution will be provided in Kilo. + pass # NOTE(ldbragst): Check to see if anything in message contains any key # specified in _SANITIZE_KEYS, if not then just return the message since diff --git a/tests/unit/test_strutils.py b/tests/unit/test_strutils.py index 71b28ee6..6c117ffd 100644 --- a/tests/unit/test_strutils.py +++ b/tests/unit/test_strutils.py @@ -590,3 +590,7 @@ class MaskPasswordTestCase(test_base.BaseTestCase): payload = ("test = node.session.auth.password --password mypassword") expected = ("test = node.session.auth.password --password ***") self.assertEqual(expected, strutils.mask_password(payload)) + + payload = "test = cmd --password my\xe9\x80\x80pass" + expected = ("test = cmd --password ***") + self.assertEqual(expected, strutils.mask_password(payload)) |