map: tickets 06+07 resolved; 05 partial (live spawn pending gitea token)
This commit is contained in:
+51
-50
@@ -13,54 +13,55 @@ const HTTP_UNAUTHORIZED = 401;
|
||||
const HTTP_NOT_FOUND = 404;
|
||||
|
||||
export function startFakeGitLab() {
|
||||
const seen = { userAuths: [], repoAuths: [] };
|
||||
const server = http.createServer((req, res) => {
|
||||
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/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, [
|
||||
{
|
||||
full_name: "lvmh/beta",
|
||||
name: "beta",
|
||||
owner: { login: "lvmh" },
|
||||
updated_at: "2025-07-01T10:00:00Z",
|
||||
html_url: `${base}/lvmh/beta`,
|
||||
default_branch: "main",
|
||||
},
|
||||
{
|
||||
full_name: "lvmh/alpha",
|
||||
name: "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) => {
|
||||
server.listen(0, "127.0.0.1", () => {
|
||||
resolve({
|
||||
url: `http://127.0.0.1:${server.address().port}`,
|
||||
pat: GOOD_PAT,
|
||||
seen,
|
||||
close() {
|
||||
server.close();
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
const seen = { userAuths: [], repoAuths: [] };
|
||||
const server = http.createServer((req, res) => {
|
||||
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/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, [
|
||||
{
|
||||
full_name: "lvmh/beta",
|
||||
name: "beta",
|
||||
owner: { login: "lvmh" },
|
||||
updated_at: "2025-07-01T10:00:00Z",
|
||||
html_url: `${base}/lvmh/beta`,
|
||||
default_branch: "main",
|
||||
},
|
||||
{
|
||||
full_name: "lvmh/alpha",
|
||||
name: "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) => {
|
||||
server.listen(0, "127.0.0.1", () => {
|
||||
resolve({
|
||||
url: `http://127.0.0.1:${server.address().port}`,
|
||||
pat: GOOD_PAT,
|
||||
seen,
|
||||
close() {
|
||||
server.close();
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user