Files
lg-smtv-mcp/tests
kiskaadee 52ec28f278
Core Architecture & Invariant CI / validate (pull_request) Successful in 16s
test(deploy): harden test seams with section-aware parsing and fault-safe fixtures
Addresses CR-01 to CR-05 from review 10 on PR #18.

- tests/test_deploy.py: resolve CR-01 — replace substring assertions with
  configparser section-aware exact key/value checks; CapabilityBoundingSet=
  now asserts empty string ''; commented-out directives are correctly
  rejected since configparser strips comment lines; assert 'Unknown key'/
  'Unknown lvalue' absent in systemd-analyze verify stderr so wrong-section
  misplacements are caught even at exit 0

- tests/test_deploy.py: resolve CR-02 — replace hardcoded personal
  identifiers ('kiskaadee', '/home/kiskaadee/...') with neutral 'testuser'
  and pytest tmp_path-derived paths in all substitution fixtures

- tests/test_deploy.py: resolve CR-03 — split the monolithic
  test_service_template_contains_placeholders_and_hardening_directives into
  three single-behavior tests: test_service_template_exists,
  test_service_template_declares_deployment_placeholders, and
  test_service_template_bounds_restart_limit_in_unit_section

- tests/test_deploy.py: resolve CR-04 — add timeout=30.0 to all
  subprocess.run calls to prevent silent CI hangs

- tests/test_deploy.py: resolve CR-05 — regex-parse numeric exposure score
  from systemd-analyze security output and assert score <= 5.0 in lieu of
  checking 'OK' label substring; test renamed to
  test_systemd_analyze_security_reports_ok_exposure_bracket

- tests/test_deploy.py: resolve CR-08 — extract shared systemd_analyze_bin
  and substituted_service_file pytest fixtures, eliminating duplicated
  shutil.which calls and substitution setup across subprocess tests

Fault injection confirmed red before green for all sensitive seams:
  Fault A: StartLimitIntervalSec/Burst in [Service] → section-mismatch fail
  Fault B: CapabilityBoundingSet=CAP_NET_RAW → non-empty string fail
  Fault C: # NoNewPrivileges=yes (commented) → None != 'yes' fail
  Fault D: sandboxing block removed → 9.0 UNSAFE score, regex no-match fail

Verification: 144 passed, ruff/pyright/pytest all green
2026-11-17 09:53:30 -05:00
..