Skip to content

Commit

Permalink
WIP: Add testinfra test
Browse files Browse the repository at this point in the history
  • Loading branch information
legoktm committed Nov 4, 2024
1 parent c13410f commit 8e108a8
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions molecule/testinfra/common/test_system_hardening.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import re
import time

import pytest
import testutils
Expand Down Expand Up @@ -176,6 +177,23 @@ def test_iptables_packages(host):
assert not host.package("ufw").is_installed


def test_ufw_removal(host):
"""Test the securedrop-remove-ufw service"""
if host.system_info.codename != "focal":
pytest.skip("only applicable/testable on focal")

with host.sudo():
if not host.package("ufw").is_installed:
cmd = host.run("apt-get install ufw --yes")
assert cmd.rc == 0
cmd = host.run("systemctl start securedrop-remove-ufw")
assert cmd.rc == 0
# Wait for the unit to run
time.sleep(5)

assert not host.package("ufw").is_installed


def test_snapd_absent(host):
assert not host.file("/lib/systemd/system/snapd.service").exists
assert not host.file("/etc/apparmor.d/usr.lib.snapd.snap-confine.real").exists
Expand Down

0 comments on commit 8e108a8

Please sign in to comment.