mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-10 04:36:40 +00:00
Conflicts resolved by keeping both sides' intent: - call-test-deploy.yml: main's re-enabled deploy concurrency group, keyed on the network axis instead of the removed tor axis. - sys-svc-proxy: main's shared headers/forwarded.conf.j2 now carries the branch's per-vhost semantics (X-Forwarded-Host, TLS port and state read from the vhost domain), so html, ws, upload and the Prometheus probes all answer per network sibling. - plugins/lookup/email.py: main's provider-agnostic mail lookup asks the network registry instead of testing the .onion suffix, as the branch does everywhere; container_extra_hosts.py likewise. The provider host's NETWORK_MODE now decides whether it is served onion-first, since a Tor node defaults to multi and keeps clearnet canonical. - workspace common.sh: main's INFINITO_DOMAIN fallback without the duplicated no-op line. - README.md and requirement 035: both sides' rows (Wazuh plus main's Pi-hole and Stalwart entries); adapter_candidate count 39. Adapted to main where the branch's rules now reach main's code: - six tests from main read the primary domain from default.env instead of writing it out, as the hardcoded-domain lint requires; - the chutney worker-check test passes ONION_SUFFIX from the network registry, which the branch's svc-net-tor test script requires; - web-app-wazuh moves its local http ports to 8096/8097 (8094/8095 now belong to web-app-stalwart) and sizes the indexer heap through service_memory_mb, the same fixes #414 carries; - web-app-wazuh's README cosmos follows Stalwart as the mail provider. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
99 lines
3.4 KiB
Python
99 lines
3.4 KiB
Python
from __future__ import annotations
|
|
|
|
import io
|
|
import tempfile
|
|
from pathlib import Path
|
|
from unittest import TestCase, main
|
|
from unittest.mock import patch
|
|
|
|
import cli.meta.domains.__main__ as mod
|
|
from utils.cache.yaml import dump_yaml_str
|
|
from utils.domains.default_primary import default_domain_primary
|
|
from utils.roles.mapping import ROLE_FILE_META_DOMAINS, ROLE_FILE_VARS_MAIN
|
|
|
|
DOMAIN = default_domain_primary()
|
|
|
|
|
|
class TestCliMetaApplicationsDomains(TestCase):
|
|
def write_role(
|
|
self, roles_dir: Path, role_name: str, app_id: str, config: dict
|
|
) -> None:
|
|
role_dir = roles_dir / role_name
|
|
(role_dir / "vars").mkdir(parents=True, exist_ok=True)
|
|
(role_dir / "meta").mkdir(parents=True, exist_ok=True)
|
|
(role_dir / ROLE_FILE_VARS_MAIN).write_text(
|
|
dump_yaml_str({"application_id": app_id}),
|
|
encoding="utf-8",
|
|
)
|
|
domains_payload = config.get("domains", {}) if isinstance(config, dict) else {}
|
|
(role_dir / ROLE_FILE_META_DOMAINS).write_text(
|
|
dump_yaml_str(domains_payload),
|
|
encoding="utf-8",
|
|
)
|
|
|
|
def _run(self, argv: list[str]) -> tuple[int, str, str]:
|
|
out = io.StringIO()
|
|
err = io.StringIO()
|
|
with patch("sys.stdout", out), patch("sys.stderr", err):
|
|
try:
|
|
with patch("sys.argv", ["prog", *argv]):
|
|
mod.main()
|
|
return 0, out.getvalue(), err.getvalue()
|
|
except SystemExit as e:
|
|
code = int(e.code) if e.code is not None else 0
|
|
return code, out.getvalue(), err.getvalue()
|
|
|
|
def test_domain_primary_default_resolution(self) -> None:
|
|
with patch.dict(mod.os.environ, {"DOMAIN": "explicit.env"}, clear=False):
|
|
self.assertEqual(
|
|
mod.parse_args(["--domain-primary", "flag.wins"]).domain_primary,
|
|
"flag.wins",
|
|
)
|
|
self.assertEqual(mod.parse_args([]).domain_primary, "explicit.env")
|
|
with patch.dict(mod.os.environ, {}, clear=True):
|
|
self.assertEqual(mod.parse_args([]).domain_primary, DOMAIN)
|
|
|
|
def test_cli_supports_alias_and_www_flags(self) -> None:
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
roles_dir = Path(tmp) / "roles"
|
|
roles_dir.mkdir()
|
|
self.write_role(
|
|
roles_dir,
|
|
"web-app-dashboard",
|
|
"web-app-dashboard",
|
|
{
|
|
"domains": {
|
|
"canonical": ["dashboard.{{ DOMAIN_PRIMARY }}"],
|
|
"aliases": ["alias.{{ DOMAIN_PRIMARY }}"],
|
|
}
|
|
},
|
|
)
|
|
|
|
with patch.object(mod.domain_list, "ROLES_DIR", roles_dir):
|
|
code, out, err = self._run(
|
|
[
|
|
"--domain-primary",
|
|
DOMAIN,
|
|
"--alias",
|
|
"--www",
|
|
]
|
|
)
|
|
|
|
self.assertEqual(code, 0)
|
|
self.assertEqual(err, "")
|
|
self.assertEqual(
|
|
out.strip().splitlines(),
|
|
[
|
|
f"alias.{DOMAIN}",
|
|
f"dashboard.{DOMAIN}",
|
|
f"test.{DOMAIN}",
|
|
f"www.alias.{DOMAIN}",
|
|
f"www.dashboard.{DOMAIN}",
|
|
f"www.test.{DOMAIN}",
|
|
],
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|