@mock.patch('st2common.logging.formatters.MASKED_ATTRIBUTES_BLACKLIST', MOCK_MASKED_ATTRIBUTES_BLACKLIST)
@mock.patch('st2common.models.db.rule.RuleDB._get_referenced_action_model')
def test_format_secret_rule_parameters_are_masked(self, mock__get_referenced_action_model):
    expected_result = {'description': 'Test description', 'tags': [], 'type': {'ref': 'standard', 'parameters': {}}, 'enabled': True, 'trigger': 'test tigger', 'metadata_file': None, 'context': {}, 'criteria': {}, 'action': {'ref': '1234', 'parameters': {'parameter1': 'value1', 'parameter2': '********'}}, 'uid': 'rule:testpack:test.action', 'pack': 'testpack', 'ref': 'testpack.test.action', 'id': None, 'name': 'test.action'}
    parameters = {'parameter1': {'type': 'string', 'required': False}, 'parameter2': {'type': 'string', 'required': False, 'secret': True}}
    mock_action_db = ActionDB(pack='testpack', name='test.action', parameters=parameters)
    mock__get_referenced_action_model.return_value = mock_action_db
    cfg.CONF.set_override(group='log', name='mask_secrets', override=True)
    mock_rule_db = RuleDB(pack='testpack', name='test.action', description='Test description', trigger='test tigger', action={'ref': '1234', 'parameters': {'parameter1': 'value1', 'parameter2': 'value2'}})
    result = mock_rule_db.to_serializable_dict(True)
    self.assertEqual(expected_result, result)
@mock.patch('st2common.logging.formatters.MASKED_ATTRIBUTES_BLACKLIST', MOCK_MASKED_ATTRIBUTES_BLACKLIST)
@mock.patch('st2common.models.db.rule.RuleDB._get_referenced_action_model')
def test_format_secret_rule_parameters_are_masked(self, mock__get_referenced_action_model):
    expected_result = {'description': 'Test description', 'tags': [], 'type': {'ref': 'standard', 'parameters': {}}, 'enabled': True, 'trigger': 'test tigger', 'metadata_file': None, 'context': {}, 'criteria': {}, 'action': {'ref': '1234', 'parameters': {'parameter1': 'value1', 'parameter2': '********'}}, 'uid': 'rule:testpack:test.action', 'pack': 'testpack', 'ref': 'testpack.test.action', 'id': None, 'name': 'test.action'}
    parameters = {'parameter1': {'type': 'string', 'required': False}, 'parameter2': {'type': 'string', 'required': False, 'secret': True}}
    mock_action_db = ActionDB(pack='testpack', name='test.action', parameters=parameters)
    mock__get_referenced_action_model.return_value = mock_action_db
    cfg.CONF.set_override(group='log', name='mask_secrets', override=True)
    mock_rule_db = RuleDB(pack='testpack', name='test.action', description='Test description', trigger='test tigger', action={'ref': '1234', 'parameters': {'parameter1': 'value1', 'parameter2': 'value2'}})
    result = mock_rule_db.to_serializable_dict(True)
    self.assertEqual(expected_result, result)