From 39f2bfb87c48bdeadc6669798b6b46350e509e24 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 6 Oct 2026 00:38:12 +0000 Subject: [PATCH 1/8] chore(deps-dev): bump eslint from 10.10.0 to 10.12.0 Bumps [eslint](https://github.com/eslint/eslint) from 10.10.0 to 10.12.0. - [Release notes](https://github.com/eslint/eslint/releases) - [Commits](https://github.com/eslint/eslint/compare/v10.10.0...v10.12.0) --- updated-dependencies: - dependency-name: eslint dependency-version: 10.12.0 dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 219614de7d..dec3a469ef 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "devDependencies": { "@eslint/js": "^10.0.1", "@playwright/test": "^1.63.0", - "eslint": "^10.9.1", + "eslint": "^10.12.0", "eslint-plugin-playwright": "^2.10.5", "globals": "^17.13.0", "stylelint": "^17.16.0" @@ -848,9 +848,9 @@ } }, "node_modules/eslint": { - "version": "10.10.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-10.10.0.tgz", - "integrity": "sha512-NPXn6r5zl4uET1DAVPaOwzX3rut4c0wcmw3dWJAfOsTM5+TogXo0DDjz8pwm/hL8cyVNpHqeK4JpN0NjnyFFNw==", + "version": "10.12.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-10.12.0.tgz", + "integrity": "sha512-npHjrHb2o4ehH3mE+YuxABR+0gyb0aVWCIolgJDArwCiHEIsonBm3ZKjel5b0U5+a+MbEvIyRCGCzD3eKKK2NA==", "dev": true, "license": "MIT", "workspaces": [ diff --git a/package.json b/package.json index d07df50441..799548eab2 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "devDependencies": { "@eslint/js": "^10.0.1", "@playwright/test": "^1.63.0", - "eslint": "^10.9.1", + "eslint": "^10.12.0", "eslint-plugin-playwright": "^2.10.5", "globals": "^17.13.0", "stylelint": "^17.16.0" From e142d07f97ec6e1b50313bc6e80761f603785418 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Tue, 6 Oct 2026 08:14:14 +0200 Subject: [PATCH 2/8] fix(web-app-xwiki): upgrade an add-on that is not on its pinned version The extension installer returned as soon as an add-on was installed, in whatever version. A new pin in meta/addons/ therefore reached a fresh wiki only, and an existing wiki kept the version it was first deployed with. The installer now skips an add-on only when the installed version equals the pin. Otherwise it calls install(id, version, namespace), which the Extension Manager resolves as an upgrade, and it reports an error when the add-on is not on the pin afterwards. The check that follows the installer compared presence only. It takes the pin as well, so a deploy fails when an add-on is installed in another version. Co-Authored-By: Claude Opus 5.5 (1M context) --- .../files/extension_installer_b64.groovy | 6 +-- .../filter_plugins/xwiki_filters.py | 9 ++-- roles/web-app-xwiki/tasks/04_extensions.yml | 5 ++- .../tasks/_check_extension_via_groovy.yml | 2 +- .../python/roles/web-app-xwiki/__init__.py | 0 .../web-app-xwiki/filter_plugins/__init__.py | 0 .../filter_plugins/test_xwiki_filters.py | 42 +++++++++++++++++++ 7 files changed, 54 insertions(+), 10 deletions(-) create mode 100644 tests/unit/python/roles/web-app-xwiki/__init__.py create mode 100644 tests/unit/python/roles/web-app-xwiki/filter_plugins/__init__.py create mode 100644 tests/unit/python/roles/web-app-xwiki/filter_plugins/test_xwiki_filters.py diff --git a/roles/web-app-xwiki/files/extension_installer_b64.groovy b/roles/web-app-xwiki/files/extension_installer_b64.groovy index 631b51497c..4d6e1d45c9 100644 --- a/roles/web-app-xwiki/files/extension_installer_b64.groovy +++ b/roles/web-app-xwiki/files/extension_installer_b64.groovy @@ -20,7 +20,7 @@ wanted.each { e -> if (!id) { println "ERROR::::Empty extension id in wanted list"; return } def already = ext.getInstalledExtension(id, ns) - if (already) { println "ALREADY_INSTALLED::${id}::${already.id?.version}"; return } + if (already && (!ver || already.id?.version?.toString() == ver)) { println "ALREADY_INSTALLED::${id}::${already.id?.version}"; return } println "INSTALL_START::${id}::${ver ? ver : 'latest'}" def job = null @@ -39,7 +39,7 @@ wanted.each { e -> def errMsg = err ? (err?.message ?: err?.toString()) : null def now = ext.getInstalledExtension(id, ns) - if (now) { + if (now && (!ver || now.id?.version?.toString() == ver)) { // Race-safe: Extension Manager can report "Failed to create install plan" // while the extension gets installed by the concurrent distribution job. if (caughtErr) println "WARN::${id}::${caughtErr}" @@ -51,6 +51,6 @@ wanted.each { e -> if (!caughtErr && !errMsg && st && st != 'FINISHED') { println "ERROR::${id}::Unexpected install state ${st}" } - println "INSTALLED_MISSING::${id}" + println now ? "ERROR::${id}::Still on ${now.id?.version}, wanted ${ver}" : "INSTALLED_MISSING::${id}" } } diff --git a/roles/web-app-xwiki/filter_plugins/xwiki_filters.py b/roles/web-app-xwiki/filter_plugins/xwiki_filters.py index 0a914d474d..4b7eea5c69 100644 --- a/roles/web-app-xwiki/filter_plugins/xwiki_filters.py +++ b/roles/web-app-xwiki/filter_plugins/xwiki_filters.py @@ -3,18 +3,18 @@ from __future__ import annotations import re -def xwiki_extension_status(raw: str) -> int: +def xwiki_extension_status(raw: str, version: str = "") -> int: """ Parse the output of the Groovy CheckExtension page. - Strips HTML tags and entities ( ) - - Returns 200 if extension is INSTALLED, otherwise 404 Args: raw: Raw HTTP body from the checker page. + version: The pinned version; empty accepts any installed version. Returns: - 200 if installed, 404 if missing/unknown. + 200 if installed in the pinned version, otherwise 404. """ if raw is None: return 404 @@ -23,7 +23,8 @@ def xwiki_extension_status(raw: str) -> int: text = text.replace(" ", " ").replace("\u00a0", " ") text = text.strip() - if text.startswith("INSTALLED::"): + suffix = f"::{version}" if version else "" + if text.startswith("INSTALLED::") and text.endswith(suffix): return 200 return 404 diff --git a/roles/web-app-xwiki/tasks/04_extensions.yml b/roles/web-app-xwiki/tasks/04_extensions.yml index f93d0eea3d..75d9d8a3be 100644 --- a/roles/web-app-xwiki/tasks/04_extensions.yml +++ b/roles/web-app-xwiki/tasks/04_extensions.yml @@ -72,6 +72,7 @@ label: "{{ plugin.id }}" vars: ext_id: "{{ plugin.id }}" + ext_version: "{{ plugin.version }}" result_var: "probe_{{ plugin.id | regex_replace('[^A-Za-z0-9_]', '_') }}" - name: "📊 XWIKI | Collect probe results" @@ -83,11 +84,11 @@ loop_var: plugin changed_when: false -- name: "✅ XWIKI | Assert all requested extensions are installed" +- name: "✅ XWIKI | Assert all requested extensions are on their pinned version" vars: missing: "{{ (_xwiki_probe_results | default([])) | selectattr('status','equalto',404) | map(attribute='id') | list }}" fail: - msg: "Missing extensions: {{ missing | join(', ') }}" + msg: "Extensions missing or not on their pinned version: {{ missing | join(', ') }}" when: missing | length > 0 - name: "🗑️ XWIKI | Delete installer page" diff --git a/roles/web-app-xwiki/tasks/_check_extension_via_groovy.yml b/roles/web-app-xwiki/tasks/_check_extension_via_groovy.yml index 5e81389e0c..cbbd210660 100644 --- a/roles/web-app-xwiki/tasks/_check_extension_via_groovy.yml +++ b/roles/web-app-xwiki/tasks/_check_extension_via_groovy.yml @@ -32,7 +32,7 @@ - name: "💾 XWIKI | Save Groovy check result for {{ ext_id }}" set_fact: "{{ result_var }}": - status: "{{ _check_output.content | xwiki_extension_status }}" + status: "{{ _check_output.content | xwiki_extension_status(ext_version) }}" raw: "{{ _check_output.content }}" - name: "🗑️ XWIKI | Delete checker page" diff --git a/tests/unit/python/roles/web-app-xwiki/__init__.py b/tests/unit/python/roles/web-app-xwiki/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/unit/python/roles/web-app-xwiki/filter_plugins/__init__.py b/tests/unit/python/roles/web-app-xwiki/filter_plugins/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/unit/python/roles/web-app-xwiki/filter_plugins/test_xwiki_filters.py b/tests/unit/python/roles/web-app-xwiki/filter_plugins/test_xwiki_filters.py new file mode 100644 index 0000000000..87142501ea --- /dev/null +++ b/tests/unit/python/roles/web-app-xwiki/filter_plugins/test_xwiki_filters.py @@ -0,0 +1,42 @@ +import importlib.util +import unittest + +from utils import PROJECT_ROOT + +_spec = importlib.util.spec_from_file_location( + "xwiki_filters", + PROJECT_ROOT / "roles/web-app-xwiki/filter_plugins/xwiki_filters.py", +) +_mod = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_mod) +xwiki_extension_status = _mod.xwiki_extension_status + +EXTENSION = "org.xwiki.contrib.oidc:oidc-authenticator" + + +class TestExtensionStatus(unittest.TestCase): + def test_the_pinned_version_counts_as_installed(self): + page = f"

INSTALLED::{EXTENSION}::2.28.1

" + self.assertEqual(xwiki_extension_status(page, "2.28.1"), 200) + + def test_another_installed_version_is_not_the_pinned_one(self): + page = f"INSTALLED::{EXTENSION}::2.19.6" + self.assertEqual(xwiki_extension_status(page, "2.28.1"), 404) + + def test_a_version_does_not_pass_for_one_it_only_starts_or_ends_like(self): + self.assertEqual( + xwiki_extension_status(f"INSTALLED::{EXTENSION}::0.10", "0.1"), 404 + ) + self.assertEqual( + xwiki_extension_status(f"INSTALLED::{EXTENSION}::10.1", "0.1"), 404 + ) + + def test_no_pin_accepts_any_installed_version(self): + self.assertEqual(xwiki_extension_status(f"INSTALLED::{EXTENSION}::2.19.6"), 200) + + def test_a_missing_extension_is_not_installed(self): + self.assertEqual(xwiki_extension_status(f"MISSING::{EXTENSION}", "2.28.1"), 404) + + +if __name__ == "__main__": + unittest.main() From 5494fbad48150a79c3e555bb962298ba039cf597 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Tue, 6 Oct 2026 00:30:55 +0200 Subject: [PATCH 3/8] fix(web-app-penpot): make the frontend wait for its backend by absolute name nginx resolves its upstreams once, at start, so the frontend starts through a guard that waits until `backend` and `exporter` resolve. A container resolves with a search domain, and the zone of a deployment answers every name with the address of the ingress. A service that Docker's DNS did not know yet therefore resolved anyway, as `backend.`. The guard let nginx start at once and nginx pinned the ingress as its backend. Every API call then failed with 502 and the SPA showed "Bad Gateway" instead of the login form, until the container was restarted. The guard now asks for the absolute names, `backend.` and `exporter.`. The search domain is not applied to those, so the lookup fails until the services themselves resolve. Closes #806 Co-Authored-By: Claude Opus 5.5 (1M context) --- roles/web-app-penpot/templates/compose.yml.j2 | 2 +- .../python/roles/web-app-penpot/__init__.py | 0 .../test_frontend_start_guard.py | 90 +++++++++++++++++++ 3 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 tests/unit/python/roles/web-app-penpot/__init__.py create mode 100644 tests/unit/python/roles/web-app-penpot/test_frontend_start_guard.py diff --git a/roles/web-app-penpot/templates/compose.yml.j2 b/roles/web-app-penpot/templates/compose.yml.j2 index e04f73a5ce..2e27c07ec1 100644 --- a/roles/web-app-penpot/templates/compose.yml.j2 +++ b/roles/web-app-penpot/templates/compose.yml.j2 @@ -8,7 +8,7 @@ command: - /bin/bash - -c - - 'until getent hosts {{ PENPOT_BACKEND_SERVICE }} >/dev/null 2>&1 && getent hosts {{ PENPOT_EXPORTER_SERVICE }} >/dev/null 2>&1; do sleep 1; done; exec nginx -g "daemon off;"' + - 'until getent hosts {{ PENPOT_BACKEND_SERVICE }}. >/dev/null 2>&1 && getent hosts {{ PENPOT_EXPORTER_SERVICE }}. >/dev/null 2>&1; do sleep 1; done; exec nginx -g "daemon off;"' {{ lookup('container_ports', ['penpot', 'http', DOCKER_BIND_HOST]) | indent(4) }} {{ lookup('container_volumes', service_name) | indent(4) }} {{ lookup('container_healthcheck', 'penpot') | indent(4) }} diff --git a/tests/unit/python/roles/web-app-penpot/__init__.py b/tests/unit/python/roles/web-app-penpot/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/unit/python/roles/web-app-penpot/test_frontend_start_guard.py b/tests/unit/python/roles/web-app-penpot/test_frontend_start_guard.py new file mode 100644 index 0000000000..66be48898e --- /dev/null +++ b/tests/unit/python/roles/web-app-penpot/test_frontend_start_guard.py @@ -0,0 +1,90 @@ +import os +import re +import subprocess +import tempfile +import unittest +from pathlib import Path + +from jinja2 import Environment, StrictUndefined, select_autoescape + +from utils import PROJECT_ROOT +from utils.cache.files import read_text +from utils.cache.yaml import load_yaml +from utils.roles.mapping import ROLE_FILE_TEMPL_COMPOSE, ROLE_FILE_VARS_MAIN + +ROLE_DIR = PROJECT_ROOT / "roles/web-app-penpot" + +GETENT_STUB = """#!/usr/bin/env bash +name="${2:-}" +if [[ "${name}" != *. ]]; then +\techo "172.30.0.10 ${name}.infinito.test" +\texit 0 +fi +lookups=$(( $(cat "${STUB_DIR}/absolute-lookups" 2>/dev/null || echo 0) + 1 )) +echo "${lookups}" >"${STUB_DIR}/absolute-lookups" +if [ "${lookups}" -le "${STUB_UNKNOWN_LOOKUPS}" ]; then +\texit 2 +fi +echo "192.168.48.5 ${name%.}" +""" + +NGINX_STUB = """#!/usr/bin/env bash +cat "${STUB_DIR}/absolute-lookups" 2>/dev/null || echo 0 +""" + +QUIET_STUB = """#!/usr/bin/env bash +exit 0 +""" + + +def start_guard() -> str: + template = read_text(str(ROLE_DIR / ROLE_FILE_TEMPL_COMPOSE)) + guard = re.search(r"^\s+- '(until getent hosts .+)'$", template, re.MULTILINE) + names = load_yaml(str(ROLE_DIR / ROLE_FILE_VARS_MAIN)) + env = Environment( + undefined=StrictUndefined, + autoescape=select_autoescape(default_for_string=False), + ) + return env.from_string(guard.group(1)).render( + PENPOT_BACKEND_SERVICE=names["PENPOT_BACKEND_SERVICE"], + PENPOT_EXPORTER_SERVICE=names["PENPOT_EXPORTER_SERVICE"], + ) + + +class TestFrontendStartGuard(unittest.TestCase): + def absolute_lookups_until_nginx_starts(self, failing_absolute_lookups: int) -> int: + with tempfile.TemporaryDirectory() as tmp: + bin_dir = Path(tmp) + stubs = ( + ("getent", GETENT_STUB), + ("nginx", NGINX_STUB), + ("sleep", QUIET_STUB), + ) + for name, body in stubs: + stub = bin_dir / name + stub.write_text(body) + stub.chmod(0o755) + env = {k: v for k, v in os.environ.items() if k != "BASH_ENV"} + env["PATH"] = f"{bin_dir}{os.pathsep}{env['PATH']}" + env["STUB_DIR"] = tmp + env["STUB_UNKNOWN_LOOKUPS"] = str(failing_absolute_lookups) + done = subprocess.run( + ["bash", "-c", start_guard()], + env=env, + capture_output=True, + text=True, + check=False, + timeout=30, + ) + self.assertEqual(done.returncode, 0, done.stderr) + return int(done.stdout) + + def test_nginx_waits_until_the_services_resolve_without_the_search_domain(self): + self.assertEqual(self.absolute_lookups_until_nginx_starts(3), 5) + + def test_nginx_starts_at_once_when_the_services_are_known(self): + self.assertEqual(self.absolute_lookups_until_nginx_starts(0), 2) + + +if __name__ == "__main__": + unittest.main() From 30084f986cd98a822870b0ab75d785f7d919a6a5 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Tue, 6 Oct 2026 01:39:19 +0200 Subject: [PATCH 4/8] fix(web-app-keycloak): keep concurrent kcadm jobs from losing the config lock In the async pass the role runs kcadm jobs side by side. Every kcadm call in the Keycloak container shares one config file. kcadm rewrites that file when it refreshes the access token, about every 55 seconds, takes the file lock with tryLock() and gives up at once when another kcadm process holds it. One of two overlapping declared-client jobs then failed with "Failed to get lock on /opt/keycloak/.keycloak/kcadm.config", and the deploy with it. keycloak_kcadm_update now repeats a call that lost the lock, up to ten times one second apart. The call fails while it refreshes its token, before it sends its own request, so repeating it is safe. Every other error still ends the call at once. That covers the module only, so the async jobs are reduced to the ones that go through it: - The default-scope assignment was an async shell task. It ran beside the shell tasks that follow it, and neither side repeats a lost lock. It runs in line now. - The two mail-settings jobs were async without a register, so nothing reaped them and a failure was never seen. They run in line now. The client job and the declared-client jobs stay async. A test fails when an async kcadm task does not use the module or is not registered for the reap. A config file of its own per call was the other option. It does not work by itself, because the admin session lives only in the shared file. Closes #805 Co-Authored-By: Claude Opus 5.5 (1M context) --- library/keycloak_kcadm_update.py | 8 ++- .../tasks/03_manager_ops/update_routines.yml | 4 +- .../tasks/update/02_mail_realm.yml | 3 - .../tasks/update/03_mail_master.yml | 3 - .../tasks/update/04_rbac_client_scope.yml | 4 -- .../web-app-keycloak/test_async_kcadm_jobs.py | 57 +++++++++++++++++++ .../test_library_keycloak_kcadm_update.py | 44 ++++++++++++++ 7 files changed, 109 insertions(+), 14 deletions(-) create mode 100644 tests/unit/python/roles/web-app-keycloak/test_async_kcadm_jobs.py diff --git a/library/keycloak_kcadm_update.py b/library/keycloak_kcadm_update.py index 3913e0ec17..863c67aca3 100755 --- a/library/keycloak_kcadm_update.py +++ b/library/keycloak_kcadm_update.py @@ -14,6 +14,9 @@ from ansible.module_utils.keycloak_scopes import converge_client_scope_lists NO_SUCH_CONTAINER_RE = re.compile(r"no such container", re.IGNORECASE) DEAD_CID_MAX_RETRIES = 80 DEAD_CID_RETRY_DELAY = 3 +CONFIG_LOCK_RE = re.compile(r"Failed to get lock on") +CONFIG_LOCK_MAX_RETRIES = 10 +CONFIG_LOCK_RETRY_DELAY = 1 DOCUMENTATION = r""" --- @@ -119,7 +122,7 @@ result: """ -def _shell(cmd, check): +def _shell(cmd, check, lock_retries=CONFIG_LOCK_MAX_RETRIES): rc = subprocess.run( # noqa: S602 - host-trusted argv; kcadm wrapper needs shell pipes/&& cmd, shell=True, @@ -128,6 +131,9 @@ def _shell(cmd, check): ) stdout = rc.stdout.decode("utf-8", errors="replace").strip() stderr = rc.stderr.decode("utf-8", errors="replace").strip() + if rc.returncode != 0 and lock_retries and CONFIG_LOCK_RE.search(stderr): + time.sleep(CONFIG_LOCK_RETRY_DELAY) + return _shell(cmd, check, lock_retries - 1) return rc.returncode, stdout, stderr diff --git a/roles/web-app-keycloak/tasks/03_manager_ops/update_routines.yml b/roles/web-app-keycloak/tasks/03_manager_ops/update_routines.yml index 2eb7d792cd..51d773280a 100644 --- a/roles/web-app-keycloak/tasks/03_manager_ops/update_routines.yml +++ b/roles/web-app-keycloak/tasks/03_manager_ops/update_routines.yml @@ -61,8 +61,6 @@ - name: "⏳ Reap the remaining Keycloak update jobs" ansible.builtin.include_tasks: utils/async/reap.yml vars: - async_reap_jobs: >- - {{ (kc_rbac_default.results | default([kc_rbac_default] if kc_rbac_default is defined else [])) - + (kc_declared_client_jobs | default([])) }} + async_reap_jobs: "{{ kc_declared_client_jobs | default([]) }}" async_reap_label: "Keycloak realm updates" async_reap_tolerate: [] diff --git a/roles/web-app-keycloak/tasks/update/02_mail_realm.yml b/roles/web-app-keycloak/tasks/update/02_mail_realm.yml index f5484e1888..073fa710df 100644 --- a/roles/web-app-keycloak/tasks/update/02_mail_realm.yml +++ b/roles/web-app-keycloak/tasks/update/02_mail_realm.yml @@ -10,6 +10,3 @@ kcadm_exec: "{{ KEYCLOAK_EXEC_KCADM }}" assert_mode: "{{ MODE_ASSERT }}" no_log: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}" - # rationale: async; smtpServer is written here and never read back anywhere - async: "{{ ASYNC_TIME if ASYNC_ENABLED | bool else omit }}" - poll: "{{ ASYNC_POLL if ASYNC_ENABLED | bool else omit }}" diff --git a/roles/web-app-keycloak/tasks/update/03_mail_master.yml b/roles/web-app-keycloak/tasks/update/03_mail_master.yml index 71d80a3d89..7340996078 100644 --- a/roles/web-app-keycloak/tasks/update/03_mail_master.yml +++ b/roles/web-app-keycloak/tasks/update/03_mail_master.yml @@ -10,6 +10,3 @@ kcadm_exec: "{{ KEYCLOAK_EXEC_KCADM }}" assert_mode: "{{ MODE_ASSERT }}" no_log: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}" - # rationale: async; writes the master realm smtpServer, which nothing reads back - async: "{{ ASYNC_TIME if ASYNC_ENABLED | bool else omit }}" - poll: "{{ ASYNC_POLL if ASYNC_ENABLED | bool else omit }}" diff --git a/roles/web-app-keycloak/tasks/update/04_rbac_client_scope.yml b/roles/web-app-keycloak/tasks/update/04_rbac_client_scope.yml index a849f9fb31..9d6ee571b9 100644 --- a/roles/web-app-keycloak/tasks/update/04_rbac_client_scope.yml +++ b/roles/web-app-keycloak/tasks/update/04_rbac_client_scope.yml @@ -92,8 +92,4 @@ {{ KEYCLOAK_EXEC_KCADM }} update clients/{{ app_client_id }}/default-client-scopes/{{ scope_id_rbac }} -r {{ KEYCLOAK_REALM }} - register: kc_rbac_default changed_when: true - # rationale: async; no task in the chain reads the scope back, reaped at the end of update_routines.yml - async: "{{ ASYNC_TIME if ASYNC_ENABLED | bool else omit }}" - poll: "{{ ASYNC_POLL if ASYNC_ENABLED | bool else omit }}" diff --git a/tests/unit/python/roles/web-app-keycloak/test_async_kcadm_jobs.py b/tests/unit/python/roles/web-app-keycloak/test_async_kcadm_jobs.py new file mode 100644 index 0000000000..f953e61abb --- /dev/null +++ b/tests/unit/python/roles/web-app-keycloak/test_async_kcadm_jobs.py @@ -0,0 +1,57 @@ +from __future__ import annotations + +import unittest + +from utils.cache.files import PROJECT_ROOT, iter_project_files +from utils.cache.yaml import load_yaml_any + +TASKS_DIR = str(PROJECT_ROOT / "roles/web-app-keycloak/tasks") + "/" +LOCK_RETRYING_MODULE = "keycloak_kcadm_update" + + +def tasks_of(node): + for task in node or []: + if not isinstance(task, dict): + continue + yield task + for nested in ("block", "rescue", "always"): + yield from tasks_of(task.get(nested)) + + +def async_kcadm_jobs(): + for path in iter_project_files(extensions=(".yml",)): + if not path.startswith(TASKS_DIR): + continue + for task in tasks_of(load_yaml_any(path)): + if "async" in task and "kcadm" in str(task).lower(): + yield f"{path[len(TASKS_DIR) :]}: {task.get('name')}", task + + +class TestAsyncKcadmJobs(unittest.TestCase): + def test_the_role_runs_kcadm_jobs_async(self): + self.assertTrue(list(async_kcadm_jobs())) + + def test_every_async_kcadm_job_goes_through_the_lock_retrying_module(self): + for label, task in async_kcadm_jobs(): + with self.subTest(task=label): + self.assertIn( + LOCK_RETRYING_MODULE, + task, + "kcadm gives up its config lock to a concurrent kcadm at once; " + "only keycloak_kcadm_update repeats such a call, so no other " + "kcadm task may run async", + ) + + def test_every_async_kcadm_job_is_registered_for_the_reap(self): + for label, task in async_kcadm_jobs(): + with self.subTest(task=label): + self.assertIn( + "register", + task, + "an async job without a register cannot be reaped, so nobody " + "sees it fail", + ) + + +if __name__ == "__main__": + unittest.main() diff --git a/tests/unit/python/roles/web_app_keycloak/test_library_keycloak_kcadm_update.py b/tests/unit/python/roles/web_app_keycloak/test_library_keycloak_kcadm_update.py index f1e9195b3a..920e3bfc44 100644 --- a/tests/unit/python/roles/web_app_keycloak/test_library_keycloak_kcadm_update.py +++ b/tests/unit/python/roles/web_app_keycloak/test_library_keycloak_kcadm_update.py @@ -15,6 +15,10 @@ if TYPE_CHECKING: ROLE_DIR = PROJECT_ROOT / "roles" / "web-app-keycloak" LIB_PATH = PROJECT_ROOT / "library" / "keycloak_kcadm_update.py" MODUTILS_PATH = PROJECT_ROOT / "utils" / "kcadm_json.py" +LOCK_ERROR = ( + "Failed to refresh access token - " + "Failed to get lock on /opt/keycloak/.keycloak/kcadm.config" +) def _load_py_module(name: str, path: Path): @@ -214,6 +218,46 @@ class TestKeycloakKcadmUpdate(unittest.TestCase): self.assertEqual(rc, 1) self.assertEqual(len(calls), 1) + def test_run_kcadm_repeats_a_call_that_lost_the_config_lock(self): + m = self.mod + outcomes = [ + DummyCompleted(1, "", LOCK_ERROR), + DummyCompleted(1, "", LOCK_ERROR), + DummyCompleted(0, "[]", ""), + ] + calls = [] + + def fake_run(cmd, **kwargs): + calls.append(cmd) + return outcomes[len(calls) - 1] + + with ( + patch.object(m.subprocess, "run", side_effect=fake_run), + patch.object(m.time, "sleep", return_value=None) as sleep, + ): + rc, out, _err = m.run_kcadm(DummyModule(), "kcadm get clients") + + self.assertEqual((rc, out), (0, "[]")) + self.assertEqual(calls, ["kcadm get clients"] * 3) + self.assertEqual(sleep.call_count, 2) + + def test_run_kcadm_gives_up_on_a_config_lock_that_never_frees(self): + m = self.mod + calls = [] + + def fake_run(cmd, **kwargs): + calls.append(cmd) + return DummyCompleted(1, "", LOCK_ERROR) + + with ( + patch.object(m.subprocess, "run", side_effect=fake_run), + patch.object(m.time, "sleep", return_value=None), + self.assertRaises(m.subprocess.CalledProcessError), + ): + m.run_kcadm(DummyModule(), "kcadm get clients") + + self.assertEqual(len(calls), m.CONFIG_LOCK_MAX_RETRIES + 1) + def test_get_current_object_parses_noisy(self): m = self.mod dummy = DummyModule() From 8dce5b3caa3c1fd24ee999d5290c22b658973015 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Mon, 5 Oct 2026 20:25:25 +0200 Subject: [PATCH 5/8] fix(web-svc-collabora): name the WOPI host and follow the vhost's TLS state The role restricted the WOPI hosts with `domain` and with `--o:net.wopi_allowed_hosts`. The distroless image that #775 brought in applies neither. `domain` was translated by the start script of the older image, which this one does not have, and coolwsd knows no setting called `net.wopi_allowed_hosts`. Its startup log listed that key among the overrides and no trusted WOPI host, so the server ran with the policy the image ships instead of the one the role declares. The allowlist now goes through `aliasgroup1`, the variable coolwsd reads itself. It carries the origin of the Nextcloud domain as the deployment resolves it, with scheme and port, so it also holds in a Tor variant. The old expression was built from DOMAIN_PRIMARY and would not have matched an onion address. No spec opened a document, which is why this went unnoticed. The richdocuments spec now uploads a document, opens it and waits for the `status:` frame on the editor websocket. Its first run on the Tor variant found a second defect. `ssl.termination` was fixed to true, so coolwsd advertised https URLs in its discovery while an onion vhost only serves http, and the browser never reached the editor. The setting now follows the TLS state of the Collabora vhost. Closes #802 Co-Authored-By: Claude Opus 5.5 (1M context) --- .../files/playwright/_shared.js | 3 + .../playwright/addons/onlyoffice.spec.js | 5 +- .../playwright/addons/richdocuments.spec.js | 62 +++++++++++++++++++ roles/web-svc-collabora/README.md | 2 +- roles/web-svc-collabora/templates/env.j2 | 4 +- roles/web-svc-collabora/vars/main.yml | 4 +- 6 files changed, 71 insertions(+), 9 deletions(-) diff --git a/roles/web-app-nextcloud/files/playwright/_shared.js b/roles/web-app-nextcloud/files/playwright/_shared.js index 06dd40577f..e154b3e2f1 100644 --- a/roles/web-app-nextcloud/files/playwright/_shared.js +++ b/roles/web-app-nextcloud/files/playwright/_shared.js @@ -22,6 +22,8 @@ const mastodonBaseUrl = decodeDotenvQuotedValue(process.env.MASTODON_BASE_URL); const moodleBaseUrl = decodeDotenvQuotedValue(process.env.MOODLE_BASE_URL); const peertubeBaseUrl = decodeDotenvQuotedValue(process.env.PEERTUBE_BASE_URL); const xwikiBaseUrl = decodeDotenvQuotedValue(process.env.XWIKI_BASE_URL); +const MINIMAL_DOCX_BASE64 = + "UEsDBBQAAAAIAEq201x5bjPX6AAAAK0BAAATAAAAW0NvbnRlbnRfVHlwZXNdLnhtbH1QyU7DMBD9FWuuKHHggBCK0wPLETiUDxjZk8SqN3nc0v49Tlt6QIXjzFv1+tXeO7GjzDYGBbdtB4KCjsaGScHn+rV5AMEFg0EXAyk4EMNq6NeHRCyqNrCCuZT0KCXrmTxyGxOFiowxeyz1zJNMqDc4kbzrunupYygUSlMWDxj6Zxpx64p42df3qUcmxyCeTsQlSwGm5KzGUnG5C+ZXSnNOaKvyyOHZJr6pBJBXExbk74Cz7r0Ok60h8YG5vKGvLPkVs5Em6q2vyvZ/mys94zhaTRf94pZy1MRcF/euvSAebfjpL49zD99QSwMECgAAAAAASrbTXAAAAAAAAAAAAAAAAAYAAABfcmVscy9QSwMEFAAAAAgASrbTXJv9N+qtAAAAKQEAAAsAAABfcmVscy8ucmVsc43POw7CMAwG4KtE3mlaBoRQ0y4IqSsqB7ASN61oHkrCo7cnAwNFDIy2f3+W6/ZpZnanECdnBVRFCYysdGqyWsClP232wGJCq3B2lgQsFKFt6jPNmPJKHCcfWTZsFDCm5A+cRzmSwVg4TzZPBhcMplwGzT3KK2ri27Lc8fBpwNpknRIQOlUB6xdP/9huGCZJRydvhmz6ceIrkWUMmpKAhwuKq3e7yCzwpuarF5sXUEsDBAoAAAAAAEq201wAAAAAAAAAAAAAAAAFAAAAd29yZC9QSwMEFAAAAAgASrbTXC5rweurAAAA6wAAABEAAAB3b3JkL2RvY3VtZW50LnhtbEWOQQ7CIBBFr0LYW6oLY5q27jyBHgBhaIkwQ4Bae3uhLty8n8lM3p/++vGOvSEmSzjwY9NyBqhIW5wG/rjfDhfOUpaopSOEgW+Q+HXs106TWjxgZkWAqVsHPuccOiGSmsHL1FAALDtD0ctcxjiJlaIOkRSkVPzeiVPbnoWXFnlVPklvNUNFrMijRWPRZmKEbiNjrAKmaAmuCFhpUq9e1LvKuDPs/LnE/8/xC1BLAQIeAxQAAAAIAEq201x5bjPX6AAAAK0BAAATAAAAAAAAAAEAAACkgQAAAABbQ29udGVudF9UeXBlc10ueG1sUEsBAh4DCgAAAAAASrbTXAAAAAAAAAAAAAAAAAYAAAAAAAAAAAAQAO1BGQEAAF9yZWxzL1BLAQIeAxQAAAAIAEq201yb/TfqrQAAACkBAAALAAAAAAAAAAEAAACkgT0BAABfcmVscy8ucmVsc1BLAQIeAwoAAAAAAEq201wAAAAAAAAAAAAAAAAFAAAAAAAAAAAAEADtQRMCAAB3b3JkL1BLAQIeAxQAAAAIAEq201wua8HrqwAAAOsAAAARAAAAAAAAAAEAAACkgTYCAAB3b3JkL2RvY3VtZW50LnhtbFBLBQYAAAAABQAFACABAAAQAwAAAAA="; const nextcloudUsernameFieldPattern = /account name(?: or email)?|username(?: or email)?/i; const nextcloudCredentialSubmitPattern = /^(sign in|log in)$/i; @@ -205,6 +207,7 @@ function beforeEach() { } module.exports = { + MINIMAL_DOCX_BASE64, env: { loginUsername, loginPassword, diff --git a/roles/web-app-nextcloud/files/playwright/addons/onlyoffice.spec.js b/roles/web-app-nextcloud/files/playwright/addons/onlyoffice.spec.js index 56333e0a42..a16e0a87e9 100644 --- a/roles/web-app-nextcloud/files/playwright/addons/onlyoffice.spec.js +++ b/roles/web-app-nextcloud/files/playwright/addons/onlyoffice.spec.js @@ -6,9 +6,6 @@ const { gotoOnion } = require("../personas"); test.use({ ignoreHTTPSErrors: true }); -const MINIMAL_DOCX_BASE64 = - "UEsDBBQAAAAIAEq201x5bjPX6AAAAK0BAAATAAAAW0NvbnRlbnRfVHlwZXNdLnhtbH1QyU7DMBD9FWuuKHHggBCK0wPLETiUDxjZk8SqN3nc0v49Tlt6QIXjzFv1+tXeO7GjzDYGBbdtB4KCjsaGScHn+rV5AMEFg0EXAyk4EMNq6NeHRCyqNrCCuZT0KCXrmTxyGxOFiowxeyz1zJNMqDc4kbzrunupYygUSlMWDxj6Zxpx64p42df3qUcmxyCeTsQlSwGm5KzGUnG5C+ZXSnNOaKvyyOHZJr6pBJBXExbk74Cz7r0Ok60h8YG5vKGvLPkVs5Em6q2vyvZ/mys94zhaTRf94pZy1MRcF/euvSAebfjpL49zD99QSwMECgAAAAAASrbTXAAAAAAAAAAAAAAAAAYAAABfcmVscy9QSwMEFAAAAAgASrbTXJv9N+qtAAAAKQEAAAsAAABfcmVscy8ucmVsc43POw7CMAwG4KtE3mlaBoRQ0y4IqSsqB7ASN61oHkrCo7cnAwNFDIy2f3+W6/ZpZnanECdnBVRFCYysdGqyWsClP232wGJCq3B2lgQsFKFt6jPNmPJKHCcfWTZsFDCm5A+cRzmSwVg4TzZPBhcMplwGzT3KK2ri27Lc8fBpwNpknRIQOlUB6xdP/9huGCZJRydvhmz6ceIrkWUMmpKAhwuKq3e7yCzwpuarF5sXUEsDBAoAAAAAAEq201wAAAAAAAAAAAAAAAAFAAAAd29yZC9QSwMEFAAAAAgASrbTXC5rweurAAAA6wAAABEAAAB3b3JkL2RvY3VtZW50LnhtbEWOQQ7CIBBFr0LYW6oLY5q27jyBHgBhaIkwQ4Bae3uhLty8n8lM3p/++vGOvSEmSzjwY9NyBqhIW5wG/rjfDhfOUpaopSOEgW+Q+HXs106TWjxgZkWAqVsHPuccOiGSmsHL1FAALDtD0ctcxjiJlaIOkRSkVPzeiVPbnoWXFnlVPklvNUNFrMijRWPRZmKEbiNjrAKmaAmuCFhpUq9e1LvKuDPs/LnE/8/xC1BLAQIeAxQAAAAIAEq201x5bjPX6AAAAK0BAAATAAAAAAAAAAEAAACkgQAAAABbQ29udGVudF9UeXBlc10ueG1sUEsBAh4DCgAAAAAASrbTXAAAAAAAAAAAAAAAAAYAAAAAAAAAAAAQAO1BGQEAAF9yZWxzL1BLAQIeAxQAAAAIAEq201yb/TfqrQAAACkBAAALAAAAAAAAAAEAAACkgT0BAABfcmVscy8ucmVsc1BLAQIeAwoAAAAAAEq201wAAAAAAAAAAAAAAAAFAAAAAAAAAAAAEADtQRMCAAB3b3JkL1BLAQIeAxQAAAAIAEq201wua8HrqwAAAOsAAAARAAAAAAAAAAEAAACkgTYCAAB3b3JkL2RvY3VtZW50LnhtbFBLBQYAAAAABQAFACABAAAQAwAAAAA="; - test("onlyoffice addon: opening a document loads the partner document-server editor", async ({ browser }) => { skipUnlessAddonEnabled("onlyoffice"); test.setTimeout(resolveTimeout(180_000)); @@ -39,7 +36,7 @@ test("onlyoffice addon: opening a document loads the partner document-server edi .setInputFiles({ name: docName, mimeType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document", - buffer: Buffer.from(MINIMAL_DOCX_BASE64, "base64"), + buffer: Buffer.from(shared.MINIMAL_DOCX_BASE64, "base64"), }); const docBasename = docName.replace(/\.docx$/, ""); diff --git a/roles/web-app-nextcloud/files/playwright/addons/richdocuments.spec.js b/roles/web-app-nextcloud/files/playwright/addons/richdocuments.spec.js index 516ee5f251..a70ee3f1b9 100644 --- a/roles/web-app-nextcloud/files/playwright/addons/richdocuments.spec.js +++ b/roles/web-app-nextcloud/files/playwright/addons/richdocuments.spec.js @@ -57,3 +57,65 @@ test("richdocuments addon: Collabora connector wired to the partner WOPI server" await context.close().catch(() => {}); } }); + +test("richdocuments addon: opening a document loads it through the partner WOPI server", async ({ browser }) => { + skipUnlessAddonEnabled("richdocuments"); + test.setTimeout(resolveTimeout(240_000)); + + const context = await browser.newContext({ ignoreHTTPSErrors: true }); + const page = await context.newPage(); + const editorReplies = []; + page.on("websocket", (socket) => { + if (!/\/cool\/(?:.+\/)?ws(?:\?|$)/.test(socket.url())) { + return; + } + socket.on("framereceived", ({ payload }) => { + const reply = payload.toString().slice(0, 120); + if (/^(status|error):/.test(reply)) { + editorReplies.push(reply); + } + }); + }); + + try { + await shared.loginToStandaloneNextcloud(page); + + const filesUrl = new URL("apps/files/", shared.env.nextcloudBaseUrl).toString(); + await gotoOnion(page, filesUrl, { waitUntil: "domcontentloaded", timeout: resolveTimeout(60_000) }); + await shared.dismissBlockingNextcloudModals(page, page); + + const docBasename = `infinito-collabora-${Date.now()}`; + await page + .locator('input[type="file"]') + .first() + .setInputFiles({ + name: `${docBasename}.docx`, + mimeType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document", + buffer: Buffer.from(shared.MINIMAL_DOCX_BASE64, "base64"), + }); + + const uploadedRow = page.getByText(docBasename, { exact: false }).first(); + await expect( + uploadedRow, + `the uploaded document '${docBasename}.docx' must appear in the Files listing before it can be opened in Collabora` + ).toBeVisible({ timeout: resolveTimeout(60_000) }); + + await shared.dismissBlockingNextcloudModals(page, page); + await uploadedRow.click(); + + await expect + .poll(() => editorReplies.length, { + message: + "opening the document must make Collabora answer on its editor websocket (/cool/ws) with a 'status:' or an 'error:' frame; silence means the browser never reached the editor that the discovery of web-svc-collabora advertises", + timeout: resolveTimeout(180_000), + }) + .toBeGreaterThan(0); + expect( + editorReplies[0], + "Collabora must answer the document load with a 'status:' frame; 'error: cmd=internal kind=unauthorized' means it refused the WOPI host (aliasgroup1 of web-svc-collabora) or its CheckFileInfo call to Nextcloud failed, and the Collabora log names which" + ).toMatch(/^status:/); + } finally { + await page.close().catch(() => {}); + await context.close().catch(() => {}); + } +}); diff --git a/roles/web-svc-collabora/README.md b/roles/web-svc-collabora/README.md index 45b628790e..11d6af36e0 100644 --- a/roles/web-svc-collabora/README.md +++ b/roles/web-svc-collabora/README.md @@ -9,7 +9,7 @@ This Ansible role deploys Collabora Online (CODE) in Docker to enable real-time, * **Dockerized Collabora CODE:** Uses the official `collabora/code` image. * **NGINX Reverse Proxy:** Configures a public-facing proxy with TLS termination and WebSocket support for `/cool/` paths. * **Docker Network Management:** Creates an isolated `/28` subnet for Collabora and connects containers securely. -* **Environment Configuration:** Generates a `.env` file with domain, credentials, and extra parameters for Collabora's WOPI server. +* **Environment Configuration:** Generates a `.env` file that names the Nextcloud origin as the only allowed WOPI host (`aliasgroup1`) and passes the extra parameters to coolwsd. ## Cosmos diff --git a/roles/web-svc-collabora/templates/env.j2 b/roles/web-svc-collabora/templates/env.j2 index f696c1518b..81817edc81 100644 --- a/roles/web-svc-collabora/templates/env.j2 +++ b/roles/web-svc-collabora/templates/env.j2 @@ -1,4 +1,4 @@ {% include 'roles/sys-svc-container/templates/env.j2' %} -domain={{ COLLABORA_ALLOWED_DOMAINS }} -extra_params=--o:ssl.enable=false --o:ssl.termination=true --o:net.service_root=/ --o:net.wopi_allowed_hosts={{ COLLABORA_ALLOWED_HOSTS }} --o:net.post_allow.host[99]={{ networks.internet.ip4 }}/32 +aliasgroup1={{ COLLABORA_WOPI_HOST }} +extra_params=--o:ssl.enable=false --o:ssl.termination={{ lookup('tls', application_id, 'enabled') | lower }} --o:net.service_root=/ --o:net.post_allow.host[99]={{ networks.internet.ip4 }}/32 diff --git a/roles/web-svc-collabora/vars/main.yml b/roles/web-svc-collabora/vars/main.yml index 3def230487..d37eddc25f 100644 --- a/roles/web-svc-collabora/vars/main.yml +++ b/roles/web-svc-collabora/vars/main.yml @@ -6,6 +6,6 @@ domain: "{{ lookup('domain',application_id) }}" http_port: "{{ lookup('config', application_id, 'services.collabora.ports.local.http') }}" COLLABORA_CONTAINER: "{{ lookup('config', application_id, 'services.collabora.name') }}" -COLLABORA_ALLOWED_DOMAINS: "(.*\\.|){{ DOMAIN_PRIMARY | regex_replace('\\.', '\\\\.') }}" -COLLABORA_ALLOWED_HOSTS: "{{ lookup('domain','web-app-nextcloud') }}" +COLLABORA_WOPI_HOST: "{{ lookup('tls', 'web-app-nextcloud', 'protocols.web') }}://{{ lookup('domain', 'web-app-nextcloud') }}:{{ lookup('tls', 'web-app-nextcloud', + 'ports.web') }}" COLLABORA_DISCOVERY_PATH: "/hosting/discovery" From 1560824ed5ed60a25704bc09222733fddba65389 Mon Sep 17 00:00:00 2001 From: evangelostsak Date: Tue, 6 Oct 2026 09:38:19 +0200 Subject: [PATCH 6/8] fix(web-app-pihole): drop the unused shared redis dependency --- roles/web-app-pihole/meta/services.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/roles/web-app-pihole/meta/services.yml b/roles/web-app-pihole/meta/services.yml index e30e2bd67c..c85d8ff8a9 100644 --- a/roles/web-app-pihole/meta/services.yml +++ b/roles/web-app-pihole/meta/services.yml @@ -21,12 +21,6 @@ email: shared: false # nocheck: dynamic-flag # nocheck: playwright-service-flag -redis: - bond: 1 - enabled: true - shared: true -# nocheck: dynamic-flag -# nocheck: playwright-service-flag javascript: bond: 1 enabled: "{{ 'web-app-keycloak' in group_names }}" From c35f2409a4b044efcaa44d5cda542664f8949569 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Tue, 6 Oct 2026 10:50:20 +0200 Subject: [PATCH 7/8] fix(web-app-odoo): make the OAuth addon work on Odoo 20 Nobody could sign in to Odoo through Keycloak. Odoo sent an http redirect URI, and Keycloak refused it as "Invalid parameter: redirect_uri". The addon auth_oauth_https builds that URI from web.base.url. Two things kept it from doing so after the image moved to Odoo 20. Its manifest declared version 19.0.1.8.0, and Odoo marks a module whose version names another series as not installable. It only warns about that, so the install task stayed green and the addon was missing. The manifest now declares 1.8.0, which Odoo prefixes with its own series. Once installed, the addon read the parameter with get_param, which Odoo 20 replaced by typed getters. The call raised AttributeError, a broad except logged it and fell back to the URL of the request, which is http behind the proxy. The addon reads the parameter with get_str now and no longer catches the error. A deploy now fails when the addon is not installed afterwards. The check reads ir_module_module, because the output of "odoo -i" does not tell an installed module from a skipped one. The spec logged out by navigating to /web/session/logout. Odoo 20 accepts POST only on that route and answered 405, so both SSO tests failed after a successful login. The spec logs out through the user menu now. A host that runs the suite with several workers still failed it. Odoo computes the session token of an account from its OAuth access token, so every new sign-in ends the other sessions of that account, and the spec files share the administrator. The role caps its suite at one worker with PLAYWRIGHT_MAX_WORKERS, which the central config now honours, and the spec asserts the cap. Closes #822 Co-Authored-By: Claude Opus 5.5 (1M context) --- .../files/role/playwright.specs.js.md | 2 + .../files/playwright.config.js | 5 ++- roles/web-app-odoo/README.md | 2 +- .../addons/auth_oauth_https/__manifest__.py | 2 +- .../auth_oauth_https/controllers/main.py | 20 +++------ .../files/playwright/playwright.spec.js | 26 +++++------ .../files/sql/select/installed-module.sql | 1 + .../tasks/03_install_modules/module_ops.yml | 12 ++++++ .../web-app-odoo/templates/playwright.env.j2 | 6 ++- .../python/roles/web-app-odoo/__init__.py | 0 .../test_addon_manifest_version.py | 43 +++++++++++++++++++ 11 files changed, 87 insertions(+), 32 deletions(-) create mode 100644 roles/web-app-odoo/files/sql/select/installed-module.sql create mode 100644 tests/unit/python/roles/web-app-odoo/__init__.py create mode 100644 tests/unit/python/roles/web-app-odoo/test_addon_manifest_version.py diff --git a/docs/contributing/artefact/files/role/playwright.specs.js.md b/docs/contributing/artefact/files/role/playwright.specs.js.md index be19d1f763..cbb0404262 100644 --- a/docs/contributing/artefact/files/role/playwright.specs.js.md +++ b/docs/contributing/artefact/files/role/playwright.specs.js.md @@ -308,6 +308,8 @@ The teardown MUST: Specs MUST decode quoted values before building URLs or typing credentials. The recurring helpers `decodeDotenvQuotedValue(value)` and `normalizeBaseUrl(value)` live in [`personas/utils/dotenv.js`](../../../../../roles/test-e2e-playwright/files/personas/utils/dotenv.js) and are re-exported through `require("./personas")`. Specs that need them MUST import from `./personas`; inline copies are forbidden and caught at review. +- A role whose spec files cannot run in parallel MUST set `PLAYWRIGHT_MAX_WORKERS` in `templates/playwright.env.j2`. + The central `playwright.config.js` runs the suite on the smaller of that value and the worker count the harness computed. ## Service gating contract 🔒 diff --git a/roles/test-e2e-playwright/files/playwright.config.js b/roles/test-e2e-playwright/files/playwright.config.js index 0587e22fcb..34ea0b334f 100644 --- a/roles/test-e2e-playwright/files/playwright.config.js +++ b/roles/test-e2e-playwright/files/playwright.config.js @@ -48,7 +48,10 @@ module.exports = defineConfig({ expect: { timeout: requiredTimeout("PLAYWRIGHT_EXPECT_TIMEOUT") }, ...(globalTimeout > 0 ? { globalTimeout } : {}), retries: 2, - workers: Number(process.env.PLAYWRIGHT_WORKERS) || 1, + workers: Math.min( + Number(process.env.PLAYWRIGHT_WORKERS) || 1, + Number(process.env.PLAYWRIGHT_MAX_WORKERS) || Infinity + ), fullyParallel: (process.env.PLAYWRIGHT_FULLY_PARALLEL || "").toLowerCase() === "true", outputDir: "/reports/test-results", reporter: [ diff --git a/roles/web-app-odoo/README.md b/roles/web-app-odoo/README.md index 62e7a4d9b5..c9904b6e56 100644 --- a/roles/web-app-odoo/README.md +++ b/roles/web-app-odoo/README.md @@ -216,7 +216,7 @@ docker logs odoo -f ## Persona contract opt-outs -The shared `biber` and `administrator` persona helpers are declared blocked in [templates/playwright.env.j2](./templates/playwright.env.j2). Odoo renders its SSO provider link only on `/web/login` inside the `.o_login_auth` container, not on the site root the persona helper starts from, and it exposes no in-app logout control — signing out means navigating to `/web/session/logout`. The full Keycloak round trip for both users is covered by the role's own `odoo: admin sso login, verify ui, logout` and `odoo: biber sso login, verify ui, logout` scenarios in [files/playwright/playwright.spec.js](./files/playwright/playwright.spec.js). +The shared `biber` and `administrator` persona helpers are declared blocked in [templates/playwright.env.j2](./templates/playwright.env.j2). Odoo renders its SSO provider link only on `/web/login` inside the `.o_login_auth` container, not on the site root the persona helper starts from, and its logout sits behind the user menu. The full Keycloak round trip for both users is covered by the role's own `odoo: admin sso login, verify ui, logout` and `odoo: biber sso login, verify ui, logout` scenarios in [files/playwright/playwright.spec.js](./files/playwright/playwright.spec.js). ## Credits diff --git a/roles/web-app-odoo/files/addons/auth_oauth_https/__manifest__.py b/roles/web-app-odoo/files/addons/auth_oauth_https/__manifest__.py index 5a042e03b9..70528d4956 100644 --- a/roles/web-app-odoo/files/addons/auth_oauth_https/__manifest__.py +++ b/roles/web-app-odoo/files/addons/auth_oauth_https/__manifest__.py @@ -1,7 +1,7 @@ # nocheck: mirrored-unit-test - an Odoo addon manifest, a bare dict literal the registry reads; there is no behaviour to exercise { # noqa: B018 Odoo addon manifests are bare dict expressions at module level by design "name": "OAuth HTTPS & Configurable UID", - "version": "19.0.1.8.0", + "version": "1.8.0", "category": "Authentication", "summary": "Force HTTPS redirect URIs and configurable OIDC UID field for OAuth", "description": """ diff --git a/roles/web-app-odoo/files/addons/auth_oauth_https/controllers/main.py b/roles/web-app-odoo/files/addons/auth_oauth_https/controllers/main.py index 0995cf2eb8..c637e3d3fe 100644 --- a/roles/web-app-odoo/files/addons/auth_oauth_https/controllers/main.py +++ b/roles/web-app-odoo/files/addons/auth_oauth_https/controllers/main.py @@ -2,14 +2,11 @@ # Part of Infinito.Nexus. See LICENSE file for full copyright and licensing details. import json -import logging import werkzeug.urls from odoo.addons.auth_oauth.controllers.main import OAuthLogin from odoo.http import request -_logger = logging.getLogger(__name__) - class OAuthLoginHTTPS(OAuthLogin): """ @@ -30,18 +27,11 @@ class OAuthLoginHTTPS(OAuthLogin): Returns the configured web.base.url, or falls back to request.httprequest.url_root if not set. """ - try: - base_url = ( - request.env["ir.config_parameter"].sudo().get_param("web.base.url") - ) - if base_url: - if not base_url.endswith("/"): - base_url += "/" - return base_url - except Exception: - _logger.exception( - "Failed to read 'web.base.url' from ir.config_parameter; falling back to request URL root." - ) + base_url = request.env["ir.config_parameter"].sudo().get_str("web.base.url") + if base_url: + if not base_url.endswith("/"): + base_url += "/" + return base_url return request.httprequest.url_root def list_providers(self): diff --git a/roles/web-app-odoo/files/playwright/playwright.spec.js b/roles/web-app-odoo/files/playwright/playwright.spec.js index bf7aeb77a2..f0dc42b44e 100644 --- a/roles/web-app-odoo/files/playwright/playwright.spec.js +++ b/roles/web-app-odoo/files/playwright/playwright.spec.js @@ -74,14 +74,9 @@ async function isOdooAuthenticated(locator) { } } -// Perform logout from Odoo by navigating directly to the logout URL. -async function performOdooLogout(page, odooBaseUrl) { - const logoutUrl = `${odooBaseUrl.replace(/\/$/, "")}/web/session/logout`; - - await gotoOnion(page, logoutUrl); - - // Give the logout a moment to process - await page.waitForTimeout(resolveTimeout(2_000)); +async function logOutThroughTheUserMenu(page) { + await page.locator("button.o_user_menu").first().click({ timeout: resolveTimeout(30_000) }); + await page.locator('[data-menu="logout"]').first().click({ timeout: resolveTimeout(30_000) }); } test.beforeEach(() => { @@ -93,6 +88,13 @@ test.beforeEach(() => { expect(biberPassword, "BIBER_PASSWORD must be set in the Playwright env file").toBeTruthy(); }); +test("odoo: the suite runs on one worker", async () => { + expect( + test.info().config.workers, + "an OAuth sign-in ends every other session of the same account, so PLAYWRIGHT_MAX_WORKERS must keep the spec files that share the administrator on one worker" + ).toBe(1); +}); + // Scenario I: Odoo → SSO login as admin → verify authenticated → logout // (dashboard-iframe mechanics covered by web-app-dashboard SPOT) test("odoo: admin sso login, verify ui, logout", async ({ page }) => { @@ -137,8 +139,8 @@ test("odoo: admin sso login, verify ui, logout", async ({ page }) => { ) .toBe(true); - // 7. Perform logout from Odoo by navigating to the logout URL - await performOdooLogout(page, odooBaseUrl); + // 7. Log out through the user menu + await logOutThroughTheUserMenu(page); // 8. Verify we're back on the login page (provider list visible again) await expect @@ -198,8 +200,8 @@ test("odoo: biber sso login, verify ui, logout", async ({ page }) => { ) .toBe(true); - // 7. Perform logout from Odoo - await performOdooLogout(page, odooBaseUrl); + // 7. Log out through the user menu + await logOutThroughTheUserMenu(page); // 8. Verify we're back on the login page await expect diff --git a/roles/web-app-odoo/files/sql/select/installed-module.sql b/roles/web-app-odoo/files/sql/select/installed-module.sql new file mode 100644 index 0000000000..0d0dde252d --- /dev/null +++ b/roles/web-app-odoo/files/sql/select/installed-module.sql @@ -0,0 +1 @@ +SELECT name FROM ir_module_module WHERE name = %(module)s AND state = 'installed'; diff --git a/roles/web-app-odoo/tasks/03_install_modules/module_ops.yml b/roles/web-app-odoo/tasks/03_install_modules/module_ops.yml index 7829592d9a..6e216510b5 100644 --- a/roles/web-app-odoo/tasks/03_install_modules/module_ops.yml +++ b/roles/web-app-odoo/tasks/03_install_modules/module_ops.yml @@ -79,6 +79,18 @@ auth_oauth_https_install.rc != 0 or 'invalid module names' in (auth_oauth_https_install.stdout ~ auth_oauth_https_install.stderr) +- name: "🛑 Fail when Odoo did not install the auth_oauth_https module" + database_query: + mask_values: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}" + config: "{{ lookup('database', application_id) }}" + query_file: "{{ role_path }}/files/sql/select/installed-module.sql" + named_args: + module: "auth_oauth_https" + expect_rows: true + register: auth_oauth_https_installed + failed_when: auth_oauth_https_installed.rows | length == 0 + when: ODOO_OIDC_ENABLED | bool + - name: "📦 Install auth_ldap module for LDAP support" no_log: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}" shell: > # nocheck: container-exec-resolver runtime-resolved CID, delegated to the hosting node diff --git a/roles/web-app-odoo/templates/playwright.env.j2 b/roles/web-app-odoo/templates/playwright.env.j2 index fc973b9455..ba10af4e05 100644 --- a/roles/web-app-odoo/templates/playwright.env.j2 +++ b/roles/web-app-odoo/templates/playwright.env.j2 @@ -28,12 +28,14 @@ ODOO_BASE_URL={{ lookup('tls', application_id, 'url.base') | dotenv_quote }} OIDC_ISSUER_URL={{ OIDC.CLIENT.ISSUER_URL | dotenv_quote }} -# nocheck: persona-block-rationale — Odoo's SSO entry is an auth_oauth provider link that only renders inside .o_login_auth on /web/login (files/playwright/playwright.spec.js:25-44), not on the APP_BASE_URL root the persona helper starts from, and Odoo offers no in-app logout control — the role logs out by navigating to /web/session/logout (files/playwright/playwright.spec.js:77-84); the admin chain is covered by "odoo: admin sso login, verify ui, logout" (see README "Persona contract opt-outs"). +# nocheck: persona-block-rationale — Odoo's SSO entry is an auth_oauth provider link that only renders inside .o_login_auth on /web/login (files/playwright/playwright.spec.js:26-45), not on the APP_BASE_URL root the persona helper starts from, and its logout sits behind the user menu (files/playwright/playwright.spec.js:77-80); the admin chain is covered by "odoo: admin sso login, verify ui, logout" (see README "Persona contract opt-outs"). PERSONA_ADMINISTRATOR_BLOCKED=true -# nocheck: persona-block-rationale — see PERSONA_ADMINISTRATOR_BLOCKED above; biber's chain is covered by "odoo: biber sso login, verify ui, logout" (files/playwright/playwright.spec.js:159). +# nocheck: persona-block-rationale — see PERSONA_ADMINISTRATOR_BLOCKED above; biber's chain is covered by "odoo: biber sso login, verify ui, logout" (files/playwright/playwright.spec.js:162). PERSONA_BIBER_BLOCKED=true +PLAYWRIGHT_MAX_WORKERS=1 + SSO_SERVICE_ENABLED={{ lookup('config', application_id, 'services.sso.enabled') | string | lower }} {{ lookup('addon_env_flags', application_id) }} diff --git a/tests/unit/python/roles/web-app-odoo/__init__.py b/tests/unit/python/roles/web-app-odoo/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/unit/python/roles/web-app-odoo/test_addon_manifest_version.py b/tests/unit/python/roles/web-app-odoo/test_addon_manifest_version.py new file mode 100644 index 0000000000..e379a4ed49 --- /dev/null +++ b/tests/unit/python/roles/web-app-odoo/test_addon_manifest_version.py @@ -0,0 +1,43 @@ +from __future__ import annotations + +import ast +import unittest + +from utils.cache.files import PROJECT_ROOT, read_text + +MANIFEST = ( + PROJECT_ROOT / "roles/web-app-odoo/files/addons/auth_oauth_https/__manifest__.py" +) + + +def manifest_version() -> str: + return ast.literal_eval(read_text(str(MANIFEST)))["version"] + + +def installable_on(series: str, version: str) -> bool: + parts = version.split(".") + if not 2 <= len(parts) <= 5 or not all(part.isdigit() for part in parts): + return False + if len(parts) <= 3 and not version.startswith(series): + version = f"{series}.{version}" + return version.startswith(series + ".") + + +class TestAddonManifestVersion(unittest.TestCase): + def test_odoo_installs_the_addon_on_every_series(self): + for series in ("19.0", "20.0", "21.0"): + with self.subTest(series=series): + self.assertTrue( + installable_on(series, manifest_version()), + f"Odoo {series} marks a module whose version names another " + "series as not installable and only warns about it; keep the " + "version in the form x.y.z so Odoo prefixes its own series", + ) + + def test_a_version_that_names_a_series_is_refused_by_the_next_one(self): + self.assertTrue(installable_on("19.0", "19.0.1.8.0")) + self.assertFalse(installable_on("20.0", "19.0.1.8.0")) + + +if __name__ == "__main__": + unittest.main() From ddb565dd2d6ebe0b179fc45ed1ebe9d6376b103b Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Tue, 6 Oct 2026 13:22:35 +0200 Subject: [PATCH 8/8] docs(web-app-pihole): regenerate the READMEs without the redis dependency 1560824ed5 dropped the unused shared redis dependency of web-app-pihole without a make docs run. This is the generator output for the current tree: the pihole cosmos loses the redis node and edge, and the root role table no longer lists Redis for Pi-hole. Co-Authored-By: Claude Opus 5.5 (1M context) --- README.md | 2 +- roles/web-app-pihole/README.md | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 4997f9f7b1..ae2daf2654 100644 --- a/README.md +++ b/README.md @@ -182,7 +182,7 @@ Every invokable role in the tested lifecycle envelope, with its upstream homepag | [Typesense](roles/svc-db-typesense/) | beta | Central Dockerized search engine shared by multiple apps with per-consumer scoped API keys | [🌐](https://typesense.org/) [🛠️](roles/svc-db-typesense/README.md#quick-setup) | [Backup Docker Volumes](roles/svc-bkp-volume-2-local/), [Tor Onion Service](roles/svc-net-tor/) | | [Unbound](roles/svc-dns-unbound/) | beta | Central recursive/forwarding DNSSEC resolver on a static IP for consumer stacks to target as their DNS | [🌐](https://nlnetlabs.nl/projects/unbound/about/) [🛠️](roles/svc-dns-unbound/README.md#quick-setup) | | | [Universal Logout](roles/web-svc-logout/) | beta | Central logout proxy for single-action sign-out across all OIDC-connected apps, with Nginx snippets and a live status UI | [🛠️](roles/web-svc-logout/README.md#quick-setup) | [Corporate Design](roles/web-svc-css/), [Matomo](roles/web-app-matomo/), [Prometheus](roles/web-app-prometheus/), [Tor Onion Service](roles/svc-net-tor/) | -| [web-app-pihole](roles/web-app-pihole/) | beta | Network-wide DNS sinkhole for blocking ads and trackers across all devices, with DHCP and a web admin dashboard | [🌐](https://pi-hole.net/) [🎬](https://youtu.be/KBXTnrD_Zs4) [🛠️](roles/web-app-pihole/README.md#quick-setup) | [Backup Docker Volumes](roles/svc-bkp-volume-2-local/), [Content Delivery Network](roles/web-svc-cdn/), [Corporate Design](roles/web-svc-css/), [Dashboard](roles/web-app-dashboard/), [Keycloak](roles/web-app-keycloak/), [Matomo](roles/web-app-matomo/), [Prometheus](roles/web-app-prometheus/), [Redis](roles/svc-db-redis/), [Tor Onion Service](roles/svc-net-tor/), [Universal Logout](roles/web-svc-logout/) | +| [web-app-pihole](roles/web-app-pihole/) | beta | Network-wide DNS sinkhole for blocking ads and trackers across all devices, with DHCP and a web admin dashboard | [🌐](https://pi-hole.net/) [🎬](https://youtu.be/KBXTnrD_Zs4) [🛠️](roles/web-app-pihole/README.md#quick-setup) | [Backup Docker Volumes](roles/svc-bkp-volume-2-local/), [Content Delivery Network](roles/web-svc-cdn/), [Corporate Design](roles/web-svc-css/), [Dashboard](roles/web-app-dashboard/), [Keycloak](roles/web-app-keycloak/), [Matomo](roles/web-app-matomo/), [Prometheus](roles/web-app-prometheus/), [Tor Onion Service](roles/svc-net-tor/), [Universal Logout](roles/web-svc-logout/) | | [Wireguard](roles/svc-net-wireguard-core/) | alpha | Host-level WireGuard VPN service with wg-quick config, package install, and IP-forwarding sysctl for secure tunnels | [🌐](https://www.wireguard.com/) [🛠️](roles/svc-net-wireguard-core/README.md#quick-setup) | | | [Wireguard Client](roles/svc-net-wireguard-plain/) | alpha | Client-side WireGuard VPN role for stable connectivity with a systemd service and script that tune interface MTU | [🌐](https://www.wireguard.com/) [🛠️](roles/svc-net-wireguard-plain/README.md#quick-setup) | | | [WireGuard Client behind NAT](roles/svc-net-wireguard-firewalled/) | alpha | Networking helper for iptables forwarding and NAT masquerading of a WireGuard client running behind NAT or a firewall | [🛠️](roles/svc-net-wireguard-firewalled/README.md#quick-setup) | | diff --git a/roles/web-app-pihole/README.md b/roles/web-app-pihole/README.md index 1f3b88fe90..c192fda89f 100644 --- a/roles/web-app-pihole/README.md +++ b/roles/web-app-pihole/README.md @@ -18,7 +18,6 @@ The diagram places web-app-pihole in the Infinito.Nexus cosmos: the components i flowchart LR subgraph deps [Dependencies] dep_svc_bkp_volume_2_local["svc-bkp-volume-2-local 💻"] - dep_svc_db_redis["svc-db-redis 🐳🐝"] dep_svc_net_tor["svc-net-tor 🐳🐝"] dep_web_app_dashboard["web-app-dashboard 🐳🐝"] dep_web_app_keycloak["web-app-keycloak 🐳🐝"] @@ -33,7 +32,6 @@ flowchart LR svc_dashboard["dashboard"] svc_matomo["matomo"] svc_email["email ❌"] - svc_redis["redis"] svc_javascript["javascript"] svc_prometheus["prometheus"] svc_tor["tor"] @@ -43,7 +41,6 @@ flowchart LR svc_container_backup["container_backup"] end dep_svc_bkp_volume_2_local -. "0..1" .-> svc_container_backup - dep_svc_db_redis -- "1:1" --> svc_redis dep_svc_net_tor -. "0..1" .-> svc_tor dep_web_app_dashboard -. "0..1" .-> svc_dashboard dep_web_app_keycloak -. "0..1" .-> svc_javascript @@ -53,7 +50,7 @@ flowchart LR dep_web_app_stalwart -- "0..0" --> svc_email dep_web_svc_css -. "0..1" .-> svc_css dep_web_svc_logout -. "0..1" .-> svc_logout - linkStyle 8 stroke:red; + linkStyle 7 stroke:red; ``` Solid `1:1` edges are fixed relationships; dashed `0..1` edges are conditional (enabled only in matching deployments); red `0..0` edges are turned off in this role. Node markers show the role's deploy modes (💻 host, 🐳 compose, 🐝 swarm); ❌ marks a service that is explicitly turned off, and ⚙️ an Ansible role dependency declared in `meta/main.yml`.