@mock.patch('st2common.logging.formatters.MASKED_ATTRIBUTES_BLACKLIST', MOCK_MASKED_ATTRIBUTES_BLACKLIST)
def test_format_secret_action_parameters_are_masked(self):
    formatter = ConsoleLogFormatter()
    mock_message = 'test message 1'
    parameters = {'parameter1': {'type': 'string', 'required': False}, 'parameter2': {'type': 'string', 'required': False, 'secret': True}}
    mock_action_db = ActionDB(pack='testpack', name='test.action', parameters=parameters)
    action = mock_action_db.to_serializable_dict()
    parameters = {'parameter1': 'value1', 'parameter2': 'value2'}
    mock_action_execution_db = ActionExecutionDB(action=action, parameters=parameters)
    record = MockRecord()
    record.msg = mock_message
    record._action_execution_db = mock_action_execution_db
    expected_msg_part = "'parameters': {u?'parameter1': u?'value1', u?'parameter2': u?'\\*\\*\\*\\*\\*\\*\\*\\*'}"
    message = formatter.format(record=record)
    self.assertIn('test message 1', message)
    self.assertRegexpMatches(message, expected_msg_part)
@mock.patch('st2common.logging.formatters.MASKED_ATTRIBUTES_BLACKLIST', MOCK_MASKED_ATTRIBUTES_BLACKLIST)
def test_format_secret_action_parameters_are_masked(self):
    formatter = ConsoleLogFormatter()
    mock_message = 'test message 1'
    parameters = {'parameter1': {'type': 'string', 'required': False}, 'parameter2': {'type': 'string', 'required': False, 'secret': True}}
    mock_action_db = ActionDB(pack='testpack', name='test.action', parameters=parameters)
    action = mock_action_db.to_serializable_dict()
    parameters = {'parameter1': 'value1', 'parameter2': 'value2'}
    mock_action_execution_db = ActionExecutionDB(action=action, parameters=parameters)
    record = MockRecord()
    record.msg = mock_message
    record._action_execution_db = mock_action_execution_db
    expected_msg_part = "'parameters': {u?'parameter1': u?'value1', u?'parameter2': u?'\\*\\*\\*\\*\\*\\*\\*\\*'}"
    message = formatter.format(record=record)
    self.assertIn('test message 1', message)
    self.assertRegexpMatches(message, expected_msg_part)