summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-01-10 00:33:45 +0000
committerGerrit Code Review <review@openstack.org>2017-01-10 00:33:45 +0000
commita71593b19e52bb4469432d682bacecfb80843d73 (patch)
treea513a1f012132ae3a5ed45f14aebe87d1b9d4c3e
parent398c8fb5160a05d4b28fb11147a9a295e11bcf31 (diff)
parente5bc019840c2dd08a4e48fd26a23bff8d1ab644c (diff)
downloadpython-keystoneclient-a71593b19e52bb4469432d682bacecfb80843d73.tar.gz
Merge "Do not log binary data during request" into stable/mitaka
-rw-r--r--keystoneclient/session.py5
-rw-r--r--keystoneclient/tests/unit/test_session.py11
2 files changed, 9 insertions, 7 deletions
diff --git a/keystoneclient/session.py b/keystoneclient/session.py
index 9e26b76..43d04bd 100644
--- a/keystoneclient/session.py
+++ b/keystoneclient/session.py
@@ -201,6 +201,11 @@ class Session(object):
% self._process_header(header))
if data:
+ if isinstance(data, six.binary_type):
+ try:
+ data = data.decode("ascii")
+ except UnicodeDecodeError:
+ data = "<binary_data>"
string_parts.append("-d '%s'" % data)
try:
logger.debug(' '.join(string_parts))
diff --git a/keystoneclient/tests/unit/test_session.py b/keystoneclient/tests/unit/test_session.py
index 2f0d266..40e1827 100644
--- a/keystoneclient/tests/unit/test_session.py
+++ b/keystoneclient/tests/unit/test_session.py
@@ -1,3 +1,5 @@
+# -*- coding: utf-8 -*-
+#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
@@ -197,7 +199,7 @@ class SessionTests(utils.TestCase):
session = client_session.Session(verify=False)
body = 'RESP'
- data = u'unicode_data'
+ data = u'αβγδ'
self.stub_url('POST', text=body)
session.post(self.TEST_URL, data=data)
@@ -223,12 +225,7 @@ class SessionTests(utils.TestCase):
# raise a UnicodeDecodeError)
session.post(unicode(self.TEST_URL), data=data)
- self.assertIn("Replaced characters that could not be decoded"
- " in log output", self.logger.output)
-
- # Our data payload should have changed to
- # include the replacement char
- self.assertIn(u"-d 'my data\ufffd'", self.logger.output)
+ self.assertNotIn('my data', self.logger.output)
def test_logging_cacerts(self):
path_to_certs = '/path/to/certs'