Update a test case to verify that custom attributes which are defined in
the config are also masked.
import mock
import unittest2
+from oslo_config import cfg
+
from st2common.middleware.logging import LoggingMiddleware
from st2common.constants.secrets import MASKED_ATTRIBUTE_VALUE
@@ -38,6 +40,9 @@ class LoggingMiddlewareTestCase(unittest2.TestCase):
router.match.return_value = (endpoint, None)
middleware = LoggingMiddleware(app=app, router=router)
+ cfg.CONF.set_override(group='log', name='mask_secrets_blacklist',
+ override=['blacklisted_4', 'blacklisted_5'])
+
environ = {}
mock_request.return_value.GET.dict_of_lists.return_value = {
'foo': 'bar',
@@ -46,7 +51,9 @@ class LoggingMiddlewareTestCase(unittest2.TestCase):
'st2-api-key': 'secret',
'password': 'secret',
'st2_auth_token': 'secret',
- 'token': 'secret'
+ 'token': 'secret',
+ 'blacklisted_4': 'super secret',
+ 'blacklisted_5': 'super secret',
}
middleware(environ=environ, start_response=mock.Mock())
@@ -57,7 +64,9 @@ class LoggingMiddlewareTestCase(unittest2.TestCase):
'st2-api-key': MASKED_ATTRIBUTE_VALUE,
'password': MASKED_ATTRIBUTE_VALUE,
'token': MASKED_ATTRIBUTE_VALUE,
- 'st2_auth_token': MASKED_ATTRIBUTE_VALUE
+ 'st2_auth_token': MASKED_ATTRIBUTE_VALUE,
+ 'blacklisted_4': MASKED_ATTRIBUTE_VALUE,
+ 'blacklisted_5': MASKED_ATTRIBUTE_VALUE,
}
call_kwargs = mock_log.info.call_args_list[0][1]
