def test_active_lines_unparsed(): context = context_wrap(AUDITD_CONF_1, AUDITD_CONF_PATH) result = AuditdConf(context) test_active_lines = [] for line in AUDITD_CONF_1.split("\n"): if not line.strip().startswith("#"): if line.strip(): test_active_lines.append(line) assert test_active_lines == result.active_lines_unparsed
def test_constructor(): context = context_wrap(AUDITD_CONF_1, AUDITD_CONF_PATH) result = AuditdConf(context) assert "tcp_listen_queue = 5" in result.active_lines_unparsed assert "SUSPEND" == result.active_settings["disk_error_action"] assert "krb5_key_file" not in result.active_settings assert "##krb5_key_file" not in result.active_settings assert "/var/log/audit/audit.log" == result.get_active_setting_value( "log_file") context = context_wrap(AUDITD_CONF_2, AUDITD_CONF_PATH) result = AuditdConf(context) assert "comment" not in result.active_settings assert "broken_option_g" not in result.active_settings assert "value_i" == result.get_active_setting_value("option_i")
def test_get_active_setting_value(): context = context_wrap(AUDITD_CONF_1, AUDITD_CONF_PATH) result = AuditdConf(context) active_settings = build_active_settings_expected() for key, value in active_settings.items(): assert result.get_active_setting_value(key) == value
def test_active_settings(): context = context_wrap(AUDITD_CONF_1, AUDITD_CONF_PATH) result = AuditdConf(context) active_settings = build_active_settings_expected() assert active_settings == result.active_settings