Пример #1
0
def test_omit_symbolic_name(InsightsCommand, InsightsFile, parse_file_spec):
    """
    Files/commands are omitted based on their symbolic name in uploader.json
    """
    c = InsightsConfig()
    data_collector = DataCollector(c)

    collection_rules = {
        'files': [{
            "file": "/etc/pam.d/vsftpd",
            "pattern": [],
            "symbolic_name": "vsftpd"
        }],
        'commands': [{
            "command": "/sbin/chkconfig --list",
            "pattern": [],
            "symbolic_name": "chkconfig"
        }],
        'pre_commands': []
    }
    rm_conf = {'files': ["vsftpd"], "commands": ["chkconfig"]}
    data_collector.run_collection(collection_rules, rm_conf, {}, '')
    parse_file_spec.assert_not_called()
    InsightsFile.assert_not_called()
    InsightsCommand.assert_not_called()
def test_omit_after_parse_command(InsightsCommand, run_pre_command):
    """
    Files are omitted based on the expanded paths of the uploader.json path
    """
    c = InsightsConfig()
    data_collector = DataCollector(c)

    collection_rules = {'commands': [{"command": "/sbin/ethtool -i", "pattern": [], "pre_command": "iface", "symbolic_name": "ethtool"}], 'files': [], "pre_commands": {"iface": "/sbin/ip -o link | awk -F ': ' '/.*link\\/ether/ {print $2}'"}}
    rm_conf = {'commands': ["/sbin/ethtool -i eth0"]}
    data_collector.run_collection(collection_rules, rm_conf, {})
    InsightsCommand.assert_not_called()