Files
computer-playbook/tests/unit/python/roles/test-e2e-playwright/test_readiness_until.py
T
kevinveenbirkenbachandClaude Opus 5.5 7fa3400cc6 Merge remote-tracking branch 'origin/main' into feature/network/multi-network-serving
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>
2026-10-13 00:14:42 +02:00

49 lines
1.4 KiB
Python

from __future__ import annotations
import unittest
from jinja2 import Environment, select_autoescape
from utils.cache.yaml import load_yaml_any
from . import PROJECT_ROOT
TASKS = PROJECT_ROOT / "roles/test-e2e-playwright/tasks/03_run_pass.yml"
TASK_NAME = "⏳ Wait until application is ready (any non-error response)"
def until_expression() -> str:
tasks = load_yaml_any(str(TASKS))
for task in tasks:
if task.get("name") == TASK_NAME:
return task["until"]
raise AssertionError(f"task {TASK_NAME!r} not found in {TASKS}")
def settles(result: dict) -> bool:
template = Environment(
autoescape=select_autoescape(default_for_string=False)
).from_string("{{ " + until_expression() + " }}")
return template.render(_wait_result=result) == "True"
class TestReadinessUntil(unittest.TestCase):
def test_a_connection_error_keeps_the_gate_waiting(self):
self.assertFalse(settles({"status": -1}))
def test_a_missing_status_keeps_the_gate_waiting(self):
self.assertFalse(settles({}))
def test_a_served_response_settles_the_gate(self):
self.assertTrue(settles({"status": 200}))
def test_a_redirect_settles_the_gate(self):
self.assertTrue(settles({"status": 302}))
def test_a_server_error_keeps_the_gate_waiting(self):
self.assertFalse(settles({"status": 502}))
if __name__ == "__main__":
unittest.main()