def test_empty_config(self): config = [{}] ret = log_beacon.validate(config) self.assertEqual(ret, (False, 'Configuration for log beacon ' 'must contain file option.'))
def test_non_list_config(self): config = {} ret = log_beacon.validate(config) self.assertEqual(ret, (False, 'Configuration for log beacon must' ' be a list.'))
def test_log_match(stub_log_entry): 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_beacon.validate(config) assert ret == (True, "Valid beacon configuration") _expected_return = [{ "error": "", "match": "yes", "raw": stub_log_entry.rstrip("\n"), "tag": "sshd", }] ret = log_beacon.beacon(config) assert ret == _expected_return
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_beacon.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.beacon(config) self.assertEqual(ret, _expected_return)
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_beacon.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.beacon(config) self.assertEqual(ret, _expected_return)
def test_empty_config(): config = [{}] ret = log_beacon.validate(config) assert ret == (False, "Configuration for log beacon must contain file option.")
def test_non_list_config(): config = {} ret = log_beacon.validate(config) assert ret == (False, "Configuration for log beacon must be a list.")