Added tests for ufw allow salt

This commit is contained in:
David Murphy 2023-08-04 17:29:30 -06:00 committed by Pedro Algarvio
parent bd17823792
commit f0743ec9a8
3 changed files with 23 additions and 0 deletions

1
changelog/64572.fixed.md Normal file
View file

@ -0,0 +1 @@
Added salt.ufw to salt-master install on Debian and Ubuntu

View file

@ -1,4 +1,5 @@
/etc/salt/master.d
/etc/ufw/applications.d/salt-master
/etc/salt/pki/master/minions
/etc/salt/pki/master/minions_autosign
/etc/salt/pki/master/minions_denied

View file

@ -5,6 +5,7 @@ Test autosigning minions based on grain values.
import os
import shutil
import stat
import subprocess
import pytest
@ -120,3 +121,23 @@ def test_autosign_grains_fail(
) # get minion to try to authenticate itself again
assert salt_minion.id not in salt_key_cli.run("-l", "acc")
assert salt_minion.id in salt_key_cli.run("-l", "un")
@pytest.mark.skip_unless_on_linux
@pytest.mark.slow_test
def test_ufw_allow(salt_master, grains):
if grains["os_family"] != "Debian":
pytest.skip("Only runs on Debian family.")
expected_output = """Skipping adding existing rule
Skipping adding existing rule (v6)
"""
proc = subprocess.Popen(
"ufw allow salt\n", shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE
)
out, err = proc.communicate()
out_strg = out.decode()
err_strg = err.decode()
assert out_strg == expected_output
assert err_strg != "ERROR: Could not find a profile matching 'salt'"