summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Carey <jecarey@us.ibm.com>2015-05-29 18:55:23 +0000
committerIhar Hrachyshka <ihrachys@redhat.com>2015-06-01 12:42:36 +0200
commit20bca5f1dc4de66fd3e4d4a7516cae68b6a8cea9 (patch)
tree1c10e7983baaaf49c563d3ee5ee9996149c858c1
parent1f909b0230690c6e12e1904bd171a29a21c40dd8 (diff)
downloadoslo-incubator-20bca5f1dc4de66fd3e4d4a7516cae68b6a8cea9.tar.gz
Enabled mask_password to handle byte code strings(2)
Second half of 232c42 Enabled mask_password to handle byte code strings which was a cherry pick of 1131b5. The code that needed to be fixed was in two places in icehouse but was only in one in juno, so the update to log.py was missed. Change-Id: I090c086e4774c8a6f09e090f25c409878ad20c0c
-rw-r--r--openstack/common/log.py7
-rw-r--r--tests/unit/test_log.py4
2 files changed, 10 insertions, 1 deletions
diff --git a/openstack/common/log.py b/openstack/common/log.py
index a0e17ff0..c2fc4ac7 100644
--- a/openstack/common/log.py
+++ b/openstack/common/log.py
@@ -264,7 +264,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_log.py b/tests/unit/test_log.py
index 57f9887b..846c6d57 100644
--- a/tests/unit/test_log.py
+++ b/tests/unit/test_log.py
@@ -864,3 +864,7 @@ class MaskPasswordTestCase(test.BaseTestCase):
payload = six.text_type(payload)
expected = """{'adminPass':'***'}"""
self.assertEqual(expected, log.mask_password(payload))
+
+ payload = 'test = "original_password" : "my\xe9\x80\x80pass"'
+ expected = 'test = "original_password" : "***"'
+ self.assertEqual(expected, log.mask_password(payload))