#!/usr/bin/env python3 """Test for mumble-web client overlay. Verifies the web client is reachable via HTTPS and serves the expected Mumble Web UI. Requires the compose.mumbleweb.yml overlay to be enabled. """ import argparse import os import sys sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..', '..')) from utils.tests.helpers import http_get, resolve_domain, wait_for_http def main(): parser = argparse.ArgumentParser( description="Mumble web client test") parser.add_argument('--domain', default=os.environ.get('TEST_DOMAIN')) args = parser.parse_args() domain = args.domain or resolve_domain('mumble') url = f"https://{domain}" print(f"Mumble web client test: {url}") print() passed = 0 failed = 0 def check(name, ok, detail=""): nonlocal passed, failed if ok: passed += 1 print(f" PASS: {name}{f' — {detail}' if detail else ''}") else: failed += 1 print(f" FAIL: {name}{f' — {detail}' if detail else ''}") # Check 1: HTTP 200 status, _ = http_get(url) check("Web client returns HTTP 200", status == 200, f"got {status}") # Check 2: Page contains Mumble Web UI markers if status == 200: import urllib.request import ssl ctx = ssl.create_default_context() ctx.check_hostname = False ctx.verify_mode = ssl.CERT_NONE req = urllib.request.Request(url) with urllib.request.urlopen(req, timeout=10, context=ctx) as resp: body = resp.read().decode("utf-8", errors="replace") has_mumble_meta = "Mumble" in body check("Page contains 'Mumble' content", has_mumble_meta) has_config_js = "config.js" in body check("Page loads config.js", has_config_js) is_html = body.strip().startswith("") check("Response is valid HTML", is_html) else: check("Page contains 'Mumble' content", False, "skipped — no 200") check("Page loads config.js", False, "skipped — no 200") check("Response is valid HTML", False, "skipped — no 200") print() print(f"Results: {passed} passed, {failed} failed") if failed > 0: sys.exit(1) if __name__ == '__main__': main()