daemon: Gitea v1 API adapter (git.westphal.fr is Gitea, not GitLab); fix golang Dockerfile to 1.26; sudo docker in deploy

This commit is contained in:
Raphael Westphal
2026-08-18 15:07:02 +02:00
parent bcd976a8ac
commit 49840225e2
10 changed files with 79 additions and 79 deletions
+25 -25
View File
@@ -1,54 +1,54 @@
// fake-gitlab.mjs — minimal GitLab v4 API stand-in on an ephemeral port.
// fake-gitlab.mjs — minimal Gitea v1 API stand-in on an ephemeral port.
// Serves exactly the two endpoints the daemon calls (daemon/gitlab.go):
// GET /api/v4/user (PAT validation)
// GET /api/v4/projects (member projects listing)
// Projects are returned UNSORTED so the harness proves the daemon sorts by
// last_activity_at.
// GET /api/v1/user (token validation)
// GET /api/v1/user/repos (repo listing)
// Repos are returned UNSORTED so the harness proves the daemon sorts by
// updated_at.
import * as http from "node:http";
export const GOOD_PAT = "glpat-e2e-0123456789abcdef";
export const GOOD_PAT = "gitea-e2e-0123456789abcdef";
const HTTP_OK = 200;
const HTTP_UNAUTHORIZED = 401;
const HTTP_NOT_FOUND = 404;
export function startFakeGitLab() {
const seen = { userAuths: [], projectAuths: [] };
const seen = { userAuths: [], repoAuths: [] };
const server = http.createServer((req, res) => {
const auth = String(req.headers["private-token"] ?? "");
const auth = String(req.headers["authorization"] ?? "");
const send = (code, obj) => {
res.writeHead(code, { "Content-Type": "application/json" });
res.end(JSON.stringify(obj));
};
if (req.url.startsWith("/api/v4/user")) {
seen.userAuths.push(auth);
return auth === GOOD_PAT
? send(HTTP_OK, { id: 1, username: "e2e-user", name: "E2E User" })
: send(HTTP_UNAUTHORIZED, { message: "401 Unauthorized" });
}
if (req.url.startsWith("/api/v4/projects")) {
seen.projectAuths.push(auth);
if (auth !== GOOD_PAT) return send(HTTP_UNAUTHORIZED, { message: "401 Unauthorized" });
if (req.url.startsWith("/api/v1/user/repos")) {
seen.repoAuths.push(auth);
if (auth !== `token ${GOOD_PAT}`) return send(HTTP_UNAUTHORIZED, { message: "401 Unauthorized" });
const base = `http://127.0.0.1:${server.address().port}`;
return send(HTTP_OK, [
{
path_with_namespace: "lvmh/beta",
full_name: "lvmh/beta",
name: "beta",
namespace: { path: "lvmh" },
last_activity_at: "2025-07-01T10:00:00Z",
web_url: `${base}/lvmh/beta`,
owner: { login: "lvmh" },
updated_at: "2025-07-01T10:00:00Z",
html_url: `${base}/lvmh/beta`,
default_branch: "main",
},
{
path_with_namespace: "lvmh/alpha",
full_name: "lvmh/alpha",
name: "alpha",
namespace: { path: "lvmh" },
last_activity_at: "2025-08-01T10:00:00Z",
web_url: `${base}/lvmh/alpha`,
owner: { login: "lvmh" },
updated_at: "2025-08-01T10:00:00Z",
html_url: `${base}/lvmh/alpha`,
default_branch: "trunk",
},
]);
}
if (req.url.startsWith("/api/v1/user")) {
seen.userAuths.push(auth);
return auth === `token ${GOOD_PAT}`
? send(HTTP_OK, { id: 1, login: "e2e-user", name: "E2E User" })
: send(HTTP_UNAUTHORIZED, { message: "401 Unauthorized" });
}
return send(HTTP_NOT_FOUND, { message: "404 Not Found" });
});
return new Promise((resolve) => {
+2 -2
View File
@@ -17,8 +17,8 @@ export async function run(ctx) {
`got ${connect.status} ${connect.text}`,
);
r.check(
"daemon validated PAT against fake /api/v4/user",
gitlab.seen.userAuths.length === 1 && gitlab.seen.userAuths[0] === gitlab.pat,
"daemon validated token against fake /api/v1/user",
gitlab.seen.userAuths.length === 1 && gitlab.seen.userAuths[0] === `token ${gitlab.pat}`,
JSON.stringify(gitlab.seen.userAuths),
);