def test_empty_config(self): config = [{}] ret = log.validate(config) self.assertEqual(ret, (False, 'Configuration for log beacon ' 'must contain file option.'))
def test_non_list_config(self): config = {} ret = log.validate(config) self.assertEqual(ret, (False, 'Configuration for log beacon must' ' be a list.'))
def test_log_match(self): with patch('salt.utils.files.fopen', mock_open(read_data=_STUB_LOG_ENTRY)): config = [{ 'file': '/var/log/auth.log', 'tags': { 'sshd': { 'regex': '.*sshd.*' } } }] ret = log.validate(config) self.assertEqual(ret, (True, 'Valid beacon configuration')) _expected_return = [{ 'error': '', 'match': 'yes', 'raw': _STUB_LOG_ENTRY.rstrip('\n'), 'tag': 'sshd' }] ret = log.beacon(config) self.assertEqual(ret, _expected_return)