gitoria

gitoria

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitfd4fc028fd4fc028Exercise member status reads with a populated check statemrefd4fc028/tests/member-merge.mjs

22.0 KB

  1. // tests/member-merge.mjs — GATE OF THE MEMBER MERGE (gitoria#48): a member of a repo (the people who may push) merges a pull request with a gtr_ user token
  2. // — POST {api}/pulls/N/merge — once the REQUIRED checks are success; the owner too; apps (gat_) and strangers never. Blocked (409) while a required status is
  3. // pending / failure, a stale head is 409, the pull_request `merged` event carries sender = the member, the Merge button shows for owner and member only.
  4. // Real HTTP, the real `git`, its own storage under .scratch/member-merge-store.
  5. // node tests/member-merge.mjs (GITORIA_MM_PORT default 8720 = gitoria, +1 event receiver, +4 ident)
  6. import { spawn, execFileSync } from 'node:child_process';
  7. import { request, createServer } from 'node:http';
  8. import { mkdirSync, rmSync, writeFileSync, existsSync } from 'node:fs';
  9. import { dirname, join, resolve } from 'node:path';
  10. import { fileURLToPath } from 'node:url';
  11. import { startIdent } from './identkit.mjs';
  12. import { launchBrowser } from './cdp.mjs';
  13. const HERE = dirname(fileURLToPath(import.meta.url));
  14. const APP = resolve(HERE, '..');
  15. const PORT = Number(process.env.GITORIA_MM_PORT || 8720), RPORT = PORT + 1, IDENT_PORT = PORT + 4;
  16. const IDENT_DIR = process.env.GITORIA_GATE_IDENT_DIR || [resolve(APP, '../ident.worldapi.org'), '/media/STORAGE/projects/WorldAPI/ident.worldapi.org'].find(d => existsSync(join(d, 'project.hl')));
  17. const STORE = join(APP, '.scratch/member-merge-store');
  18. const J = JSON.stringify, sleep = (ms) => new Promise(r => setTimeout(r, ms));
  19. let passes = 0, failures = 0;
  20. const check = (label, ok, detail = '') => { console.log(`${ok ? 'ok ' : 'FAIL'} ${label}${ok ? '' : ' — ' + detail}`); if (ok) passes++; else failures++; };
  21. const got = [];
  22. const receiver = createServer((req, res) => { const c = []; req.on('data', d => c.push(d)); req.on('end', () => { got.push({ path: req.url, headers: req.headers, body: Buffer.concat(c).toString('utf8') }); res.statusCode = 204; res.end(); }); });
  23. await new Promise(r => receiver.listen(RPORT, '127.0.0.1', r));
  24. function raw(method, path, { host = `localhost:${PORT}`, headers = {}, body = null, cookie = null } = {}) {
  25. return new Promise((res, rej) => {
  26. const h = { host, ...headers }; if (cookie) h.cookie = cookie;
  27. if (body !== null) h['content-length'] = Buffer.byteLength(body);
  28. const r = request({ host: '127.0.0.1', port: PORT, method, path, headers: h }, (m) => { const c = []; m.on('data', d => c.push(d)); m.on('end', () => res({ status: m.statusCode, headers: m.headers, body: Buffer.concat(c).toString('utf8') })); });
  29. r.on('error', rej); if (body !== null) r.write(body); r.end();
  30. });
  31. }
  32. const get = (path, o = {}) => raw('GET', path, o);
  33. const errOf = (r) => { try { return JSON.parse(r.body).error; } catch { return {}; } };
  34. let server = null, log = '';
  35. async function up() { for (let i = 0; i < 960; i++) { try { if ((await get('/api/repos')).status === 200) return; } catch {} await sleep(250); } throw new Error('gitoria did not come up\n' + log); }
  36. const stop = async () => { if (server) { const p = server; server = null; p.kill(); await new Promise(r => p.once('exit', r)); } };
  37. let ident;
  38. try {
  39. rmSync(STORE, { recursive: true, force: true }); mkdirSync(STORE, { recursive: true });
  40. ident = await startIdent({ identDir: IDENT_DIR, workDir: join(STORE, 'ident'), port: IDENT_PORT });
  41. const alice = await ident.signIn('[email protected]'), bob = await ident.signIn('[email protected]'), carol = await ident.signIn('[email protected]');
  42. const BASE = `http://localhost:${PORT}`;
  43. const app = await ident.registerApp(alice, 'gitoria (member-merge gate)', [BASE]);
  44. const GIT = join(STORE, 'git');
  45. const env = { GITORIA_STORAGE: join(STORE, 'mpackdb'), GITORIA_SESSIONS: join(STORE, 'sessions') + '/', GITORIA_GIT: GIT, IDENT_URL: ident.base, IDENT_EXCHANGE_URL: ident.base, IDENT_API_KEY: app.key, IDENT_API_SECRET: app.secret };
  46. server = spawn(join(APP, 'bin/hybriel'), ['project.hl'], { cwd: APP, stdio: ['ignore', 'pipe', 'pipe'],
  47. env: { ...process.env, GITORIA_PORT: String(PORT), GITORIA_WATCH: '0', GITORIA_PUBLIC_URL: BASE, GITORIA_SSH_SECRET: 'sshsecret-mm-gate', GITORIA_TICKETS_URL: 'http://127.0.0.1:1', GITORIA_APP_HOSTS: `http://127.0.0.1:${RPORT}`, GITORIA_EVENTS_TICK: '0.3', ...env } });
  48. server.stdout.on('data', d => log += d); server.stderr.on('data', d => log += d);
  49. await up();
  50. const cookieOf = (r) => (r.headers['set-cookie'] || []).map(c => c.split(';')[0])[0] || null;
  51. const login = async (who) => { const ck = cookieOf(await get('/')); const cb = await get('/login/callback?ident_code=' + await ident.selectorCode(who, app, BASE) + '&next=%2F', { cookie: ck }); return { cookie: cookieOf(cb) || ck }; };
  52. let n = 0;
  53. const face = async (who, event, payload) => { const r = await raw('POST', '/__hl/emit', { headers: { 'content-type': 'application/json' }, cookie: who && who.cookie, body: J({ t: 'emit', i: ++n, event, payload }) }); let j = null; try { j = JSON.parse(r.body); } catch {} return j && j.value; };
  54. const A = await login(alice), B = await login(bob), C = await login(carol);
  55. await face(A, 'gitoriaSaveName', ['Alice']); await face(B, 'gitoriaSaveName', ['Bob']); await face(C, 'gitoriaSaveName', ['Carol']);
  56. const tA = (await face(A, 'gitoriaMakeToken', ['a'])).token, tB = (await face(B, 'gitoriaMakeToken', ['b'])).token, tC = (await face(C, 'gitoriaMakeToken', ['c'])).token;
  57. const W = join(STORE, 'work'); mkdirSync(W, { recursive: true });
  58. const genv = { ...process.env, GIT_TERMINAL_PROMPT: '0', GIT_CONFIG_GLOBAL: '/dev/null', GIT_AUTHOR_NAME: 'a', GIT_AUTHOR_EMAIL: 'a@a', GIT_COMMITTER_NAME: 'a', GIT_COMMITTER_EMAIL: 'a@a' };
  59. const g = (...a) => execFileSync('git', a, { cwd: W, encoding: 'utf8', env: genv, stdio: ['ignore', 'pipe', 'pipe'] });
  60. const bare = (...a) => execFileSync('git', a, { cwd: join(GIT, 'mm.git'), encoding: 'utf8', env: genv, stdio: ['ignore', 'pipe', 'pipe'] }).trim();
  61. const push = (...refs) => { try { g('push', '-q', `http://a:${tA}@mm.localhost:${PORT}/mm.git`, ...refs); return true; } catch { return false; } };
  62. const sha = () => g('rev-parse', 'HEAD').trim();
  63. const mkPr = (branch, title) => { g('checkout', '-q', 'main'); g('checkout', '-q', '-b', branch); writeFileSync(join(W, branch + '.txt'), branch + '\n'); g('add', '-A'); g('commit', '-q', '-m', '|||PR ' + title); const s = sha(); push(branch); return s; };
  64. g('init', '-q', '-b', 'main'); writeFileSync(join(W, 'README.md'), '# t\n'); g('add', '-A'); g('commit', '-q', '-m', 'init');
  65. check('alice creates "mm", pushes main', !!(await face(A, 'gitoriaCreate', ['mm', 'm'])).repo && push('main'));
  66. const added = await face(A, 'gitoriaChangeMember', ['mm', 'Bob', true]);
  67. check('alice adds Bob as a member (Carol is not)', added && added.members && added.members.length === 1, J(added));
  68. const kApp = await face(A, 'gitoriaAppAdd', ['mm', 'Kunibert', `http://127.0.0.1:${RPORT}/a`]);
  69. const tApp = JSON.parse((await raw('POST', '/api/apps/token', { host: `mm.localhost:${PORT}`, headers: { authorization: 'Bearer ' + kApp.key } })).body).token;
  70. const idK = (kApp.rows.find(x => x.name === 'Kunibert') || {}).id;
  71. check('an app (Kunibert) is connected to mm and has a token', /^gak_/.test(kApp.key || '') && !!tApp && !!idK);
  72. const HOST = `mm.localhost:${PORT}`;
  73. const merge = (token, num, body = null) => raw('POST', `/api/pulls/${num}/merge`, { host: HOST, headers: { ...(token ? { authorization: 'Bearer ' + token } : {}), 'content-type': 'application/json' }, body });
  74. const put = (sha_, state) => raw('PUT', '/api/statuses/' + sha_, { host: HOST, headers: { authorization: 'Bearer ' + tApp, 'content-type': 'application/json' }, body: J({ context: 'ci', state, title: 't', summary: '', url: null }) });
  75. const prNum = async (s) => { const l = JSON.parse((await raw('GET', '/api/pulls?state=all', { host: HOST, headers: { authorization: 'Bearer ' + tApp } })).body).pulls; const p = l.find(x => x.head === s || x.sha === s); return p ? p.number : null; };
  76. // ---- 1. nothing required yet: the owner merges (API), a member merges through the button's face
  77. const s1 = mkPr('f1', 'one'), s2 = mkPr('f2', 'two'), s3 = mkPr('f3', 'three'), s4 = mkPr('f4', 'four');
  78. const n1 = await prNum(s1), n2 = await prNum(s2), n3 = await prNum(s3), n4 = await prNum(s4);
  79. check('four PRs are numbered', [n1, n2, n3, n4].every(x => x != null) && new Set([n1, n2, n3, n4]).size === 4, J([n1, n2, n3, n4]));
  80. // W49: member reads share the app body shape; only apps can write or inspect deliveries.
  81. const api = (token, method, path, body = null) => raw(method, path, { host: HOST, headers: { ...(token ? { authorization: 'Bearer ' + token } : {}), 'content-type': 'application/json' }, body: body == null ? null : J(body) });
  82. const review = await api(tApp, 'POST', `/api/pulls/${n3}/reviews`, { head: s3, verdict: 'comment', body: 'first review', comments: [{ path: 'f3.txt', line: 1, body: 'inline' }] });
  83. check('W49 app still posts a review with an inline thread', review.status === 201, review.body);
  84. const threadId = JSON.parse(review.body).threads[0].id;
  85. check('W49 app still posts a conversation comment', (await api(tApp, 'POST', `/api/pulls/${n3}/comments`, { body: 'conversation' })).status === 201);
  86. await put(s4, 'pending');
  87. const paths = ['/api/pulls?state=all', `/api/pulls/${n3}`, `/api/pulls/${n3}/reviews`, `/api/pulls/${n3}/threads`, `/api/pulls/${n3}/comments`, '/api/statuses/' + s4];
  88. for (const path of paths) {
  89. const a = await api(tApp, 'GET', path), b = await api(tB, 'GET', path), owner = await api(tA, 'GET', path);
  90. check('W49 member and owner read same app body: ' + path, a.status === 200 && b.status === 200 && owner.status === 200 && a.body === b.body && a.body === owner.body, [a.status, b.status, owner.status].join());
  91. const stranger = await api(tC, 'GET', path), anon = await api(null, 'GET', path), bad = await api('gtr_' + 'a'.repeat(40), 'GET', path);
  92. check('W49 stranger 404, no token and unknown user token 401: ' + path, stranger.status === 404 && errOf(stranger).code === 'not_found' && anon.status === 401 && bad.status === 401);
  93. }
  94. if (process.env.W49_REAL_CDP) {
  95. process.env.HL_CDP_URL = process.env.W49_REAL_CDP;
  96. const before = (await (await fetch(process.env.HL_CDP_URL + '/json/list')).json()).filter(t => t.type === 'page');
  97. writeFileSync(join(APP, '.scratch/w49/chrome-before.json'), J(before));
  98. const browser = await launchBrowser(); let page;
  99. try {
  100. page = await browser.newPage();
  101. await page.goto(`http://mm.localhost:${PORT}/pulls/${n3}`);
  102. for (const [width, height] of [[390, 844], [800, 1280], [1280, 800], [1280, 900]]) {
  103. await page.send('Emulation.setDeviceMetricsOverride', { width, height, deviceScaleFactor: 1, mobile: width === 390 });
  104. for (const path of paths) {
  105. const got = await page.evaluate(`(async () => { const r = await fetch(${J(path)}, { headers: { authorization: ${J('Bearer ' + tB)} } }); return { status: r.status, body: await r.text() }; })()`);
  106. check(`W49 real Chrome ${width}x${height} member reads ${path}`, got.status === 200, got.status);
  107. }
  108. await page.send('Page.reload');
  109. await page.waitForSelector('#pullpage');
  110. const shot = await page.send('Page.captureScreenshot', { format: 'png' });
  111. writeFileSync(join(APP, `.scratch/w49/chrome-${width}x${height}.png`), Buffer.from(shot.data, 'base64'));
  112. }
  113. } finally {
  114. try { if (page) await page.close(); } finally { browser.conn.close(); }
  115. const after = (await (await fetch(process.env.HL_CDP_URL + '/json/list')).json()).filter(t => t.type === 'page');
  116. writeFileSync(join(APP, '.scratch/w49/chrome-after.json'), J(after));
  117. check('W49 real Chrome leaves only original page targets', J(after.map(t => t.id).sort()) === J(before.map(t => t.id).sort()));
  118. delete process.env.HL_CDP_URL;
  119. }
  120. }
  121. const message = 'this route needs an app token (gat_); user tokens (gtr_) can read pulls, reviews, threads, comments and statuses and merge with POST /pulls/N/merge';
  122. for (const [method, path] of [['POST', `/api/pulls/${n3}/reviews`], ['POST', `/api/pulls/${n3}/comments`], ['POST', `/api/pulls/${n3}/threads/${threadId}/replies`], ['POST', `/api/pulls/${n3}/threads/${threadId}/resolve`], ['PUT', '/api/statuses/' + s3], ['GET', '/api/deliveries'], ['POST', '/api/deliveries/unknown/redeliver'], ['POST', '/api/apps/token']]) {
  123. const r = await api(tB, method, path, {});
  124. check('W49 app-only explains gtr_: ' + method + ' ' + path, r.status === 401 && errOf(r).code === 'unauthorized' && errOf(r).message === message, r.status + r.body);
  125. }
  126. check('W49 unknown app token retains old message', /missing, unknown or expired token/.test(errOf(await api('gat_unknown', 'GET', paths[0])).message || ''));
  127. const kSecond = await face(A, 'gitoriaAppAdd', ['mm', 'Second', `http://127.0.0.1:${RPORT}/b`]);
  128. const tSecond = JSON.parse((await api(kSecond.key, 'POST', '/api/apps/token')).body).token;
  129. const review2 = await api(tSecond, 'POST', `/api/pulls/${n3}/reviews`, { head: s3, verdict: 'comment', body: 'second review', comments: [{ path: 'f3.txt', line: 1, body: 'second inline' }] });
  130. check('W49 another app posts its review and thread', review2.status === 201);
  131. for (const kind of ['reviews', 'threads']) {
  132. const path = `/api/pulls/${n3}/${kind}`;
  133. const member = JSON.parse((await api(tB, 'GET', path)).body), appOne = JSON.parse((await api(tApp, 'GET', path)).body), appTwo = JSON.parse((await api(tSecond, 'GET', path)).body);
  134. check('W49 member sees both apps; each app retains own ' + kind, member[kind].length === 2 && appOne[kind].length === 1 && appTwo[kind].length === 1 && appOne[kind][0].id !== appTwo[kind][0].id);
  135. const first = JSON.parse((await api(tB, 'GET', path + '?limit=1')).body);
  136. const next = JSON.parse((await api(tB, 'GET', path + '?limit=1&cursor=' + encodeURIComponent(first.next))).body);
  137. check('W49 member pagination has distinct stable ids: ' + kind, first[kind].length === 1 && next[kind].length === 1 && first[kind][0].id !== next[kind][0].id);
  138. }
  139. const m1 = await merge(tA, n1);
  140. const j1 = (() => { try { return JSON.parse(m1.body); } catch { return {}; } })();
  141. check('the OWNER merges PR 1 with her gtr_ token: 200 { merged, mergeCommit, pull }', m1.status === 200 && j1.merged === true && /^[0-9a-f]{40}$/.test(j1.mergeCommit || '') && j1.pull && j1.pull.number === n1 && j1.pull.state === 'merged', m1.status + m1.body.slice(0, 300));
  142. check('PR 1: mergeCommit is the tip of main, author = her display name', j1.mergeCommit === bare('rev-parse', 'refs/heads/main') && bare('log', '-1', '--format=%an', 'main') === 'Alice', bare('log', '-1', '--format=%an', 'main'));
  143. const btn = await face(B, 'gitoriaMergePull', ['mm', s2]);
  144. check('the MEMBER merges PR 2 with the button (server face)', btn && !btn.error && btn.result, J(btn).slice(0, 200));
  145. check('PR 2 is merged; author of the merge commit = Bob', bare('log', '-1', '--format=%an', 'main') === 'Bob', '');
  146. const strangerFace = await face(C, 'gitoriaMergePull', ['mm', s3]);
  147. check('the button\'s face refuses a stranger and a signed-out caller', strangerFace && /only the owner and the members/.test(strangerFace.error || '') && !!((await face(null, 'gitoriaMergePull', ['mm', s3])) || {}).error);
  148. // ---- 2. required check
  149. const rq = await face(A, 'gitoriaRequiredAdd', ['mm', idK, 'ci']);
  150. check('the owner requires Kunibert · ci', rq && rq.rows && rq.rows.length === 1, J(rq));
  151. const before = bare('rev-parse', 'refs/heads/main');
  152. const r0 = await merge(tB, n3);
  153. check('member, status not set → 409 conflict naming ci', r0.status === 409 && errOf(r0).code === 'conflict' && /ci \(not set\)/.test(errOf(r0).message || ''), r0.status + r0.body.slice(0, 200));
  154. await put(s3, 'pending');
  155. const r1 = await merge(tB, n3);
  156. check('member, status pending → 409, main unchanged', r1.status === 409 && /ci \(pending\)/.test(errOf(r1).message || '') && bare('rev-parse', 'refs/heads/main') === before, r1.status + r1.body.slice(0, 200));
  157. await put(s3, 'failure');
  158. const r2 = await merge(tB, n3);
  159. check('member, status failure → 409, main unchanged', r2.status === 409 && /ci \(failure\)/.test(errOf(r2).message || '') && bare('rev-parse', 'refs/heads/main') === before, r2.status + r2.body.slice(0, 200));
  160. const rOwn = await merge(tA, n3);
  161. check('the owner is held by the same required check (409)', rOwn.status === 409, rOwn.status);
  162. // ---- 3. who may not
  163. await put(s3, 'success');
  164. const rApp = await merge(tApp, n3);
  165. check('an app token (gat_) → 403 forbidden "apps cannot merge", even with the status green', rApp.status === 403 && errOf(rApp).code === 'forbidden' && errOf(rApp).message === 'apps cannot merge', rApp.status + rApp.body);
  166. const rC = await merge(tC, n3);
  167. check('a signed-in non-member (gtr_) → 403', rC.status === 403 && errOf(rC).code === 'forbidden', rC.status + rC.body);
  168. const rNo = await merge(null, n3), rBad = await merge('gtr_' + 'a'.repeat(40), n3), rJunk = await merge('nonsense', n3);
  169. check('no token / an unknown gtr_ / junk → 401', rNo.status === 401 && rBad.status === 401 && rJunk.status === 401, [rNo.status, rBad.status, rJunk.status].join());
  170. check('GET on the merge route → 405', (await raw('GET', `/api/pulls/${n3}/merge`, { host: HOST, headers: { authorization: 'Bearer ' + tB } })).status === 405);
  171. const r404 = await merge(tB, 999);
  172. check('unknown PR → 404 not_found', r404.status === 404 && errOf(r404).code === 'not_found', r404.status);
  173. check('PR 3 still open after all refusals', bare('rev-parse', 'refs/heads/main') === before);
  174. // ---- 4. the button: visible for owner + member, hidden for others
  175. const listBtn = async (who) => { const b = (await get('/pulls', { host: HOST, cookie: who && who.cookie })).body; return (b.match(/<button class="([^"]*)" type="button" value="[0-9a-f]{40}">Merge/g) || []).map(x => x.match(/class="([^"]*)"/)[1]); };
  176. const pageBtn = async (who, num) => { const b = (await get('/pulls/' + num, { host: HOST, cookie: who && who.cookie })).body; return (b.match(/<button id="mergepull" class="([^"]*)"/) || [])[1]; };
  177. const lb = await listBtn(B), lc = await listBtn(C), ln = await listBtn(null), la = await listBtn(A);
  178. check('/pulls: Bob (member) and Alice see a visible Merge button on the green PR (quiet mergepr)', lb.includes('quiet mergepr') && la.includes('quiet mergepr'), J([lb, la]));
  179. check('/pulls: Carol and the signed-out viewer see no visible Merge button', !lc.includes('quiet mergepr') && !ln.includes('quiet mergepr'), J([lc, ln]));
  180. const pb = await pageBtn(B, n3), pa = await pageBtn(A, n3), pc = await pageBtn(C, n3), pn = await pageBtn(null, n3);
  181. check('/pulls/N: Bob and Alice get the Merge button (mergepr), Carol and signed-out get nomerge', pb === 'mergepr' && pa === 'mergepr' && pc === 'nomerge' && pn === 'nomerge', J([pb, pa, pc, pn]));
  182. const pageFace = await face(C, 'gitoriaPrMerge', ['mm', '' + n3]);
  183. check('the PR page\'s merge face refuses a stranger', pageFace && /only the owner and the members/.test(pageFace.error || ''), J(pageFace));
  184. // ---- 5. stale head, then the member merges (event with sender = Bob)
  185. const stale = await merge(tB, n3, J({ head: 'f'.repeat(40) }));
  186. check('a head that is not the current head → 409, nothing merged', stale.status === 409 && /head/.test(errOf(stale).message || '') && bare('rev-parse', 'refs/heads/main') === before, stale.status + stale.body.slice(0, 200));
  187. check('a malformed head → 422', (await merge(tB, n3, J({ head: 'abc' }))).status === 422);
  188. check('a body that is not JSON → 400', (await merge(tB, n3, 'nope')).status === 400);
  189. const k = got.length;
  190. const ok = await merge(tB, n3, J({ head: s3 }));
  191. const jo = (() => { try { return JSON.parse(ok.body); } catch { return {}; } })();
  192. check('the MEMBER merges PR 3 (status success, the right head): 200 { merged, mergeCommit, pull }', ok.status === 200 && jo.merged === true && jo.mergeCommit === bare('rev-parse', 'refs/heads/main') && jo.pull.state === 'merged' && jo.pull.number === n3, ok.status + ok.body.slice(0, 300));
  193. check('the merge commit author = Bob', bare('log', '-1', '--format=%an', 'main') === 'Bob');
  194. for (let i = 0; i < 100 && !got.slice(k).some(x => x.body.includes('"merged"')); i++) await sleep(100);
  195. const ev = got.slice(k).map(x => { try { return JSON.parse(x.body); } catch { return {}; } }).find(x => x.event === 'pull_request' && x.action === 'merged' && x.pull && x.pull.number === n3);
  196. check('the pull_request merged event reached the app: sender = Bob, mergeCommit = the new tip', ev && ev.sender && ev.sender.name === 'Bob' && ev.mergeCommit === jo.mergeCommit, J(ev).slice(0, 300));
  197. const again = await merge(tB, n3);
  198. check('merging it again → 409 already merged', again.status === 409 && /already merged/.test(errOf(again).message || ''), again.status + again.body.slice(0, 200));
  199. check('the stored PR reads as merged with GET /api/pulls/N', JSON.parse((await raw('GET', '/api/pulls/' + n3, { host: HOST, headers: { authorization: 'Bearer ' + tApp } })).body).state === 'merged');
  200. // the PR page's own Merge button (its face) merges for the owner and answers the page read again
  201. await put(s4, 'success');
  202. const pm = await face(A, 'gitoriaPrMerge', ['mm', '' + n4]);
  203. check('the PR page\'s Merge face merges PR 4 for the owner: the view says merged, the button hides', pm && pm.view && pm.view.pr.state === 'merged' && pm.view.mergeClass === 'nomerge' && bare('merge-base', '--is-ancestor', s4, 'main') === '', J(pm).slice(0, 200));
  204. // a member who is removed can merge no more
  205. const s5 = mkPr('f5', 'five'), n5 = await prNum(s5);
  206. await put(s5, 'success');
  207. await face(A, 'gitoriaChangeMember', ['mm', 'Bob', false]);
  208. check('Bob removed → his token no longer merges (403)', (await merge(tB, n5)).status === 403);
  209. for (const path of paths) check('W49 removed member loses read: ' + path, (await api(tB, 'GET', path)).status === 404);
  210. const pbGone = await pageBtn(B, n5);
  211. check('and his Merge button is gone', pbGone === 'nomerge', pbGone);
  212. } catch (e) {
  213. check('the gate ran without an exception', false, String(e && e.stack || e));
  214. } finally {
  215. await stop().catch(() => {});
  216. try { receiver.close(); } catch {}
  217. try { ident && ident.stop && await ident.stop(); } catch {}
  218. console.log(`\n${passes} passed, ${failures} failed`);
  219. process.exit(failures ? 1 : 0);
  220. }

Branches

Latest commits

  • fd4fc028Exercise member status reads with a populated check statemre
  • 536ca6f9Allow repository members to read pull workflow APIs with user tokensmre
  • 705dd834W49 missionmre
  • b554cd5flogmre
  • f4c9440ddeploy.sh: tar --hard-dereference for the live data backupmre
  • 1a687b15Merge branch 'w48-member-merge'mre
  • 166c775fW48 report, logmre
  • 1b4623f0Members merge pull requests: API route, button on /pulls and /pulls/N, one shared merge pathmre
  • 1075c38cW48 mission, logmre
  • 17bdd0d6V37/V39 missions, logmre
  • 146de5f8Re-vendor gitoria to Hybriel set-day39 (51e921d7)mre
  • e874e44dtests/status-keyed: app token lives 60 s so it outlives the gate's two restartsmre
  • 270b8d61deploy.sh: DEPLOY_STOP_START=1 stops, waits for the old pid, then starts (mpackdb freeze, replaces the standby swap)mre
  • 3f9235b8project.hl: drop the dummy /pulls/:n component route (hybriel#294 is fixed in day37)mre
  • c90daf19Re-vendor gitoria to Hybriel set-day37 (f6b3d45b)mre
  • 03b5bb08W39 report to reports/, drop scratch repro, mission + logmre
  • 154d333fMerge w39-create-api: POST /api/repos with a user token (#39)mre
  • 149dd512Rewrite W39 reportmre
  • e5385075Expect 401 for POST /api/repos without a tokenmre
  • 1a76055cDocument repository creation APImre