Files
computer-playbook/roles/web-app-gitlab/files/playwright/test-integrations.js
T
kevinveenbirkenbachandClaude Opus 5 75e90d0a3c fix(web-app-gitlab): declare the service keys its addons resolve against
c83c00da7d gave the role six addons whose enabled reads
lookup('config', 'web-app-gitlab', 'services.<x>.enabled'), but meta/services.yml
never gained confluence, jenkins, jira, matrix or mattermost. The lookup takes
two terms there, so strict=True applies and a missing path does not fall back:

    AppConfigKeyError: Key 'confluence' not found in dict at 'confluence'
    Full path so far: applications['web-app-gitlab'].services.confluence

Measured against HEAD: none of the five keys exist, and the strict getter
raises rather than yielding a false. Rendering any of those addons aborts.

jenkins, matrix and mattermost get the dynamic consumer flag. confluence and
jira are pinned to a literal false with a dynamic-flag marker, because both
roles are end of life and no inventory may bind them.

Each dynamic flag gets exactly one true-pinning round — mattermost in variant 0,
matrix in variant 1, jenkins in variant 2 — so the coverage contract is met
without pairing two heavy partners in one round.

test-integrations.js asserts that each instance integration page stays
admin-only, registered from playwright.spec.js.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-10-03 01:34:30 +02:00

51 lines
2.4 KiB
JavaScript

const { test, expect } = require("@playwright/test");
const { skipUnlessServiceEnabled } = require("./service-gating");
const { gotoOnion, normalizeBaseUrl } = require("./personas");
async function expectInstanceIntegrationIsAdminOnly(page, addon, label) {
const appBaseUrl = normalizeBaseUrl(process.env.APP_BASE_URL || "");
expect(appBaseUrl, "APP_BASE_URL must be set").toBeTruthy();
await page.context().clearCookies();
const url = `${appBaseUrl}/admin/application_settings/integrations/${addon}/edit`;
const response = await gotoOnion(page, url, { waitUntil: "domcontentloaded" });
expect(response, `Expected a response from ${url}`).toBeTruthy();
expect(
response.status(),
`GitLab answered ${response.status()} for the ${label} instance-integration settings page, so this build does not route instance-level integrations at all`,
).toBeLessThan(400);
expect(
page.url(),
`the ${label} instance-integration settings page must bounce an anonymous visitor to the sign-in form; serving it would expose the integration credentials of every project`,
).toContain("/users/sign_in");
}
function register() {
test("integration confluence: the Confluence instance-integration page is routed and admin-only", async ({ page }) => {
skipUnlessServiceEnabled("confluence");
await expectInstanceIntegrationIsAdminOnly(page, "confluence", "Confluence");
});
test("integration jenkins: the Jenkins instance-integration page is routed and admin-only", async ({ page }) => {
skipUnlessServiceEnabled("jenkins");
await expectInstanceIntegrationIsAdminOnly(page, "jenkins", "Jenkins");
});
test("integration jira: the Jira instance-integration page is routed and admin-only", async ({ page }) => {
skipUnlessServiceEnabled("jira");
await expectInstanceIntegrationIsAdminOnly(page, "jira", "Jira");
});
test("integration matrix: the Matrix instance-integration page is routed and admin-only", async ({ page }) => {
skipUnlessServiceEnabled("matrix");
await expectInstanceIntegrationIsAdminOnly(page, "matrix", "Matrix");
});
test("integration mattermost: the Mattermost notifications instance-integration page is routed and admin-only", async ({ page }) => {
skipUnlessServiceEnabled("mattermost");
await expectInstanceIntegrationIsAdminOnly(page, "mattermost", "Mattermost notifications");
});
}
module.exports = { expectInstanceIntegrationIsAdminOnly, register };