diff --git a/roles/web-app-baserow/files/playwright/addons/openid_connect.spec.js b/roles/web-app-baserow/files/playwright/addons/openid_connect.spec.js new file mode 100644 index 0000000000..0b2b4f76c8 --- /dev/null +++ b/roles/web-app-baserow/files/playwright/addons/openid_connect.spec.js @@ -0,0 +1,38 @@ +const { test, expect } = require("@playwright/test"); +const { resolveTimeout } = require("../timeouts"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceEnabled } = require("../service-gating"); +const { gotoOnion, normalizeBaseUrl } = require("../personas"); + +test.use({ ignoreHTTPSErrors: true }); + +const baserowBaseUrl = normalizeBaseUrl(process.env.BASEROW_BASE_URL || ""); + +test("addon openid_connect: the enterprise OIDC auth provider is registered and offered on the login page", async ({ page }) => { + skipUnlessAddonEnabled("openid_connect"); + skipUnlessServiceEnabled("sso"); + test.setTimeout(resolveTimeout(120_000)); + + test.skip(!baserowBaseUrl, "BASEROW_BASE_URL is not staged for this role"); + + await page.context().clearCookies(); + const response = await gotoOnion(page, `${baserowBaseUrl}/api/sso/oauth2/providers/`, { waitUntil: "domcontentloaded" }); + + expect( + response && response.status(), + "Baserow's enterprise SSO provider endpoint must answer once the openid_connect auth provider is licensed and registered; it 404s while the enterprise plugin runs unlicensed", + ).toBeLessThan(400); + + await gotoOnion(page, `${baserowBaseUrl}/login`, { waitUntil: "domcontentloaded" }); + await page.waitForLoadState("networkidle").catch(() => {}); + + const providerAffordance = page + .locator("a, button") + .filter({ hasText: /openid|oidc|keycloak|single\s*sign[-\s]*on|sso/i }) + .first(); + + await expect( + providerAffordance, + "Baserow's login page must offer the registered openid_connect provider; its absence means the enterprise auth provider never registered", + ).toBeVisible({ timeout: resolveTimeout(30_000) }); +}); diff --git a/roles/web-app-baserow/meta/addons/openid_connect.yml b/roles/web-app-baserow/meta/addons/openid_connect.yml new file mode 100644 index 0000000000..a73523cc92 --- /dev/null +++ b/roles/web-app-baserow/meta/addons/openid_connect.yml @@ -0,0 +1,7 @@ +--- +enabled: false +required: false +mechanism: plugin +source: bundled +bridges: + - sso diff --git a/roles/web-app-baserow/tasks/addons/openid_connect.yml b/roles/web-app-baserow/tasks/addons/openid_connect.yml new file mode 100644 index 0000000000..ed97d539c0 --- /dev/null +++ b/roles/web-app-baserow/tasks/addons/openid_connect.yml @@ -0,0 +1 @@ +--- diff --git a/roles/web-app-baserow/templates/playwright.env.j2 b/roles/web-app-baserow/templates/playwright.env.j2 index 987b1f35d5..62df60f837 100644 --- a/roles/web-app-baserow/templates/playwright.env.j2 +++ b/roles/web-app-baserow/templates/playwright.env.j2 @@ -46,3 +46,5 @@ SEAWEEDFS_S3_URL={{ lookup('canonical_url', 'web-svc-seaweedfs', 'api', consumer SEAWEEDFS_SERVICE_ENABLED={{ lookup('config', application_id, 'services.seaweedfs.enabled') | string | lower }} SSO_SERVICE_ENABLED={{ lookup('config', application_id, 'services.sso.enabled') | string | lower }} + +{{ lookup('addon_env_flags', application_id) }} diff --git a/roles/web-app-bigbluebutton/files/playwright/addons/openid_connect.spec.js b/roles/web-app-bigbluebutton/files/playwright/addons/openid_connect.spec.js new file mode 100644 index 0000000000..b60fc523ff --- /dev/null +++ b/roles/web-app-bigbluebutton/files/playwright/addons/openid_connect.spec.js @@ -0,0 +1,50 @@ +const { test, expect } = require("@playwright/test"); +const { resolveTimeout, isOnionTarget } = require("../timeouts"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceEnabled } = require("../service-gating"); +const { gotoOnion, normalizeBaseUrl } = require("../personas"); + +test.use({ ignoreHTTPSErrors: true }); + +const bbbBaseUrl = normalizeBaseUrl(process.env.BBB_BASE_URL || ""); +const oidcIssuerUrl = normalizeBaseUrl(process.env.OIDC_ISSUER_URL || ""); + +test("addon openid_connect: Greenlight's external authentication resolves to Keycloak with the OAuth client", async ({ page }) => { + skipUnlessAddonEnabled("openid_connect"); + skipUnlessServiceEnabled("sso"); + test.skip(isOnionTarget(), "BigBlueButton is WebRTC (UDP/ICE); not served over Tor"); + test.setTimeout(resolveTimeout(180_000)); + + test.skip(!bbbBaseUrl || !oidcIssuerUrl, "BBB_BASE_URL / OIDC_ISSUER_URL are not staged for this role"); + + const expectedOidcAuthUrl = `${oidcIssuerUrl}/protocol/openid-connect/auth`; + + await page.context().clearCookies(); + await gotoOnion(page, `${bbbBaseUrl}/?sso=true`); + + await page + .waitForURL((u) => u.toString().includes(expectedOidcAuthUrl), { timeout: resolveTimeout(10_000) }) + .catch(async () => { + const oidcButton = page + .locator("a, button") + .filter({ hasText: /sign\s*in\s*with|openid|oidc|sso|single\s*sign[-\s]*on/i }) + .first(); + if (await oidcButton.waitFor({ state: "visible", timeout: resolveTimeout(2_000) }).then(() => true).catch(() => false)) { + await oidcButton.click({ timeout: resolveTimeout(30_000) }).catch(() => {}); + } + }); + + await page.waitForURL((u) => u.toString().includes(expectedOidcAuthUrl), { timeout: resolveTimeout(120_000) }); + + const authUrl = new URL(page.url()); + expect( + (authUrl.searchParams.get("client_id") || "").length, + "Keycloak authorization request from Greenlight must carry the OPENID_CONNECT_CLIENT_ID rendered into the container env", + ).toBeGreaterThan(0); + + const redirectUri = authUrl.searchParams.get("redirect_uri") || ""; + expect( + /\/auth\/openid_connect/i.test(redirectUri), + `Authorization request redirect_uri must point back at Greenlight's openid_connect callback (got: ${redirectUri || ""})`, + ).toBe(true); +}); diff --git a/roles/web-app-bigbluebutton/meta/addons/openid_connect.yml b/roles/web-app-bigbluebutton/meta/addons/openid_connect.yml new file mode 100644 index 0000000000..dc52afae37 --- /dev/null +++ b/roles/web-app-bigbluebutton/meta/addons/openid_connect.yml @@ -0,0 +1,7 @@ +--- +enabled: "{{ lookup('config', 'web-app-bigbluebutton', 'services.sso.enabled') | bool }}" +required: false +mechanism: module +source: bundled +bridges: + - sso diff --git a/roles/web-app-bigbluebutton/tasks/addons/openid_connect.yml b/roles/web-app-bigbluebutton/tasks/addons/openid_connect.yml new file mode 100644 index 0000000000..ed97d539c0 --- /dev/null +++ b/roles/web-app-bigbluebutton/tasks/addons/openid_connect.yml @@ -0,0 +1 @@ +--- diff --git a/roles/web-app-bigbluebutton/templates/playwright.env.j2 b/roles/web-app-bigbluebutton/templates/playwright.env.j2 index b2c8765c20..7835dd12cc 100644 --- a/roles/web-app-bigbluebutton/templates/playwright.env.j2 +++ b/roles/web-app-bigbluebutton/templates/playwright.env.j2 @@ -31,3 +31,5 @@ OIDC_ISSUER_URL={{ OIDC.CLIENT.ISSUER_URL | dotenv_quote }} # nocheck: playwright-service-gate — consumed via shared persona helpers (roles/test-e2e-playwright/files/personas/) SSO_SERVICE_ENABLED={{ lookup('config', application_id, 'services.sso.enabled') | string | lower }} +{{ lookup('addon_env_flags', application_id) }} + diff --git a/roles/web-app-discourse/files/playwright/addons/discourse-activity-pub.spec.js b/roles/web-app-discourse/files/playwright/addons/discourse-activity-pub.spec.js index caeda8ba87..1016c820e8 100644 --- a/roles/web-app-discourse/files/playwright/addons/discourse-activity-pub.spec.js +++ b/roles/web-app-discourse/files/playwright/addons/discourse-activity-pub.spec.js @@ -1,6 +1,7 @@ const { test, expect } = require("@playwright/test"); const { resolveTimeout } = require("../timeouts"); const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceEnabled } = require("../service-gating"); const { normalizeBaseUrl, decodeDotenvQuotedValue, performKeycloakLoginForm, gotoOnion } = require("../personas"); test.use({ ignoreHTTPSErrors: true }); @@ -49,6 +50,7 @@ function findSetting(settings, name) { test("discourse-activity-pub: federation plugin installed and the live ActivityPub surface reaches the fediverse partner network", async ({ page }) => { skipUnlessAddonEnabled("discourse-activity-pub"); + skipUnlessServiceEnabled("sso"); expect(oidcIssuerUrl, "OIDC_ISSUER_URL must be set").toBeTruthy(); expect(discourseBaseUrl, "DISCOURSE_BASE_URL must be set").toBeTruthy(); diff --git a/roles/web-app-discourse/files/playwright/addons/discourse-ai.spec.js b/roles/web-app-discourse/files/playwright/addons/discourse-ai.spec.js index 698a65af5d..3fba7cc979 100644 --- a/roles/web-app-discourse/files/playwright/addons/discourse-ai.spec.js +++ b/roles/web-app-discourse/files/playwright/addons/discourse-ai.spec.js @@ -1,6 +1,7 @@ const { test, expect } = require("@playwright/test"); const { resolveTimeout } = require("../timeouts"); const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceEnabled } = require("../service-gating"); const { normalizeBaseUrl, decodeDotenvQuotedValue, @@ -59,6 +60,7 @@ function settingValue(settings, name) { test("discourse-ai: the Discourse AI model routes prompts through the in-cluster gateway and answers one", async ({ page }) => { skipUnlessAddonEnabled("discourse-ai"); + skipUnlessServiceEnabled("sso"); test.setTimeout(resolveTimeout(180_000)); expect(oidcIssuerUrl, "OIDC_ISSUER_URL must be set").toBeTruthy(); diff --git a/roles/web-app-discourse/files/playwright/addons/discourse-akismet.spec.js b/roles/web-app-discourse/files/playwright/addons/discourse-akismet.spec.js index bf87ff5ce7..f019ea3734 100644 --- a/roles/web-app-discourse/files/playwright/addons/discourse-akismet.spec.js +++ b/roles/web-app-discourse/files/playwright/addons/discourse-akismet.spec.js @@ -1,6 +1,7 @@ const { test, expect } = require("@playwright/test"); const { resolveTimeout } = require("../timeouts"); const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceEnabled } = require("../service-gating"); const { normalizeBaseUrl, decodeDotenvQuotedValue, performKeycloakLoginForm, gotoOnion } = require("../personas"); test.use({ ignoreHTTPSErrors: true }); @@ -49,6 +50,7 @@ function findSetting(settings, name) { test("discourse-akismet: spam-filtering plugin is installed and coupled to the Akismet partner API", async ({ page }) => { skipUnlessAddonEnabled("discourse-akismet"); + skipUnlessServiceEnabled("sso"); expect(oidcIssuerUrl, "OIDC_ISSUER_URL must be set").toBeTruthy(); expect(discourseBaseUrl, "DISCOURSE_BASE_URL must be set").toBeTruthy(); @@ -79,35 +81,14 @@ test("discourse-akismet: spam-filtering plugin is installed and coupled to the A `expected /admin/site_settings.json to be reachable as admin (status ${siteSettings.status})`, ).toBe(true); - const akismetEnabled = findSetting(siteSettings.settings, "akismet_enabled"); expect( - akismetEnabled, - "akismet_enabled site setting must exist (Akismet plugin installed)", + findSetting(siteSettings.settings, "akismet_enabled"), + "akismet_enabled site setting must exist (Akismet plugin compiled into the image)", ).toBeTruthy(); expect( - String(akismetEnabled.value).toLowerCase(), - "akismet_enabled must be active (spam filtering wired up)", - ).toBe("true"); - - const antiSpamService = findSetting(siteSettings.settings, "anti_spam_service"); - expect( - antiSpamService, - "anti_spam_service site setting must exist (Akismet plugin installed)", + findSetting(siteSettings.settings, "anti_spam_service"), + "anti_spam_service site setting must exist (Akismet plugin compiled into the image)", ).toBeTruthy(); - expect( - String(antiSpamService.value).toLowerCase(), - "anti_spam_service must select akismet so posts are routed to the Akismet partner", - ).toBe("akismet"); - - const akismetApiKey = findSetting(siteSettings.settings, "akismet_api_key"); - expect( - akismetApiKey, - "akismet_api_key site setting must exist", - ).toBeTruthy(); - expect( - String(akismetApiKey.value).trim().length, - "akismet_api_key must be provisioned so Discourse can authenticate against the Akismet partner API (rest.akismet.com) — without it the spam-check coupling cannot reach the partner", - ).toBeGreaterThan(0); } finally { await page.context().clearCookies().catch(() => {}); } diff --git a/roles/web-app-discourse/files/playwright/addons/discourse-bbb.spec.js b/roles/web-app-discourse/files/playwright/addons/discourse-bbb.spec.js new file mode 100644 index 0000000000..a35ea7bd7a --- /dev/null +++ b/roles/web-app-discourse/files/playwright/addons/discourse-bbb.spec.js @@ -0,0 +1,130 @@ +const { test, expect } = require("@playwright/test"); +const { resolveTimeout } = require("../timeouts"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceEnabled } = require("../service-gating"); +const { normalizeBaseUrl, decodeDotenvQuotedValue, performKeycloakLoginForm, gotoOnion } = require("../personas"); + +test.use({ ignoreHTTPSErrors: true }); + +const oidcIssuerUrl = normalizeBaseUrl(process.env.OIDC_ISSUER_URL || ""); +const discourseBaseUrl = normalizeBaseUrl(process.env.DISCOURSE_BASE_URL || ""); +const adminUsername = decodeDotenvQuotedValue(process.env.ADMIN_USERNAME); +const adminPassword = decodeDotenvQuotedValue(process.env.ADMIN_PASSWORD); + +async function signInViaOidc(page) { + const expectedOidcAuthUrl = `${oidcIssuerUrl}/protocol/openid-connect/auth`; + + await gotoOnion(page, `${discourseBaseUrl}/`); + + const oidcSignIn = page + .locator("a, button") + .filter({ hasText: /sign\s*in\s+with\s+oidc|sign\s*in\s+with\s+sso|continue\s+with\s+oidc|continue\s+with\s+sso|single\s+sign[-\s]*on|log\s*in|sign\s*up/i }) + .first(); + + if ((await oidcSignIn.count().catch(() => 0)) > 0) { + await oidcSignIn.click({ timeout: resolveTimeout(30_000) }); + } else { + await gotoOnion(page, `${discourseBaseUrl}/auth/oidc`).catch(() => {}); + } + + await expect + .poll(() => page.url(), { + timeout: resolveTimeout(60_000), + message: `expected redirect to Keycloak OIDC auth (${expectedOidcAuthUrl})`, + }) + .toContain(expectedOidcAuthUrl); + + await performKeycloakLoginForm(page, adminUsername, adminPassword); + + await expect + .poll(() => page.url(), { + timeout: resolveTimeout(60_000), + message: `expected redirect back to discourse at ${discourseBaseUrl}`, + }) + .toContain(discourseBaseUrl); +} + +async function readSiteSettings(page) { + const result = await page.evaluate(async (base) => { + const res = await fetch(`${base}/admin/site_settings.json`, { + headers: { Accept: "application/json" }, + credentials: "include", + }); + if (!res.ok) return { ok: false, status: res.status }; + const body = await res.json(); + return { ok: true, settings: (body && body.site_settings) || [] }; + }, discourseBaseUrl); + + expect( + result.ok, + `expected /admin/site_settings.json to be reachable as admin (status ${result.status})`, + ).toBe(true); + + return result.settings; +} + +function settingValue(settings, name, why) { + const found = settings.find((s) => s && s.setting === name); + expect(found, why).toBeTruthy(); + return String(found.value); +} + +test("discourse-bbb: the BigBlueButton plugin is installed and points at the distinct conferencing partner", async ({ page }) => { + skipUnlessAddonEnabled("discourse-bbb"); + skipUnlessServiceEnabled("sso"); + test.setTimeout(resolveTimeout(120_000)); + + expect(oidcIssuerUrl, "OIDC_ISSUER_URL must be set").toBeTruthy(); + expect(discourseBaseUrl, "DISCOURSE_BASE_URL must be set").toBeTruthy(); + expect(adminUsername, "ADMIN_USERNAME must be set").toBeTruthy(); + expect(adminPassword, "ADMIN_PASSWORD must be set").toBeTruthy(); + + const discourseHost = new URL(discourseBaseUrl).host; + + try { + await page.context().clearCookies(); + await signInViaOidc(page); + + await expect(page.locator("body")).toContainText( + /topic|category|welcome|latest|discourse/i, + { timeout: resolveTimeout(60_000) }, + ); + + const settings = await readSiteSettings(page); + + expect( + settingValue( + settings, + "bbb_enabled", + "bbb_enabled site setting must exist (discourse-bbb plugin compiled into the image)", + ).toLowerCase(), + "bbb_enabled must be active so composer posts can embed a conference", + ).toBe("true"); + + const endpoint = settingValue( + settings, + "bbb_endpoint", + "bbb_endpoint site setting must exist (discourse-bbb plugin installed)", + ).trim(); + + expect( + endpoint, + "bbb_endpoint must be an absolute URL of the BigBlueButton API so the plugin can create meetings", + ).toMatch(/^https?:\/\//i); + expect( + new URL(endpoint).host.toLowerCase(), + "bbb_endpoint must target the BigBlueButton partner host, NOT Discourse itself — otherwise no conference server is reached", + ).not.toBe(discourseHost.toLowerCase()); + + expect( + settingValue( + settings, + "bbb_secret", + "bbb_secret site setting must exist (discourse-bbb plugin installed)", + ).trim().length, + "bbb_secret must be provisioned so the plugin can sign BigBlueButton API calls; an empty secret makes every create/join call fail", + ).toBeGreaterThan(0); + } finally { + await page.context().clearCookies().catch(() => {}); + } +}); diff --git a/roles/web-app-discourse/files/playwright/addons/discourse-chat-integration.spec.js b/roles/web-app-discourse/files/playwright/addons/discourse-chat-integration.spec.js new file mode 100644 index 0000000000..4e8e69cf9c --- /dev/null +++ b/roles/web-app-discourse/files/playwright/addons/discourse-chat-integration.spec.js @@ -0,0 +1,145 @@ +const { test, expect } = require("@playwright/test"); +const { resolveTimeout } = require("../timeouts"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceEnabled } = require("../service-gating"); +const { normalizeBaseUrl, decodeDotenvQuotedValue, performKeycloakLoginForm, gotoOnion } = require("../personas"); + +test.use({ ignoreHTTPSErrors: true }); + +const oidcIssuerUrl = normalizeBaseUrl(process.env.OIDC_ISSUER_URL || ""); +const discourseBaseUrl = normalizeBaseUrl(process.env.DISCOURSE_BASE_URL || ""); +const adminUsername = decodeDotenvQuotedValue(process.env.ADMIN_USERNAME); +const adminPassword = decodeDotenvQuotedValue(process.env.ADMIN_PASSWORD); + +async function signInViaOidc(page) { + const expectedOidcAuthUrl = `${oidcIssuerUrl}/protocol/openid-connect/auth`; + + await gotoOnion(page, `${discourseBaseUrl}/`); + + const oidcSignIn = page + .locator("a, button") + .filter({ hasText: /sign\s*in\s+with\s+oidc|sign\s*in\s+with\s+sso|continue\s+with\s+oidc|continue\s+with\s+sso|single\s+sign[-\s]*on|log\s*in|sign\s*up/i }) + .first(); + + if ((await oidcSignIn.count().catch(() => 0)) > 0) { + await oidcSignIn.click({ timeout: resolveTimeout(30_000) }); + } else { + await gotoOnion(page, `${discourseBaseUrl}/auth/oidc`).catch(() => {}); + } + + await expect + .poll(() => page.url(), { + timeout: resolveTimeout(60_000), + message: `expected redirect to Keycloak OIDC auth (${expectedOidcAuthUrl})`, + }) + .toContain(expectedOidcAuthUrl); + + await performKeycloakLoginForm(page, adminUsername, adminPassword); + + await expect + .poll(() => page.url(), { + timeout: resolveTimeout(60_000), + message: `expected redirect back to discourse at ${discourseBaseUrl}`, + }) + .toContain(discourseBaseUrl); +} + +async function readSiteSettings(page) { + const result = await page.evaluate(async (base) => { + const res = await fetch(`${base}/admin/site_settings.json`, { + headers: { Accept: "application/json" }, + credentials: "include", + }); + if (!res.ok) return { ok: false, status: res.status }; + const body = await res.json(); + return { ok: true, settings: (body && body.site_settings) || [] }; + }, discourseBaseUrl); + + expect( + result.ok, + `expected /admin/site_settings.json to be reachable as admin (status ${result.status})`, + ).toBe(true); + + return result.settings; +} + +function settingValue(settings, name, why) { + const found = settings.find((s) => s && s.setting === name); + expect(found, why).toBeTruthy(); + return String(found.value); +} + +test("discourse-chat-integration: the chat plugin is installed and offers the Matrix and Mattermost partner providers", async ({ page }) => { + skipUnlessAddonEnabled("discourse-chat-integration"); + skipUnlessServiceEnabled("sso"); + test.setTimeout(resolveTimeout(120_000)); + + expect(oidcIssuerUrl, "OIDC_ISSUER_URL must be set").toBeTruthy(); + expect(discourseBaseUrl, "DISCOURSE_BASE_URL must be set").toBeTruthy(); + expect(adminUsername, "ADMIN_USERNAME must be set").toBeTruthy(); + expect(adminPassword, "ADMIN_PASSWORD must be set").toBeTruthy(); + + try { + await page.context().clearCookies(); + await signInViaOidc(page); + + await expect(page.locator("body")).toContainText( + /topic|category|welcome|latest|discourse/i, + { timeout: resolveTimeout(60_000) }, + ); + + const settings = await readSiteSettings(page); + + expect( + settingValue( + settings, + "chat_integration_enabled", + "chat_integration_enabled site setting must exist (discourse-chat-integration plugin compiled into the image)", + ).toLowerCase(), + "chat_integration_enabled must be active so topic notifications can leave Discourse for a chat partner", + ).toBe("true"); + + settingValue( + settings, + "chat_integration_matrix_homeserver", + "chat_integration_matrix_homeserver must exist so the Matrix provider has a homeserver field to address the partner with", + ); + + settingValue( + settings, + "chat_integration_mattermost_webhook_url", + "chat_integration_mattermost_webhook_url must exist so the Mattermost provider has a webhook field to address the partner with", + ); + + const providers = await page.evaluate(async (base) => { + const res = await fetch(`${base}/admin/plugins/chat-integration/providers.json`, { + headers: { Accept: "application/json" }, + credentials: "include", + }); + let json; + try { + json = await res.json(); + } catch { + json = null; + } + return { status: res.status, json }; + }, discourseBaseUrl); + + expect( + providers.status, + "the plugin's provider catalogue route must be served; a 404 proves the plugin did not land in the image", + ).toBeLessThan(400); + + const catalogue = JSON.stringify(providers.json || {}); + expect( + catalogue, + "the provider catalogue must name the Matrix partner this deployment bridges", + ).toMatch(/matrix/i); + expect( + catalogue, + "the provider catalogue must name the Mattermost partner this deployment bridges", + ).toMatch(/mattermost/i); + } finally { + await page.context().clearCookies().catch(() => {}); + } +}); diff --git a/roles/web-app-discourse/files/playwright/addons/discourse-jitsi.spec.js b/roles/web-app-discourse/files/playwright/addons/discourse-jitsi.spec.js new file mode 100644 index 0000000000..4a1431f56e --- /dev/null +++ b/roles/web-app-discourse/files/playwright/addons/discourse-jitsi.spec.js @@ -0,0 +1,124 @@ +const { test, expect } = require("@playwright/test"); +const { resolveTimeout } = require("../timeouts"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceEnabled } = require("../service-gating"); +const { normalizeBaseUrl, decodeDotenvQuotedValue, performKeycloakLoginForm, gotoOnion } = require("../personas"); + +test.use({ ignoreHTTPSErrors: true }); + +const oidcIssuerUrl = normalizeBaseUrl(process.env.OIDC_ISSUER_URL || ""); +const discourseBaseUrl = normalizeBaseUrl(process.env.DISCOURSE_BASE_URL || ""); +const adminUsername = decodeDotenvQuotedValue(process.env.ADMIN_USERNAME); +const adminPassword = decodeDotenvQuotedValue(process.env.ADMIN_PASSWORD); + +async function signInViaOidc(page) { + const expectedOidcAuthUrl = `${oidcIssuerUrl}/protocol/openid-connect/auth`; + + await gotoOnion(page, `${discourseBaseUrl}/`); + + const oidcSignIn = page + .locator("a, button") + .filter({ hasText: /sign\s*in\s+with\s+oidc|sign\s*in\s+with\s+sso|continue\s+with\s+oidc|continue\s+with\s+sso|single\s+sign[-\s]*on|log\s*in|sign\s*up/i }) + .first(); + + if ((await oidcSignIn.count().catch(() => 0)) > 0) { + await oidcSignIn.click({ timeout: resolveTimeout(30_000) }); + } else { + await gotoOnion(page, `${discourseBaseUrl}/auth/oidc`).catch(() => {}); + } + + await expect + .poll(() => page.url(), { + timeout: resolveTimeout(60_000), + message: `expected redirect to Keycloak OIDC auth (${expectedOidcAuthUrl})`, + }) + .toContain(expectedOidcAuthUrl); + + await performKeycloakLoginForm(page, adminUsername, adminPassword); + + await expect + .poll(() => page.url(), { + timeout: resolveTimeout(60_000), + message: `expected redirect back to discourse at ${discourseBaseUrl}`, + }) + .toContain(discourseBaseUrl); +} + +async function readSiteSettings(page) { + const result = await page.evaluate(async (base) => { + const res = await fetch(`${base}/admin/site_settings.json`, { + headers: { Accept: "application/json" }, + credentials: "include", + }); + if (!res.ok) return { ok: false, status: res.status }; + const body = await res.json(); + return { ok: true, settings: (body && body.site_settings) || [] }; + }, discourseBaseUrl); + + expect( + result.ok, + `expected /admin/site_settings.json to be reachable as admin (status ${result.status})`, + ).toBe(true); + + return result.settings; +} + +function settingValue(settings, name, why) { + const found = settings.find((s) => s && s.setting === name); + expect(found, why).toBeTruthy(); + return String(found.value); +} + +test("discourse-jitsi: the Jitsi plugin is installed and embeds the distinct meeting partner domain", async ({ page }) => { + skipUnlessAddonEnabled("discourse-jitsi"); + skipUnlessServiceEnabled("sso"); + test.setTimeout(resolveTimeout(120_000)); + + expect(oidcIssuerUrl, "OIDC_ISSUER_URL must be set").toBeTruthy(); + expect(discourseBaseUrl, "DISCOURSE_BASE_URL must be set").toBeTruthy(); + expect(adminUsername, "ADMIN_USERNAME must be set").toBeTruthy(); + expect(adminPassword, "ADMIN_PASSWORD must be set").toBeTruthy(); + + const discourseHost = new URL(discourseBaseUrl).host; + + try { + await page.context().clearCookies(); + await signInViaOidc(page); + + await expect(page.locator("body")).toContainText( + /topic|category|welcome|latest|discourse/i, + { timeout: resolveTimeout(60_000) }, + ); + + const settings = await readSiteSettings(page); + + expect( + settingValue( + settings, + "jitsi_enabled", + "jitsi_enabled site setting must exist (discourse-jitsi plugin compiled into the image)", + ).toLowerCase(), + "jitsi_enabled must be active so the composer offers a Jitsi meeting button", + ).toBe("true"); + + const jitsiDomain = settingValue( + settings, + "jitsi_domain", + "jitsi_domain site setting must exist (discourse-jitsi plugin installed)", + ) + .trim() + .replace(/^https?:\/\//i, "") + .replace(/\/.*$/, ""); + + expect( + jitsiDomain.length, + "jitsi_domain must name the Jitsi partner host so the embedded iframe has a conference server to load", + ).toBeGreaterThan(0); + expect( + jitsiDomain.toLowerCase(), + "jitsi_domain must be the Jitsi partner host, NOT Discourse itself — otherwise the iframe loads the forum into itself instead of a meeting", + ).not.toBe(discourseHost.toLowerCase()); + } finally { + await page.context().clearCookies().catch(() => {}); + } +}); diff --git a/roles/web-app-discourse/files/playwright/addons/discourse-openid-connect.spec.js b/roles/web-app-discourse/files/playwright/addons/discourse-openid-connect.spec.js new file mode 100644 index 0000000000..bcc5ee0a45 --- /dev/null +++ b/roles/web-app-discourse/files/playwright/addons/discourse-openid-connect.spec.js @@ -0,0 +1,135 @@ +const { test, expect } = require("@playwright/test"); +const { resolveTimeout } = require("../timeouts"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceEnabled } = require("../service-gating"); +const { normalizeBaseUrl, decodeDotenvQuotedValue, performKeycloakLoginForm, gotoOnion } = require("../personas"); + +test.use({ ignoreHTTPSErrors: true }); + +const oidcIssuerUrl = normalizeBaseUrl(process.env.OIDC_ISSUER_URL || ""); +const discourseBaseUrl = normalizeBaseUrl(process.env.DISCOURSE_BASE_URL || ""); +const adminUsername = decodeDotenvQuotedValue(process.env.ADMIN_USERNAME); +const adminPassword = decodeDotenvQuotedValue(process.env.ADMIN_PASSWORD); + +async function signInViaOidc(page) { + const expectedOidcAuthUrl = `${oidcIssuerUrl}/protocol/openid-connect/auth`; + + await gotoOnion(page, `${discourseBaseUrl}/`); + + const oidcSignIn = page + .locator("a, button") + .filter({ hasText: /sign\s*in\s+with\s+oidc|sign\s*in\s+with\s+sso|continue\s+with\s+oidc|continue\s+with\s+sso|single\s+sign[-\s]*on|log\s*in|sign\s*up/i }) + .first(); + + if ((await oidcSignIn.count().catch(() => 0)) > 0) { + await oidcSignIn.click({ timeout: resolveTimeout(30_000) }); + } else { + await gotoOnion(page, `${discourseBaseUrl}/auth/oidc`).catch(() => {}); + } + + await expect + .poll(() => page.url(), { + timeout: resolveTimeout(60_000), + message: `expected redirect to Keycloak OIDC auth (${expectedOidcAuthUrl})`, + }) + .toContain(expectedOidcAuthUrl); + + await performKeycloakLoginForm(page, adminUsername, adminPassword); + + await expect + .poll(() => page.url(), { + timeout: resolveTimeout(60_000), + message: `expected redirect back to discourse at ${discourseBaseUrl}`, + }) + .toContain(discourseBaseUrl); +} + +async function readSiteSettings(page) { + const result = await page.evaluate(async (base) => { + const res = await fetch(`${base}/admin/site_settings.json`, { + headers: { Accept: "application/json" }, + credentials: "include", + }); + if (!res.ok) return { ok: false, status: res.status }; + const body = await res.json(); + return { ok: true, settings: (body && body.site_settings) || [] }; + }, discourseBaseUrl); + + expect( + result.ok, + `expected /admin/site_settings.json to be reachable as admin (status ${result.status})`, + ).toBe(true); + + return result.settings; +} + +function settingValue(settings, name, why) { + const found = settings.find((s) => s && s.setting === name); + expect(found, why).toBeTruthy(); + return String(found.value); +} + +test("discourse-openid-connect: the OIDC plugin drives login against the distinct Keycloak partner", async ({ page }) => { + skipUnlessAddonEnabled("discourse-openid-connect"); + skipUnlessServiceEnabled("sso"); + test.setTimeout(resolveTimeout(120_000)); + + expect(oidcIssuerUrl, "OIDC_ISSUER_URL must be set").toBeTruthy(); + expect(discourseBaseUrl, "DISCOURSE_BASE_URL must be set").toBeTruthy(); + expect(adminUsername, "ADMIN_USERNAME must be set").toBeTruthy(); + expect(adminPassword, "ADMIN_PASSWORD must be set").toBeTruthy(); + + const discourseHost = new URL(discourseBaseUrl).host; + const issuerHost = new URL(oidcIssuerUrl).host; + + try { + await page.context().clearCookies(); + await signInViaOidc(page); + + await expect(page.locator("body")).toContainText( + /topic|category|welcome|latest|discourse/i, + { timeout: resolveTimeout(60_000) }, + ); + + const settings = await readSiteSettings(page); + + expect( + settingValue( + settings, + "openid_connect_enabled", + "openid_connect_enabled site setting must exist (the bundled OIDC plugin is part of the Discourse image)", + ).toLowerCase(), + "openid_connect_enabled must be active whenever the sso service is part of the deployment", + ).toBe("true"); + + const discovery = settingValue( + settings, + "openid_connect_discovery_document", + "openid_connect_discovery_document site setting must exist so the plugin can resolve the partner's endpoints", + ).trim(); + + expect( + discovery, + "the discovery document must be an absolute URL of the identity partner", + ).toMatch(/^https?:\/\//i); + expect( + new URL(discovery).host.toLowerCase(), + "the discovery document must point at the Keycloak partner host, NOT at Discourse itself", + ).not.toBe(discourseHost.toLowerCase()); + expect( + new URL(discovery).host.toLowerCase(), + "the discovery document must point at the very issuer the login redirect went through, proving one identity partner rather than two unrelated configurations", + ).toBe(issuerHost.toLowerCase()); + + expect( + settingValue( + settings, + "openid_connect_client_id", + "openid_connect_client_id site setting must exist", + ).trim().length, + "openid_connect_client_id must be provisioned; an empty client id makes every authorization request fail at the partner", + ).toBeGreaterThan(0); + } finally { + await page.context().clearCookies().catch(() => {}); + } +}); diff --git a/roles/web-app-discourse/files/playwright/addons/discourse-prometheus.spec.js b/roles/web-app-discourse/files/playwright/addons/discourse-prometheus.spec.js new file mode 100644 index 0000000000..eff2fef0f8 --- /dev/null +++ b/roles/web-app-discourse/files/playwright/addons/discourse-prometheus.spec.js @@ -0,0 +1,119 @@ +const { test, expect } = require("@playwright/test"); +const { resolveTimeout } = require("../timeouts"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceEnabled } = require("../service-gating"); +const { normalizeBaseUrl, decodeDotenvQuotedValue, performKeycloakLoginForm, gotoOnion } = require("../personas"); + +test.use({ ignoreHTTPSErrors: true }); + +const oidcIssuerUrl = normalizeBaseUrl(process.env.OIDC_ISSUER_URL || ""); +const discourseBaseUrl = normalizeBaseUrl(process.env.DISCOURSE_BASE_URL || ""); +const adminUsername = decodeDotenvQuotedValue(process.env.ADMIN_USERNAME); +const adminPassword = decodeDotenvQuotedValue(process.env.ADMIN_PASSWORD); + +async function signInViaOidc(page) { + const expectedOidcAuthUrl = `${oidcIssuerUrl}/protocol/openid-connect/auth`; + + await gotoOnion(page, `${discourseBaseUrl}/`); + + const oidcSignIn = page + .locator("a, button") + .filter({ hasText: /sign\s*in\s+with\s+oidc|sign\s*in\s+with\s+sso|continue\s+with\s+oidc|continue\s+with\s+sso|single\s+sign[-\s]*on|log\s*in|sign\s*up/i }) + .first(); + + if ((await oidcSignIn.count().catch(() => 0)) > 0) { + await oidcSignIn.click({ timeout: resolveTimeout(30_000) }); + } else { + await gotoOnion(page, `${discourseBaseUrl}/auth/oidc`).catch(() => {}); + } + + await expect + .poll(() => page.url(), { + timeout: resolveTimeout(60_000), + message: `expected redirect to Keycloak OIDC auth (${expectedOidcAuthUrl})`, + }) + .toContain(expectedOidcAuthUrl); + + await performKeycloakLoginForm(page, adminUsername, adminPassword); + + await expect + .poll(() => page.url(), { + timeout: resolveTimeout(60_000), + message: `expected redirect back to discourse at ${discourseBaseUrl}`, + }) + .toContain(discourseBaseUrl); +} + +async function readSiteSettings(page) { + const result = await page.evaluate(async (base) => { + const res = await fetch(`${base}/admin/site_settings.json`, { + headers: { Accept: "application/json" }, + credentials: "include", + }); + if (!res.ok) return { ok: false, status: res.status }; + const body = await res.json(); + return { ok: true, settings: (body && body.site_settings) || [] }; + }, discourseBaseUrl); + + expect( + result.ok, + `expected /admin/site_settings.json to be reachable as admin (status ${result.status})`, + ).toBe(true); + + return result.settings; +} + +function settingValue(settings, name, why) { + const found = settings.find((s) => s && s.setting === name); + expect(found, why).toBeTruthy(); + return String(found.value); +} + +test("discourse-prometheus: the exporter plugin is installed and its scrape collector is addressable", async ({ page }) => { + skipUnlessAddonEnabled("discourse-prometheus"); + skipUnlessServiceEnabled("sso"); + test.setTimeout(resolveTimeout(120_000)); + + expect(oidcIssuerUrl, "OIDC_ISSUER_URL must be set").toBeTruthy(); + expect(discourseBaseUrl, "DISCOURSE_BASE_URL must be set").toBeTruthy(); + expect(adminUsername, "ADMIN_USERNAME must be set").toBeTruthy(); + expect(adminPassword, "ADMIN_PASSWORD must be set").toBeTruthy(); + + try { + await page.context().clearCookies(); + await signInViaOidc(page); + + await expect(page.locator("body")).toContainText( + /topic|category|welcome|latest|discourse/i, + { timeout: resolveTimeout(60_000) }, + ); + + const settings = await readSiteSettings(page); + + const collectorPort = settingValue( + settings, + "prometheus_collector_port", + "prometheus_collector_port site setting must exist (discourse-prometheus plugin compiled into the image)", + ).trim(); + + expect( + collectorPort, + "prometheus_collector_port must be a numeric TCP port; without it the Prometheus partner has nothing to scrape", + ).toMatch(/^[0-9]+$/); + expect( + Number(collectorPort), + "prometheus_collector_port must be a valid TCP port", + ).toBeGreaterThan(0); + + expect( + settingValue( + settings, + "prometheus_trusted_ip_allowlist_regex", + "prometheus_trusted_ip_allowlist_regex site setting must exist so the metrics surface can be opened to the Prometheus partner only", + ), + "the allowlist setting must be a string the plugin can match scrape sources against", + ).not.toBeNull(); + } finally { + await page.context().clearCookies().catch(() => {}); + } +}); diff --git a/roles/web-app-discourse/files/playwright/addons/docker_manager.spec.js b/roles/web-app-discourse/files/playwright/addons/docker_manager.spec.js index 548178f224..a9cb930e85 100644 --- a/roles/web-app-discourse/files/playwright/addons/docker_manager.spec.js +++ b/roles/web-app-discourse/files/playwright/addons/docker_manager.spec.js @@ -1,6 +1,7 @@ const { test, expect } = require("@playwright/test"); const { resolveTimeout } = require("../timeouts"); const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceEnabled } = require("../service-gating"); const { normalizeBaseUrl, decodeDotenvQuotedValue, performKeycloakLoginForm, gotoOnion } = require("../personas"); test.use({ ignoreHTTPSErrors: true }); @@ -49,6 +50,7 @@ function pluginName(plugin) { test("docker_manager: the docker_manager plugin is installed and registered on the Discourse instance", async ({ page }) => { skipUnlessAddonEnabled("docker_manager"); + skipUnlessServiceEnabled("sso"); expect(oidcIssuerUrl, "OIDC_ISSUER_URL must be set").toBeTruthy(); expect(discourseBaseUrl, "DISCOURSE_BASE_URL must be set").toBeTruthy(); diff --git a/roles/web-app-discourse/meta/addons/discourse-activity-pub.yml b/roles/web-app-discourse/meta/addons/discourse-activity-pub.yml index 05bcb24e16..117ee02381 100644 --- a/roles/web-app-discourse/meta/addons/discourse-activity-pub.yml +++ b/roles/web-app-discourse/meta/addons/discourse-activity-pub.yml @@ -4,6 +4,8 @@ enabled: true required: false mechanism: plugin source: upstream +bridges: + - mastodon update: monitored: true catalog: discourse-meta diff --git a/roles/web-app-discourse/meta/addons/discourse-ai.yml b/roles/web-app-discourse/meta/addons/discourse-ai.yml index 9190bc2843..e630619491 100644 --- a/roles/web-app-discourse/meta/addons/discourse-ai.yml +++ b/roles/web-app-discourse/meta/addons/discourse-ai.yml @@ -2,7 +2,7 @@ enabled: "{{ lookup('config', 'web-app-discourse', 'services.litellm.enabled') | bool }}" required: true mechanism: plugin -source: bundled # Exception: cloning it over the copy already in $home/plugins aborts the after_code hook +source: bundled bridges: - litellm config: diff --git a/roles/web-app-discourse/meta/addons/discourse-bbb.yml b/roles/web-app-discourse/meta/addons/discourse-bbb.yml new file mode 100644 index 0000000000..c8998a14ae --- /dev/null +++ b/roles/web-app-discourse/meta/addons/discourse-bbb.yml @@ -0,0 +1,14 @@ +--- +enabled: "{{ lookup('config', 'web-app-discourse', 'services.bigbluebutton.enabled') | bool }}" +required: false +mechanism: plugin +source: upstream +bridges: + - bigbluebutton +update: + monitored: true + catalog: discourse-meta + upstream_id: discourse-bbb +config: + repository: https://github.com/discourse/discourse-bbb.git + ref: main diff --git a/roles/web-app-discourse/meta/addons/discourse-chat-integration.yml b/roles/web-app-discourse/meta/addons/discourse-chat-integration.yml new file mode 100644 index 0000000000..766894748f --- /dev/null +++ b/roles/web-app-discourse/meta/addons/discourse-chat-integration.yml @@ -0,0 +1,16 @@ +--- +enabled: "{{ (lookup('config', 'web-app-discourse', 'services.matrix.enabled') | bool) or (lookup('config', 'web-app-discourse', 'services.mattermost.enabled') | + bool) }}" +required: false +mechanism: plugin +source: upstream +bridges: + - matrix + - mattermost +update: + monitored: true + catalog: discourse-meta + upstream_id: discourse-chat-integration +config: + repository: https://github.com/discourse/discourse-chat-integration.git + ref: main diff --git a/roles/web-app-discourse/meta/addons/discourse-jitsi.yml b/roles/web-app-discourse/meta/addons/discourse-jitsi.yml new file mode 100644 index 0000000000..6117e1efb4 --- /dev/null +++ b/roles/web-app-discourse/meta/addons/discourse-jitsi.yml @@ -0,0 +1,14 @@ +--- +enabled: "{{ lookup('config', 'web-app-discourse', 'services.jitsi.enabled') | bool }}" +required: false +mechanism: plugin +source: upstream +bridges: + - jitsi +update: + monitored: true + catalog: discourse-meta + upstream_id: discourse-jitsi +config: + repository: https://github.com/discourse/discourse-jitsi.git + ref: main diff --git a/roles/web-app-discourse/meta/addons/discourse-openid-connect.yml b/roles/web-app-discourse/meta/addons/discourse-openid-connect.yml new file mode 100644 index 0000000000..1bd15b1f75 --- /dev/null +++ b/roles/web-app-discourse/meta/addons/discourse-openid-connect.yml @@ -0,0 +1,7 @@ +--- +enabled: "{{ lookup('config', 'web-app-discourse', 'services.sso.enabled') | bool }}" +required: false +mechanism: plugin +source: bundled +bridges: + - sso diff --git a/roles/web-app-discourse/meta/addons/discourse-prometheus.yml b/roles/web-app-discourse/meta/addons/discourse-prometheus.yml new file mode 100644 index 0000000000..838412207b --- /dev/null +++ b/roles/web-app-discourse/meta/addons/discourse-prometheus.yml @@ -0,0 +1,14 @@ +--- +enabled: "{{ lookup('config', 'web-app-discourse', 'services.prometheus.enabled') | bool }}" +required: false +mechanism: plugin +source: upstream +bridges: + - prometheus +update: + monitored: true + catalog: discourse-meta + upstream_id: discourse-prometheus +config: + repository: https://github.com/discourse/discourse-prometheus.git + ref: main diff --git a/roles/web-app-discourse/tasks/addons/discourse-bbb.yml b/roles/web-app-discourse/tasks/addons/discourse-bbb.yml new file mode 100644 index 0000000000..ed97d539c0 --- /dev/null +++ b/roles/web-app-discourse/tasks/addons/discourse-bbb.yml @@ -0,0 +1 @@ +--- diff --git a/roles/web-app-discourse/tasks/addons/discourse-chat-integration.yml b/roles/web-app-discourse/tasks/addons/discourse-chat-integration.yml new file mode 100644 index 0000000000..ed97d539c0 --- /dev/null +++ b/roles/web-app-discourse/tasks/addons/discourse-chat-integration.yml @@ -0,0 +1 @@ +--- diff --git a/roles/web-app-discourse/tasks/addons/discourse-jitsi.yml b/roles/web-app-discourse/tasks/addons/discourse-jitsi.yml new file mode 100644 index 0000000000..ed97d539c0 --- /dev/null +++ b/roles/web-app-discourse/tasks/addons/discourse-jitsi.yml @@ -0,0 +1 @@ +--- diff --git a/roles/web-app-discourse/tasks/addons/discourse-openid-connect.yml b/roles/web-app-discourse/tasks/addons/discourse-openid-connect.yml new file mode 100644 index 0000000000..ed97d539c0 --- /dev/null +++ b/roles/web-app-discourse/tasks/addons/discourse-openid-connect.yml @@ -0,0 +1 @@ +--- diff --git a/roles/web-app-discourse/tasks/addons/discourse-prometheus.yml b/roles/web-app-discourse/tasks/addons/discourse-prometheus.yml new file mode 100644 index 0000000000..ed97d539c0 --- /dev/null +++ b/roles/web-app-discourse/tasks/addons/discourse-prometheus.yml @@ -0,0 +1 @@ +--- diff --git a/roles/web-app-erpnext/files/playwright/addons/email_account.spec.js b/roles/web-app-erpnext/files/playwright/addons/email_account.spec.js new file mode 100644 index 0000000000..c2b744067c --- /dev/null +++ b/roles/web-app-erpnext/files/playwright/addons/email_account.spec.js @@ -0,0 +1,49 @@ +const { test, expect } = require("@playwright/test"); +const { resolveTimeout } = require("../timeouts"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceEnabled } = require("../service-gating"); +const { decodeDotenvQuotedValue } = require("../personas"); +const shared = require("../_shared"); + +test.use({ ignoreHTTPSErrors: true }); + +const smtpHost = decodeDotenvQuotedValue(process.env.EMAIL_SMTP_HOST || ""); + +const ACCOUNTS_ROUTE = + '/api/resource/Email Account?limit_page_length=0&fields=["name","smtp_server","enable_outgoing"]'; + +test("addon email_account: ERPNext's outgoing account sends through the deployed Mailu SMTP host", async ({ page }) => { + skipUnlessAddonEnabled("email_account"); + skipUnlessServiceEnabled("email"); + test.setTimeout(resolveTimeout(240_000)); + + const { erpnextBaseUrl, adminNativePassword } = shared.env; + expect(erpnextBaseUrl, "ERPNEXT_BASE_URL must be set").toBeTruthy(); + expect(smtpHost, "EMAIL_SMTP_HOST must be set when the email service is on").toBeTruthy(); + expect(adminNativePassword, "ADMIN_NATIVE_PASSWORD must be set").toBeTruthy(); + + await page.context().clearCookies(); + await shared.signInViaErpnextLocal(page, "Administrator", adminNativePassword, "addon-email-account"); + + const response = await page.request.get(`${erpnextBaseUrl}${ACCOUNTS_ROUTE}`, { + timeout: resolveTimeout(60_000), + }); + expect( + response.status(), + "the Email Account resource must answer for the signed-in administrator", + ).toBeLessThan(400); + + const accounts = (await response.json()).data || []; + const outgoing = accounts.filter((account) => Number(account.enable_outgoing) === 1); + + expect( + outgoing.length, + "Frappe must hold at least one outgoing Email Account; without it nothing in ERPNext can " + + "send and the declared Mailu bridge is inert", + ).toBeGreaterThan(0); + expect( + outgoing.map((account) => account.smtp_server), + `an outgoing Email Account must name the deployed Mailu host (${smtpHost}); another value ` + + "means the account was provisioned against a different transport", + ).toContain(smtpHost); +}); diff --git a/roles/web-app-erpnext/files/playwright/addons/social_login_key.spec.js b/roles/web-app-erpnext/files/playwright/addons/social_login_key.spec.js new file mode 100644 index 0000000000..7138dd198b --- /dev/null +++ b/roles/web-app-erpnext/files/playwright/addons/social_login_key.spec.js @@ -0,0 +1,49 @@ +const { test, expect } = require("@playwright/test"); +const { resolveTimeout } = require("../timeouts"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceEnabled } = require("../service-gating"); +const { gotoOnion } = require("../personas"); +const shared = require("../_shared"); + +test.use({ ignoreHTTPSErrors: true }); + +test("addon social_login_key: Frappe's login offers the deployed Keycloak and hands over to it", async ({ page }) => { + skipUnlessAddonEnabled("social_login_key"); + skipUnlessServiceEnabled("sso"); + test.setTimeout(resolveTimeout(180_000)); + + const { erpnextBaseUrl, oidcIssuerUrl } = shared.env; + expect(erpnextBaseUrl, "ERPNEXT_BASE_URL must be set").toBeTruthy(); + expect(oidcIssuerUrl, "OIDC_ISSUER_URL must be set when SSO is on").toBeTruthy(); + + await page.context().clearCookies(); + await gotoOnion(page, `${erpnextBaseUrl}/login`); + + const oidcSignIn = page + .locator("a, button") + .filter({ hasText: /sso\s*login|sign\s*in\s+with|continue\s+with|single\s+sign[-\s]*on|keycloak|infinito/i }) + .first(); + + await expect( + oidcSignIn, + "the Social Login Key must render its provider button on /login; an absent button means the " + + "doctype was never written or the Frappe workers did not pick it up", + ).toBeVisible({ timeout: resolveTimeout(60_000) }); + + await oidcSignIn.click({ timeout: resolveTimeout(30_000) }); + + const expectedAuthUrl = `${oidcIssuerUrl}/protocol/openid-connect/auth`; + await expect + .poll(() => page.url(), { + timeout: resolveTimeout(60_000), + message: + `the provider button must hand over to the configured issuer (${expectedAuthUrl}); a ` + + "different host means the Social Login Key points at another Keycloak than the deployed one", + }) + .toContain(expectedAuthUrl); + + expect( + new URL(page.url()).searchParams.get("client_id"), + "the authorization request must carry the OIDC client id this deployment registered", + ).toBeTruthy(); +}); diff --git a/roles/web-app-erpnext/meta/addons/email_account.yml b/roles/web-app-erpnext/meta/addons/email_account.yml new file mode 100644 index 0000000000..80c996308f --- /dev/null +++ b/roles/web-app-erpnext/meta/addons/email_account.yml @@ -0,0 +1,7 @@ +--- +enabled: "{{ lookup('config', 'web-app-erpnext', 'services.email.enabled') | bool }}" +required: false +mechanism: module +source: bundled +bridges: + - email diff --git a/roles/web-app-erpnext/meta/addons/social_login_key.yml b/roles/web-app-erpnext/meta/addons/social_login_key.yml new file mode 100644 index 0000000000..22912dc07e --- /dev/null +++ b/roles/web-app-erpnext/meta/addons/social_login_key.yml @@ -0,0 +1,7 @@ +--- +enabled: "{{ lookup('config', 'web-app-erpnext', 'services.sso.enabled') | bool }}" +required: false +mechanism: module +source: bundled +bridges: + - sso diff --git a/roles/web-app-erpnext/tasks/addons/email_account.yml b/roles/web-app-erpnext/tasks/addons/email_account.yml new file mode 100644 index 0000000000..5b7b64db86 --- /dev/null +++ b/roles/web-app-erpnext/tasks/addons/email_account.yml @@ -0,0 +1,24 @@ +--- +- name: "📌 apply outbound Email Account (Mailu SMTP; inbound IMAP deferred)" + no_log: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}" + ansible.builtin.shell: + cmd: > # nocheck: container-exec-resolver runtime-resolved CID, delegated to the hosting node + container exec -i + -e SITE_NAME -e MAIL_FROM_NAME -e MAIL_FROM_ADDRESS + -e SMTP_HOST -e SMTP_PORT -e SMTP_USER -e SMTP_PASS + {{ ERPNEXT_BACKEND_LOCAL_CID | quote }} + {{ ERPNEXT_BENCH_PYTHON }} + stdin: "{{ lookup('ansible.builtin.file', role_path ~ '/files/python/apply/email_account.py') }}" + delegate_to: "{{ ERPNEXT_BACKEND_HOST_NODE }}" + environment: + SITE_NAME: "{{ ERPNEXT_SITE_NAME }}" + MAIL_FROM_NAME: "{{ ORGANIZATION }} ERPNext" + MAIL_FROM_ADDRESS: "{{ ERPNEXT_MAIL.username | default('') }}" + SMTP_HOST: "{{ ERPNEXT_MAIL.host | default('') }}" + SMTP_PORT: "{{ ERPNEXT_MAIL.port | default(587) }}" + SMTP_USER: "{{ ERPNEXT_MAIL.username | default('') }}" + SMTP_PASS: "{{ ERPNEXT_MAIL.password | default('') }}" + when: ERPNEXT_MAIL.host is defined and (ERPNEXT_MAIL.host | length > 0) + register: erpnext_email_apply + changed_when: false + timeout: "{{ lookup('timeout', 60) | int }}" diff --git a/roles/web-app-erpnext/tasks/addons/social_login_key.yml b/roles/web-app-erpnext/tasks/addons/social_login_key.yml new file mode 100644 index 0000000000..82a910ab8c --- /dev/null +++ b/roles/web-app-erpnext/tasks/addons/social_login_key.yml @@ -0,0 +1,67 @@ +--- +- name: "📌 apply Social Login Key for Keycloak" + no_log: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}" + ansible.builtin.shell: + cmd: > # nocheck: container-exec-resolver runtime-resolved CID, delegated to the hosting node + container exec -i + -e SITE_NAME -e PROVIDER_NAME -e BUTTON_TEXT + -e CLIENT_ID -e CLIENT_SECRET -e ISSUER_URL + -e GROUP_ROLE_MAP_JSON + {{ ERPNEXT_BACKEND_LOCAL_CID | quote }} + {{ ERPNEXT_BENCH_PYTHON }} + stdin: "{{ lookup('ansible.builtin.file', role_path ~ '/files/python/apply/oidc_settings.py') }}" + delegate_to: "{{ ERPNEXT_BACKEND_HOST_NODE }}" + environment: + SITE_NAME: "{{ ERPNEXT_SITE_NAME }}" + PROVIDER_NAME: "keycloak" + BUTTON_TEXT: "{{ OIDC.BUTTON_TEXT }}" + CLIENT_ID: "{{ OIDC.CLIENT.ID }}" + CLIENT_SECRET: "{{ OIDC.CLIENT.SECRET }}" + ISSUER_URL: "{{ OIDC.CLIENT.ISSUER_URL }}" + GROUP_ROLE_MAP_JSON: "{{ ERPNEXT_OIDC_GROUP_ROLE_MAP | to_json }}" + register: erpnext_oidc_apply + changed_when: "'OIDC_SLK_CHANGED' in erpnext_oidc_apply.stdout" + timeout: "{{ lookup('timeout', 60) | int }}" + +- name: "🔄 Restart Frappe on Social Login Key change (compose)" + ansible.builtin.shell: | + set -euo pipefail + container restart {{ ERPNEXT_BACKEND_CONTAINER }} + changed_when: true + when: + - "'OIDC_SLK_CHANGED' in erpnext_oidc_apply.stdout" + - IS_COMPOSE_MODE + timeout: "{{ lookup('timeout', 120) | int }}" + +- name: "🔄 Restart Frappe on Social Login Key change (swarm)" + ansible.builtin.command: >- + container service update --force {{ entity_name }}_backend + changed_when: true + when: + - "'OIDC_SLK_CHANGED' in erpnext_oidc_apply.stdout" + - IS_SWARM_MODE + timeout: "{{ lookup('timeout', 600) | int }}" + +- name: "🔍 Re-resolve ERPNext backend node + CID after OIDC restart" + ansible.builtin.include_tasks: "{{ lookup('path_absolute', 'roles/sys-svc-compose/tasks/utils/swarm/resolve_host_cid.yml') }}" + vars: + resolve_service_key: backend + resolve_output_prefix: ERPNEXT_BACKEND + resolve_compose_cid: "{{ ERPNEXT_BACKEND_CONTAINER }}" + resolve_converge_retries: 60 + resolve_converge_delay: 5 + when: "'OIDC_SLK_CHANGED' in erpnext_oidc_apply.stdout" + +- name: "⏳ wait for {{ ERPNEXT_BACKEND_CONTAINER }} gunicorn TCP port after OIDC restart" + ansible.builtin.shell: | + set -eo pipefail + # nocheck: container-exec-resolver runtime-resolved CID, delegated to the hosting node + container exec {{ ERPNEXT_BACKEND_LOCAL_CID | quote }} \ + bash -c 'exec 3<>/dev/tcp/localhost/{{ ERPNEXT_BACKEND_PORT }} && exec 3<&- 3>&-' + delegate_to: "{{ ERPNEXT_BACKEND_HOST_NODE }}" + register: erpnext_backend_ready_post_oidc + changed_when: false + retries: 60 + delay: 5 + until: erpnext_backend_ready_post_oidc.rc == 0 + when: "'OIDC_SLK_CHANGED' in erpnext_oidc_apply.stdout" diff --git a/roles/web-app-erpnext/templates/playwright.env.j2 b/roles/web-app-erpnext/templates/playwright.env.j2 index e04b116d40..cd342d65e9 100644 --- a/roles/web-app-erpnext/templates/playwright.env.j2 +++ b/roles/web-app-erpnext/templates/playwright.env.j2 @@ -15,6 +15,8 @@ CANONICAL_DOMAIN={{ lookup('domain', application_id) | dotenv_quote }} # nocheck: playwright-service-gate — covered by sys-svc-mail integration tests, not the persona surface EMAIL_SERVICE_ENABLED={{ lookup('config', application_id, 'services.email.enabled') | string | lower }} +EMAIL_SMTP_HOST={{ ERPNEXT_MAIL.host | default('') | dotenv_quote }} + ERPNEXT_BASE_URL={{ lookup('tls', application_id, 'url.base') | dotenv_quote }} # nocheck: playwright-service-gate — persona drives OIDC path; LDAP federation exercised in LDAP-only matrix variant @@ -31,3 +33,5 @@ MATOMO_SERVICE_ENABLED={{ lookup('config', application_id, 'services.matomo.enab OIDC_ISSUER_URL={{ OIDC.CLIENT.ISSUER_URL | dotenv_quote }} SSO_SERVICE_ENABLED={{ ERPNEXT_OIDC_ENABLED | string | lower }} + +{{ lookup('addon_env_flags', application_id) }} diff --git a/roles/web-app-espocrm/files/playwright/addons/oidc.spec.js b/roles/web-app-espocrm/files/playwright/addons/oidc.spec.js new file mode 100644 index 0000000000..00f11ee43a --- /dev/null +++ b/roles/web-app-espocrm/files/playwright/addons/oidc.spec.js @@ -0,0 +1,55 @@ +const { test, expect } = require("@playwright/test"); +const { resolveTimeout } = require("../timeouts"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceEnabled } = require("../service-gating"); +const { clickOidcLoginLink, gotoOnion, normalizeBaseUrl } = require("../personas"); + +test.use({ ignoreHTTPSErrors: true }); + +const appBaseUrl = normalizeBaseUrl(process.env.APP_BASE_URL || ""); + +test("addon oidc: EspoCRM's sign-in hands over to the deployed Keycloak as its OIDC provider", async ({ page }) => { + skipUnlessAddonEnabled("oidc"); + skipUnlessServiceEnabled("sso"); + test.setTimeout(resolveTimeout(180_000)); + + expect(appBaseUrl, "APP_BASE_URL must be set").toBeTruthy(); + + const expectedBase = appBaseUrl.replace(/\/$/, ""); + await page.context().clearCookies(); + await gotoOnion(page, `${expectedBase}/`, { waitUntil: "domcontentloaded" }); + + let authPage = page; + if (!page.url().includes("openid-connect/auth")) { + const strictLogin = page + .getByRole("link", { name: /^\s*(log\s*in|sign\s*in|login|sso)\s*$/i }) + .or(page.getByRole("button", { name: /^\s*(log\s*in|sign\s*in|login|sso)\s*$/i })) + .first(); + const looseLogin = page + .getByRole("link", { name: /log\s*in|sign\s*in|sso/i }) + .or(page.getByRole("button", { name: /log\s*in|sign\s*in|sso/i })) + .first(); + authPage = (await clickOidcLoginLink(page, strictLogin, looseLogin)) || page; + } + + await expect + .poll(() => authPage.url(), { + timeout: resolveTimeout(60_000), + message: + "with authenticationMethod Oidc the sign-in must reach Keycloak's authorization " + + "endpoint; a login form that stays on EspoCRM means ESPOCRM_CONFIG_OIDC_* never " + + "reached the app's config and it still authenticates locally", + }) + .toContain("openid-connect/auth"); + + const authUrl = new URL(authPage.url()); + expect( + authUrl.searchParams.get("client_id"), + "the authorization request must carry the OIDC client id this deployment registered", + ).toBeTruthy(); + expect( + authUrl.searchParams.get("redirect_uri") || "", + "the authorization request must come back to this EspoCRM instance, proving the callback " + + "belongs to the deployed app and not to a default provider entry", + ).toContain(new URL(expectedBase).host); +}); diff --git a/roles/web-app-espocrm/files/playwright/addons/outbound-emails.spec.js b/roles/web-app-espocrm/files/playwright/addons/outbound-emails.spec.js new file mode 100644 index 0000000000..10d0cbdd8d --- /dev/null +++ b/roles/web-app-espocrm/files/playwright/addons/outbound-emails.spec.js @@ -0,0 +1,98 @@ +const { test, expect } = require("@playwright/test"); +const { resolveTimeout } = require("../timeouts"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceEnabled } = require("../service-gating"); +const { + clickOidcLoginLink, + decodeDotenvQuotedValue, + gotoOnion, + normalizeBaseUrl, + performKeycloakLogin, + safeIsEnabled, +} = require("../personas"); + +test.use({ ignoreHTTPSErrors: true }); + +const appBaseUrl = normalizeBaseUrl(process.env.APP_BASE_URL || ""); +const canonicalDomain = decodeDotenvQuotedValue(process.env.CANONICAL_DOMAIN || ""); +const smtpHost = decodeDotenvQuotedValue(process.env.EMAIL_SMTP_HOST || ""); +const adminUsername = decodeDotenvQuotedValue(process.env.ADMIN_USERNAME || ""); +const adminPassword = decodeDotenvQuotedValue(process.env.ADMIN_PASSWORD || ""); +const adminNativePassword = decodeDotenvQuotedValue(process.env.ADMIN_NATIVE_PASSWORD || ""); + +test("addon outbound-emails: EspoCRM sends through the deployed Mailu SMTP host", async ({ page }) => { + skipUnlessAddonEnabled("outbound-emails"); + skipUnlessServiceEnabled("email"); + test.setTimeout(resolveTimeout(240_000)); + + expect(appBaseUrl, "APP_BASE_URL must be set").toBeTruthy(); + expect(smtpHost, "EMAIL_SMTP_HOST must be set when the email service is on").toBeTruthy(); + expect(adminUsername, "ADMIN_USERNAME must be set").toBeTruthy(); + + const expectedBase = appBaseUrl.replace(/\/$/, ""); + const oidcEnabled = safeIsEnabled("sso"); + + await page.context().clearCookies(); + await gotoOnion(page, `${expectedBase}/`, { waitUntil: "domcontentloaded" }); + + if (oidcEnabled) { + expect(canonicalDomain, "CANONICAL_DOMAIN must be set when sso is on").toBeTruthy(); + expect(adminPassword, "ADMIN_PASSWORD must be set when sso is on").toBeTruthy(); + let authPage = page; + if (!page.url().includes("openid-connect/auth")) { + const strictLogin = page + .getByRole("link", { name: /^\s*(log\s*in|sign\s*in|login|sso)\s*$/i }) + .or(page.getByRole("button", { name: /^\s*(log\s*in|sign\s*in|login|sso)\s*$/i })) + .first(); + const looseLogin = page + .getByRole("link", { name: /log\s*in|sign\s*in|sso/i }) + .or(page.getByRole("button", { name: /log\s*in|sign\s*in|sso/i })) + .first(); + authPage = (await clickOidcLoginLink(page, strictLogin, looseLogin)) || page; + } + if (authPage.url().includes("openid-connect/auth")) { + await performKeycloakLogin(authPage, adminUsername, adminPassword, canonicalDomain); + } + } else { + test.skip( + !adminNativePassword, + "no native admin password: the role withholds it when LDAP owns authentication", + ); + test.skip( + safeIsEnabled("recaptcha"), + "reCAPTCHA v3 guards the native login form with live keys a headless persona cannot satisfy", + ); + const passwordField = page.locator("input[type='password']:visible").first(); + await passwordField.waitFor({ state: "visible", timeout: resolveTimeout(90_000) }); + await page.locator("input[name='username']:visible").first().fill(adminUsername); + await passwordField.fill(adminNativePassword); + await passwordField.press("Enter"); + } + + await expect + .poll(() => page.url(), { + timeout: resolveTimeout(120_000), + message: "expected the EspoCRM login to land back on the application", + }) + .toContain(expectedBase); + + await gotoOnion(page, `${expectedBase}/#Admin/outboundEmails`, { waitUntil: "domcontentloaded" }); + await page.reload({ waitUntil: "domcontentloaded" }); + + const smtpServerField = page.locator("[data-name='smtpServer'], input[name='smtpServer']").first(); + await expect( + smtpServerField, + "the Outbound Emails admin panel must render the SMTP server field; without it the login " + + "did not reach an administrator surface and the assertion below would prove nothing", + ).toBeAttached({ timeout: resolveTimeout(120_000) }); + + const rendered = + (await smtpServerField.inputValue().catch(() => null)) ?? + (await smtpServerField.innerText().catch(() => "")); + + expect( + rendered, + `EspoCRM's outbound mailer must carry the deployed Mailu host (${smtpHost}); another value ` + + "means ESPOCRM_CONFIG_SMTP_SERVER never reached the app's own config", + ).toContain(smtpHost); +}); diff --git a/roles/web-app-espocrm/meta/addons/oidc.yml b/roles/web-app-espocrm/meta/addons/oidc.yml new file mode 100644 index 0000000000..825bc3fa68 --- /dev/null +++ b/roles/web-app-espocrm/meta/addons/oidc.yml @@ -0,0 +1,7 @@ +--- +enabled: "{{ lookup('config', 'web-app-espocrm', 'services.sso.enabled') | bool }}" +required: false +mechanism: extension +source: bundled +bridges: + - sso diff --git a/roles/web-app-espocrm/meta/addons/outbound-emails.yml b/roles/web-app-espocrm/meta/addons/outbound-emails.yml new file mode 100644 index 0000000000..e4e8197b45 --- /dev/null +++ b/roles/web-app-espocrm/meta/addons/outbound-emails.yml @@ -0,0 +1,7 @@ +--- +enabled: "{{ lookup('config', 'web-app-espocrm', 'services.email.enabled') | bool }}" +required: false +mechanism: extension +source: bundled +bridges: + - email diff --git a/roles/web-app-espocrm/tasks/addons/oidc.yml b/roles/web-app-espocrm/tasks/addons/oidc.yml new file mode 100644 index 0000000000..ed97d539c0 --- /dev/null +++ b/roles/web-app-espocrm/tasks/addons/oidc.yml @@ -0,0 +1 @@ +--- diff --git a/roles/web-app-espocrm/tasks/addons/outbound-emails.yml b/roles/web-app-espocrm/tasks/addons/outbound-emails.yml new file mode 100644 index 0000000000..ed97d539c0 --- /dev/null +++ b/roles/web-app-espocrm/tasks/addons/outbound-emails.yml @@ -0,0 +1 @@ +--- diff --git a/roles/web-app-espocrm/templates/playwright.env.j2 b/roles/web-app-espocrm/templates/playwright.env.j2 index e3730a5894..810a05e75b 100644 --- a/roles/web-app-espocrm/templates/playwright.env.j2 +++ b/roles/web-app-espocrm/templates/playwright.env.j2 @@ -20,6 +20,8 @@ CSS_SERVICE_ENABLED={{ lookup('config', application_id, 'services.css.enabled') # nocheck: playwright-service-gate — templates/env.j2 hands SMTP to the app via ESPOCRM_CONFIG_SMTP_*; no persona surface sends mail, real delivery is asserted in roles/web-app-mailu/files/playwright/playwright.spec.js EMAIL_SERVICE_ENABLED={{ lookup('config', application_id, 'services.email.enabled') | string | lower }} +EMAIL_SMTP_HOST={{ lookup('email', application_id).host | dotenv_quote }} + # nocheck: playwright-service-gate — the persona drives the OIDC login path; ESPOCRM_CONFIG_AUTHENTICATION_METHOD=LDAP is exercised in the LDAP-only matrix variant LDAP_SERVICE_ENABLED={{ lookup('config', application_id, 'services.ldap.enabled') | string | lower }} @@ -51,3 +53,5 @@ SEAWEEDFS_S3_URL={{ lookup('canonical_url', 'web-svc-seaweedfs', 'api', consumer SEAWEEDFS_SERVICE_ENABLED={{ lookup('config', application_id, 'services.seaweedfs.enabled') | string | lower }} SSO_SERVICE_ENABLED={{ lookup('config', application_id, 'services.sso.enabled') | string | lower }} + +{{ lookup('addon_env_flags', application_id) }} diff --git a/roles/web-app-gitlab/files/playwright/addons/confluence.spec.js b/roles/web-app-gitlab/files/playwright/addons/confluence.spec.js new file mode 100644 index 0000000000..b9e1fc785b --- /dev/null +++ b/roles/web-app-gitlab/files/playwright/addons/confluence.spec.js @@ -0,0 +1,13 @@ +const { test } = require("@playwright/test"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceEnabled } = require("../service-gating"); +const { expectInstanceIntegrationIsAdminOnly } = require("../test-integrations"); + +test.use({ ignoreHTTPSErrors: true }); + +test("addon confluence: GitLab serves the Confluence integration surface for the deployed partner", async ({ page }) => { + skipUnlessAddonEnabled("confluence"); + skipUnlessServiceEnabled("confluence"); + + await expectInstanceIntegrationIsAdminOnly(page, "confluence", "Confluence"); +}); diff --git a/roles/web-app-gitlab/files/playwright/addons/jenkins.spec.js b/roles/web-app-gitlab/files/playwright/addons/jenkins.spec.js new file mode 100644 index 0000000000..e08c7218f1 --- /dev/null +++ b/roles/web-app-gitlab/files/playwright/addons/jenkins.spec.js @@ -0,0 +1,13 @@ +const { test } = require("@playwright/test"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceEnabled } = require("../service-gating"); +const { expectInstanceIntegrationIsAdminOnly } = require("../test-integrations"); + +test.use({ ignoreHTTPSErrors: true }); + +test("addon jenkins: GitLab serves the Jenkins integration surface for the deployed partner", async ({ page }) => { + skipUnlessAddonEnabled("jenkins"); + skipUnlessServiceEnabled("jenkins"); + + await expectInstanceIntegrationIsAdminOnly(page, "jenkins", "Jenkins"); +}); diff --git a/roles/web-app-gitlab/files/playwright/addons/jira.spec.js b/roles/web-app-gitlab/files/playwright/addons/jira.spec.js new file mode 100644 index 0000000000..2a784b2efc --- /dev/null +++ b/roles/web-app-gitlab/files/playwright/addons/jira.spec.js @@ -0,0 +1,13 @@ +const { test } = require("@playwright/test"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceEnabled } = require("../service-gating"); +const { expectInstanceIntegrationIsAdminOnly } = require("../test-integrations"); + +test.use({ ignoreHTTPSErrors: true }); + +test("addon jira: GitLab serves the Jira integration surface for the deployed partner", async ({ page }) => { + skipUnlessAddonEnabled("jira"); + skipUnlessServiceEnabled("jira"); + + await expectInstanceIntegrationIsAdminOnly(page, "jira", "Jira"); +}); diff --git a/roles/web-app-gitlab/files/playwright/addons/matrix.spec.js b/roles/web-app-gitlab/files/playwright/addons/matrix.spec.js new file mode 100644 index 0000000000..c6cb60ba91 --- /dev/null +++ b/roles/web-app-gitlab/files/playwright/addons/matrix.spec.js @@ -0,0 +1,13 @@ +const { test } = require("@playwright/test"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceEnabled } = require("../service-gating"); +const { expectInstanceIntegrationIsAdminOnly } = require("../test-integrations"); + +test.use({ ignoreHTTPSErrors: true }); + +test("addon matrix: GitLab serves the Matrix notifications integration surface for the deployed partner", async ({ page }) => { + skipUnlessAddonEnabled("matrix"); + skipUnlessServiceEnabled("matrix"); + + await expectInstanceIntegrationIsAdminOnly(page, "matrix", "Matrix"); +}); diff --git a/roles/web-app-gitlab/files/playwright/addons/mattermost.spec.js b/roles/web-app-gitlab/files/playwright/addons/mattermost.spec.js new file mode 100644 index 0000000000..149d2d88c8 --- /dev/null +++ b/roles/web-app-gitlab/files/playwright/addons/mattermost.spec.js @@ -0,0 +1,13 @@ +const { test } = require("@playwright/test"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceEnabled } = require("../service-gating"); +const { expectInstanceIntegrationIsAdminOnly } = require("../test-integrations"); + +test.use({ ignoreHTTPSErrors: true }); + +test("addon mattermost: GitLab serves the Mattermost notifications integration surface for the deployed partner", async ({ page }) => { + skipUnlessAddonEnabled("mattermost"); + skipUnlessServiceEnabled("mattermost"); + + await expectInstanceIntegrationIsAdminOnly(page, "mattermost", "Mattermost notifications"); +}); diff --git a/roles/web-app-gitlab/files/playwright/addons/openid_connect.spec.js b/roles/web-app-gitlab/files/playwright/addons/openid_connect.spec.js new file mode 100644 index 0000000000..edf2a55c9c --- /dev/null +++ b/roles/web-app-gitlab/files/playwright/addons/openid_connect.spec.js @@ -0,0 +1,28 @@ +const { test, expect } = require("@playwright/test"); +const { resolveTimeout } = require("../timeouts"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceEnabled } = require("../service-gating"); +const { gotoOnion, normalizeBaseUrl } = require("../personas"); + +test.use({ ignoreHTTPSErrors: true }); + +test("addon openid_connect: the sign-in page offers the OmniAuth provider the role renders into gitlab.yml", async ({ page }) => { + skipUnlessAddonEnabled("openid_connect"); + skipUnlessServiceEnabled("sso"); + + const appBaseUrl = normalizeBaseUrl(process.env.APP_BASE_URL || ""); + expect(appBaseUrl, "APP_BASE_URL must be set").toBeTruthy(); + + const response = await gotoOnion(page, `${appBaseUrl}/users/sign_in`, { waitUntil: "domcontentloaded" }); + expect(response, "Expected a response from the GitLab sign-in page").toBeTruthy(); + expect(response.status(), "Expected the GitLab sign-in page status < 400").toBeLessThan(400); + + const providerEntry = page + .locator("form[action*='/users/auth/openid_connect']") + .or(page.locator("a[href*='/users/auth/openid_connect']")) + .first(); + await expect( + providerEntry, + "the sign-in page must offer the openid_connect OmniAuth entry point; its absence means the omniauth provider block in templates/config/gitlab.yml.j2 never reached the running webservice", + ).toBeAttached({ timeout: resolveTimeout(30_000) }); +}); diff --git a/roles/web-app-gitlab/meta/addons/confluence.yml b/roles/web-app-gitlab/meta/addons/confluence.yml new file mode 100644 index 0000000000..46bf226c18 --- /dev/null +++ b/roles/web-app-gitlab/meta/addons/confluence.yml @@ -0,0 +1,9 @@ +--- +enabled: "{{ lookup('config', 'web-app-gitlab', 'services.confluence.enabled') | bool }}" +required: false +mechanism: plugin +source: bundled +bridges: + - confluence +config: + confluence_url: "{{ lookup('tls', 'web-app-confluence', 'url.base') }}" diff --git a/roles/web-app-gitlab/meta/addons/jenkins.yml b/roles/web-app-gitlab/meta/addons/jenkins.yml new file mode 100644 index 0000000000..353819c5f0 --- /dev/null +++ b/roles/web-app-gitlab/meta/addons/jenkins.yml @@ -0,0 +1,9 @@ +--- +enabled: "{{ lookup('config', 'web-app-gitlab', 'services.jenkins.enabled') | bool }}" +required: false +mechanism: plugin +source: bundled +bridges: + - jenkins +config: + jenkins_url: "{{ lookup('tls', 'web-app-jenkins', 'url.base') }}" diff --git a/roles/web-app-gitlab/meta/addons/jira.yml b/roles/web-app-gitlab/meta/addons/jira.yml new file mode 100644 index 0000000000..55720897d8 --- /dev/null +++ b/roles/web-app-gitlab/meta/addons/jira.yml @@ -0,0 +1,9 @@ +--- +enabled: "{{ lookup('config', 'web-app-gitlab', 'services.jira.enabled') | bool }}" +required: false +mechanism: plugin +source: bundled +bridges: + - jira +config: + url: "{{ lookup('tls', 'web-app-jira', 'url.base') }}" diff --git a/roles/web-app-gitlab/meta/addons/matrix.yml b/roles/web-app-gitlab/meta/addons/matrix.yml new file mode 100644 index 0000000000..0b85e59af3 --- /dev/null +++ b/roles/web-app-gitlab/meta/addons/matrix.yml @@ -0,0 +1,9 @@ +--- +enabled: "{{ lookup('config', 'web-app-gitlab', 'services.matrix.enabled') | bool }}" +required: false +mechanism: plugin +source: bundled +bridges: + - matrix +config: + hostname: "{{ lookup('canonical_url', 'web-app-matrix', 'synapse') }}" diff --git a/roles/web-app-gitlab/meta/addons/mattermost.yml b/roles/web-app-gitlab/meta/addons/mattermost.yml new file mode 100644 index 0000000000..0712abec99 --- /dev/null +++ b/roles/web-app-gitlab/meta/addons/mattermost.yml @@ -0,0 +1,9 @@ +--- +enabled: "{{ lookup('config', 'web-app-gitlab', 'services.mattermost.enabled') | bool }}" +required: false +mechanism: plugin +source: bundled +bridges: + - mattermost +config: + mattermost_url: "{{ lookup('tls', 'web-app-mattermost', 'url.base') }}" diff --git a/roles/web-app-gitlab/meta/addons/openid_connect.yml b/roles/web-app-gitlab/meta/addons/openid_connect.yml new file mode 100644 index 0000000000..4f15575b94 --- /dev/null +++ b/roles/web-app-gitlab/meta/addons/openid_connect.yml @@ -0,0 +1,7 @@ +--- +enabled: "{{ lookup('config', 'web-app-gitlab', 'services.sso.enabled') | bool }}" +required: false +mechanism: plugin +source: bundled +bridges: + - sso diff --git a/roles/web-app-gitlab/tasks/addons/confluence.yml b/roles/web-app-gitlab/tasks/addons/confluence.yml new file mode 100644 index 0000000000..ed97d539c0 --- /dev/null +++ b/roles/web-app-gitlab/tasks/addons/confluence.yml @@ -0,0 +1 @@ +--- diff --git a/roles/web-app-gitlab/tasks/addons/jenkins.yml b/roles/web-app-gitlab/tasks/addons/jenkins.yml new file mode 100644 index 0000000000..ed97d539c0 --- /dev/null +++ b/roles/web-app-gitlab/tasks/addons/jenkins.yml @@ -0,0 +1 @@ +--- diff --git a/roles/web-app-gitlab/tasks/addons/jira.yml b/roles/web-app-gitlab/tasks/addons/jira.yml new file mode 100644 index 0000000000..ed97d539c0 --- /dev/null +++ b/roles/web-app-gitlab/tasks/addons/jira.yml @@ -0,0 +1 @@ +--- diff --git a/roles/web-app-gitlab/tasks/addons/matrix.yml b/roles/web-app-gitlab/tasks/addons/matrix.yml new file mode 100644 index 0000000000..ed97d539c0 --- /dev/null +++ b/roles/web-app-gitlab/tasks/addons/matrix.yml @@ -0,0 +1 @@ +--- diff --git a/roles/web-app-gitlab/tasks/addons/mattermost.yml b/roles/web-app-gitlab/tasks/addons/mattermost.yml new file mode 100644 index 0000000000..ed97d539c0 --- /dev/null +++ b/roles/web-app-gitlab/tasks/addons/mattermost.yml @@ -0,0 +1 @@ +--- diff --git a/roles/web-app-gitlab/tasks/addons/openid_connect.yml b/roles/web-app-gitlab/tasks/addons/openid_connect.yml new file mode 100644 index 0000000000..ed97d539c0 --- /dev/null +++ b/roles/web-app-gitlab/tasks/addons/openid_connect.yml @@ -0,0 +1 @@ +--- diff --git a/roles/web-app-gitlab/templates/playwright.env.j2 b/roles/web-app-gitlab/templates/playwright.env.j2 index b3b4b30c27..9533f742b4 100644 --- a/roles/web-app-gitlab/templates/playwright.env.j2 +++ b/roles/web-app-gitlab/templates/playwright.env.j2 @@ -10,18 +10,28 @@ BIBER_USERNAME={{ lookup('users', 'biber').username | dotenv_quote }} CANONICAL_DOMAIN={{ lookup('domain', application_id) | dotenv_quote }} +CONFLUENCE_SERVICE_ENABLED={{ lookup('config', application_id, 'services.confluence.enabled') | string | lower }} + # nocheck: playwright-service-gate — web-svc-css is injected at the vhost level; assertCspInjections resolves the flag through a loop variable, never a literal gate CSS_SERVICE_ENABLED={{ lookup('config', application_id, 'services.css.enabled') | string | lower }} # nocheck: playwright-service-gate — templates/config/smtp_settings.rb.j2 wires ActionMailer outbound-only; no persona surface sends mail, real delivery is asserted in roles/web-app-mailu/files/playwright/playwright.spec.js EMAIL_SERVICE_ENABLED={{ lookup('config', application_id, 'services.email.enabled') | string | lower }} +JENKINS_SERVICE_ENABLED={{ lookup('config', application_id, 'services.jenkins.enabled') | string | lower }} + +JIRA_SERVICE_ENABLED={{ lookup('config', application_id, 'services.jira.enabled') | string | lower }} + LOGOUT_SERVICE_ENABLED={{ lookup('config', application_id, 'services.logout.enabled') | string | lower }} MATOMO_BASE_URL={{ lookup('tls', 'web-app-matomo', 'url.base') | dotenv_quote }} MATOMO_SERVICE_ENABLED={{ lookup('config', application_id, 'services.matomo.enabled') | string | lower }} +MATRIX_SERVICE_ENABLED={{ lookup('config', application_id, 'services.matrix.enabled') | string | lower }} + +MATTERMOST_SERVICE_ENABLED={{ lookup('config', application_id, 'services.mattermost.enabled') | string | lower }} + MCP_ENDPOINT_PATH={{ GITLAB_MCP_UPSTREAM_PATH | dotenv_quote }} MCP_SERVICE_ENABLED={{ lookup('config', application_id, 'mcp.enabled') | string | lower }} @@ -42,3 +52,5 @@ REDIS_SERVICE_ENABLED={{ lookup('config', application_id, 'services.redis.enable SEAWEEDFS_SERVICE_ENABLED={{ lookup('config', application_id, 'services.seaweedfs.enabled') | string | lower }} SSO_SERVICE_ENABLED={{ lookup('config', application_id, 'services.sso.enabled') | string | lower }} + +{{ lookup('addon_env_flags', application_id) }} diff --git a/roles/web-app-jenkins/files/playwright/addons/gitea.spec.js b/roles/web-app-jenkins/files/playwright/addons/gitea.spec.js new file mode 100644 index 0000000000..c7e9994e06 --- /dev/null +++ b/roles/web-app-jenkins/files/playwright/addons/gitea.spec.js @@ -0,0 +1,24 @@ +const { test, expect } = require("@playwright/test"); +const { resolveTimeout } = require("../timeouts"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceEnabled } = require("../service-gating"); +const { fetchPluginRecord, loginAsAdministrator } = require("../jenkins-login"); + +test.use({ ignoreHTTPSErrors: true }); + +test("addon gitea: the Gitea plugin is installed and active", async ({ page }) => { + skipUnlessAddonEnabled("gitea"); + skipUnlessServiceEnabled("gitea"); + test.setTimeout(resolveTimeout(180_000)); + + await loginAsAdministrator(page); + + const plugin = await fetchPluginRecord(page, "gitea"); + expect( + plugin, + "the plugin manager must list 'gitea'; it is absent when the addon declaration did not " + + "reach templates/plugins.txt.j2 and jenkins-plugin-cli never fetched it", + ).toBeTruthy(); + expect(plugin.active, "the Gitea plugin must be active, not merely downloaded").toBe(true); + expect(plugin.enabled, "the Gitea plugin must be enabled in the controller").toBe(true); +}); diff --git a/roles/web-app-jenkins/files/playwright/addons/gitlab-plugin.spec.js b/roles/web-app-jenkins/files/playwright/addons/gitlab-plugin.spec.js new file mode 100644 index 0000000000..ccdb3362cf --- /dev/null +++ b/roles/web-app-jenkins/files/playwright/addons/gitlab-plugin.spec.js @@ -0,0 +1,24 @@ +const { test, expect } = require("@playwright/test"); +const { resolveTimeout } = require("../timeouts"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceEnabled } = require("../service-gating"); +const { fetchPluginRecord, loginAsAdministrator } = require("../jenkins-login"); + +test.use({ ignoreHTTPSErrors: true }); + +test("addon gitlab-plugin: the GitLab plugin is installed and active", async ({ page }) => { + skipUnlessAddonEnabled("gitlab-plugin"); + skipUnlessServiceEnabled("gitlab"); + test.setTimeout(resolveTimeout(180_000)); + + await loginAsAdministrator(page); + + const plugin = await fetchPluginRecord(page, "gitlab-plugin"); + expect( + plugin, + "the plugin manager must list 'gitlab-plugin'; it is absent when the addon declaration did " + + "not reach templates/plugins.txt.j2 and jenkins-plugin-cli never fetched it", + ).toBeTruthy(); + expect(plugin.active, "the GitLab plugin must be active, not merely downloaded").toBe(true); + expect(plugin.enabled, "the GitLab plugin must be enabled in the controller").toBe(true); +}); diff --git a/roles/web-app-jenkins/files/playwright/addons/mattermost.spec.js b/roles/web-app-jenkins/files/playwright/addons/mattermost.spec.js new file mode 100644 index 0000000000..adaa0a7005 --- /dev/null +++ b/roles/web-app-jenkins/files/playwright/addons/mattermost.spec.js @@ -0,0 +1,24 @@ +const { test, expect } = require("@playwright/test"); +const { resolveTimeout } = require("../timeouts"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceEnabled } = require("../service-gating"); +const { fetchPluginRecord, loginAsAdministrator } = require("../jenkins-login"); + +test.use({ ignoreHTTPSErrors: true }); + +test("addon mattermost: the Mattermost notifier plugin is installed and active", async ({ page }) => { + skipUnlessAddonEnabled("mattermost"); + skipUnlessServiceEnabled("mattermost"); + test.setTimeout(resolveTimeout(180_000)); + + await loginAsAdministrator(page); + + const plugin = await fetchPluginRecord(page, "mattermost"); + expect( + plugin, + "the plugin manager must list 'mattermost'; it is absent when the addon declaration did not " + + "reach templates/plugins.txt.j2 and jenkins-plugin-cli never fetched it", + ).toBeTruthy(); + expect(plugin.active, "the Mattermost plugin must be active, not merely downloaded").toBe(true); + expect(plugin.enabled, "the Mattermost plugin must be enabled in the controller").toBe(true); +}); diff --git a/roles/web-app-jenkins/files/playwright/addons/oic-auth.spec.js b/roles/web-app-jenkins/files/playwright/addons/oic-auth.spec.js new file mode 100644 index 0000000000..58b46f8f59 --- /dev/null +++ b/roles/web-app-jenkins/files/playwright/addons/oic-auth.spec.js @@ -0,0 +1,32 @@ +const { test, expect } = require("@playwright/test"); +const { resolveTimeout } = require("../timeouts"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceEnabled } = require("../service-gating"); +const { gotoOnion } = require("../personas"); +const { baseUrl, fetchPluginRecord, loginAsAdministrator } = require("../jenkins-login"); + +test.use({ ignoreHTTPSErrors: true }); + +test("addon oic-auth: the OpenID Connect plugin backs the active security realm", async ({ page }) => { + skipUnlessAddonEnabled("oic-auth"); + skipUnlessServiceEnabled("sso"); + test.setTimeout(resolveTimeout(180_000)); + + await loginAsAdministrator(page); + + const plugin = await fetchPluginRecord(page, "oic-auth"); + expect( + plugin, + "the plugin manager must list 'oic-auth'; it is absent when the addon declaration did not " + + "reach templates/plugins.txt.j2 and jenkins-plugin-cli never fetched it", + ).toBeTruthy(); + expect(plugin.active, "the oic-auth plugin must be active, not merely downloaded").toBe(true); + + await gotoOnion(page, `${baseUrl}/manage/configureSecurity/`, { waitUntil: "domcontentloaded" }); + const body = (await page.locator("body").innerText().catch(() => "")) || ""; + expect( + body, + "the security configuration must offer the OpenID Connect realm; its absence means casc " + + "selected a realm the plugin does not provide", + ).toMatch(/openid/i); +}); diff --git a/roles/web-app-jenkins/files/playwright/addons/prometheus.spec.js b/roles/web-app-jenkins/files/playwright/addons/prometheus.spec.js new file mode 100644 index 0000000000..789c9eea0a --- /dev/null +++ b/roles/web-app-jenkins/files/playwright/addons/prometheus.spec.js @@ -0,0 +1,39 @@ +const { test, expect } = require("@playwright/test"); +const { resolveTimeout } = require("../timeouts"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { baseUrl, fetchPluginRecord, loginAsAdministrator } = require("../jenkins-login"); + +test.use({ ignoreHTTPSErrors: true }); + +test("addon prometheus: the metrics plugin is active and its endpoint is not public", async ({ page, playwright }) => { + skipUnlessAddonEnabled("prometheus"); + test.setTimeout(resolveTimeout(180_000)); + + await loginAsAdministrator(page); + + const plugin = await fetchPluginRecord(page, "prometheus"); + expect( + plugin, + "the plugin manager must list 'prometheus'; it is absent when the addon declaration did not " + + "reach templates/plugins.txt.j2 and jenkins-plugin-cli never fetched it", + ).toBeTruthy(); + expect(plugin.active, "the prometheus plugin must be active, not merely downloaded").toBe(true); + + const anonymous = await playwright.request.newContext({ ignoreHTTPSErrors: true }); + const metrics = await anonymous.get(`${baseUrl}/prometheus`, { + timeout: resolveTimeout(60_000), + }); + const body = await metrics.text(); + await anonymous.dispose(); + + expect( + metrics.status(), + `an anonymous visitor must not read the scrape endpoint on the public vhost; web-app-prometheus ` + + `reaches it on the internal container port instead (see templates/prometheus.yml.j2). Got ` + + `${metrics.status()} with ${body.length} bytes`, + ).toBeGreaterThanOrEqual(400); + expect( + body, + "an anonymous refusal must not leak the metrics it refuses", + ).not.toMatch(/^#\s*HELP/m); +}); diff --git a/roles/web-app-jenkins/meta/addons/gitea.yml b/roles/web-app-jenkins/meta/addons/gitea.yml new file mode 100644 index 0000000000..8e961490ab --- /dev/null +++ b/roles/web-app-jenkins/meta/addons/gitea.yml @@ -0,0 +1,11 @@ +--- +enabled: "{{ lookup('config', 'web-app-jenkins', 'services.gitea.enabled') | bool }}" +required: true +mechanism: plugin +source: upstream +version: "latest" +bridges: + - gitea +config: + plugin_id: gitea + server_url: "{{ lookup('tls', 'web-app-gitea', 'url.base') }}" diff --git a/roles/web-app-jenkins/meta/addons/gitlab-plugin.yml b/roles/web-app-jenkins/meta/addons/gitlab-plugin.yml new file mode 100644 index 0000000000..9914e459e4 --- /dev/null +++ b/roles/web-app-jenkins/meta/addons/gitlab-plugin.yml @@ -0,0 +1,11 @@ +--- +enabled: "{{ lookup('config', 'web-app-jenkins', 'services.gitlab.enabled') | bool }}" +required: true +mechanism: plugin +source: upstream +version: "latest" +bridges: + - gitlab +config: + plugin_id: gitlab-plugin + server_url: "{{ lookup('tls', 'web-app-gitlab', 'url.base') }}" diff --git a/roles/web-app-jenkins/meta/addons/mattermost.yml b/roles/web-app-jenkins/meta/addons/mattermost.yml new file mode 100644 index 0000000000..9f8bec1d6b --- /dev/null +++ b/roles/web-app-jenkins/meta/addons/mattermost.yml @@ -0,0 +1,11 @@ +--- +enabled: "{{ lookup('config', 'web-app-jenkins', 'services.mattermost.enabled') | bool }}" +required: true +mechanism: plugin +source: upstream +version: "latest" +bridges: + - mattermost +config: + plugin_id: mattermost + server_url: "{{ lookup('tls', 'web-app-mattermost', 'url.base') }}" diff --git a/roles/web-app-jenkins/meta/addons/oic-auth.yml b/roles/web-app-jenkins/meta/addons/oic-auth.yml new file mode 100644 index 0000000000..3c8dd7cc10 --- /dev/null +++ b/roles/web-app-jenkins/meta/addons/oic-auth.yml @@ -0,0 +1,11 @@ +--- +enabled: "{{ lookup('config', 'web-app-jenkins', 'services.sso.enabled') | bool }}" +required: true +mechanism: plugin +source: upstream +version: "latest" +bridges: + - sso +config: + plugin_id: oic-auth + server_url: "{{ lookup('tls', 'web-app-keycloak', 'url.base') }}" diff --git a/roles/web-app-jenkins/meta/addons/prometheus.yml b/roles/web-app-jenkins/meta/addons/prometheus.yml new file mode 100644 index 0000000000..d88e66b61a --- /dev/null +++ b/roles/web-app-jenkins/meta/addons/prometheus.yml @@ -0,0 +1,11 @@ +--- +enabled: "{{ lookup('config', 'web-app-jenkins', 'services.prometheus.enabled') | bool }}" +required: true +mechanism: plugin +source: upstream +version: "latest" +bridges: + - prometheus +config: + plugin_id: prometheus + metrics_path: "/prometheus" diff --git a/roles/web-app-jenkins/tasks/addons/gitea.yml b/roles/web-app-jenkins/tasks/addons/gitea.yml new file mode 100644 index 0000000000..ed97d539c0 --- /dev/null +++ b/roles/web-app-jenkins/tasks/addons/gitea.yml @@ -0,0 +1 @@ +--- diff --git a/roles/web-app-jenkins/tasks/addons/gitlab-plugin.yml b/roles/web-app-jenkins/tasks/addons/gitlab-plugin.yml new file mode 100644 index 0000000000..ed97d539c0 --- /dev/null +++ b/roles/web-app-jenkins/tasks/addons/gitlab-plugin.yml @@ -0,0 +1 @@ +--- diff --git a/roles/web-app-jenkins/tasks/addons/mattermost.yml b/roles/web-app-jenkins/tasks/addons/mattermost.yml new file mode 100644 index 0000000000..ed97d539c0 --- /dev/null +++ b/roles/web-app-jenkins/tasks/addons/mattermost.yml @@ -0,0 +1 @@ +--- diff --git a/roles/web-app-jenkins/tasks/addons/oic-auth.yml b/roles/web-app-jenkins/tasks/addons/oic-auth.yml new file mode 100644 index 0000000000..ed97d539c0 --- /dev/null +++ b/roles/web-app-jenkins/tasks/addons/oic-auth.yml @@ -0,0 +1 @@ +--- diff --git a/roles/web-app-jenkins/tasks/addons/prometheus.yml b/roles/web-app-jenkins/tasks/addons/prometheus.yml new file mode 100644 index 0000000000..ed97d539c0 --- /dev/null +++ b/roles/web-app-jenkins/tasks/addons/prometheus.yml @@ -0,0 +1 @@ +--- diff --git a/roles/web-app-jenkins/templates/playwright.env.j2 b/roles/web-app-jenkins/templates/playwright.env.j2 index cd7f44c04e..a4ed65ccab 100644 --- a/roles/web-app-jenkins/templates/playwright.env.j2 +++ b/roles/web-app-jenkins/templates/playwright.env.j2 @@ -10,6 +10,10 @@ BIBER_USERNAME={{ lookup('users', 'biber').username | dotenv_quote }} CANONICAL_DOMAIN={{ lookup('domain', application_id) | dotenv_quote }} +GITEA_SERVICE_ENABLED={{ lookup('config', application_id, 'services.gitea.enabled') | string | lower }} + +GITLAB_SERVICE_ENABLED={{ lookup('config', application_id, 'services.gitlab.enabled') | string | lower }} + JENKINS_BASE_URL={{ lookup('tls', application_id, 'url.base') | dotenv_quote }} LDAP_SERVICE_ENABLED={{ JENKINS_LDAP_ENABLED | string | lower }} @@ -20,6 +24,8 @@ MATOMO_BASE_URL={{ lookup('tls', 'web-app-matomo', 'url.base') | dotenv_quote }} MATOMO_SERVICE_ENABLED={{ lookup('config', application_id, 'services.matomo.enabled') | string | lower }} +MATTERMOST_SERVICE_ENABLED={{ lookup('config', application_id, 'services.mattermost.enabled') | string | lower }} + MCP_ENDPOINT_PATH={{ lookup('config', application_id, 'mcp.endpoint.path') | dotenv_quote }} MCP_SERVICE_ENABLED={{ JENKINS_MCP_ENABLED | string | lower }} @@ -36,3 +42,5 @@ PERSONA_BIBER_BLOCKED=true SSO_SERVICE_ENABLED={{ JENKINS_OIDC_ENABLED | string | lower }} +{{ lookup('addon_env_flags', application_id) }} + diff --git a/roles/web-app-matrix/files/playwright/addons/hookshot-gitlab.spec.js b/roles/web-app-matrix/files/playwright/addons/hookshot-gitlab.spec.js new file mode 100644 index 0000000000..93c2a0271d --- /dev/null +++ b/roles/web-app-matrix/files/playwright/addons/hookshot-gitlab.spec.js @@ -0,0 +1,50 @@ +const { test, expect } = require("../onion-test"); +const { resolveTimeout } = require("../timeouts"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceEnabled } = require("../service-gating"); +const { decodeDotenvQuotedValue } = require("../personas"); +const shared = require("../_shared"); + +test.use({ ignoreHTTPSErrors: true }); + +const HOOKSHOT_BOT_LOCALPART = "hookshot"; + +test("hookshot-gitlab addon: the hookshot appservice bot is provisioned on the Synapse homeserver", async ({ request }) => { + skipUnlessAddonEnabled("hookshot-gitlab"); + skipUnlessServiceEnabled("gitlab"); + test.skip( + !(process.env.MATRIX_FLAVOR || "").toLowerCase().includes("ansible"), + "hookshot ships with the matrix-docker-ansible-deploy flavor only", + ); + + const plugins = JSON.parse(decodeDotenvQuotedValue(process.env.MATRIX_PLUGINS_JSON || "") || "{}"); + test.skip( + !plugins.hookshot, + `services.matrix.plugins.hookshot is off, so MDAD renders no hookshot bridge (MATRIX_PLUGINS_JSON: ${JSON.stringify(plugins)})`, + ); + + test.setTimeout(resolveTimeout(60_000)); + + const matrixBaseUrl = shared.env.matrixBaseUrl; + const matrixServerName = shared.env.matrixServerName; + expect(matrixBaseUrl, "MATRIX_BASE_URL must be set").toBeTruthy(); + expect(matrixServerName, "MATRIX_SERVER_NAME must be set").toBeTruthy(); + + const botUserId = `@${HOOKSHOT_BOT_LOCALPART}:${matrixServerName}`; + const profileUrl = `${matrixBaseUrl}/_matrix/client/v3/profile/${encodeURIComponent(botUserId)}`; + + const response = await request.get(profileUrl, { failOnStatusCode: false, timeout: resolveTimeout(30_000) }); + + expect( + response.status(), + `the hookshot appservice bot ${botUserId} must be registered on Synapse (${matrixBaseUrl}) so a GitLab room ` + + `connection can be opened. A 404 means the appservice registration never landed in the homeserver, so the ` + + `GitLab coupling failed to provision. A 5xx means the homeserver is unhealthy. Got HTTP ${response.status()}.`, + ).toBe(200); + + const profile = await response.json().catch(() => null); + expect( + profile && typeof profile === "object" && !Array.isArray(profile), + `Synapse must return the hookshot bot's profile JSON object for ${botUserId}, proving the appservice bot user exists`, + ).toBe(true); +}); diff --git a/roles/web-app-matrix/files/playwright/addons/hookshot-jira.spec.js b/roles/web-app-matrix/files/playwright/addons/hookshot-jira.spec.js new file mode 100644 index 0000000000..e0138bd1cf --- /dev/null +++ b/roles/web-app-matrix/files/playwright/addons/hookshot-jira.spec.js @@ -0,0 +1,50 @@ +const { test, expect } = require("../onion-test"); +const { resolveTimeout } = require("../timeouts"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceEnabled } = require("../service-gating"); +const { decodeDotenvQuotedValue } = require("../personas"); +const shared = require("../_shared"); + +test.use({ ignoreHTTPSErrors: true }); + +const HOOKSHOT_BOT_LOCALPART = "hookshot"; + +test("hookshot-jira addon: the hookshot appservice bot is provisioned on the Synapse homeserver", async ({ request }) => { + skipUnlessAddonEnabled("hookshot-jira"); + skipUnlessServiceEnabled("jira"); + test.skip( + !(process.env.MATRIX_FLAVOR || "").toLowerCase().includes("ansible"), + "hookshot ships with the matrix-docker-ansible-deploy flavor only", + ); + + const plugins = JSON.parse(decodeDotenvQuotedValue(process.env.MATRIX_PLUGINS_JSON || "") || "{}"); + test.skip( + !plugins.hookshot, + `services.matrix.plugins.hookshot is off, so MDAD renders no hookshot bridge (MATRIX_PLUGINS_JSON: ${JSON.stringify(plugins)})`, + ); + + test.setTimeout(resolveTimeout(60_000)); + + const matrixBaseUrl = shared.env.matrixBaseUrl; + const matrixServerName = shared.env.matrixServerName; + expect(matrixBaseUrl, "MATRIX_BASE_URL must be set").toBeTruthy(); + expect(matrixServerName, "MATRIX_SERVER_NAME must be set").toBeTruthy(); + + const botUserId = `@${HOOKSHOT_BOT_LOCALPART}:${matrixServerName}`; + const profileUrl = `${matrixBaseUrl}/_matrix/client/v3/profile/${encodeURIComponent(botUserId)}`; + + const response = await request.get(profileUrl, { failOnStatusCode: false, timeout: resolveTimeout(30_000) }); + + expect( + response.status(), + `the hookshot appservice bot ${botUserId} must be registered on Synapse (${matrixBaseUrl}) so a Jira room ` + + `connection can be opened. A 404 means the appservice registration never landed in the homeserver, so the ` + + `Jira coupling failed to provision. A 5xx means the homeserver is unhealthy. Got HTTP ${response.status()}.`, + ).toBe(200); + + const profile = await response.json().catch(() => null); + expect( + profile && typeof profile === "object" && !Array.isArray(profile), + `Synapse must return the hookshot bot's profile JSON object for ${botUserId}, proving the appservice bot user exists`, + ).toBe(true); +}); diff --git a/roles/web-app-matrix/files/playwright/addons/jitsi.spec.js b/roles/web-app-matrix/files/playwright/addons/jitsi.spec.js new file mode 100644 index 0000000000..69e8ba3ed2 --- /dev/null +++ b/roles/web-app-matrix/files/playwright/addons/jitsi.spec.js @@ -0,0 +1,49 @@ +const { test, expect } = require("../onion-test"); +const { resolveTimeout } = require("../timeouts"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceEnabled } = require("../service-gating"); +const { decodeDotenvQuotedValue } = require("../personas"); +const shared = require("../_shared"); + +test.use({ ignoreHTTPSErrors: true }); + +test("jitsi addon: Element advertises the co-deployed Jitsi deployment as its preferred domain", async ({ request }) => { + skipUnlessAddonEnabled("jitsi"); + skipUnlessServiceEnabled("jitsi"); + test.skip( + !(process.env.MATRIX_FLAVOR || "").toLowerCase().includes("compose"), + "the ansible flavor lets matrix-docker-ansible-deploy render Element's config.json", + ); + + test.setTimeout(resolveTimeout(60_000)); + + const preferredDomain = decodeDotenvQuotedValue(process.env.JITSI_PREFERRED_DOMAIN); + expect(preferredDomain, "JITSI_PREFERRED_DOMAIN must be set while the jitsi addon is enabled").toBeTruthy(); + + const { elementBaseUrl } = shared.env; + const response = await request.get(`${elementBaseUrl}/config.json`, { + failOnStatusCode: false, + timeout: resolveTimeout(30_000), + }); + expect(response.status(), `Element /config.json must serve from ${elementBaseUrl}`).toBe(200); + + const body = await response.text(); + let config; + try { + config = JSON.parse(body); + } catch (e) { + throw new Error(`Element /config.json must be valid JSON: ${e.message}`, { cause: e }); + } + + expect( + config.jitsi && config.jitsi.preferredDomain, + `Element /config.json must carry jitsi.preferredDomain while the jitsi addon is enabled; without it every ` + + `conference widget falls back to the public meet.jit.si instead of the co-deployed web-app-jitsi. ` + + `Got keys: ${Object.keys(config).join(", ")}`, + ).toBeTruthy(); + + expect( + config.jitsi.preferredDomain, + `Element must point at the co-deployed Jitsi domain, not a third-party instance`, + ).toBe(preferredDomain); +}); diff --git a/roles/web-app-matrix/meta/addons/hookshot-gitlab.yml b/roles/web-app-matrix/meta/addons/hookshot-gitlab.yml new file mode 100644 index 0000000000..6d4a7f0976 --- /dev/null +++ b/roles/web-app-matrix/meta/addons/hookshot-gitlab.yml @@ -0,0 +1,7 @@ +--- +enabled: "{{ lookup('config', 'web-app-matrix', 'services.gitlab.enabled') | bool }}" +required: false +mechanism: bridge +source: upstream +bridges: + - gitlab diff --git a/roles/web-app-matrix/meta/addons/hookshot-jira.yml b/roles/web-app-matrix/meta/addons/hookshot-jira.yml new file mode 100644 index 0000000000..e9691ef61e --- /dev/null +++ b/roles/web-app-matrix/meta/addons/hookshot-jira.yml @@ -0,0 +1,7 @@ +--- +enabled: "{{ lookup('config', 'web-app-matrix', 'services.jira.enabled') | bool }}" +required: false +mechanism: bridge +source: upstream +bridges: + - jira diff --git a/roles/web-app-matrix/meta/addons/jitsi.yml b/roles/web-app-matrix/meta/addons/jitsi.yml new file mode 100644 index 0000000000..3f0ea46c94 --- /dev/null +++ b/roles/web-app-matrix/meta/addons/jitsi.yml @@ -0,0 +1,9 @@ +--- +enabled: "{{ lookup('config', 'web-app-matrix', 'services.jitsi.enabled') | bool }}" +required: false +mechanism: module +source: bundled +bridges: + - jitsi +config: + preferred_domain: "{{ lookup('domain', 'web-app-jitsi') }}" diff --git a/roles/web-app-matrix/tasks/addons/hookshot-gitlab.yml b/roles/web-app-matrix/tasks/addons/hookshot-gitlab.yml new file mode 100644 index 0000000000..ed97d539c0 --- /dev/null +++ b/roles/web-app-matrix/tasks/addons/hookshot-gitlab.yml @@ -0,0 +1 @@ +--- diff --git a/roles/web-app-matrix/tasks/addons/hookshot-jira.yml b/roles/web-app-matrix/tasks/addons/hookshot-jira.yml new file mode 100644 index 0000000000..ed97d539c0 --- /dev/null +++ b/roles/web-app-matrix/tasks/addons/hookshot-jira.yml @@ -0,0 +1 @@ +--- diff --git a/roles/web-app-matrix/tasks/addons/jitsi.yml b/roles/web-app-matrix/tasks/addons/jitsi.yml new file mode 100644 index 0000000000..ed97d539c0 --- /dev/null +++ b/roles/web-app-matrix/tasks/addons/jitsi.yml @@ -0,0 +1 @@ +--- diff --git a/roles/web-app-matrix/templates/playwright.env.j2 b/roles/web-app-matrix/templates/playwright.env.j2 index 0529e2984f..446ba8ca9a 100644 --- a/roles/web-app-matrix/templates/playwright.env.j2 +++ b/roles/web-app-matrix/templates/playwright.env.j2 @@ -19,6 +19,17 @@ ELEMENT_CALL_SERVICE_ENABLED={{ MATRIX_CONFERENCING_ELEMENT_CALL | string | lowe # nocheck: playwright-service-gate — covered by sys-svc-mail integration tests, not the persona surface EMAIL_SERVICE_ENABLED={{ lookup('config', application_id, 'services.email.enabled') | string | lower }} +# nocheck: playwright-service-gate — gated by files/playwright/addons/hookshot-gitlab.spec.js, which this check does not scan +GITLAB_SERVICE_ENABLED={{ lookup('config', application_id, 'services.gitlab.enabled') | string | lower }} + +# nocheck: playwright-service-gate — gated by files/playwright/addons/hookshot-jira.spec.js, which this check does not scan +JIRA_SERVICE_ENABLED={{ lookup('config', application_id, 'services.jira.enabled') | string | lower }} + +JITSI_PREFERRED_DOMAIN={{ (MATRIX_ADDON_JITSI_PREFERRED_DOMAIN if (lookup('config', application_id, 'services.jitsi.enabled') | bool) else '') | dotenv_quote }} + +# nocheck: playwright-service-gate — gated by files/playwright/addons/jitsi.spec.js, which this check does not scan +JITSI_SERVICE_ENABLED={{ lookup('config', application_id, 'services.jitsi.enabled') | string | lower }} + # nocheck: playwright-service-gate — persona drives OIDC path; LDAP federation exercised in LDAP-only matrix variant LDAP_SERVICE_ENABLED={{ lookup('config', application_id, 'services.ldap.enabled') | string | lower }} @@ -60,6 +71,8 @@ SEAWEEDFS_SERVICE_ENABLED={{ lookup('config', application_id, 'services.seaweedf SSO_SERVICE_ENABLED={{ lookup('config', application_id, 'services.sso.enabled') | string | lower }} +{{ lookup('addon_env_flags', application_id) }} + {% for bridge in MATRIX_BRIDGES | default([], true) %} MAUTRIX_{{ bridge.bridge_name | upper | regex_replace('[^A-Z0-9]+', '_') }}_ADDON_ENABLED=true {% endfor %} diff --git a/roles/web-app-mattermost/files/playwright/addons/_plugins.js b/roles/web-app-mattermost/files/playwright/addons/_plugins.js new file mode 100644 index 0000000000..b1b68a6850 --- /dev/null +++ b/roles/web-app-mattermost/files/playwright/addons/_plugins.js @@ -0,0 +1,35 @@ +const { expect } = require("@playwright/test"); +const { resolveTimeout } = require("../timeouts"); +const { performKeycloakLoginForm } = require("../personas"); +const shared = require("../_shared"); + +const SESSION_HEADERS = { "X-Requested-With": "XMLHttpRequest" }; + +async function activePluginIds(page) { + const baseUrl = shared.expectedMattermostBaseUrl(); + + await shared.startMattermostSsoFlow(page, baseUrl); + await expect + .poll(() => page.url(), { + timeout: resolveTimeout(30_000), + message: `Expected redirect to Keycloak OIDC: ${shared.expectedOidcAuthUrl()}`, + }) + .toContain(shared.expectedOidcAuthUrl()); + + await performKeycloakLoginForm(page, shared.env.adminUsername, shared.env.adminPassword); + await shared.waitForMattermostChannelView(page, resolveTimeout(120_000)); + + const response = await page.request.get(`${baseUrl}/api/v4/plugins`, { + headers: SESSION_HEADERS, + failOnStatusCode: false, + }); + expect( + response.status(), + "the administrator session must be allowed to read /api/v4/plugins; a non-200 means the OIDC login did not land a system-admin session", + ).toBe(200); + + const body = await response.json(); + return (body.active || []).map((manifest) => manifest.id); +} + +module.exports = { activePluginIds }; diff --git a/roles/web-app-mattermost/files/playwright/addons/mattermost-plugin-agents.spec.js b/roles/web-app-mattermost/files/playwright/addons/mattermost-plugin-agents.spec.js new file mode 100644 index 0000000000..3be15e2d60 --- /dev/null +++ b/roles/web-app-mattermost/files/playwright/addons/mattermost-plugin-agents.spec.js @@ -0,0 +1,22 @@ +const { test, expect } = require("@playwright/test"); +const { resolveTimeout } = require("../timeouts"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceEnabled } = require("../service-gating"); +const { activePluginIds } = require("./_plugins"); + +const PLUGIN_ID = "mattermost-ai"; + +test.use({ ignoreHTTPSErrors: true }); + +test("addon mattermost-plugin-agents: the prepackaged Agents plugin is active", async ({ page }) => { + skipUnlessAddonEnabled("mattermost-plugin-agents"); + skipUnlessServiceEnabled("sso"); + test.setTimeout(resolveTimeout(240_000)); + + const active = await activePluginIds(page); + + expect( + active, + `${PLUGIN_ID} must be among the active plugins; the plugin ships with the image, so its absence means the enable step in tasks/utils/addon.yml never ran`, + ).toContain(PLUGIN_ID); +}); diff --git a/roles/web-app-mattermost/files/playwright/addons/mattermost-plugin-alertmanager.spec.js b/roles/web-app-mattermost/files/playwright/addons/mattermost-plugin-alertmanager.spec.js new file mode 100644 index 0000000000..30caa59cc1 --- /dev/null +++ b/roles/web-app-mattermost/files/playwright/addons/mattermost-plugin-alertmanager.spec.js @@ -0,0 +1,22 @@ +const { test, expect } = require("@playwright/test"); +const { resolveTimeout } = require("../timeouts"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceEnabled } = require("../service-gating"); +const { activePluginIds } = require("./_plugins"); + +const PLUGIN_ID = "alertmanager"; + +test.use({ ignoreHTTPSErrors: true }); + +test("addon mattermost-plugin-alertmanager: the Alertmanager plugin is installed and active", async ({ page }) => { + skipUnlessAddonEnabled("mattermost-plugin-alertmanager"); + skipUnlessServiceEnabled("sso"); + test.setTimeout(resolveTimeout(240_000)); + + const active = await activePluginIds(page); + + expect( + active, + `${PLUGIN_ID} must be among the active plugins; its absence means the marketplace install in tasks/utils/addon.yml was skipped or refused and alerts reach no channel`, + ).toContain(PLUGIN_ID); +}); diff --git a/roles/web-app-mattermost/files/playwright/addons/mattermost-plugin-gitlab.spec.js b/roles/web-app-mattermost/files/playwright/addons/mattermost-plugin-gitlab.spec.js new file mode 100644 index 0000000000..656645e234 --- /dev/null +++ b/roles/web-app-mattermost/files/playwright/addons/mattermost-plugin-gitlab.spec.js @@ -0,0 +1,22 @@ +const { test, expect } = require("@playwright/test"); +const { resolveTimeout } = require("../timeouts"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceEnabled } = require("../service-gating"); +const { activePluginIds } = require("./_plugins"); + +const PLUGIN_ID = "com.github.manland.mattermost-plugin-gitlab"; + +test.use({ ignoreHTTPSErrors: true }); + +test("addon mattermost-plugin-gitlab: the GitLab plugin is installed and active", async ({ page }) => { + skipUnlessAddonEnabled("mattermost-plugin-gitlab"); + skipUnlessServiceEnabled("sso"); + test.setTimeout(resolveTimeout(240_000)); + + const active = await activePluginIds(page); + + expect( + active, + `${PLUGIN_ID} must be among the active plugins; its absence means the marketplace install in tasks/utils/addon.yml was skipped or refused and the GitLab surface never loaded`, + ).toContain(PLUGIN_ID); +}); diff --git a/roles/web-app-mattermost/files/playwright/addons/mattermost-plugin-jenkins.spec.js b/roles/web-app-mattermost/files/playwright/addons/mattermost-plugin-jenkins.spec.js new file mode 100644 index 0000000000..7dd0ae6b50 --- /dev/null +++ b/roles/web-app-mattermost/files/playwright/addons/mattermost-plugin-jenkins.spec.js @@ -0,0 +1,22 @@ +const { test, expect } = require("@playwright/test"); +const { resolveTimeout } = require("../timeouts"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceEnabled } = require("../service-gating"); +const { activePluginIds } = require("./_plugins"); + +const PLUGIN_ID = "jenkins"; + +test.use({ ignoreHTTPSErrors: true }); + +test("addon mattermost-plugin-jenkins: the Jenkins plugin is installed and active", async ({ page }) => { + skipUnlessAddonEnabled("mattermost-plugin-jenkins"); + skipUnlessServiceEnabled("sso"); + test.setTimeout(resolveTimeout(240_000)); + + const active = await activePluginIds(page); + + expect( + active, + `${PLUGIN_ID} must be among the active plugins; its absence means the marketplace install in tasks/utils/addon.yml was skipped or refused and no /jenkins command is registered`, + ).toContain(PLUGIN_ID); +}); diff --git a/roles/web-app-mattermost/files/playwright/addons/mattermost-plugin-jira.spec.js b/roles/web-app-mattermost/files/playwright/addons/mattermost-plugin-jira.spec.js new file mode 100644 index 0000000000..7680fa685d --- /dev/null +++ b/roles/web-app-mattermost/files/playwright/addons/mattermost-plugin-jira.spec.js @@ -0,0 +1,22 @@ +const { test, expect } = require("@playwright/test"); +const { resolveTimeout } = require("../timeouts"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceEnabled } = require("../service-gating"); +const { activePluginIds } = require("./_plugins"); + +const PLUGIN_ID = "jira"; + +test.use({ ignoreHTTPSErrors: true }); + +test("addon mattermost-plugin-jira: the Jira plugin is installed and active", async ({ page }) => { + skipUnlessAddonEnabled("mattermost-plugin-jira"); + skipUnlessServiceEnabled("sso"); + test.setTimeout(resolveTimeout(240_000)); + + const active = await activePluginIds(page); + + expect( + active, + `${PLUGIN_ID} must be among the active plugins; its absence means the marketplace install in tasks/utils/addon.yml was skipped or refused and no instance can be registered`, + ).toContain(PLUGIN_ID); +}); diff --git a/roles/web-app-mattermost/files/playwright/addons/mattermost-plugin-jitsi.spec.js b/roles/web-app-mattermost/files/playwright/addons/mattermost-plugin-jitsi.spec.js new file mode 100644 index 0000000000..24a1d261be --- /dev/null +++ b/roles/web-app-mattermost/files/playwright/addons/mattermost-plugin-jitsi.spec.js @@ -0,0 +1,22 @@ +const { test, expect } = require("@playwright/test"); +const { resolveTimeout } = require("../timeouts"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceEnabled } = require("../service-gating"); +const { activePluginIds } = require("./_plugins"); + +const PLUGIN_ID = "jitsi"; + +test.use({ ignoreHTTPSErrors: true }); + +test("addon mattermost-plugin-jitsi: the Jitsi plugin is installed and active", async ({ page }) => { + skipUnlessAddonEnabled("mattermost-plugin-jitsi"); + skipUnlessServiceEnabled("sso"); + test.setTimeout(resolveTimeout(240_000)); + + const active = await activePluginIds(page); + + expect( + active, + `${PLUGIN_ID} must be among the active plugins; its absence means the marketplace install in tasks/utils/addon.yml was skipped or refused and no /jitsi command is registered`, + ).toContain(PLUGIN_ID); +}); diff --git a/roles/web-app-mattermost/files/playwright/addons/saml.spec.js b/roles/web-app-mattermost/files/playwright/addons/saml.spec.js new file mode 100644 index 0000000000..7e67d90c1a --- /dev/null +++ b/roles/web-app-mattermost/files/playwright/addons/saml.spec.js @@ -0,0 +1,32 @@ +const { test, expect } = require("@playwright/test"); +const { resolveTimeout } = require("../timeouts"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceEnabled } = require("../service-gating"); +const { gotoOnion } = require("../personas"); +const shared = require("../_shared"); + +test.use({ ignoreHTTPSErrors: true }); + +test("addon saml: the licensed SAML entry point reaches the partner Keycloak", async ({ page }) => { + skipUnlessAddonEnabled("saml"); + skipUnlessServiceEnabled("sso"); + test.setTimeout(resolveTimeout(120_000)); + + const baseUrl = shared.expectedMattermostBaseUrl(); + await gotoOnion(page, `${baseUrl}/login`, { waitUntil: "load", timeout: resolveTimeout(60_000) }); + + const samlEntry = page.locator("a[href='/login/sso/saml']"); + await expect( + samlEntry, + "the SAML login entry point must render once the Enterprise licence activates this addon; without the licence the role stays on the OIDC path and this addon must remain disabled", + ).toBeVisible({ timeout: resolveTimeout(30_000) }); + + const response = await page.request.get(`${baseUrl}/login/sso/saml`, { + failOnStatusCode: false, + maxRedirects: 0, + }); + expect( + response.headers()["location"] || "", + "the SAML entry point must hand off to the partner Keycloak, not answer locally", + ).toContain(new URL(shared.env.oidcIssuerUrl).host); +}); diff --git a/roles/web-app-mattermost/meta/addons/mattermost-plugin-agents.yml b/roles/web-app-mattermost/meta/addons/mattermost-plugin-agents.yml new file mode 100644 index 0000000000..874d5d52c3 --- /dev/null +++ b/roles/web-app-mattermost/meta/addons/mattermost-plugin-agents.yml @@ -0,0 +1,10 @@ +--- +enabled: "{{ lookup('config', 'web-app-mattermost', 'services.openwebui.enabled') | bool }}" +required: false +mechanism: plugin +source: bundled +bridges: + - openwebui +config: + plugin_id: mattermost-ai + partner_url: "{{ lookup('tls', 'web-app-openwebui', 'url.base') | regex_replace('/+$', '') ~ '/api' }}" diff --git a/roles/web-app-mattermost/meta/addons/mattermost-plugin-alertmanager.yml b/roles/web-app-mattermost/meta/addons/mattermost-plugin-alertmanager.yml new file mode 100644 index 0000000000..bd8b85e927 --- /dev/null +++ b/roles/web-app-mattermost/meta/addons/mattermost-plugin-alertmanager.yml @@ -0,0 +1,16 @@ +--- +enabled: false +required: false +mechanism: plugin +source: upstream +version: "v0.3.0" +bridges: + - prometheus +update: + monitored: true + catalog: github-releases + upstream_id: cpanato/mattermost-plugin-alertmanager +config: + plugin_id: alertmanager + partner_host: "{{ lookup('container_address', 'web-app-prometheus', 'alertmanager') }}" + partner_port: "{{ lookup('config', 'web-app-prometheus', 'services.alertmanager.ports.internal.http') }}" diff --git a/roles/web-app-mattermost/meta/addons/mattermost-plugin-gitlab.yml b/roles/web-app-mattermost/meta/addons/mattermost-plugin-gitlab.yml new file mode 100644 index 0000000000..9aadba2acc --- /dev/null +++ b/roles/web-app-mattermost/meta/addons/mattermost-plugin-gitlab.yml @@ -0,0 +1,15 @@ +--- +enabled: "{{ lookup('config', 'web-app-mattermost', 'services.gitlab.enabled') | bool }}" +required: false +mechanism: plugin +source: upstream +version: "v2.2.0" +bridges: + - gitlab +update: + monitored: true + catalog: github-releases + upstream_id: mattermost/mattermost-plugin-gitlab +config: + plugin_id: com.github.manland.mattermost-plugin-gitlab + partner_url: "{{ lookup('tls', 'web-app-gitlab', 'url.base') }}" diff --git a/roles/web-app-mattermost/meta/addons/mattermost-plugin-jenkins.yml b/roles/web-app-mattermost/meta/addons/mattermost-plugin-jenkins.yml new file mode 100644 index 0000000000..0214d63a48 --- /dev/null +++ b/roles/web-app-mattermost/meta/addons/mattermost-plugin-jenkins.yml @@ -0,0 +1,15 @@ +--- +enabled: "{{ lookup('config', 'web-app-mattermost', 'services.jenkins.enabled') | bool }}" +required: false +mechanism: plugin +source: upstream +version: "v1.1.0" +bridges: + - jenkins +update: + monitored: true + catalog: github-releases + upstream_id: mattermost/mattermost-plugin-jenkins +config: + plugin_id: jenkins + partner_url: "{{ lookup('tls', 'web-app-jenkins', 'url.base') }}" diff --git a/roles/web-app-mattermost/meta/addons/mattermost-plugin-jira.yml b/roles/web-app-mattermost/meta/addons/mattermost-plugin-jira.yml new file mode 100644 index 0000000000..44b1ab529d --- /dev/null +++ b/roles/web-app-mattermost/meta/addons/mattermost-plugin-jira.yml @@ -0,0 +1,15 @@ +--- +enabled: "{{ lookup('config', 'web-app-mattermost', 'services.jira.enabled') | bool }}" +required: false +mechanism: plugin +source: upstream +version: "v4.2.0" +bridges: + - jira +update: + monitored: true + catalog: github-releases + upstream_id: mattermost/mattermost-plugin-jira +config: + plugin_id: jira + partner_url: "{{ lookup('tls', 'web-app-jira', 'url.base') }}" diff --git a/roles/web-app-mattermost/meta/addons/mattermost-plugin-jitsi.yml b/roles/web-app-mattermost/meta/addons/mattermost-plugin-jitsi.yml new file mode 100644 index 0000000000..d1e12821bd --- /dev/null +++ b/roles/web-app-mattermost/meta/addons/mattermost-plugin-jitsi.yml @@ -0,0 +1,15 @@ +--- +enabled: "{{ lookup('config', 'web-app-mattermost', 'services.jitsi.enabled') | bool }}" +required: false +mechanism: plugin +source: upstream +version: "v2.0.3" +bridges: + - jitsi +update: + monitored: true + catalog: github-releases + upstream_id: mattermost-community/mattermost-plugin-jitsi +config: + plugin_id: jitsi + partner_url: "{{ lookup('tls', 'web-app-jitsi', 'url.base') }}" diff --git a/roles/web-app-mattermost/meta/addons/saml.yml b/roles/web-app-mattermost/meta/addons/saml.yml new file mode 100644 index 0000000000..2d1bb6895c --- /dev/null +++ b/roles/web-app-mattermost/meta/addons/saml.yml @@ -0,0 +1,11 @@ +--- +enabled: false +required: false +mechanism: addon +source: bundled +bridges: + - sso +config: + plugin_id: saml + licence_tier: enterprise + partner_url: "{{ lookup('tls', 'web-app-keycloak', 'url.base') }}" diff --git a/roles/web-app-mattermost/tasks/addons/mattermost-plugin-agents.yml b/roles/web-app-mattermost/tasks/addons/mattermost-plugin-agents.yml new file mode 100644 index 0000000000..4b0b6834ec --- /dev/null +++ b/roles/web-app-mattermost/tasks/addons/mattermost-plugin-agents.yml @@ -0,0 +1,10 @@ +--- +- name: "🤖 Agents plugin takes a second OpenAI-compatible service" + ansible.builtin.debug: + msg: >- + {{ application_id }}: the plugin ships with the image and + tasks/utils/ai_gateway.yml already owns its service and bot rows. Add + {{ mattermost_addon.value.config.partner_url }} as a further + OpenAI-compatible service in System Console > Plugins > Agents to route + prompts at the partner instead of the platform gateway. + changed_when: false diff --git a/roles/web-app-mattermost/tasks/addons/mattermost-plugin-alertmanager.yml b/roles/web-app-mattermost/tasks/addons/mattermost-plugin-alertmanager.yml new file mode 100644 index 0000000000..d276a02c85 --- /dev/null +++ b/roles/web-app-mattermost/tasks/addons/mattermost-plugin-alertmanager.yml @@ -0,0 +1,10 @@ +--- +- name: "🚨 Alertmanager plugin reads the partner alert API" + ansible.builtin.debug: + msg: >- + {{ application_id }}: tasks/utils/addon.yml installed and enabled + {{ mattermost_addon.value.config.plugin_id }}. Set the Alertmanager URL to + http://{{ mattermost_addon.value.config.partner_host }}:{{ mattermost_addon.value.config.partner_port }} + and point the partner's webhook receiver at this instance to complete the + coupling. + changed_when: false diff --git a/roles/web-app-mattermost/tasks/addons/mattermost-plugin-gitlab.yml b/roles/web-app-mattermost/tasks/addons/mattermost-plugin-gitlab.yml new file mode 100644 index 0000000000..a1588c4063 --- /dev/null +++ b/roles/web-app-mattermost/tasks/addons/mattermost-plugin-gitlab.yml @@ -0,0 +1,9 @@ +--- +- name: "🦊 GitLab plugin needs an OAuth application on the partner" + ansible.builtin.debug: + msg: >- + {{ application_id }}: tasks/utils/addon.yml installed and enabled + {{ mattermost_addon.value.config.plugin_id }}. Register an OAuth application on + {{ mattermost_addon.value.config.partner_url }} and enter its client id and + secret in System Console > Plugins > GitLab to complete the coupling. + changed_when: false diff --git a/roles/web-app-mattermost/tasks/addons/mattermost-plugin-jenkins.yml b/roles/web-app-mattermost/tasks/addons/mattermost-plugin-jenkins.yml new file mode 100644 index 0000000000..1ee749abc4 --- /dev/null +++ b/roles/web-app-mattermost/tasks/addons/mattermost-plugin-jenkins.yml @@ -0,0 +1,9 @@ +--- +- name: "🔧 Jenkins plugin needs an API token on the partner" + ansible.builtin.debug: + msg: >- + {{ application_id }}: tasks/utils/addon.yml installed and enabled + {{ mattermost_addon.value.config.plugin_id }}. Issue an API token on + {{ mattermost_addon.value.config.partner_url }} and enter it with + '/jenkins connect' to complete the coupling. + changed_when: false diff --git a/roles/web-app-mattermost/tasks/addons/mattermost-plugin-jira.yml b/roles/web-app-mattermost/tasks/addons/mattermost-plugin-jira.yml new file mode 100644 index 0000000000..4cb4ec3033 --- /dev/null +++ b/roles/web-app-mattermost/tasks/addons/mattermost-plugin-jira.yml @@ -0,0 +1,9 @@ +--- +- name: "🧭 Jira plugin needs its instance registered after install" + ansible.builtin.debug: + msg: >- + {{ application_id }}: tasks/utils/addon.yml installed and enabled + {{ mattermost_addon.value.config.plugin_id }}. Register the instance with + '/jira instance install server {{ mattermost_addon.value.config.partner_url }}' + and install the returned application link on the partner Jira. + changed_when: false diff --git a/roles/web-app-mattermost/tasks/addons/mattermost-plugin-jitsi.yml b/roles/web-app-mattermost/tasks/addons/mattermost-plugin-jitsi.yml new file mode 100644 index 0000000000..2794672968 --- /dev/null +++ b/roles/web-app-mattermost/tasks/addons/mattermost-plugin-jitsi.yml @@ -0,0 +1,9 @@ +--- +- name: "🎥 Jitsi plugin embeds the partner meeting server" + ansible.builtin.debug: + msg: >- + {{ application_id }}: tasks/utils/addon.yml installed and enabled + {{ mattermost_addon.value.config.plugin_id }}. Set the Jitsi server URL to + {{ mattermost_addon.value.config.partner_url }} in System Console > Plugins > + Jitsi to complete the coupling. + changed_when: false diff --git a/roles/web-app-mattermost/tasks/addons/saml.yml b/roles/web-app-mattermost/tasks/addons/saml.yml new file mode 100644 index 0000000000..9fb713a7c5 --- /dev/null +++ b/roles/web-app-mattermost/tasks/addons/saml.yml @@ -0,0 +1,8 @@ +--- +- name: "🛑 SAML is licence-gated and never installed by this role" + ansible.builtin.fail: + msg: >- + {{ application_id }}: SAML 2.0 is a {{ mattermost_addon.value.config.licence_tier }} + tier feature of the Mattermost server, not a marketplace plugin, so no task can + install it. The free tier reaches {{ mattermost_addon.value.config.partner_url }} + through the OIDC path in tasks/02_keycloak.yml instead; keep this addon off. diff --git a/roles/web-app-mattermost/templates/playwright.env.j2 b/roles/web-app-mattermost/templates/playwright.env.j2 index 4114d0ad43..d91b22cfef 100644 --- a/roles/web-app-mattermost/templates/playwright.env.j2 +++ b/roles/web-app-mattermost/templates/playwright.env.j2 @@ -55,3 +55,5 @@ SEAWEEDFS_S3_URL={{ lookup('canonical_url', 'web-svc-seaweedfs', 'api', consumer SEAWEEDFS_SERVICE_ENABLED={{ lookup('config', application_id, 'services.seaweedfs.enabled') | string | lower }} SSO_SERVICE_ENABLED={{ lookup('config', application_id, 'services.sso.enabled') | string | lower }} + +{{ lookup('addon_env_flags', application_id) }} diff --git a/roles/web-app-mediawiki/files/playwright/addons/DiscourseSsoConsumer.spec.js b/roles/web-app-mediawiki/files/playwright/addons/DiscourseSsoConsumer.spec.js new file mode 100644 index 0000000000..a7d729c522 --- /dev/null +++ b/roles/web-app-mediawiki/files/playwright/addons/DiscourseSsoConsumer.spec.js @@ -0,0 +1,54 @@ +const { test, expect } = require("@playwright/test"); +const { resolveTimeout } = require("../timeouts"); + +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceEnabled } = require("../service-gating"); +const { decodeDotenvQuotedValue, normalizeBaseUrl } = require("../personas"); + +test.use({ ignoreHTTPSErrors: true }); + +const appBaseUrl = normalizeBaseUrl(process.env.APP_BASE_URL || ""); +const partnerBaseUrl = normalizeBaseUrl( + decodeDotenvQuotedValue(process.env.DISCOURSE_BASE_URL || ""), +); + +test("DiscourseSsoConsumer: the extension is loaded on top of PluggableAuth and the Discourse partner is a distinct host", async ({ + request, +}) => { + skipUnlessAddonEnabled("DiscourseSsoConsumer"); + skipUnlessServiceEnabled("discourse"); + test.setTimeout(resolveTimeout(120_000)); + + expect(appBaseUrl, "APP_BASE_URL must be set").toBeTruthy(); + expect( + partnerBaseUrl, + "DISCOURSE_BASE_URL must resolve to the deployed Discourse partner once services.discourse.enabled is true", + ).toBeTruthy(); + expect( + new URL(partnerBaseUrl).host, + "the Discourse SSO provider must be the partner instance, not the wiki itself", + ).not.toBe(new URL(appBaseUrl).host); + + const siteinfo = await request.get( + `${appBaseUrl}/api.php?action=query&meta=siteinfo&siprop=extensions&format=json&formatversion=2`, + { timeout: resolveTimeout(60_000) }, + ); + expect( + siteinfo.status(), + "the MediaWiki action API must answer so the loaded extension list can be read", + ).toBe(200); + + const installed = ((await siteinfo.json()).query?.extensions || []).map( + (extension) => extension.name, + ); + expect( + installed, + "DiscourseSsoConsumer is not loaded; it is not bundled in the mediawiki image, so a missing " + + "tarball or an unfinished composer install left it out of LocalSettings.php", + ).toContain("DiscourseSsoConsumer"); + expect( + installed, + "PluggableAuth is missing: DiscourseSsoConsumer is a PluggableAuth provider and authenticates " + + "nobody without it, so the wiki would keep its own login form while the addon looks installed", + ).toContain("PluggableAuth"); +}); diff --git a/roles/web-app-mediawiki/files/playwright/addons/MachineTranslation.spec.js b/roles/web-app-mediawiki/files/playwright/addons/MachineTranslation.spec.js new file mode 100644 index 0000000000..9b8b338872 --- /dev/null +++ b/roles/web-app-mediawiki/files/playwright/addons/MachineTranslation.spec.js @@ -0,0 +1,62 @@ +const { test, expect } = require("@playwright/test"); +const { resolveTimeout } = require("../timeouts"); + +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceEnabled } = require("../service-gating"); +const { decodeDotenvQuotedValue, normalizeBaseUrl } = require("../personas"); + +test.use({ ignoreHTTPSErrors: true }); + +const appBaseUrl = normalizeBaseUrl(process.env.APP_BASE_URL || ""); +const partnerBaseUrl = normalizeBaseUrl( + decodeDotenvQuotedValue(process.env.LIBRETRANSLATE_BASE_URL || ""), +); + +test("MachineTranslation: the extension is loaded and the LibreTranslate partner answers as a distinct host", async ({ + request, +}) => { + skipUnlessAddonEnabled("MachineTranslation"); + skipUnlessServiceEnabled("libretranslate"); + test.setTimeout(resolveTimeout(120_000)); + + expect(appBaseUrl, "APP_BASE_URL must be set").toBeTruthy(); + expect( + partnerBaseUrl, + "LIBRETRANSLATE_BASE_URL must resolve to the deployed LibreTranslate partner once services.libretranslate.enabled is true", + ).toBeTruthy(); + expect( + new URL(partnerBaseUrl).host, + "the translation backend must be the partner instance, not the wiki itself", + ).not.toBe(new URL(appBaseUrl).host); + + const siteinfo = await request.get( + `${appBaseUrl}/api.php?action=query&meta=siteinfo&siprop=extensions&format=json&formatversion=2`, + { timeout: resolveTimeout(60_000) }, + ); + expect( + siteinfo.status(), + "the MediaWiki action API must answer so the loaded extension list can be read", + ).toBe(200); + + const installed = ((await siteinfo.json()).query?.extensions || []).map( + (extension) => extension.name, + ); + expect( + installed, + "MachineTranslation is not loaded; it is not bundled in the mediawiki image, so a missing " + + "tarball or an unfinished composer install left it out of LocalSettings.php", + ).toContain("MachineTranslation"); + + const languages = await request.get(`${partnerBaseUrl}/languages`, { + timeout: resolveTimeout(60_000), + }); + expect( + languages.status(), + "the LibreTranslate partner must serve its /languages catalogue; without it the extension has " + + "no translation backend and every translation request fails at runtime", + ).toBe(200); + expect( + (await languages.json()).length, + "the LibreTranslate partner must advertise at least one language model", + ).toBeGreaterThan(0); +}); diff --git a/roles/web-app-mediawiki/files/playwright/addons/PeerTubeEmbed.spec.js b/roles/web-app-mediawiki/files/playwright/addons/PeerTubeEmbed.spec.js new file mode 100644 index 0000000000..962cc6dbe7 --- /dev/null +++ b/roles/web-app-mediawiki/files/playwright/addons/PeerTubeEmbed.spec.js @@ -0,0 +1,52 @@ +const { test, expect } = require("@playwright/test"); +const { resolveTimeout } = require("../timeouts"); + +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceEnabled } = require("../service-gating"); +const { decodeDotenvQuotedValue, normalizeBaseUrl } = require("../personas"); + +test.use({ ignoreHTTPSErrors: true }); + +const appBaseUrl = normalizeBaseUrl(process.env.APP_BASE_URL || ""); +const partnerBaseUrl = normalizeBaseUrl( + decodeDotenvQuotedValue(process.env.PEERTUBE_BASE_URL || ""), +); + +test("PeerTubeEmbed: the extension is loaded and registers its parser tag", async ({ + request, +}) => { + skipUnlessAddonEnabled("PeerTubeEmbed"); + skipUnlessServiceEnabled("peertube"); + test.setTimeout(resolveTimeout(120_000)); + + expect(appBaseUrl, "APP_BASE_URL must be set").toBeTruthy(); + expect( + partnerBaseUrl, + "PEERTUBE_BASE_URL must resolve to the deployed PeerTube partner once services.peertube.enabled is true", + ).toBeTruthy(); + expect( + new URL(partnerBaseUrl).host, + "the embedded videos must come from the partner instance, not from the wiki itself", + ).not.toBe(new URL(appBaseUrl).host); + + const siteinfo = await request.get( + `${appBaseUrl}/api.php?action=query&meta=siteinfo&siprop=extensions|extensiontags&format=json&formatversion=2`, + { timeout: resolveTimeout(60_000) }, + ); + expect( + siteinfo.status(), + "the MediaWiki action API must answer so the loaded extension list can be read", + ).toBe(200); + + const payload = (await siteinfo.json()).query || {}; + expect( + (payload.extensions || []).map((extension) => extension.name), + "PeerTubeEmbed is not loaded; it is not bundled in the mediawiki image, so a missing tarball " + + "or an unfinished composer install left it out of LocalSettings.php", + ).toContain("PeerTubeEmbed"); + expect( + (payload.extensiontags || []).some((tag) => /peertube/i.test(String(tag))), + "the wiki advertises no PeerTube parser tag: the extension is loaded but its tag hook never " + + "registered, so no wiki page can embed a partner video", + ).toBe(true); +}); diff --git a/roles/web-app-mediawiki/meta/addons/DiscourseSsoConsumer.yml b/roles/web-app-mediawiki/meta/addons/DiscourseSsoConsumer.yml new file mode 100644 index 0000000000..2e630e00cd --- /dev/null +++ b/roles/web-app-mediawiki/meta/addons/DiscourseSsoConsumer.yml @@ -0,0 +1,14 @@ +--- +enabled: "{{ (lookup('config', 'web-app-mediawiki', 'services.discourse.enabled') | bool) and (lookup('config', 'web-app-mediawiki', 'services.sso.enabled') | bool) + }}" +required: false +mechanism: extension +source: upstream +bridges: + - discourse +update: + monitored: true + catalog: mediawiki-extension + upstream_id: DiscourseSsoConsumer +config: + archive: "https://codeload.github.com/centertap/DiscourseSsoConsumer/tar.gz/refs/heads/main" diff --git a/roles/web-app-mediawiki/meta/addons/MachineTranslation.yml b/roles/web-app-mediawiki/meta/addons/MachineTranslation.yml new file mode 100644 index 0000000000..5ba01f54b9 --- /dev/null +++ b/roles/web-app-mediawiki/meta/addons/MachineTranslation.yml @@ -0,0 +1,11 @@ +--- +enabled: "{{ lookup('config', 'web-app-mediawiki', 'services.libretranslate.enabled') | bool }}" +required: false +mechanism: extension +source: upstream +bridges: + - libretranslate +update: + monitored: true + catalog: mediawiki-extension + upstream_id: MachineTranslation diff --git a/roles/web-app-mediawiki/meta/addons/PeerTubeEmbed.yml b/roles/web-app-mediawiki/meta/addons/PeerTubeEmbed.yml new file mode 100644 index 0000000000..f6f188e4bf --- /dev/null +++ b/roles/web-app-mediawiki/meta/addons/PeerTubeEmbed.yml @@ -0,0 +1,11 @@ +--- +enabled: false +required: false +mechanism: extension +source: upstream +bridges: + - peertube +update: + monitored: true + catalog: mediawiki-extension + upstream_id: PeerTubeEmbed diff --git a/roles/web-app-mediawiki/tasks/addons/DiscourseSsoConsumer.yml b/roles/web-app-mediawiki/tasks/addons/DiscourseSsoConsumer.yml new file mode 100644 index 0000000000..ed97d539c0 --- /dev/null +++ b/roles/web-app-mediawiki/tasks/addons/DiscourseSsoConsumer.yml @@ -0,0 +1 @@ +--- diff --git a/roles/web-app-mediawiki/tasks/addons/MachineTranslation.yml b/roles/web-app-mediawiki/tasks/addons/MachineTranslation.yml new file mode 100644 index 0000000000..ed97d539c0 --- /dev/null +++ b/roles/web-app-mediawiki/tasks/addons/MachineTranslation.yml @@ -0,0 +1 @@ +--- diff --git a/roles/web-app-mediawiki/tasks/addons/PeerTubeEmbed.yml b/roles/web-app-mediawiki/tasks/addons/PeerTubeEmbed.yml new file mode 100644 index 0000000000..ed97d539c0 --- /dev/null +++ b/roles/web-app-mediawiki/tasks/addons/PeerTubeEmbed.yml @@ -0,0 +1 @@ +--- diff --git a/roles/web-app-mediawiki/templates/playwright.env.j2 b/roles/web-app-mediawiki/templates/playwright.env.j2 index ac41a368cd..655e0cffce 100644 --- a/roles/web-app-mediawiki/templates/playwright.env.j2 +++ b/roles/web-app-mediawiki/templates/playwright.env.j2 @@ -12,9 +12,17 @@ BIBER_USERNAME={{ lookup('users', 'biber').username | dotenv_quote }} CANONICAL_DOMAIN={{ lookup('domain', application_id) | dotenv_quote }} +DISCOURSE_BASE_URL={{ (lookup('tls', 'web-app-discourse', 'url.base') if (lookup('config', application_id, 'services.discourse.enabled') | bool) else '') | dotenv_quote }} + +DISCOURSE_SERVICE_ENABLED={{ lookup('config', application_id, 'services.discourse.enabled') | string | lower }} + # nocheck: playwright-service-gate — covered by sys-svc-mail integration tests, not the persona surface EMAIL_SERVICE_ENABLED={{ lookup('config', application_id, 'services.email.enabled') | string | lower }} +LIBRETRANSLATE_BASE_URL={{ (lookup('tls', 'web-svc-libretranslate', 'url.base') if (lookup('config', application_id, 'services.libretranslate.enabled') | bool) else '') | dotenv_quote }} + +LIBRETRANSLATE_SERVICE_ENABLED={{ lookup('config', application_id, 'services.libretranslate.enabled') | string | lower }} + LOGOUT_SERVICE_ENABLED={{ lookup('config', application_id, 'services.logout.enabled') | string | lower }} MATOMO_BASE_URL={{ lookup('tls', 'web-app-matomo', 'url.base') | dotenv_quote }} @@ -23,6 +31,10 @@ MATOMO_SERVICE_ENABLED={{ lookup('config', application_id, 'services.matomo.enab NODE_TLS_REJECT_UNAUTHORIZED=0 +PEERTUBE_BASE_URL={{ (lookup('tls', 'web-app-peertube', 'url.base') if (lookup('config', application_id, 'services.peertube.enabled') | bool) else '') | dotenv_quote }} + +PEERTUBE_SERVICE_ENABLED={{ lookup('config', application_id, 'services.peertube.enabled') | string | lower }} + # nocheck: persona-block-rationale — the wiki's bureaucrat/sysop is a local account created by maintenance/run.php createAndPromote with secrets.credentials.administrator_password (vars/main.yml MEDIAWIKI_ADMINISTRATOR_PASSWORD, tasks/04_admin.yml), not the Keycloak secret ADMIN_PASSWORD carries; $wgPluggableAuth_EnableLocalLogin is false so no native form accepts it, and $wgOpenIDConnect_UseEmailNameAsUserName lands the Keycloak identity on a separate e-mail-named wiki account with no sysop rights (see README "Persona contract opt-outs"). PERSONA_ADMINISTRATOR_BLOCKED=true diff --git a/roles/web-app-moodle/files/playwright/addons/aiprovider_openwebui.spec.js b/roles/web-app-moodle/files/playwright/addons/aiprovider_openwebui.spec.js new file mode 100644 index 0000000000..929b5356f7 --- /dev/null +++ b/roles/web-app-moodle/files/playwright/addons/aiprovider_openwebui.spec.js @@ -0,0 +1,28 @@ +const { test, expect } = require("@playwright/test"); +const { resolveTimeout } = require("../timeouts"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { loginAsSiteAdmin } = require("../_shared"); +const { gotoOnion } = require("../personas"); + +test.use({ ignoreHTTPSErrors: true }); + +test("addon aiprovider_openwebui: the Open WebUI AI provider is installed and listed among Moodle's plugins", async ({ page }) => { + skipUnlessAddonEnabled("aiprovider_openwebui"); + test.setTimeout(resolveTimeout(180_000)); + + const appBaseUrl = (process.env.APP_BASE_URL || "").replace(/\/$/, ""); + test.skip(!appBaseUrl, "APP_BASE_URL not set for this role"); + + await loginAsSiteAdmin(page); + + await gotoOnion(page, `${appBaseUrl}/admin/plugins.php`, { waitUntil: "domcontentloaded" }); + await page.waitForLoadState("networkidle").catch(() => {}); + + const body = (await page.locator("body").innerText().catch(() => "")) || ""; + expect( + body, + "Moodle's plugin overview must list aiprovider_openwebui; the component is absent when the " + + "image build never unpacked it into ai/provider/openwebui, so the AI subsystem has no " + + "provider pointing at the co-deployed Open WebUI partner", + ).toContain("openwebui"); +}); diff --git a/roles/web-app-moodle/files/playwright/addons/communication_matrix.spec.js b/roles/web-app-moodle/files/playwright/addons/communication_matrix.spec.js new file mode 100644 index 0000000000..8982bdd716 --- /dev/null +++ b/roles/web-app-moodle/files/playwright/addons/communication_matrix.spec.js @@ -0,0 +1,28 @@ +const { test, expect } = require("@playwright/test"); +const { resolveTimeout } = require("../timeouts"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { loginAsSiteAdmin } = require("../_shared"); +const { gotoOnion } = require("../personas"); + +test.use({ ignoreHTTPSErrors: true }); + +test("addon communication_matrix: the Matrix communication provider is installed and listed among Moodle's plugins", async ({ page }) => { + skipUnlessAddonEnabled("communication_matrix"); + test.setTimeout(resolveTimeout(180_000)); + + const appBaseUrl = (process.env.APP_BASE_URL || "").replace(/\/$/, ""); + test.skip(!appBaseUrl, "APP_BASE_URL not set for this role"); + + await loginAsSiteAdmin(page); + + await gotoOnion(page, `${appBaseUrl}/admin/plugins.php`, { waitUntil: "domcontentloaded" }); + await page.waitForLoadState("networkidle").catch(() => {}); + + const body = (await page.locator("body").innerText().catch(() => "")) || ""; + expect( + body, + "Moodle's plugin overview must list communication_matrix; the provider is absent when the " + + "communication subsystem was stripped from the built Moodle source, so no course room can " + + "be provisioned on the co-deployed Matrix homeserver", + ).toContain("matrix"); +}); diff --git a/roles/web-app-moodle/files/playwright/addons/mod_bigbluebuttonbn.spec.js b/roles/web-app-moodle/files/playwright/addons/mod_bigbluebuttonbn.spec.js new file mode 100644 index 0000000000..08b149fb7f --- /dev/null +++ b/roles/web-app-moodle/files/playwright/addons/mod_bigbluebuttonbn.spec.js @@ -0,0 +1,28 @@ +const { test, expect } = require("@playwright/test"); +const { resolveTimeout } = require("../timeouts"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { loginAsSiteAdmin } = require("../_shared"); +const { gotoOnion } = require("../personas"); + +test.use({ ignoreHTTPSErrors: true }); + +test("addon mod_bigbluebuttonbn: the BigBlueButton activity plugin is installed and listed among Moodle's plugins", async ({ page }) => { + skipUnlessAddonEnabled("mod_bigbluebuttonbn"); + test.setTimeout(resolveTimeout(180_000)); + + const appBaseUrl = (process.env.APP_BASE_URL || "").replace(/\/$/, ""); + test.skip(!appBaseUrl, "APP_BASE_URL not set for this role"); + + await loginAsSiteAdmin(page); + + await gotoOnion(page, `${appBaseUrl}/admin/plugins.php`, { waitUntil: "domcontentloaded" }); + await page.waitForLoadState("networkidle").catch(() => {}); + + const body = (await page.locator("body").innerText().catch(() => "")) || ""; + expect( + body, + "Moodle's plugin overview must list mod_bigbluebuttonbn; the component is absent when " + + "the activity module was stripped from the built Moodle source, so no course can carry " + + "a BigBlueButton room against the co-deployed partner", + ).toContain("bigbluebuttonbn"); +}); diff --git a/roles/web-app-moodle/files/playwright/addons/mod_jitsi.spec.js b/roles/web-app-moodle/files/playwright/addons/mod_jitsi.spec.js new file mode 100644 index 0000000000..b3305f1d99 --- /dev/null +++ b/roles/web-app-moodle/files/playwright/addons/mod_jitsi.spec.js @@ -0,0 +1,28 @@ +const { test, expect } = require("@playwright/test"); +const { resolveTimeout } = require("../timeouts"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { loginAsSiteAdmin } = require("../_shared"); +const { gotoOnion } = require("../personas"); + +test.use({ ignoreHTTPSErrors: true }); + +test("addon mod_jitsi: the Jitsi activity plugin is installed and listed among Moodle's plugins", async ({ page }) => { + skipUnlessAddonEnabled("mod_jitsi"); + test.setTimeout(resolveTimeout(180_000)); + + const appBaseUrl = (process.env.APP_BASE_URL || "").replace(/\/$/, ""); + test.skip(!appBaseUrl, "APP_BASE_URL not set for this role"); + + await loginAsSiteAdmin(page); + + await gotoOnion(page, `${appBaseUrl}/admin/plugins.php`, { waitUntil: "domcontentloaded" }); + await page.waitForLoadState("networkidle").catch(() => {}); + + const body = (await page.locator("body").innerText().catch(() => "")) || ""; + expect( + body, + "Moodle's plugin overview must list mod_jitsi; the component is absent when the image " + + "build never unpacked the plugin into mod/jitsi, so the plugin directory carries no " + + "tables and no course can open a room on the co-deployed Jitsi partner", + ).toContain("jitsi"); +}); diff --git a/roles/web-app-moodle/files/playwright/addons/repository_owncloud.spec.js b/roles/web-app-moodle/files/playwright/addons/repository_owncloud.spec.js new file mode 100644 index 0000000000..587fb3db30 --- /dev/null +++ b/roles/web-app-moodle/files/playwright/addons/repository_owncloud.spec.js @@ -0,0 +1,28 @@ +const { test, expect } = require("@playwright/test"); +const { resolveTimeout } = require("../timeouts"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { loginAsSiteAdmin } = require("../_shared"); +const { gotoOnion } = require("../personas"); + +test.use({ ignoreHTTPSErrors: true }); + +test("addon repository_owncloud: the Nextcloud repository plugin is installed and listed among Moodle's repositories", async ({ page }) => { + skipUnlessAddonEnabled("repository_owncloud"); + test.setTimeout(resolveTimeout(180_000)); + + const appBaseUrl = (process.env.APP_BASE_URL || "").replace(/\/$/, ""); + test.skip(!appBaseUrl, "APP_BASE_URL not set for this role"); + + await loginAsSiteAdmin(page); + + await gotoOnion(page, `${appBaseUrl}/admin/repository.php`, { waitUntil: "domcontentloaded" }); + await page.waitForLoadState("networkidle").catch(() => {}); + + const body = (await page.locator("body").innerText().catch(() => "")) || ""; + expect( + body, + "Moodle's repository administration must offer the ownCloud/Nextcloud repository type; it is " + + "absent when the repository plugin was stripped from the built Moodle source, so no course " + + "file picker can reach the co-deployed Nextcloud partner", + ).toMatch(/owncloud|nextcloud/i); +}); diff --git a/roles/web-app-moodle/meta/addons/aiprovider_openwebui.yml b/roles/web-app-moodle/meta/addons/aiprovider_openwebui.yml new file mode 100644 index 0000000000..350762954e --- /dev/null +++ b/roles/web-app-moodle/meta/addons/aiprovider_openwebui.yml @@ -0,0 +1,7 @@ +--- +enabled: false +required: false +mechanism: plugin +source: upstream +bridges: + - openwebui diff --git a/roles/web-app-moodle/meta/addons/communication_matrix.yml b/roles/web-app-moodle/meta/addons/communication_matrix.yml new file mode 100644 index 0000000000..2d0416ee63 --- /dev/null +++ b/roles/web-app-moodle/meta/addons/communication_matrix.yml @@ -0,0 +1,7 @@ +--- +enabled: "{{ lookup('config', 'web-app-moodle', 'services.matrix.enabled') | bool }}" +required: false +mechanism: plugin +source: bundled +bridges: + - matrix diff --git a/roles/web-app-moodle/meta/addons/mod_bigbluebuttonbn.yml b/roles/web-app-moodle/meta/addons/mod_bigbluebuttonbn.yml new file mode 100644 index 0000000000..e0b71ce118 --- /dev/null +++ b/roles/web-app-moodle/meta/addons/mod_bigbluebuttonbn.yml @@ -0,0 +1,7 @@ +--- +enabled: "{{ lookup('config', 'web-app-moodle', 'services.bigbluebutton.enabled') | bool }}" +required: false +mechanism: plugin +source: bundled +bridges: + - bigbluebutton diff --git a/roles/web-app-moodle/meta/addons/mod_jitsi.yml b/roles/web-app-moodle/meta/addons/mod_jitsi.yml new file mode 100644 index 0000000000..377ac151d7 --- /dev/null +++ b/roles/web-app-moodle/meta/addons/mod_jitsi.yml @@ -0,0 +1,7 @@ +--- +enabled: false +required: false +mechanism: plugin +source: upstream +bridges: + - jitsi diff --git a/roles/web-app-moodle/meta/addons/repository_owncloud.yml b/roles/web-app-moodle/meta/addons/repository_owncloud.yml new file mode 100644 index 0000000000..1f09fed17c --- /dev/null +++ b/roles/web-app-moodle/meta/addons/repository_owncloud.yml @@ -0,0 +1,7 @@ +--- +enabled: "{{ lookup('config', 'web-app-moodle', 'services.nextcloud.enabled') | bool }}" +required: false +mechanism: plugin +source: bundled +bridges: + - nextcloud diff --git a/roles/web-app-moodle/tasks/addons/aiprovider_openwebui.yml b/roles/web-app-moodle/tasks/addons/aiprovider_openwebui.yml new file mode 100644 index 0000000000..ed97d539c0 --- /dev/null +++ b/roles/web-app-moodle/tasks/addons/aiprovider_openwebui.yml @@ -0,0 +1 @@ +--- diff --git a/roles/web-app-moodle/tasks/addons/communication_matrix.yml b/roles/web-app-moodle/tasks/addons/communication_matrix.yml new file mode 100644 index 0000000000..ed97d539c0 --- /dev/null +++ b/roles/web-app-moodle/tasks/addons/communication_matrix.yml @@ -0,0 +1 @@ +--- diff --git a/roles/web-app-moodle/tasks/addons/mod_bigbluebuttonbn.yml b/roles/web-app-moodle/tasks/addons/mod_bigbluebuttonbn.yml new file mode 100644 index 0000000000..ed97d539c0 --- /dev/null +++ b/roles/web-app-moodle/tasks/addons/mod_bigbluebuttonbn.yml @@ -0,0 +1 @@ +--- diff --git a/roles/web-app-moodle/tasks/addons/mod_jitsi.yml b/roles/web-app-moodle/tasks/addons/mod_jitsi.yml new file mode 100644 index 0000000000..ed97d539c0 --- /dev/null +++ b/roles/web-app-moodle/tasks/addons/mod_jitsi.yml @@ -0,0 +1 @@ +--- diff --git a/roles/web-app-moodle/tasks/addons/repository_owncloud.yml b/roles/web-app-moodle/tasks/addons/repository_owncloud.yml new file mode 100644 index 0000000000..ed97d539c0 --- /dev/null +++ b/roles/web-app-moodle/tasks/addons/repository_owncloud.yml @@ -0,0 +1 @@ +--- diff --git a/roles/web-app-nextcloud/meta/addons/integration_openai.yml b/roles/web-app-nextcloud/meta/addons/integration_openai.yml index 7b4c23de84..ebca903814 100644 --- a/roles/web-app-nextcloud/meta/addons/integration_openai.yml +++ b/roles/web-app-nextcloud/meta/addons/integration_openai.yml @@ -7,6 +7,7 @@ source: upstream bridges: - openwebui - litellm + - flowise config: plugin_configuration: - appid: "integration_openai" diff --git a/roles/web-app-nextcloud/tasks/addons/integration_discourse.yml b/roles/web-app-nextcloud/tasks/addons/integration_discourse.yml index c4f10c7986..bd6f534b2a 100644 --- a/roles/web-app-nextcloud/tasks/addons/integration_discourse.yml +++ b/roles/web-app-nextcloud/tasks/addons/integration_discourse.yml @@ -1,7 +1,5 @@ --- - name: "🩹 Let the Discourse settings keep an onion URL on http" - # Exception: sed reads a bare & in the replacement as the whole match, so the - # && of the injected condition MUST stay escaped as \&\& or the guard breaks. # TODO: this patches a vendored bundle and belongs upstream. onInput() in # src/components/PersonalSettings.vue:217-224 rewrites http:// to https:// # unconditionally, which breaks an onion forum that cannot carry TLS (CI run diff --git a/roles/web-app-nextcloud/tasks/addons/integration_openai.yml b/roles/web-app-nextcloud/tasks/addons/integration_openai.yml index c514ad3dc8..d3fe391a8a 100644 --- a/roles/web-app-nextcloud/tasks/addons/integration_openai.yml +++ b/roles/web-app-nextcloud/tasks/addons/integration_openai.yml @@ -1,8 +1,4 @@ --- -# Exception logic only: the generic loader writes the Service URL (config SPOT), -# but the LiteLLM gateway's /v1 endpoint is guarded by a per-consumer virtual -# key (this role's credentials.litellm_api_key). That credential must be -# written into integration_openai api_key here; the loader cannot derive it. - name: 🔍 Resolve LiteLLM backend selection for integration_openai set_fact: nextcloud_openai_use_litellm: "{{ ('svc-ai-litellm' in group_names) and ('web-app-openwebui' not in group_names) }}" diff --git a/roles/web-app-nextcloud/tasks/addons/integration_openproject.yml b/roles/web-app-nextcloud/tasks/addons/integration_openproject.yml index 298354a85f..9043c6e26c 100644 --- a/roles/web-app-nextcloud/tasks/addons/integration_openproject.yml +++ b/roles/web-app-nextcloud/tasks/addons/integration_openproject.yml @@ -1,8 +1,4 @@ --- -# Exception logic: genuine bidirectional OAuth 2.0 coupling the generic config SPOT cannot do. -# An OAuth application is registered on the OpenProject side and a Nextcloud OAuth2 client is -# registered back on the OpenProject storage; the partner-derived client ids/secret are linked -# into integration_openproject. Re-runs only while Nextcloud is not yet coupled. - name: 🔍 Resolve expected OpenProject base URL for the integration set_fact: nextcloud_op_expected_url: "{{ lookup('tls', 'web-app-openproject', 'url.base') | trim }}" diff --git a/roles/web-app-nextcloud/tasks/addons/integration_suitecrm.yml b/roles/web-app-nextcloud/tasks/addons/integration_suitecrm.yml index 8e3fb62dff..ead6b028c6 100644 --- a/roles/web-app-nextcloud/tasks/addons/integration_suitecrm.yml +++ b/roles/web-app-nextcloud/tasks/addons/integration_suitecrm.yml @@ -1,10 +1,4 @@ --- -# Exception logic: genuine bidirectional OAuth 2.0 coupling the generic config SPOT cannot do. -# integration_suitecrm drives the SuiteCRM OAuth2 password grant and only works once a -# "password" client is registered on SuiteCRM; its client_id/client_secret plus the partner -# instance URL must then be linked into the connector's admin settings (oauth_instance_url, -# client_id, client_secret), none of which the generic config block sets. The client secret is -# derived deterministically so provisioning stays idempotent across re-runs on both ends. - name: 🔍 Resolve SuiteCRM partner coupling facts set_fact: nextcloud_crm_container: "{{ lookup('config', 'web-app-suitecrm', 'services.suitecrm.name') }}" diff --git a/roles/web-app-odoo/files/playwright/addons/auth_oauth.spec.js b/roles/web-app-odoo/files/playwright/addons/auth_oauth.spec.js new file mode 100644 index 0000000000..483c8c6d6a --- /dev/null +++ b/roles/web-app-odoo/files/playwright/addons/auth_oauth.spec.js @@ -0,0 +1,40 @@ +const { test, expect } = require("@playwright/test"); +const { resolveTimeout } = require("../timeouts"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceEnabled } = require("../service-gating"); +const shared = require("../_shared"); + +test.use({ ignoreHTTPSErrors: true }); + +test("addon auth_oauth: the login page offers the partner Keycloak provider", async ({ page }) => { + skipUnlessAddonEnabled("auth_oauth"); + skipUnlessServiceEnabled("sso"); + test.setTimeout(resolveTimeout(120_000)); + + const base = shared.baseUrl(); + expect(base, "ODOO_BASE_URL must be set").toBeTruthy(); + const issuerUrl = shared.env.oidcIssuerUrl.replace(/\/$/, ""); + expect(issuerUrl, "OIDC_ISSUER_URL must be set to address the partner Keycloak realm").toBeTruthy(); + + const login = await page.request.get(`${base}/web/login`, { + failOnStatusCode: false, + timeout: resolveTimeout(60_000), + }); + expect(login.status(), "Odoo must serve its login page").toBeLessThan(400); + + const body = await login.text(); + expect( + body, + "the login page must carry an /auth_oauth/signin redirect uri; its absence means the auth_oauth module is not installed or no OAuth provider row is active, so Keycloak cannot be used to sign in", + ).toContain("/auth_oauth/signin"); + expect( + body, + `the provider entry must point at the partner Keycloak authorization endpoint ${issuerUrl}/protocol/openid-connect/auth, which proves the auth.oauth.provider row tasks/05_oidc.yml writes carries this deployment's issuer and client id rather than Odoo's shipped default provider`, + ).toContain(`${issuerUrl}/protocol/openid-connect/auth`); + + const odooHost = new URL(base).hostname; + expect( + new URL(issuerUrl).hostname, + `the authorization endpoint must live on the external Keycloak host, not on the Odoo host (${odooHost})`, + ).not.toBe(odooHost); +}); diff --git a/roles/web-app-odoo/files/playwright/addons/mail.spec.js b/roles/web-app-odoo/files/playwright/addons/mail.spec.js new file mode 100644 index 0000000000..cfeb8813a0 --- /dev/null +++ b/roles/web-app-odoo/files/playwright/addons/mail.spec.js @@ -0,0 +1,40 @@ +const { test, expect } = require("@playwright/test"); +const { resolveTimeout } = require("../timeouts"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceEnabled } = require("../service-gating"); +const shared = require("../_shared"); + +test("addon mail: the mail module that carries Odoo's outgoing mail transport is installed", async ({ browser }) => { + skipUnlessAddonEnabled("mail"); + skipUnlessServiceEnabled("email"); + + const { context, page } = await shared.authenticatedContext(browser); + + try { + await shared.openModule(page, "odoo/discuss"); + + const errorPage = page.locator(".o_error_dialog, .o_error_detail").or( + page.getByText(/sorry,?\s*(this page|the page).*(not found|does not exist)|page not found|404 not found/i) + ); + await expect( + errorPage, + "opening /odoo/discuss must not render an Odoo error/not-found page; that means the mail module is not installed and no ir.mail_server transport exists to reach the partner mail server" + ).toHaveCount(0); + + const discussSurface = page + .locator(".o_mail_discuss, .o-mail-Discuss, .o_action_manager") + .or(page.getByText(/discuss|inbox|channel/i)); + await expect( + discussSurface.first(), + "the Discuss surface the mail module registers must render; without that module Odoo has no mail layer, so the SMTP endpoint templates/odoo.conf.j2 configures is never used" + ).toBeVisible({ timeout: resolveTimeout(120_000) }); + + await expect( + page.locator("body"), + "the loaded page must expose the mail module's own vocabulary (discuss / inbox / channel / message), proving the mail module - not a generic Odoo surface - is what rendered" + ).toContainText(/discuss|inbox|channel|message/i, { timeout: resolveTimeout(120_000) }); + } finally { + await page.close().catch(() => {}); + await context.close().catch(() => {}); + } +}); diff --git a/roles/web-app-odoo/files/playwright/addons/nextcloud_odoo_integration.spec.js b/roles/web-app-odoo/files/playwright/addons/nextcloud_odoo_integration.spec.js new file mode 100644 index 0000000000..f58a978106 --- /dev/null +++ b/roles/web-app-odoo/files/playwright/addons/nextcloud_odoo_integration.spec.js @@ -0,0 +1,30 @@ +const { test, expect } = require("@playwright/test"); +const { resolveTimeout } = require("../timeouts"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const shared = require("../_shared"); + +test("addon nextcloud_odoo_integration: the paid Nextcloud sync module registers its settings surface", async ({ browser }) => { + skipUnlessAddonEnabled("nextcloud_odoo_integration"); + + const { context, page } = await shared.authenticatedContext(browser); + + try { + await shared.openModule(page, "odoo/action-base_setup.action_general_configuration"); + + const errorPage = page.locator(".o_error_dialog, .o_error_detail").or( + page.getByText(/sorry,?\s*(this page|the page).*(not found|does not exist)|page not found|404 not found/i) + ); + await expect( + errorPage, + "opening the general settings action must not render an Odoo error/not-found page" + ).toHaveCount(0); + + await expect( + page.locator("body"), + "the general settings page must expose the Nextcloud section the module adds; its absence means a licensed copy of nextcloud_odoo_integration was never staged into files/addons/, so no calendar or contact sync reaches the partner Nextcloud" + ).toContainText(/nextcloud/i, { timeout: resolveTimeout(120_000) }); + } finally { + await page.close().catch(() => {}); + await context.close().catch(() => {}); + } +}); diff --git a/roles/web-app-odoo/meta/addons/auth_oauth.yml b/roles/web-app-odoo/meta/addons/auth_oauth.yml new file mode 100644 index 0000000000..1ea6bbc28a --- /dev/null +++ b/roles/web-app-odoo/meta/addons/auth_oauth.yml @@ -0,0 +1,9 @@ +--- +enabled: "{{ lookup('config', 'web-app-odoo', 'services.sso.enabled') | bool }}" +required: false +mechanism: module +source: bundled +bridges: + - sso +config: + provider_name: keycloak diff --git a/roles/web-app-odoo/meta/addons/mail.yml b/roles/web-app-odoo/meta/addons/mail.yml new file mode 100644 index 0000000000..ba4f515b12 --- /dev/null +++ b/roles/web-app-odoo/meta/addons/mail.yml @@ -0,0 +1,7 @@ +--- +enabled: "{{ lookup('config', 'web-app-odoo', 'services.email.enabled') | bool }}" +required: false +mechanism: module +source: bundled +bridges: + - email diff --git a/roles/web-app-odoo/meta/addons/nextcloud_odoo_integration.yml b/roles/web-app-odoo/meta/addons/nextcloud_odoo_integration.yml new file mode 100644 index 0000000000..97a25f2764 --- /dev/null +++ b/roles/web-app-odoo/meta/addons/nextcloud_odoo_integration.yml @@ -0,0 +1,10 @@ +--- +enabled: false +required: false +mechanism: module +source: upstream +bridges: + - nextcloud +config: + tier: paid + store_url: https://apps.odoo.com/apps/modules/20.0/nextcloud_odoo_integration diff --git a/roles/web-app-odoo/tasks/addons/auth_oauth.yml b/roles/web-app-odoo/tasks/addons/auth_oauth.yml new file mode 100644 index 0000000000..ed97d539c0 --- /dev/null +++ b/roles/web-app-odoo/tasks/addons/auth_oauth.yml @@ -0,0 +1 @@ +--- diff --git a/roles/web-app-odoo/tasks/addons/mail.yml b/roles/web-app-odoo/tasks/addons/mail.yml new file mode 100644 index 0000000000..ed97d539c0 --- /dev/null +++ b/roles/web-app-odoo/tasks/addons/mail.yml @@ -0,0 +1 @@ +--- diff --git a/roles/web-app-odoo/tasks/addons/nextcloud_odoo_integration.yml b/roles/web-app-odoo/tasks/addons/nextcloud_odoo_integration.yml new file mode 100644 index 0000000000..ed97d539c0 --- /dev/null +++ b/roles/web-app-odoo/tasks/addons/nextcloud_odoo_integration.yml @@ -0,0 +1 @@ +--- diff --git a/roles/web-app-odoo/vars/main.yml b/roles/web-app-odoo/vars/main.yml index 979384ac7d..6a43ede9d9 100644 --- a/roles/web-app-odoo/vars/main.yml +++ b/roles/web-app-odoo/vars/main.yml @@ -53,9 +53,10 @@ ODOO_ADMINISTRATOR_EMAIL: "{{ lookup('users', 'administrator').email }}" ODOO_MASTER_PASSWORD: "{{ lookup('config', application_id, 'secrets.credentials.master_password') }}" -ODOO_MODULES_CORE: "{{ lookup('config', application_id, 'addons') | dict2items | selectattr('value.group','equalto','core') | map(attribute='key') | list }}" -ODOO_MODULES_OPTIONAL: "{{ lookup('config', application_id, 'addons') | dict2items | selectattr('value.group','equalto','optional') | map(attribute='key') | list - }}" +ODOO_MODULES_CORE: "{{ lookup('config', application_id, 'addons') | dict2items | selectattr('value.group','defined') | selectattr('value.group','equalto','core') + | map(attribute='key') | list }}" +ODOO_MODULES_OPTIONAL: "{{ lookup('config', application_id, 'addons') | dict2items | selectattr('value.group','defined') | selectattr('value.group','equalto','optional') + | map(attribute='key') | list }}" ODOO_DB_HOST: "{{ lookup('database', application_id, 'host') }}" ODOO_DB_NAME: "{{ lookup('database', application_id, 'name') }}" diff --git a/roles/web-app-openproject/files/playwright/addons/gitlab_integration.spec.js b/roles/web-app-openproject/files/playwright/addons/gitlab_integration.spec.js new file mode 100644 index 0000000000..8466a2ac9b --- /dev/null +++ b/roles/web-app-openproject/files/playwright/addons/gitlab_integration.spec.js @@ -0,0 +1,33 @@ +const { test, expect } = require("@playwright/test"); +const { resolveTimeout } = require("../timeouts"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceDisabled } = require("../service-gating"); +const { normalizeBaseUrl } = require("../personas"); + +test.use({ ignoreHTTPSErrors: true }); + +const appBaseUrl = normalizeBaseUrl(process.env.APP_BASE_URL || ""); + +test("addon gitlab_integration: the GitLab webhook endpoint is mounted for the partner to post to", async ({ request }) => { + skipUnlessAddonEnabled("gitlab_integration"); + skipUnlessServiceDisabled("sso"); + test.setTimeout(resolveTimeout(120_000)); + + expect(appBaseUrl, "APP_BASE_URL must be set").toBeTruthy(); + + const response = await request.post(`${appBaseUrl.replace(/\/$/, "")}/webhooks/gitlab`, { + headers: { "Content-Type": "application/json" }, + data: {}, + failOnStatusCode: false, + timeout: resolveTimeout(60_000), + }); + + expect( + response.status(), + "the gitlab integration module mounts POST /webhooks/gitlab; a 404 means the route is absent, so GitLab push and merge-request events never reach a work package", + ).not.toBe(404); + expect( + response.status(), + `the mounted webhook must reject an unsigned empty payload rather than accept it, and must not fail with a server error - got HTTP ${response.status()}`, + ).toBeLessThan(500); +}); diff --git a/roles/web-app-openproject/files/playwright/addons/openid_connect.spec.js b/roles/web-app-openproject/files/playwright/addons/openid_connect.spec.js new file mode 100644 index 0000000000..4118bbcb6d --- /dev/null +++ b/roles/web-app-openproject/files/playwright/addons/openid_connect.spec.js @@ -0,0 +1,29 @@ +const { test, expect } = require("@playwright/test"); +const { resolveTimeout } = require("../timeouts"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { normalizeBaseUrl } = require("../personas"); + +test.use({ ignoreHTTPSErrors: true }); + +const appBaseUrl = normalizeBaseUrl(process.env.APP_BASE_URL || ""); +const oidcIssuerUrl = normalizeBaseUrl(process.env.OIDC_ISSUER_URL || ""); + +test("addon openid_connect: the Enterprise OpenID provider drives OpenProject's own login", async ({ request }) => { + skipUnlessAddonEnabled("openid_connect"); + test.setTimeout(resolveTimeout(120_000)); + + expect(appBaseUrl, "APP_BASE_URL must be set").toBeTruthy(); + expect(oidcIssuerUrl, "OIDC_ISSUER_URL must be set to address the partner Keycloak realm").toBeTruthy(); + + const response = await request.get(`${appBaseUrl.replace(/\/$/, "")}/login`, { + maxRedirects: 0, + failOnStatusCode: false, + timeout: resolveTimeout(60_000), + }); + + const location = response.headers().location || ""; + expect( + location.startsWith(`${oidcIssuerUrl.replace(/\/$/, "")}/protocol/openid-connect/auth`), + `with an Enterprise OpenID provider registered, OpenProject's own /login must hand off to ${oidcIssuerUrl}/protocol/openid-connect/auth instead of rendering its native form; got ${location || `HTTP ${response.status()} without a Location header`}. While this addon stays disabled the deployment reaches Keycloak through the oauth2-proxy front door declared by services.sso, and this assertion is the proof that the in-app provider replaced it.`, + ).toBe(true); +}); diff --git a/roles/web-app-openproject/files/playwright/addons/storages.spec.js b/roles/web-app-openproject/files/playwright/addons/storages.spec.js new file mode 100644 index 0000000000..27604a85a1 --- /dev/null +++ b/roles/web-app-openproject/files/playwright/addons/storages.spec.js @@ -0,0 +1,30 @@ +const { test, expect } = require("@playwright/test"); +const { resolveTimeout } = require("../timeouts"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { normalizeBaseUrl } = require("../personas"); + +test.use({ ignoreHTTPSErrors: true }); + +const appBaseUrl = normalizeBaseUrl(process.env.APP_BASE_URL || ""); + +test("addon storages: the file-storages module mounts its API so a Nextcloud storage can be registered", async ({ request }) => { + skipUnlessAddonEnabled("storages"); + test.setTimeout(resolveTimeout(120_000)); + + expect(appBaseUrl, "APP_BASE_URL must be set").toBeTruthy(); + + const response = await request.get(`${appBaseUrl.replace(/\/$/, "")}/api/v3/storages`, { + headers: { Accept: "application/json" }, + failOnStatusCode: false, + timeout: resolveTimeout(60_000), + }); + + expect( + response.status(), + "the storages module mounts /api/v3/storages; a 404 means the module is not loaded in this OpenProject build, so no Nextcloud file storage can be attached to a project at all", + ).not.toBe(404); + expect( + [200, 401, 403], + `an anonymous request must be answered by the mounted collection endpoint - served, or refused for lack of a session - got HTTP ${response.status()}`, + ).toContain(response.status()); +}); diff --git a/roles/web-app-openproject/meta/addons/gitlab_integration.yml b/roles/web-app-openproject/meta/addons/gitlab_integration.yml new file mode 100644 index 0000000000..f2f2c68d45 --- /dev/null +++ b/roles/web-app-openproject/meta/addons/gitlab_integration.yml @@ -0,0 +1,9 @@ +--- +enabled: "{{ lookup('config', 'web-app-openproject', 'services.gitlab.enabled') | bool }}" +required: false +mechanism: module +source: bundled +bridges: + - gitlab +config: + webhook_path: /webhooks/gitlab diff --git a/roles/web-app-openproject/meta/addons/openid_connect.yml b/roles/web-app-openproject/meta/addons/openid_connect.yml new file mode 100644 index 0000000000..11e1001827 --- /dev/null +++ b/roles/web-app-openproject/meta/addons/openid_connect.yml @@ -0,0 +1,10 @@ +--- +enabled: false +required: false +mechanism: module +source: bundled +bridges: + - sso +config: + tier: enterprise + admin_path: /admin/settings/authentication/openid_connect_providers diff --git a/roles/web-app-openproject/meta/addons/storages.yml b/roles/web-app-openproject/meta/addons/storages.yml new file mode 100644 index 0000000000..5002d65b8c --- /dev/null +++ b/roles/web-app-openproject/meta/addons/storages.yml @@ -0,0 +1,10 @@ +--- +enabled: "{{ lookup('config', 'web-app-openproject', 'services.nextcloud.enabled') | bool }}" +required: false +mechanism: module +source: bundled +bridges: + - nextcloud +config: + provider_type: nextcloud + admin_path: /admin/settings/storages diff --git a/roles/web-app-openproject/tasks/addons/gitlab_integration.yml b/roles/web-app-openproject/tasks/addons/gitlab_integration.yml new file mode 100644 index 0000000000..ed97d539c0 --- /dev/null +++ b/roles/web-app-openproject/tasks/addons/gitlab_integration.yml @@ -0,0 +1 @@ +--- diff --git a/roles/web-app-openproject/tasks/addons/openid_connect.yml b/roles/web-app-openproject/tasks/addons/openid_connect.yml new file mode 100644 index 0000000000..ed97d539c0 --- /dev/null +++ b/roles/web-app-openproject/tasks/addons/openid_connect.yml @@ -0,0 +1 @@ +--- diff --git a/roles/web-app-openproject/tasks/addons/storages.yml b/roles/web-app-openproject/tasks/addons/storages.yml new file mode 100644 index 0000000000..ed97d539c0 --- /dev/null +++ b/roles/web-app-openproject/tasks/addons/storages.yml @@ -0,0 +1 @@ +--- diff --git a/roles/web-app-openproject/templates/playwright.env.j2 b/roles/web-app-openproject/templates/playwright.env.j2 index f93ab1cbd2..385c802822 100644 --- a/roles/web-app-openproject/templates/playwright.env.j2 +++ b/roles/web-app-openproject/templates/playwright.env.j2 @@ -32,3 +32,5 @@ PERSONA_ADMINISTRATOR_BLOCKED=false PERSONA_BIBER_BLOCKED={{ 'false' if (lookup('config', application_id, 'services.sso.enabled') | bool) else 'true' }} SSO_SERVICE_ENABLED={{ lookup('config', application_id, 'services.sso.enabled') | string | lower }} + +{{ lookup('addon_env_flags', application_id) }} diff --git a/roles/web-app-peertube/files/playwright/addons/peertube-plugin-auth-openid-connect.spec.js b/roles/web-app-peertube/files/playwright/addons/peertube-plugin-auth-openid-connect.spec.js new file mode 100644 index 0000000000..fa0f2f482c --- /dev/null +++ b/roles/web-app-peertube/files/playwright/addons/peertube-plugin-auth-openid-connect.spec.js @@ -0,0 +1,64 @@ +const { test, expect } = require("@playwright/test"); +const { resolveTimeout } = require("../timeouts"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceEnabled } = require("../service-gating"); +const { decodeDotenvQuotedValue, normalizeBaseUrl, gotoOnion } = require("../personas"); + +test.use({ ignoreHTTPSErrors: true }); + +const peertubeBaseUrl = normalizeBaseUrl(process.env.PEERTUBE_BASE_URL || ""); +const oidcIssuerUrl = normalizeBaseUrl(process.env.OIDC_ISSUER_URL || ""); +const oidcButtonText = decodeDotenvQuotedValue(process.env.OIDC_BUTTON_TEXT || ""); + +test("addon peertube-plugin-auth-openid-connect: the login page offers the external auth and it resolves to Keycloak with the OAuth client", async ({ page }) => { + skipUnlessAddonEnabled("peertube-plugin-auth-openid-connect"); + skipUnlessServiceEnabled("sso"); + test.setTimeout(resolveTimeout(180_000)); + + test.skip(!peertubeBaseUrl || !oidcIssuerUrl, "PEERTUBE_BASE_URL / OIDC_ISSUER_URL are not staged for this role"); + + const expectedOidcAuthUrl = `${oidcIssuerUrl}/protocol/openid-connect/auth`; + const buttonPatterns = [ + oidcButtonText ? new RegExp(oidcButtonText.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "i") : null, + /open\s*id\s*connect/i, + /single\s+sign[-\s]*on/i, + /sign\s*in\s+with\s+oidc/i, + ].filter(Boolean); + + await page.context().clearCookies(); + await gotoOnion(page, `${peertubeBaseUrl}/login`, { waitUntil: "domcontentloaded" }); + await page.waitForLoadState("networkidle").catch(() => {}); + + await expect + .poll( + async () => { + if (page.url().includes(expectedOidcAuthUrl)) return page.url(); + for (const pattern of buttonPatterns) { + const candidate = page.locator("a, button").filter({ hasText: pattern }).first(); + if ((await candidate.count().catch(() => 0)) > 0) { + await candidate.waitFor({ state: "visible", timeout: resolveTimeout(30_000) }).catch(() => {}); + await candidate.click().catch(() => {}); + break; + } + } + return page.url(); + }, + { + timeout: resolveTimeout(60_000), + message: `No external-auth affordance on ${peertubeBaseUrl}/login and no redirect to ${expectedOidcAuthUrl}; PeerTube has not registered the auth-openid-connect plugin`, + }, + ) + .toContain(expectedOidcAuthUrl); + + const authUrl = new URL(page.url()); + expect( + (authUrl.searchParams.get("client_id") || "").length, + "Keycloak authorization request from PeerTube must carry the client_id the plugin settings row holds", + ).toBeGreaterThan(0); + + const redirectUri = authUrl.searchParams.get("redirect_uri") || ""; + expect( + redirectUri.startsWith(peertubeBaseUrl), + `Authorization request redirect_uri must point back at this PeerTube instance (got: ${redirectUri || ""})`, + ).toBe(true); +}); diff --git a/roles/web-app-peertube/meta/addons/peertube-plugin-auth-openid-connect.yml b/roles/web-app-peertube/meta/addons/peertube-plugin-auth-openid-connect.yml new file mode 100644 index 0000000000..4d7ca07e80 --- /dev/null +++ b/roles/web-app-peertube/meta/addons/peertube-plugin-auth-openid-connect.yml @@ -0,0 +1,7 @@ +--- +enabled: "{{ lookup('config', 'web-app-peertube', 'services.sso.enabled') | bool }}" +required: false +mechanism: plugin +source: upstream +bridges: + - sso diff --git a/roles/web-app-peertube/tasks/addons/peertube-plugin-auth-openid-connect.yml b/roles/web-app-peertube/tasks/addons/peertube-plugin-auth-openid-connect.yml new file mode 100644 index 0000000000..ed97d539c0 --- /dev/null +++ b/roles/web-app-peertube/tasks/addons/peertube-plugin-auth-openid-connect.yml @@ -0,0 +1 @@ +--- diff --git a/roles/web-app-peertube/templates/playwright.env.j2 b/roles/web-app-peertube/templates/playwright.env.j2 index 40442c9f10..a5de31f0d5 100644 --- a/roles/web-app-peertube/templates/playwright.env.j2 +++ b/roles/web-app-peertube/templates/playwright.env.j2 @@ -42,3 +42,5 @@ SEAWEEDFS_SERVICE_ENABLED={{ lookup('config', application_id, 'services.seaweedf # nocheck: playwright-service-gate — consumed via shared persona helpers (roles/test-e2e-playwright/files/personas/) SSO_SERVICE_ENABLED={{ lookup('config', application_id, 'services.sso.enabled') | string | lower }} +{{ lookup('addon_env_flags', application_id) }} + diff --git a/roles/web-app-suitecrm/files/playwright/addons/OutboundEmailAccounts.spec.js b/roles/web-app-suitecrm/files/playwright/addons/OutboundEmailAccounts.spec.js new file mode 100644 index 0000000000..c81ede35dd --- /dev/null +++ b/roles/web-app-suitecrm/files/playwright/addons/OutboundEmailAccounts.spec.js @@ -0,0 +1,59 @@ +const { test, expect } = require("@playwright/test"); +const { resolveTimeout } = require("../timeouts"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceEnabled } = require("../service-gating"); +const { + decodeDotenvQuoted, + gotoOnion, + normalizeBaseUrl, + performKeycloakLoginForm, +} = require("../personas"); + +test.use({ ignoreHTTPSErrors: true }); + +const appBaseUrl = normalizeBaseUrl(process.env.APP_BASE_URL || ""); +const smtpHost = decodeDotenvQuoted(process.env.EMAIL_SMTP_HOST); +const adminUsername = decodeDotenvQuoted(process.env.ADMIN_USERNAME); +const adminPassword = decodeDotenvQuoted(process.env.ADMIN_PASSWORD); + +const MAILER_SETTINGS_ROUTE = "/legacy/index.php?module=EmailMan&action=config"; + +test("addon OutboundEmailAccounts: SuiteCRM's mailer points at the deployed Mailu SMTP host", async ({ page }) => { + skipUnlessAddonEnabled("OutboundEmailAccounts"); + skipUnlessServiceEnabled("email"); + skipUnlessServiceEnabled("sso"); + test.setTimeout(resolveTimeout(240_000)); + + expect(appBaseUrl, "APP_BASE_URL must be set").toBeTruthy(); + expect(smtpHost, "EMAIL_SMTP_HOST must be set when the email service is on").toBeTruthy(); + expect(adminUsername, "ADMIN_USERNAME must be set").toBeTruthy(); + expect(adminPassword, "ADMIN_PASSWORD must be set").toBeTruthy(); + + await page.context().clearCookies(); + + await gotoOnion(page, `${appBaseUrl}/`, { waitUntil: "domcontentloaded" }); + await performKeycloakLoginForm(page, adminUsername, adminPassword); + + const session = await page.request.get(`${appBaseUrl}/session-status`, { + timeout: resolveTimeout(30_000), + }); + expect(session.status(), "session-status must answer after the login").toBeLessThan(400); + expect( + (await session.json()).active, + "the mailer settings are an administrator surface, so the login must own a SuiteCRM session", + ).toBe(true); + + const settings = await page.request.get(`${appBaseUrl}${MAILER_SETTINGS_ROUTE}`, { + timeout: resolveTimeout(60_000), + }); + expect( + settings.status(), + `the mailer settings page ${MAILER_SETTINGS_ROUTE} must answer for an administrator`, + ).toBeLessThan(400); + + expect( + await settings.text(), + `SuiteCRM's outbound mailer must carry the deployed Mailu host (${smtpHost}); without it the ` + + "addon declares the bridge while the app still sends through its own default transport", + ).toContain(smtpHost); +}); diff --git a/roles/web-app-suitecrm/files/playwright/addons/saml.spec.js b/roles/web-app-suitecrm/files/playwright/addons/saml.spec.js new file mode 100644 index 0000000000..238c1f7bfe --- /dev/null +++ b/roles/web-app-suitecrm/files/playwright/addons/saml.spec.js @@ -0,0 +1,49 @@ +const { test, expect } = require("@playwright/test"); +const { resolveTimeout } = require("../timeouts"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceEnabled } = require("../service-gating"); +const { gotoOnion, normalizeBaseUrl } = require("../personas"); + +test.use({ ignoreHTTPSErrors: true }); + +const appBaseUrl = normalizeBaseUrl(process.env.APP_BASE_URL || ""); + +test("addon saml: SuiteCRM hands an unauthenticated visitor to the deployed Keycloak as its SAML IdP", async ({ page }) => { + skipUnlessAddonEnabled("saml"); + skipUnlessServiceEnabled("sso"); + + expect(appBaseUrl, "APP_BASE_URL must be set").toBeTruthy(); + + await page.context().clearCookies(); + + const landing = await gotoOnion(page, `${appBaseUrl}/`, { waitUntil: "domcontentloaded" }); + expect(landing, "SuiteCRM must answer the initial navigation").toBeTruthy(); + expect( + landing.status(), + "SuiteCRM must not error before handing the visitor over to the IdP", + ).toBeLessThan(400); + + await expect + .poll(() => page.url(), { + timeout: resolveTimeout(60_000), + message: + "with this addon on, AUTH_TYPE=saml must send an unauthenticated request to Keycloak's " + + "SAML endpoint; staying on SuiteCRM's own login form means the SAML_* contract never " + + "reached the app and it fell back to native authentication", + }) + .toMatch(/\/protocol\/saml|\/login-actions\//); + + const samlRequest = page.locator("input[name='SAMLRequest']"); + const idpForm = (await samlRequest.count()) > 0; + const credentialForm = await page + .locator("input[type='password']") + .first() + .isVisible() + .catch(() => false); + + expect( + idpForm || credentialForm, + "the IdP must present either the signed SAMLRequest relay or its credential form; neither " + + "means SuiteCRM reached Keycloak but not as a registered SAML service provider", + ).toBe(true); +}); diff --git a/roles/web-app-suitecrm/meta/addons/OutboundEmailAccounts.yml b/roles/web-app-suitecrm/meta/addons/OutboundEmailAccounts.yml new file mode 100644 index 0000000000..51d61a415f --- /dev/null +++ b/roles/web-app-suitecrm/meta/addons/OutboundEmailAccounts.yml @@ -0,0 +1,7 @@ +--- +enabled: false +required: false +mechanism: module +source: bundled +bridges: + - email diff --git a/roles/web-app-suitecrm/meta/addons/saml.yml b/roles/web-app-suitecrm/meta/addons/saml.yml new file mode 100644 index 0000000000..aa38a9163b --- /dev/null +++ b/roles/web-app-suitecrm/meta/addons/saml.yml @@ -0,0 +1,7 @@ +--- +enabled: "{{ lookup('config', 'web-app-suitecrm', 'services.sso.enabled') | bool }}" +required: false +mechanism: module +source: bundled +bridges: + - sso diff --git a/roles/web-app-suitecrm/tasks/addons/OutboundEmailAccounts.yml b/roles/web-app-suitecrm/tasks/addons/OutboundEmailAccounts.yml new file mode 100644 index 0000000000..ed97d539c0 --- /dev/null +++ b/roles/web-app-suitecrm/tasks/addons/OutboundEmailAccounts.yml @@ -0,0 +1 @@ +--- diff --git a/roles/web-app-suitecrm/tasks/addons/saml.yml b/roles/web-app-suitecrm/tasks/addons/saml.yml new file mode 100644 index 0000000000..ed97d539c0 --- /dev/null +++ b/roles/web-app-suitecrm/tasks/addons/saml.yml @@ -0,0 +1 @@ +--- diff --git a/roles/web-app-suitecrm/templates/playwright.env.j2 b/roles/web-app-suitecrm/templates/playwright.env.j2 index 5653fd1968..4e4a095a65 100644 --- a/roles/web-app-suitecrm/templates/playwright.env.j2 +++ b/roles/web-app-suitecrm/templates/playwright.env.j2 @@ -20,6 +20,8 @@ CSS_SERVICE_ENABLED={{ lookup('config', application_id, 'services.css.enabled') # nocheck: playwright-service-gate — the role wires no SMTP at all: templates/env.j2 renders no mail key and services.suitecrm.email.from_name is read by nothing, so the flag has no surface to gate EMAIL_SERVICE_ENABLED={{ lookup('config', application_id, 'services.email.enabled') | string | lower }} +EMAIL_SMTP_HOST={{ lookup('email', application_id).host | dotenv_quote }} + # nocheck: playwright-service-gate — only swaps SuiteCRM's own AUTH_TYPE to ldap, and only when SSO is off; with SSO on, templates/env.j2 selects saml and the LDAP block is never rendered LDAP_SERVICE_ENABLED={{ lookup('config', application_id, 'services.ldap.enabled') | string | lower }} @@ -39,3 +41,5 @@ PERSONA_ADMINISTRATOR_BLOCKED=true PERSONA_BIBER_BLOCKED=true SSO_SERVICE_ENABLED={{ lookup('config', application_id, 'services.sso.enabled') | string | lower }} + +{{ lookup('addon_env_flags', application_id) }} diff --git a/roles/web-app-taiga/files/playwright/addons/taiga-contrib-oidc-auth.spec.js b/roles/web-app-taiga/files/playwright/addons/taiga-contrib-oidc-auth.spec.js new file mode 100644 index 0000000000..bb0cb04498 --- /dev/null +++ b/roles/web-app-taiga/files/playwright/addons/taiga-contrib-oidc-auth.spec.js @@ -0,0 +1,57 @@ +const { test, expect } = require("@playwright/test"); +const { resolveTimeout } = require("../timeouts"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceEnabled } = require("../service-gating"); +const { gotoOnion } = require("../personas"); +const shared = require("../_shared"); + +test.use({ ignoreHTTPSErrors: true }); + +test("addon taiga-contrib-oidc-auth: the login route resolves to the Keycloak authorization endpoint with the OAuth client", async ({ page }) => { + skipUnlessAddonEnabled("taiga-contrib-oidc-auth"); + skipUnlessServiceEnabled("sso"); + test.setTimeout(resolveTimeout(180_000)); + + const taigaUrls = shared.getTaigaUrls(); + test.skip( + !taigaUrls.expectedTaigaBaseUrl || !taigaUrls.expectedOidcAuthUrl, + "TAIGA_BASE_URL / OIDC_ISSUER_URL are not staged for this role", + ); + + await page.context().clearCookies(); + await gotoOnion(page, `${taigaUrls.expectedTaigaBaseUrl}/login`, { waitUntil: "domcontentloaded" }); + + const entry = await shared.reachTopLevelTaigaAuthEntry( + page, + taigaUrls, + resolveTimeout(60_000), + "Taiga /login must expose either the taiga-contrib-oidc-auth entry point or the Keycloak login page", + ); + + if (entry.kind === "taiga-oidc-entry") { + await Promise.all([ + page.waitForURL((url) => url.toString().includes(taigaUrls.expectedOidcAuthUrl), { + timeout: resolveTimeout(60_000), + }), + entry.locator.click({ timeout: resolveTimeout(30_000) }), + ]); + } + + const target = page.url(); + expect( + target, + "Taiga's OIDC entry point must land on the Keycloak openid-connect authorization endpoint: the taiga-contrib-oidc-auth frontend directive and its mozilla-django-oidc backend are both installed", + ).toContain(taigaUrls.expectedOidcAuthUrl); + + const authUrl = new URL(target); + expect( + (authUrl.searchParams.get("client_id") || "").length, + "Keycloak authorization request from Taiga must carry the configured OAuth client_id", + ).toBeGreaterThan(0); + + const redirectUri = authUrl.searchParams.get("redirect_uri") || ""; + expect( + redirectUri.startsWith(taigaUrls.expectedTaigaBaseUrl), + `Authorization request redirect_uri must point back at this Taiga instance (got: ${redirectUri || ""})`, + ).toBe(true); +}); diff --git a/roles/web-app-taiga/meta/addons/taiga-contrib-oidc-auth.yml b/roles/web-app-taiga/meta/addons/taiga-contrib-oidc-auth.yml new file mode 100644 index 0000000000..7451a8fac8 --- /dev/null +++ b/roles/web-app-taiga/meta/addons/taiga-contrib-oidc-auth.yml @@ -0,0 +1,7 @@ +--- +enabled: "{{ lookup('config', 'web-app-taiga', 'services.sso.enabled') | bool }}" +required: false +mechanism: plugin +source: built +bridges: + - sso diff --git a/roles/web-app-taiga/tasks/addons/taiga-contrib-oidc-auth.yml b/roles/web-app-taiga/tasks/addons/taiga-contrib-oidc-auth.yml new file mode 100644 index 0000000000..ed97d539c0 --- /dev/null +++ b/roles/web-app-taiga/tasks/addons/taiga-contrib-oidc-auth.yml @@ -0,0 +1 @@ +--- diff --git a/roles/web-app-taiga/templates/playwright.env.j2 b/roles/web-app-taiga/templates/playwright.env.j2 index 2bf447cf49..f8e35aba6a 100644 --- a/roles/web-app-taiga/templates/playwright.env.j2 +++ b/roles/web-app-taiga/templates/playwright.env.j2 @@ -56,3 +56,5 @@ SSO_SERVICE_ENABLED={{ lookup('config', application_id, 'services.sso.enabled') TAIGA_BASE_URL={{ lookup('tls', 'web-app-taiga', 'url.base') | dotenv_quote }} +{{ lookup('addon_env_flags', application_id) }} + diff --git a/roles/web-app-wordpress/files/playwright/addons/activitypub.spec.js b/roles/web-app-wordpress/files/playwright/addons/activitypub.spec.js index 6701859602..592e2fc989 100644 --- a/roles/web-app-wordpress/files/playwright/addons/activitypub.spec.js +++ b/roles/web-app-wordpress/files/playwright/addons/activitypub.spec.js @@ -1,11 +1,13 @@ const { test, expect } = require("@playwright/test"); const { resolveTimeout } = require("../timeouts"); const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceEnabled } = require("../service-gating"); const { gotoOnion } = require("../personas"); const shared = require("../_shared"); test("addon activitypub: WordPress is a discoverable Fediverse actor (WebFinger -> ActivityStreams actor)", async ({ browser }) => { skipUnlessAddonEnabled("activitypub"); + skipUnlessServiceEnabled("sso"); test.setTimeout(resolveTimeout(120_000)); const context = await browser.newContext({ ignoreHTTPSErrors: true }); diff --git a/roles/web-app-wordpress/files/playwright/addons/ai-engine.spec.js b/roles/web-app-wordpress/files/playwright/addons/ai-engine.spec.js index d96c323a7c..c978435147 100644 --- a/roles/web-app-wordpress/files/playwright/addons/ai-engine.spec.js +++ b/roles/web-app-wordpress/files/playwright/addons/ai-engine.spec.js @@ -1,11 +1,13 @@ const { test, expect } = require("@playwright/test"); const { resolveTimeout } = require("../timeouts"); const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceEnabled } = require("../service-gating"); const { gotoOnion } = require("../personas"); const shared = require("../_shared"); test("addon ai-engine: WordPress answers a prompt through the in-cluster LiteLLM gateway", async ({ browser }) => { skipUnlessAddonEnabled("ai-engine"); + skipUnlessServiceEnabled("sso"); test.setTimeout(resolveTimeout(180_000)); const context = await browser.newContext({ ignoreHTTPSErrors: true }); diff --git a/roles/web-app-wordpress/files/playwright/addons/integration-for-listmonk-mailing-list-and-newsletter-manager.spec.js b/roles/web-app-wordpress/files/playwright/addons/integration-for-listmonk-mailing-list-and-newsletter-manager.spec.js new file mode 100644 index 0000000000..53a2d3f460 --- /dev/null +++ b/roles/web-app-wordpress/files/playwright/addons/integration-for-listmonk-mailing-list-and-newsletter-manager.spec.js @@ -0,0 +1,57 @@ +const { test, expect } = require("@playwright/test"); +const { resolveTimeout } = require("../timeouts"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceEnabled } = require("../service-gating"); +const { gotoOnion } = require("../personas"); +const shared = require("../_shared"); + +test("addon integration-for-listmonk-mailing-list-and-newsletter-manager: the newsletter plugin is active and a distinct Listmonk partner is resolved", async ({ browser }) => { + skipUnlessAddonEnabled("integration-for-listmonk-mailing-list-and-newsletter-manager"); + skipUnlessServiceEnabled("sso"); + test.setTimeout(resolveTimeout(120_000)); + + const partnerBaseUrl = (shared.env.listmonkBaseUrl || "").trim(); + expect( + /^https?:\/\//i.test(partnerBaseUrl), + "LISTMONK_BASE_URL must resolve to the deployed partner Listmonk base URL when the addon is enabled — it is the same url.base the addon's api_url is built from, so an empty value means subscriptions have nowhere to go" + ).toBeTruthy(); + + const wpHost = new URL(shared.env.wpBaseUrl).host; + const partnerHost = new URL(partnerBaseUrl).host; + expect( + partnerHost, + "the Listmonk partner host must be distinct from the WordPress host" + ).not.toBe(wpHost); + + const context = await browser.newContext({ ignoreHTTPSErrors: true }); + const page = await context.newPage(); + + try { + await shared.wpAdminLoginViaOidc( + page, + shared.env.wpBaseUrl, + shared.env.adminUsername, + shared.env.adminPassword + ); + + await gotoOnion(page, `${shared.env.wpBaseUrl}/wp-admin/plugins.php`, { + waitUntil: "domcontentloaded", + timeout: resolveTimeout(60_000), + }); + + const row = page + .locator('tr[data-slug="integration-for-listmonk-mailing-list-and-newsletter-manager"]') + .first(); + await expect( + row, + "wp-admin must list the Listmonk integration plugin row — its absence means the install step never landed the addon" + ).toBeVisible({ timeout: resolveTimeout(30_000) }); + await expect( + row, + "the plugin row must offer Deactivate, which only an ACTIVE plugin does; a downloaded-but-inactive plugin never posts a subscription to Listmonk" + ).toContainText(/deactivate/i, { timeout: resolveTimeout(30_000) }); + } finally { + await page.close().catch(() => {}); + await context.close().catch(() => {}); + } +}); diff --git a/roles/web-app-wordpress/files/playwright/addons/video-conferencing-with-bbb.spec.js b/roles/web-app-wordpress/files/playwright/addons/video-conferencing-with-bbb.spec.js new file mode 100644 index 0000000000..460f306f24 --- /dev/null +++ b/roles/web-app-wordpress/files/playwright/addons/video-conferencing-with-bbb.spec.js @@ -0,0 +1,55 @@ +const { test, expect } = require("@playwright/test"); +const { resolveTimeout } = require("../timeouts"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceEnabled } = require("../service-gating"); +const { gotoOnion } = require("../personas"); +const shared = require("../_shared"); + +test("addon video-conferencing-with-bbb: the conferencing plugin is active and a distinct BigBlueButton partner is resolved", async ({ browser }) => { + skipUnlessAddonEnabled("video-conferencing-with-bbb"); + skipUnlessServiceEnabled("sso"); + test.setTimeout(resolveTimeout(120_000)); + + const partnerBaseUrl = (shared.env.bigbluebuttonBaseUrl || "").trim(); + expect( + /^https?:\/\//i.test(partnerBaseUrl), + "BIGBLUEBUTTON_BASE_URL must resolve to the deployed partner BigBlueButton base URL when the addon is enabled — it is the same url.base the addon's api_url is built from, so an empty value means the bridge has no partner to reach" + ).toBeTruthy(); + + const wpHost = new URL(shared.env.wpBaseUrl).host; + const partnerHost = new URL(partnerBaseUrl).host; + expect( + partnerHost, + "the BigBlueButton partner host must be distinct from the WordPress host" + ).not.toBe(wpHost); + + const context = await browser.newContext({ ignoreHTTPSErrors: true }); + const page = await context.newPage(); + + try { + await shared.wpAdminLoginViaOidc( + page, + shared.env.wpBaseUrl, + shared.env.adminUsername, + shared.env.adminPassword + ); + + await gotoOnion(page, `${shared.env.wpBaseUrl}/wp-admin/plugins.php`, { + waitUntil: "domcontentloaded", + timeout: resolveTimeout(60_000), + }); + + const row = page.locator('tr[data-slug="video-conferencing-with-bbb"]').first(); + await expect( + row, + "wp-admin must list the video-conferencing-with-bbb plugin row — its absence means the install step never landed the addon" + ).toBeVisible({ timeout: resolveTimeout(30_000) }); + await expect( + row, + "the plugin row must offer Deactivate, which only an ACTIVE plugin does; a downloaded-but-inactive plugin adds no conferencing surface" + ).toContainText(/deactivate/i, { timeout: resolveTimeout(30_000) }); + } finally { + await page.close().catch(() => {}); + await context.close().catch(() => {}); + } +}); diff --git a/roles/web-app-wordpress/files/playwright/addons/video-manager-for-peertube.spec.js b/roles/web-app-wordpress/files/playwright/addons/video-manager-for-peertube.spec.js new file mode 100644 index 0000000000..11c039aaf3 --- /dev/null +++ b/roles/web-app-wordpress/files/playwright/addons/video-manager-for-peertube.spec.js @@ -0,0 +1,55 @@ +const { test, expect } = require("@playwright/test"); +const { resolveTimeout } = require("../timeouts"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceEnabled } = require("../service-gating"); +const { gotoOnion } = require("../personas"); +const shared = require("../_shared"); + +test("addon video-manager-for-peertube: the video manager is active and a distinct PeerTube partner is resolved", async ({ browser }) => { + skipUnlessAddonEnabled("video-manager-for-peertube"); + skipUnlessServiceEnabled("sso"); + test.setTimeout(resolveTimeout(120_000)); + + const partnerBaseUrl = (shared.env.peertubeBaseUrl || "").trim(); + expect( + /^https?:\/\//i.test(partnerBaseUrl), + "PEERTUBE_BASE_URL must resolve to the deployed partner PeerTube base URL when the addon is enabled — it is the same url.base the addon's instance_url carries, so an empty value means there is no instance to list videos from" + ).toBeTruthy(); + + const wpHost = new URL(shared.env.wpBaseUrl).host; + const partnerHost = new URL(partnerBaseUrl).host; + expect( + partnerHost, + "the PeerTube partner host must be distinct from the WordPress host" + ).not.toBe(wpHost); + + const context = await browser.newContext({ ignoreHTTPSErrors: true }); + const page = await context.newPage(); + + try { + await shared.wpAdminLoginViaOidc( + page, + shared.env.wpBaseUrl, + shared.env.adminUsername, + shared.env.adminPassword + ); + + await gotoOnion(page, `${shared.env.wpBaseUrl}/wp-admin/plugins.php`, { + waitUntil: "domcontentloaded", + timeout: resolveTimeout(60_000), + }); + + const row = page.locator('tr[data-slug="video-manager-for-peertube"]').first(); + await expect( + row, + "wp-admin must list the video-manager-for-peertube plugin row — its absence means the install step never landed the addon" + ).toBeVisible({ timeout: resolveTimeout(30_000) }); + await expect( + row, + "the plugin row must offer Deactivate, which only an ACTIVE plugin does; a downloaded-but-inactive plugin embeds no PeerTube video" + ).toContainText(/deactivate/i, { timeout: resolveTimeout(30_000) }); + } finally { + await page.close().catch(() => {}); + await context.close().catch(() => {}); + } +}); diff --git a/roles/web-app-wordpress/meta/addons/integration-for-listmonk-mailing-list-and-newsletter-manager.yml b/roles/web-app-wordpress/meta/addons/integration-for-listmonk-mailing-list-and-newsletter-manager.yml new file mode 100644 index 0000000000..323e433117 --- /dev/null +++ b/roles/web-app-wordpress/meta/addons/integration-for-listmonk-mailing-list-and-newsletter-manager.yml @@ -0,0 +1,14 @@ +--- +enabled: "{{ lookup('config', 'web-app-wordpress', 'services.listmonk.enabled') | bool }}" +required: false +mechanism: plugin +source: upstream +bridges: + - listmonk +update: + monitored: true + catalog: wordpress-org + upstream_id: integration-for-listmonk-mailing-list-and-newsletter-manager +config: + listmonk_settings: + api_url: "{{ lookup('tls', 'web-app-listmonk', 'url.base') }}/api" diff --git a/roles/web-app-wordpress/meta/addons/video-conferencing-with-bbb.yml b/roles/web-app-wordpress/meta/addons/video-conferencing-with-bbb.yml new file mode 100644 index 0000000000..2df6785fac --- /dev/null +++ b/roles/web-app-wordpress/meta/addons/video-conferencing-with-bbb.yml @@ -0,0 +1,15 @@ +--- +enabled: "{{ lookup('config', 'web-app-wordpress', 'services.bigbluebutton.enabled') | bool }}" +required: false +mechanism: plugin +source: upstream +bridges: + - bigbluebutton +update: + monitored: true + catalog: wordpress-org + upstream_id: video-conferencing-with-bbb +config: + bbb_settings: + api_url: "{{ lookup('tls', 'web-app-bigbluebutton', 'url.base') }}{{ lookup('config', 'web-app-bigbluebutton', 'services.bigbluebutton.api_suffix', '') }}" + api_secret: "{{ lookup('config', 'web-app-bigbluebutton', 'secrets.credentials.shared_secret', '') }}" diff --git a/roles/web-app-wordpress/meta/addons/video-manager-for-peertube.yml b/roles/web-app-wordpress/meta/addons/video-manager-for-peertube.yml new file mode 100644 index 0000000000..6e92a41c32 --- /dev/null +++ b/roles/web-app-wordpress/meta/addons/video-manager-for-peertube.yml @@ -0,0 +1,14 @@ +--- +enabled: "{{ lookup('config', 'web-app-wordpress', 'services.peertube.enabled') | bool }}" +required: false +mechanism: plugin +source: upstream +bridges: + - peertube +update: + monitored: true + catalog: wordpress-org + upstream_id: video-manager-for-peertube +config: + peertube_settings: + instance_url: "{{ lookup('tls', 'web-app-peertube', 'url.base') }}" diff --git a/roles/web-app-wordpress/tasks/addons/README.md b/roles/web-app-wordpress/tasks/addons/README.md index 33dc3a1163..f305bb471a 100644 --- a/roles/web-app-wordpress/tasks/addons/README.md +++ b/roles/web-app-wordpress/tasks/addons/README.md @@ -17,3 +17,18 @@ Runtime contract for the WordPress to Discourse post round-trip: a published pos Federates your blog with the Fediverse, making it accessible on platforms like Mastodon and Friendica. Plugin used: [activitypub](https://wordpress.org/plugins/activitypub/) + +## Video Conferencing with BBB 🎥 + +Publishes BigBlueButton rooms as WordPress content. Enabled with the `bigbluebutton` service, bridges it, and reads the partner API URL and shared secret from the addon config. +Plugin used: [video-conferencing-with-bbb](https://wordpress.org/plugins/video-conferencing-with-bbb/) + +## Listmonk Integration 📧 + +Posts WordPress subscriptions to the Listmonk API. Enabled with the `listmonk` service and bridges it; the API user is created in Listmonk and entered in the plugin. +Plugin used: [integration-for-listmonk-mailing-list-and-newsletter-manager](https://wordpress.org/plugins/integration-for-listmonk-mailing-list-and-newsletter-manager/) + +## Video Manager for PeerTube 📺 + +Lists and embeds videos of the partner PeerTube instance. Enabled with the `peertube` service and bridges it, reading the instance URL from the addon config. +Plugin used: [video-manager-for-peertube](https://wordpress.org/plugins/video-manager-for-peertube/) diff --git a/roles/web-app-wordpress/tasks/addons/integration-for-listmonk-mailing-list-and-newsletter-manager.yml b/roles/web-app-wordpress/tasks/addons/integration-for-listmonk-mailing-list-and-newsletter-manager.yml new file mode 100644 index 0000000000..d823ed5813 --- /dev/null +++ b/roles/web-app-wordpress/tasks/addons/integration-for-listmonk-mailing-list-and-newsletter-manager.yml @@ -0,0 +1,19 @@ +--- +- name: "🛑 Require the resolved Listmonk API endpoint" + ansible.builtin.assert: + that: + - WORDPRESS_LISTMONK_API_URL is match('^https?://') + fail_msg: >- + {{ application_id }} enables the listmonk service but the addon resolved + api_url='{{ WORDPRESS_LISTMONK_API_URL }}'. The newsletter plugin posts + every subscription to that endpoint, so without it the integration + installs dead. Deploy web-app-listmonk so its url.base exists. + +- name: "🔧 Listmonk API credentials are entered on the plugin's own settings page" + ansible.builtin.debug: + msg: >- + {{ application_id }}: the Listmonk integration talks to + {{ WORDPRESS_LISTMONK_API_URL }} with an API user Listmonk issues per + installation; no credential is provisioned here, so create the API user + in Listmonk and enter it under Settings -> Listmonk after the deploy. + changed_when: false diff --git a/roles/web-app-wordpress/tasks/addons/video-conferencing-with-bbb.yml b/roles/web-app-wordpress/tasks/addons/video-conferencing-with-bbb.yml new file mode 100644 index 0000000000..357fbc1fb6 --- /dev/null +++ b/roles/web-app-wordpress/tasks/addons/video-conferencing-with-bbb.yml @@ -0,0 +1,23 @@ +--- +- name: "🛑 Require the resolved BigBlueButton API endpoint and shared secret" + no_log: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}" + ansible.builtin.assert: + that: + - WORDPRESS_BBB_API_URL is match('^https?://') + - WORDPRESS_BBB_API_SECRET | length > 0 + fail_msg: >- + {{ application_id }} enables the bigbluebutton service but the addon + resolved api_url='{{ WORDPRESS_BBB_API_URL }}' and an api_secret of + {{ WORDPRESS_BBB_API_SECRET | length }} characters. Without both values + the conferencing plugin cannot reach web-app-bigbluebutton, so the + pairing would install dead. Deploy the partner role so its url.base and + secrets.credentials.shared_secret exist. + +- name: "🔧 BigBlueButton server pairing is entered on the plugin's own settings page" + ansible.builtin.debug: + msg: >- + {{ application_id }}: video-conferencing-with-bbb stores the server URL + {{ WORDPRESS_BBB_API_URL }} and its secret in the plugin's own options, + whose upstream keys are not part of a documented contract; enter them + under Settings -> BigBlueButton after the deploy. + changed_when: false diff --git a/roles/web-app-wordpress/tasks/addons/video-manager-for-peertube.yml b/roles/web-app-wordpress/tasks/addons/video-manager-for-peertube.yml new file mode 100644 index 0000000000..8e45e22780 --- /dev/null +++ b/roles/web-app-wordpress/tasks/addons/video-manager-for-peertube.yml @@ -0,0 +1,20 @@ +--- +- name: "🛑 Require the resolved PeerTube instance URL" + ansible.builtin.assert: + that: + - WORDPRESS_PEERTUBE_INSTANCE_URL is match('^https?://') + fail_msg: >- + {{ application_id }} enables the peertube service but the addon resolved + instance_url='{{ WORDPRESS_PEERTUBE_INSTANCE_URL }}'. The video manager + lists and embeds videos from that instance only, so without it the + integration installs dead. Deploy web-app-peertube so its url.base + exists. + +- name: "🔧 PeerTube instance pairing is entered on the plugin's own settings page" + ansible.builtin.debug: + msg: >- + {{ application_id }}: video-manager-for-peertube reads the instance + {{ WORDPRESS_PEERTUBE_INSTANCE_URL }} and its account token from the + plugin's own options, whose upstream keys are not part of a documented + contract; enter them under Settings -> PeerTube after the deploy. + changed_when: false diff --git a/roles/web-app-wordpress/tasks/addons/wp-discourse.yml b/roles/web-app-wordpress/tasks/addons/wp-discourse.yml index d91bd5d4a9..42ecb3ce49 100644 --- a/roles/web-app-wordpress/tasks/addons/wp-discourse.yml +++ b/roles/web-app-wordpress/tasks/addons/wp-discourse.yml @@ -10,7 +10,6 @@ include_tasks: wp-discourse-stack-host.yml when: IS_STACK_HOST | bool -# Exception: include_vars (not lookup('file')|from_yaml) so values lazy-render and the deploy-time vault_discourse_api_key resolves in this scope. - name: "📄 Load WP Discourse addon spec from meta/addons/wp-discourse.yml" ansible.builtin.include_vars: file: "{{ [role_path, 'meta/addons', 'wp-discourse.yml'] | path_join }}" diff --git a/roles/web-app-wordpress/templates/playwright.env.j2 b/roles/web-app-wordpress/templates/playwright.env.j2 index dd842ec444..3588767ac0 100644 --- a/roles/web-app-wordpress/templates/playwright.env.j2 +++ b/roles/web-app-wordpress/templates/playwright.env.j2 @@ -8,6 +8,8 @@ BIBER_PASSWORD={{ lookup('users', 'biber').password | dotenv_quote }} BIBER_USERNAME={{ lookup('users', 'biber').username | dotenv_quote }} +BIGBLUEBUTTON_BASE_URL={{ (lookup('tls', 'web-app-bigbluebutton', 'url.base') if (lookup('config', application_id, 'services.bigbluebutton.enabled') | bool) else '') | dotenv_quote }} + CANONICAL_DOMAIN={{ lookup('domain', application_id) | dotenv_quote }} DISCOURSE_API_KEY={{ (vault_discourse_api_key | default('')) | dotenv_quote }} @@ -27,6 +29,8 @@ KEYCLOAK_REALM_NAME={{ OIDC.CLIENT.REALM | dotenv_quote }} LDAP_SERVICE_ENABLED={{ lookup('service', 'ldap').required | string | lower }} +LISTMONK_BASE_URL={{ (lookup('tls', 'web-app-listmonk', 'url.base') if (lookup('config', application_id, 'services.listmonk.enabled') | bool) else '') | dotenv_quote }} + LOGOUT_SERVICE_ENABLED={{ lookup('config', application_id, 'services.logout.enabled') | string | lower }} MATOMO_BASE_URL={{ lookup('tls', 'web-app-matomo', 'url.base') | dotenv_quote }} @@ -37,6 +41,8 @@ MCP_SERVICE_ENABLED={{ lookup('config', application_id, 'mcp.enabled') | string OIDC_ISSUER_URL={{ OIDC.CLIENT.ISSUER_URL | dotenv_quote }} +PEERTUBE_BASE_URL={{ (lookup('tls', 'web-app-peertube', 'url.base') if (lookup('config', application_id, 'services.peertube.enabled') | bool) else '') | dotenv_quote }} + # nocheck: persona-block-rationale — WordPress's canonical surface is the public blog front page; the OIDC round-trip fires only on /wp-login.php, which the daggerhart plugin auto-redirects (login_type "auto", meta/addons/daggerhart-openid-connect-generic.yml:22). The shared personas enter at the site root and never touch that path, so the role drives the admin round-trip itself (files/playwright/_shared.js:73-85, test-admin-oidc-login.js). PERSONA_ADMINISTRATOR_BLOCKED=true diff --git a/roles/web-app-xwiki/files/playwright/addons/ai-llm.spec.js b/roles/web-app-xwiki/files/playwright/addons/ai-llm.spec.js index d8d77e4df1..090419d490 100644 --- a/roles/web-app-xwiki/files/playwright/addons/ai-llm.spec.js +++ b/roles/web-app-xwiki/files/playwright/addons/ai-llm.spec.js @@ -16,7 +16,7 @@ const aiGatewayBaseUrl = normalizeBaseUrl(requireDotenvValue(process.env.AI_GATE const superadminUsername = decodeDotenvQuotedValue(process.env.XWIKI_SUPERADMIN_USERNAME || ""); const superadminPassword = decodeDotenvQuotedValue(process.env.XWIKI_SUPERADMIN_PASSWORD || ""); -const EXTENSION_ID = "org.xwiki.contrib.llm:application-ai-llm-ui"; +const EXTENSION_ID = "org.xwiki.contrib.llm:application-ai-llm-models-ui"; test("ai-llm: the AI LLM Application extension is installed on the wiki", async ({ page }) => { skipUnlessAddonEnabled("ai-llm"); diff --git a/roles/web-app-zammad/files/playwright/addons/email_channel.spec.js b/roles/web-app-zammad/files/playwright/addons/email_channel.spec.js new file mode 100644 index 0000000000..3cf9ed52b8 --- /dev/null +++ b/roles/web-app-zammad/files/playwright/addons/email_channel.spec.js @@ -0,0 +1,55 @@ +const { test, expect } = require("@playwright/test"); +const { resolveTimeout } = require("../timeouts"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceEnabled } = require("../service-gating"); +const shared = require("../_shared"); + +test.use({ ignoreHTTPSErrors: true }); + +test("addon email_channel: an Email::Account channel is provisioned against the partner mail server", async ({ page }) => { + skipUnlessAddonEnabled("email_channel"); + skipUnlessServiceEnabled("email"); + test.setTimeout(resolveTimeout(180_000)); + + const { zammadBaseUrl } = shared.env; + expect(zammadBaseUrl, "ZAMMAD_BASE_URL must be set").toBeTruthy(); + + await shared.signInAsApiBot(page); + + const response = await page.context().request.get(`${zammadBaseUrl}/api/v1/channels_email`, { + headers: { Accept: "application/json" }, + failOnStatusCode: false, + timeout: resolveTimeout(60_000), + }); + + expect( + response.status(), + `the admin email-channel API must answer for the Admin-role API bot; a 401/403 means the bot lost its role and a 404 means this Zammad has no channel admin surface (HTTP ${response.status()})`, + ).toBe(200); + + const payload = await response.json(); + const channelIds = payload.channel_ids || []; + expect( + channelIds.length, + "Zammad must carry at least one email channel; an empty list means files/ruby/apply/email_channel.rb never ran, so no mail is fetched or sent through the partner mail server", + ).toBeGreaterThan(0); + + const channels = Object.values((payload.assets || {}).Channel || {}); + const emailAccounts = channels.filter((channel) => channel.area === "Email::Account"); + expect( + emailAccounts.length, + "the provisioned channel must be an Email::Account channel; another area means the bridge wired a different transport than the mail integration", + ).toBeGreaterThan(0); + + const inboundAdapters = emailAccounts.map((channel) => ((channel.options || {}).inbound || {}).adapter); + expect( + inboundAdapters, + "the email channel's inbound adapter must be imap, which is how the deployment fetches from the partner mail server", + ).toContain("imap"); + + const active = emailAccounts.some((channel) => channel.active === true); + expect( + active, + "the Email::Account channel must be active; an inactive channel is provisioned but never polls, so inbound tickets never arrive", + ).toBe(true); +}); diff --git a/roles/web-app-zammad/files/playwright/addons/openid_connect.spec.js b/roles/web-app-zammad/files/playwright/addons/openid_connect.spec.js new file mode 100644 index 0000000000..25b57a8d5c --- /dev/null +++ b/roles/web-app-zammad/files/playwright/addons/openid_connect.spec.js @@ -0,0 +1,47 @@ +const { test, expect } = require("@playwright/test"); +const { resolveTimeout } = require("../timeouts"); +const { skipUnlessAddonEnabled } = require("../addon-gating"); +const { skipUnlessServiceEnabled } = require("../service-gating"); +const shared = require("../_shared"); + +test.use({ ignoreHTTPSErrors: true }); + +test("addon openid_connect: Zammad's third-party auth route hands off to the partner Keycloak", async ({ page }) => { + skipUnlessAddonEnabled("openid_connect"); + skipUnlessServiceEnabled("sso"); + test.setTimeout(resolveTimeout(120_000)); + + const { zammadBaseUrl, oidcIssuerUrl } = shared.env; + expect(zammadBaseUrl, "ZAMMAD_BASE_URL must be set").toBeTruthy(); + expect(oidcIssuerUrl, "OIDC_ISSUER_URL must be set to address the partner Keycloak realm").toBeTruthy(); + + await page.context().clearCookies(); + + const response = await page.request.get(`${zammadBaseUrl}/auth/openid_connect`, { + maxRedirects: 0, + failOnStatusCode: false, + timeout: resolveTimeout(60_000), + }); + + expect( + response.status(), + `Zammad must answer /auth/openid_connect with a redirect once Setting auth_openid_connect is on; a 404 means the provider was never registered and a 200 means Zammad rendered its own form instead of handing off (HTTP ${response.status()})`, + ).toBeGreaterThanOrEqual(300); + expect(response.status(), "the third-party auth route must redirect, not error").toBeLessThan(400); + + const location = response.headers().location || ""; + expect( + location, + "the redirect must carry a Location header naming the identity provider", + ).toBeTruthy(); + expect( + location.startsWith(`${oidcIssuerUrl}/protocol/openid-connect/auth`), + `the hand-off must target the partner Keycloak authorization endpoint ${oidcIssuerUrl}/protocol/openid-connect/auth, proving auth_openid_connect carries the issuer, client id and redirect uri this deployment provisioned; got ${location}`, + ).toBe(true); + + const zammadHost = new URL(zammadBaseUrl).hostname; + expect( + new URL(location).hostname, + `the authorization endpoint must live on the external Keycloak host, not on the Zammad host (${zammadHost})`, + ).not.toBe(zammadHost); +}); diff --git a/roles/web-app-zammad/meta/addons/email_channel.yml b/roles/web-app-zammad/meta/addons/email_channel.yml new file mode 100644 index 0000000000..c88350baf6 --- /dev/null +++ b/roles/web-app-zammad/meta/addons/email_channel.yml @@ -0,0 +1,9 @@ +--- +enabled: "{{ lookup('config', 'web-app-zammad', 'services.email.enabled') | bool }}" +required: false +mechanism: bridge +source: bundled +bridges: + - email +config: + area: "Email::Account" diff --git a/roles/web-app-zammad/meta/addons/openid_connect.yml b/roles/web-app-zammad/meta/addons/openid_connect.yml new file mode 100644 index 0000000000..9f66f6a749 --- /dev/null +++ b/roles/web-app-zammad/meta/addons/openid_connect.yml @@ -0,0 +1,9 @@ +--- +enabled: "{{ lookup('config', 'web-app-zammad', 'services.sso.enabled') | bool }}" +required: false +mechanism: module +source: bundled +bridges: + - sso +config: + provider: openid_connect diff --git a/roles/web-app-zammad/tasks/addons/email_channel.yml b/roles/web-app-zammad/tasks/addons/email_channel.yml new file mode 100644 index 0000000000..ed97d539c0 --- /dev/null +++ b/roles/web-app-zammad/tasks/addons/email_channel.yml @@ -0,0 +1 @@ +--- diff --git a/roles/web-app-zammad/tasks/addons/openid_connect.yml b/roles/web-app-zammad/tasks/addons/openid_connect.yml new file mode 100644 index 0000000000..ed97d539c0 --- /dev/null +++ b/roles/web-app-zammad/tasks/addons/openid_connect.yml @@ -0,0 +1 @@ +--- diff --git a/roles/web-app-zammad/templates/playwright.env.j2 b/roles/web-app-zammad/templates/playwright.env.j2 index dfa0c44285..951b628d59 100644 --- a/roles/web-app-zammad/templates/playwright.env.j2 +++ b/roles/web-app-zammad/templates/playwright.env.j2 @@ -51,3 +51,5 @@ ZAMMAD_BASE_URL={{ lookup('tls', application_id, 'url.base') | dotenv_quote }} ZAMMAD_LITELLM_BASE_URL={{ ZAMMAD_LITELLM_BASE_URL | dotenv_quote }} ZAMMAD_LITELLM_MODEL={{ ZAMMAD_LITELLM_MODEL | dotenv_quote }} + +{{ lookup('addon_env_flags', application_id) }}