deploy/tests: add visudo syntax test for the sudoers drop-in
Pre-deploy syntax guard; replaces ckn-bw's per-item test_with which won't apply to a symlink-delivered file (see deployment-responsibility migration step 3).
This commit is contained in:
parent
3703749252
commit
2c4bf1a27f
1 changed files with 17 additions and 0 deletions
17
deploy/tests/test_sudoers.py
Normal file
17
deploy/tests/test_sudoers.py
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
"""Syntax-check the sudoers drop-in via visudo before it leaves the repo."""
|
||||||
|
import shutil
|
||||||
|
import subprocess
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
SUDOERS = Path(__file__).resolve().parents[2] / "deploy/files/etc/sudoers.d/left4me"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.skipif(shutil.which("visudo") is None, reason="visudo not installed")
|
||||||
|
def test_sudoers_parses():
|
||||||
|
result = subprocess.run(
|
||||||
|
["visudo", "-cf", str(SUDOERS)],
|
||||||
|
capture_output=True, text=True,
|
||||||
|
)
|
||||||
|
assert result.returncode == 0, f"visudo -cf failed: {result.stdout}{result.stderr}"
|
||||||
Loading…
Reference in a new issue