Files
computer-playbook/roles/web-app-gitea/files/playwright/_shared.js
kevinveenbirkenbachandClaude Opus 5 3036b7ba19 feat(gitea): serve MCP through the project-owned sidecar
Gitea ships no MCP server, so the role runs the project-owned gitea-mcp
package as a sidecar next to it and points it at the instance over the
container network.

Two things the image forces. Its command carries the binary path
explicitly because the image declares no ENTRYPOINT, so a bare flag list
would replace the binary instead of extending it. The port is stringified
because Ansible's native types make a bare lookup an int, and compose
rejects a non-string in a command array.

Keep the surface internal. The public vhost answers a bearerless probe
with an SSO redirect, so the guest spec pins maxRedirects to 0 and
asserts no MCP response is ever served; following the redirect would land
on a login page and pass for the wrong reason.

Calls run with administrator rights, so the tool policy is pinned
read-only and the sidecar starts with the read-only flag and a scope
list.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-02 22:10:15 +02:00

35 lines
1.1 KiB
JavaScript

// Shared Gitea Playwright spec state: env vars, persona helpers and the
// `beforeEach` env-presence guard. `playwright.spec.js` wires the lifecycle
// hook and `require()`s one test module per scenario so each test stays
// atomar and individually inspectable.
const { expect } = require("@playwright/test");
const { decodeDotenvQuotedValue, runAdminFlow, runBiberFlow, runGuestFlow } = require("./personas");
// `docker --env-file` preserves the quotes emitted by `dotenv_quote`,
// so normalize these values before building URLs or typing credentials.
const gitEaBaseUrl = decodeDotenvQuotedValue(process.env.GITEA_BASE_URL);
function healthzReadyUrl() {
return `${gitEaBaseUrl.replace(/\/$/, "")}/healthz/ready`;
}
function mcpEndpointUrl() {
return `${gitEaBaseUrl.replace(/\/$/, "")}/mcp`;
}
function beforeEach() {
expect(gitEaBaseUrl, "GITEA_BASE_URL must be set in the Playwright env file").toBeTruthy();
}
module.exports = {
env: { gitEaBaseUrl },
healthzReadyUrl,
mcpEndpointUrl,
runAdminFlow,
runBiberFlow,
runGuestFlow,
beforeEach,
};