summaryrefslogtreecommitdiff
path: root/openstackclient/tests
diff options
context:
space:
mode:
authorAlvaro Lopez Garcia <aloga@ifca.unican.es>2016-06-20 12:37:22 +0200
committerAlvaro Lopez Garcia <aloga@ifca.unican.es>2016-06-21 06:56:23 +0000
commit1de4c66009485b6e42791ac84684da7b5a1f0736 (patch)
tree24a7baaa14e5c9399bbf16ff5ed09ab5a0dc6b43 /openstackclient/tests
parent7cda2b2a066cd45c7aeb9a6d92c1a83e49d48128 (diff)
downloadpython-openstackclient-1de4c66009485b6e42791ac84684da7b5a1f0736.tar.gz
Improve masking of secrets in configuration show
The command "configuration show" tries to redact some of the secrets that are shown on the screen. However, this failed redacting options that were marked as secrete by the auth plugins (if any) and it redacted other options that were not redacted at all. For example, when using the OpenID Connect plugins, it redacted the "access_token_endpoint" as the word "token" appears there, but it failed to redact "client_secret" even when this option is marked as secret in the corresponding plugin. Change-Id: Idfad4fbbe5ddcff5e729e1dcd756d0379ad31dee
Diffstat (limited to 'openstackclient/tests')
-rw-r--r--openstackclient/tests/common/test_configuration.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/openstackclient/tests/common/test_configuration.py b/openstackclient/tests/common/test_configuration.py
index e81550ed..915e5bd3 100644
--- a/openstackclient/tests/common/test_configuration.py
+++ b/openstackclient/tests/common/test_configuration.py
@@ -11,6 +11,8 @@
# under the License.
#
+import mock
+
from openstackclient.common import configuration
from openstackclient.tests import fakes
from openstackclient.tests import utils
@@ -33,7 +35,12 @@ class TestConfiguration(utils.TestCommand):
fakes.REGION_NAME,
)
- def test_show(self):
+ opts = [mock.Mock(secret=True, dest="password"),
+ mock.Mock(secret=True, dest="token")]
+
+ @mock.patch("keystoneauth1.loading.base.get_plugin_options",
+ return_value=opts)
+ def test_show(self, m_get_plugin_opts):
arglist = []
verifylist = [('mask', True)]
cmd = configuration.ShowConfiguration(self.app, None)
@@ -44,7 +51,9 @@ class TestConfiguration(utils.TestCommand):
self.assertEqual(self.columns, columns)
self.assertEqual(self.datalist, data)
- def test_show_unmask(self):
+ @mock.patch("keystoneauth1.loading.base.get_plugin_options",
+ return_value=opts)
+ def test_show_unmask(self, m_get_plugin_opts):
arglist = ['--unmask']
verifylist = [('mask', False)]
cmd = configuration.ShowConfiguration(self.app, None)
@@ -62,7 +71,9 @@ class TestConfiguration(utils.TestCommand):
)
self.assertEqual(datalist, data)
- def test_show_mask(self):
+ @mock.patch("keystoneauth1.loading.base.get_plugin_options",
+ return_value=opts)
+ def test_show_mask(self, m_get_plugin_opts):
arglist = ['--mask']
verifylist = [('mask', True)]
cmd = configuration.ShowConfiguration(self.app, None)