コード例 #1
0
ファイル: test_log_beacon.py プロジェクト: crimv42/saltstack
    def test_empty_config(self):
        config = [{}]

        ret = log_beacon.validate(config)

        self.assertEqual(ret, (False, 'Configuration for log beacon '
                               'must contain file option.'))
コード例 #2
0
ファイル: test_log_beacon.py プロジェクト: crimv42/saltstack
    def test_non_list_config(self):
        config = {}

        ret = log_beacon.validate(config)

        self.assertEqual(ret, (False, 'Configuration for log beacon must'
                               ' be a list.'))
コード例 #3
0
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
コード例 #4
0
ファイル: test_log_beacon.py プロジェクト: crimv42/saltstack
    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)
コード例 #5
0
    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)
コード例 #6
0
def test_empty_config():
    config = [{}]

    ret = log_beacon.validate(config)
    assert ret == (False,
                   "Configuration for log beacon must contain file option.")
コード例 #7
0
def test_non_list_config():
    config = {}

    ret = log_beacon.validate(config)
    assert ret == (False, "Configuration for log beacon must be a list.")