#!/usr/bin/env python3 """WOPI configuration verification test.""" import argparse import os import sys import urllib.request sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..', '..')) from utils.tests.helpers import resolve_domain def main(): parser = argparse.ArgumentParser() parser.add_argument('--domain', default=os.environ.get('TEST_DOMAIN')) args = parser.parse_args() domain = args.domain or resolve_domain('lasuite-drive') collabora_url = f"https://collabora.{domain}/hosting/discovery" onlyoffice_url = f"https://onlyoffice.{domain}/hosting/discovery" print("Testing WOPI configuration") print() # Step 1: Check Collabora discovery endpoint print("Step 1: Checking Collabora discovery endpoint ...") try: req = urllib.request.Request(collabora_url) with urllib.request.urlopen(req, timeout=15) as resp: body = resp.read().decode('utf-8', errors='replace') status = resp.getcode() except Exception as e: print(f" FAIL: Collabora discovery check failed: {e}") sys.exit(1) if status == 200 and 'wopi-discovery' in body: print(" PASS: Collabora discovery returns valid WOPI XML") else: print(f" FAIL: Collabora discovery check failed (HTTP {status})") sys.exit(1) # Step 2: Check OnlyOffice discovery endpoint print("Step 2: Checking OnlyOffice discovery endpoint ...") try: req = urllib.request.Request(onlyoffice_url) with urllib.request.urlopen(req, timeout=15) as resp: body = resp.read().decode('utf-8', errors='replace') status = resp.getcode() except Exception as e: print(f" FAIL: OnlyOffice discovery check failed: {e}") sys.exit(1) if status == 200 and 'wopi-discovery' in body: print(" PASS: OnlyOffice discovery returns valid WOPI XML") else: print(f" FAIL: OnlyOffice discovery check failed (HTTP {status})") sys.exit(1) print() print("PASS: WOPI discovery endpoints are reachable and returning valid XML") if __name__ == '__main__': main()