@@ -0,0 +1,2456 @@
+# Licensed to the StackStorm, Inc ('StackStorm') under one or more%0A# contributor license agreements.  See the NOTICE file distributed with%0A# this work for additional information regarding copyright ownership.%0A# The ASF licenses this file to You under the Apache License, Version 2.0%0A# (the %22License%22); you may not use this file except in compliance with%0A# the License.  You may obtain a copy of the License at%0A#%0A#     http://www.apache.org/licenses/LICENSE-2.0%0A#%0A# Unless required by applicable law or agreed to in writing, software%0A# distributed under the License is distributed on an %22AS IS%22 BASIS,%0A# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A# See the License for the specific language governing permissions and%0A# limitations under the License.%0A%0Aimport mock%0Aimport unittest2%0A%0Afrom st2common.middleware.logging import LoggingMiddleware%0Afrom st2common.constants.secrets import MASKED_ATTRIBUTE_VALUE%0A%0A__all__ = %5B%0A    'LoggingMiddlewareTestCase'%0A%5D%0A%0A%0Aclass LoggingMiddlewareTestCase(unittest2.TestCase):%0A    @mock.patch('st2common.middleware.logging.LOG')%0A    @mock.patch('st2common.middleware.logging.Request')%0A    def test_secret_parameters_are_masked_in_log_message(self, mock_request, mock_log):%0A%0A        def app(environ, custom_start_response):%0A            custom_start_response(status='200 OK', headers=%5B('Content-Length', 100)%5D)%0A            return %5BNone%5D%0A%0A        router = mock.Mock()%0A        endpoint = mock.Mock()%0A        router.match.return_value = (endpoint, None)%0A        middleware = LoggingMiddleware(app=app, router=router)%0A%0A        environ = %7B%7D%0A        mock_request.return_value.GET.dict_of_lists.return_value = %7B%0A            'foo': 'bar',%0A            'bar': 'baz',%0A            'x-auth-token': 'secret',%0A            'st2-api-key': 'secret',%0A            'password': 'secret',%0A            'st2_auth_token': 'secret',%0A            'token': 'secret'%0A        %7D%0A        middleware(environ=environ, start_response=mock.Mock())%0A%0A        expected_query = %7B%0A            'foo': 'bar',%0A            'bar': 'baz',%0A            'x-auth-token': MASKED_ATTRIBUTE_VALUE,%0A            'st2-api-key': MASKED_ATTRIBUTE_VALUE,%0A            'password': MASKED_ATTRIBUTE_VALUE,%0A            'token': MASKED_ATTRIBUTE_VALUE,%0A            'st2_auth_token': MASKED_ATTRIBUTE_VALUE%0A        %7D%0A%0A        call_kwargs = mock_log.info.call_args_list%5B0%5D%5B1%5D%0A        query = call_kwargs%5B'extra'%5D%5B'query'%5D%0A        self.assertEqual(query, expected_query)%0A

Add a test case for masking secret values in API log messages.