Skip to content

Commit

Permalink
Refactor Snort test for macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
bengo237 committed Sep 12, 2024
1 parent 7285f02 commit 5582a5f
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions scripts/tests/test_macos.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,27 @@ def test_snort_is_installed_mac(host):
snort = host.package("snort")
assert snort.is_installed, "Snort should be installed"


def test_snort_conf_file_exists_mac(host):
"""Test if snort.lua file exists on macOS."""
snort_conf = host.file("/usr/local/etc/snort/snort.lua")
assert snort_conf.exists, "snort.lua file should exist"


def test_snort_interface_configuration_mac(host):
"""Test if the network interface is correctly configured in the Snort configuration file on macOS."""
interface = host.run("ip route | grep default | awk '{print $5}'").stdout.strip()

# Read the snort configuration file
snort_conf = host.file("/usr/local/etc/snort/snort.lua")
assert interface in snort_conf.content_string, "Interface should be present in snort.lua"


def test_update_ossec_conf_mac(host):
"""Test if ossec.conf is correctly updated on macOS."""
ossec_conf_path = "/usr/local/etc/ossec.conf"
ossec_conf_path = "/opt/homebrew/etc/ossec.conf"
expected_content = """
<!-- snort -->
<localfile>
<log_format>snort-full</log_format>
<location>/usr/local/var/log/snort/snort.alert.fast</location>
"""
<location>/var/log/snort/alert_fast.txt</location>
</localfile>
"""

ossec_conf = host.file(ossec_conf_path)
assert (
Expand Down

0 comments on commit 5582a5f

Please sign in to comment.