gitoria

gitoria

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Main branchmainfe209ffeMerge branch 'w56-owner-members' into mainGitoriamain/tests/status.mjs

23.0 KB

  1. import { requiredPort } from './gate-ports.mjs';
  2. // tests/status.mjs — GATE OF THE STATUS AN APP SETS (gitoria#46): PUT {api}/statuses/<sha> (store, replace, validation, unknown sha 422, foreign repo / no token),
  3. // the owner's "required before merge" (Settings, owner only), the Merge refused on the server until every required context is success on the PR's CURRENT head
  4. // (a push after success blocks again), the badges on /pulls. Real HTTP and the real `git`.
  5. // node tests/status.mjs (GITORIA_STATUS_PORT required, GITORIA_STATUS_IDENT_PORT required)
  6. import { spawn, execFileSync } from 'node:child_process';
  7. import { request } 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. const HERE = dirname(fileURLToPath(import.meta.url));
  13. const APP = resolve(HERE, '..');
  14. const PORT = requiredPort('GITORIA_STATUS_PORT'), IDENT_PORT = requiredPort('GITORIA_STATUS_IDENT_PORT');
  15. 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')));
  16. const STORE = join(APP, '.scratch/status-store');
  17. const LIFE = 60000; // the token is minted once and must outlive the gate's restart (a cold start takes ~2 s; 3 s let it expire before the PUT)
  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. function raw(method, path, { host = `localhost:${PORT}`, headers = {}, body = null, cookie = null } = {}) {
  22. return new Promise((res, rej) => {
  23. const h = { host, ...headers }; if (cookie) h.cookie = cookie;
  24. if (body !== null) h['content-length'] = Buffer.byteLength(body);
  25. 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') })); });
  26. r.on('error', rej); if (body !== null) r.write(body); r.end();
  27. });
  28. }
  29. const get = (path, o = {}) => raw('GET', path, o);
  30. const at = (label, path, method = 'GET', o = {}) => raw(method, path, { host: `${label}.localhost:${PORT}`, ...o });
  31. const errCode = (r) => { try { return JSON.parse(r.body).error.code; } catch { return null; } };
  32. let server = null, log = '';
  33. function startServer(env) {
  34. log = '';
  35. const p = spawn(join(APP, 'bin/hybriel'), ['project.hl'], { cwd: APP, stdio: ['ignore', 'pipe', 'pipe'],
  36. env: { ...process.env, GITORIA_PORT: String(PORT), GITORIA_WATCH: '0', GITORIA_PUBLIC_URL: `http://localhost:${PORT}`, GITORIA_SSH_SECRET: 'sshsecret-status-gate', GITORIA_TICKETS_URL: 'http://127.0.0.1:1', GITORIA_APP_TOKEN_LIFE_MS: String(LIFE), ...env } });
  37. p.stdout.on('data', d => log += d); p.stderr.on('data', d => log += d);
  38. server = p; return p;
  39. }
  40. 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); }
  41. const stop = async () => { if (server) { const p = server; server = null; p.kill(); await new Promise(r => p.once('exit', r)); } };
  42. let ident;
  43. try {
  44. rmSync(STORE, { recursive: true, force: true }); mkdirSync(STORE, { recursive: true });
  45. ident = await startIdent({ identDir: IDENT_DIR, workDir: join(STORE, 'ident'), port: IDENT_PORT });
  46. const alice = await ident.signIn('[email protected]');
  47. const BASE = `http://localhost:${PORT}`;
  48. const app = await ident.registerApp(alice, 'gitoria (status gate)', [BASE]);
  49. const ENV = { GITORIA_STORAGE: join(STORE, 'mpackdb'), GITORIA_SESSIONS: join(STORE, 'sessions') + '/', GITORIA_GIT: join(STORE, 'git'), IDENT_URL: ident.base, IDENT_EXCHANGE_URL: ident.base, IDENT_API_KEY: app.key, IDENT_API_SECRET: app.secret };
  50. startServer(ENV); await up();
  51. const cookieOf = (r) => (r.headers['set-cookie'] || []).map(c => c.split(';')[0])[0] || null;
  52. const ck0 = cookieOf(await get('/'));
  53. const cb = await get('/login/callback?ident_code=' + await ident.selectorCode(alice, app, BASE) + '&next=%2F', { cookie: ck0 });
  54. const A = { cookie: cookieOf(cb) || ck0 };
  55. let n = 0;
  56. const face = async (event, payload, cookie = A.cookie) => {
  57. const r = await raw('POST', '/__hl/emit', { headers: { 'content-type': 'application/json' }, cookie, body: J({ t: 'emit', i: ++n, event, payload }) });
  58. let j = null; try { j = JSON.parse(r.body); } catch {}
  59. return j && j.value;
  60. };
  61. await face('gitoriaSaveName', ['Alice']);
  62. const tA = (await face('gitoriaMakeToken', ['a'])).token;
  63. const W = join(STORE, 'work'); mkdirSync(W, { recursive: true });
  64. 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' };
  65. const g = (...a) => execFileSync('git', a, { cwd: W, encoding: 'utf8', env: genv, stdio: ['ignore', 'pipe', 'pipe'] });
  66. const sh = (fn) => { try { return fn(); } catch (e) { return null; } };
  67. const urlOf = (host, path) => `http://a:${tA}@${host}.localhost:${PORT}/${path}`;
  68. const push = (host, path, ...refs) => sh(() => { g('push', '-q', urlOf(host, path), ...refs); return true; });
  69. const sha = () => g('rev-parse', 'HEAD').trim();
  70. g('init', '-q', '-b', 'main'); writeFileSync(join(W, 'README.md'), '# t\n'); g('add', '-A'); g('commit', '-q', '-m', 'init');
  71. const mainSha = sha();
  72. check('alice creates "pub" and "other"', !!(await face('gitoriaCreate', ['pub', 'p'])).repo && !!(await face('gitoriaCreate', ['other', 'o'])).repo);
  73. check('alice pushes main to pub and to other', push('pub', 'pub.git', 'main') === true && push('other', 'other.git', 'main') === true);
  74. // a pull request on pub: branch feat with a |||PR commit
  75. g('checkout', '-q', '-b', 'feat'); writeFileSync(join(W, 'a.txt'), 'a\n'); g('add', '-A'); g('commit', '-q', '-m', '|||PR Add a');
  76. const prCommit = sha(), h1 = sha();
  77. check('alice pushes the branch feat with a |||PR commit', push('pub', 'pub.git', 'feat') === true);
  78. g('checkout', '-q', 'main'); g('checkout', '-q', '-b', 'lone'); writeFileSync(join(W, 'o.txt'), 'o\n'); g('add', '-A'); g('commit', '-q', '-m', 'only on other');
  79. const otherSha = sha();
  80. check('a commit that exists only in the repo "other"', push('other', 'other.git', 'lone') === true);
  81. const addApp = (slug, name) => face('gitoriaAppAdd', [slug, name, 'https://kunibert.worldapi.org/hook']);
  82. const kPub = await addApp('pub', 'Kunibert'), kOther = await addApp('other', 'Otto');
  83. const kMal = await addApp('pub', 'Mallory');
  84. const idOf = (r, name) => ((r.rows || []).find(x => x.name === name) || {}).id;
  85. const idK = idOf(kPub, 'Kunibert');
  86. check('apps added with keys', /^gak_/.test(kPub.key || '') && /^gak_/.test(kOther.key || ''), J([kPub, kOther]).slice(0, 200));
  87. const tok = async (host, key) => JSON.parse((await raw('POST', '/api/apps/token', { host: `${host}.localhost:${PORT}`, headers: { authorization: 'Bearer ' + key } })).body).token;
  88. const tPub = await tok('pub', kPub.key), tMal = await tok('pub', kMal.key), tOther = await tok('other', kOther.key);
  89. const put = (host, token, shaArg, body, path = '/api/statuses/') => raw('PUT', path + shaArg, { host: `${host}.localhost:${PORT}`, headers: { ...(token ? { authorization: 'Bearer ' + token } : {}), 'content-type': 'application/json' }, body: typeof body === 'string' ? body : J(body) });
  90. const ok = (r) => { try { return JSON.parse(r.body).status; } catch { return null; } };
  91. const st = (context, state, extra = {}) => ({ context, state, title: 'a title', summary: '**md**', url: null, ...extra });
  92. const pullsHtml = async () => { const b = (await get('/pulls', { host: `pub.localhost:${PORT}`, cookie: A.cookie })).body; writeFileSync(join(STORE, 'pulls.html'), b); return b; };
  93. const mergeClass = (html) => (html.match(/<button class="([^"]*)" type="button" value="[0-9a-f]{40}">Merge/) || [])[1];
  94. // ---- 1. the PUT ------------------------------------------------------------------------------------------------------------------
  95. const r1 = await put('pub', tPub, h1, st('kunibert', 'pending'));
  96. const s1 = ok(r1);
  97. check('PUT statuses/<sha>: 200 { status } with sha, context, state, title, summary, url, app, updated', r1.status === 200 && s1 && s1.sha === h1 && s1.context === 'kunibert' && s1.state === 'pending' && s1.title === 'a title' && s1.summary === '**md**' && s1.url === null && s1.app.name === 'Kunibert' && /^\d{4}-.*Z$/.test(s1.updated), r1.status + r1.body);
  98. await sleep(20);
  99. const r2 = await put('pub', tPub, h1, st('kunibert', 'failure', { title: 'second', url: 'https://kunibert.worldapi.org/r/1' }));
  100. const s2 = ok(r2);
  101. check('a newer PUT of the same (sha, context) replaces it: new state, title and https url, newer time', r2.status === 200 && s2.state === 'failure' && s2.title === 'second' && s2.url === 'https://kunibert.worldapi.org/r/1' && Date.parse(s2.updated) >= Date.parse(s1.updated), r2.body);
  102. let html = await pullsHtml();
  103. check('/pulls shows ONE badge for it (replaced, not added): failure, "Kunibert: kunibert", the title as text', (html.match(/<span class="label">Kunibert: kunibert<\/span>/g) || []).length === 1 && /<span class="badge failure"><span class="pull-status-state">failure<\/span>/.test(html) && /<span class="muted">second<\/span>/.test(html) && !/<span class="muted">a title<\/span>/.test(html), html.slice(html.indexOf('pulllist'), html.indexOf('pulllist') + 900));
  104. const big = await put('pub', tPub, h1, st('big', 'success', { summary: 'x'.repeat(65536) }));
  105. check('a summary of exactly 65,536 characters is accepted', big.status === 200, big.status + big.body.slice(0, 100));
  106. const bigger = await put('pub', tPub, h1, st('big', 'success', { summary: 'x'.repeat(65537) }));
  107. check('a summary of 65,537 characters → 422 invalid', bigger.status === 422 && errCode(bigger) === 'invalid', bigger.status);
  108. for (const [label, body] of [['an unknown state', st('c', 'done')], ['no context', st('', 'success')], ['an http url', st('c', 'success', { url: 'http://x.worldapi.org/' })], ['a javascript: url', st('c', 'success', { url: 'javascript:alert(1)' })], ['a two-line context', st('a\nb', 'success')]]) {
  109. const r = await put('pub', tPub, h1, body);
  110. check(`${label} → 422 invalid with details`, r.status === 422 && errCode(r) === 'invalid' && Array.isArray(JSON.parse(r.body).error.details), r.status + r.body.slice(0, 120));
  111. }
  112. check('a body that is not JSON → 400 invalid_json', errCode(await put('pub', tPub, h1, 'nope')) === 'invalid_json');
  113. check('no token → 401, an unknown token → 401', (await put('pub', null, h1, st('c', 'success'))).status === 401 && (await put('pub', 'gat_' + 'a'.repeat(40), h1, st('c', 'success'))).status === 401);
  114. check('POST on the status route → 405', (await raw('POST', '/api/statuses/' + h1, { host: `pub.localhost:${PORT}`, headers: { authorization: 'Bearer ' + tPub }, body: '{}' })).status === 405);
  115. // ---- 2. foreign repo, unknown sha ----------------------------------------------------------------------------------------------
  116. check('the token of the app of "other" on the address of pub → 404 not_found', (await put('pub', tOther, h1, st('c', 'success'))).status === 404 && errCode(await put('pub', tOther, h1, st('c', 'success'))) === 'not_found');
  117. check('an address that names no repo → 404', (await put('nosuch', tPub, h1, st('c', 'success'))).status === 404);
  118. const u1 = await put('pub', tPub, '0'.repeat(40), st('c', 'success'));
  119. check('a well-formed sha that is no object → 422 invalid', u1.status === 422 && errCode(u1) === 'invalid', u1.status + u1.body.slice(0, 120));
  120. check('a commit that exists only in ANOTHER repo → 422 (and nothing is stored)', (await put('pub', tPub, otherSha, st('c', 'success'))).status === 422);
  121. check('a short sha and garbage → 422', (await put('pub', tPub, h1.slice(0, 8), st('c', 'success'))).status === 422 && (await put('pub', tPub, 'zz%20zz', st('c', 'success'))).status === 422);
  122. check('the other app sets a status on its own repo (200)', (await put('other', tOther, otherSha, st('lint', 'success'))).status === 200);
  123. check('a tree/blob sha of pub is no commit → 422', (await put('pub', tPub, g('rev-parse', mainSha + '^{tree}').trim(), st('c', 'success'))).status === 422);
  124. // ---- 3. required before merge --------------------------------------------------------------------------------------------------
  125. html = await pullsHtml();
  126. check('before anything is required the Merge button is on', mergeClass(html) === 'quiet mergepr', mergeClass(html));
  127. check('Settings: nobody signed in cannot require a context', ((await face('gitoriaRequiredAdd', ['pub', idK, 'kunibert'], null)) || {}).error != null);
  128. const bob = await ident.signIn('[email protected]');
  129. const ckb0 = cookieOf(await get('/'));
  130. const cbb = await get('/login/callback?ident_code=' + await ident.selectorCode(bob, app, BASE) + '&next=%2F', { cookie: ckb0 });
  131. const B = cookieOf(cbb) || ckb0;
  132. check('Settings: a signed-in person who does not own the repo cannot require a context', ((await face('gitoriaRequiredAdd', ['pub', idK, 'kunibert'], B)) || {}).error != null);
  133. const sBob = (await get('/settings', { host: `pub.localhost:${PORT}`, cookie: B })).body;
  134. writeFileSync(join(STORE, 'settings-bob.html'), sBob);
  135. check('Settings page: the owner sees "Required before merge", another person does not', !/<h2>Required before merge/.test(sBob) && /id="requiredform"/.test((await get('/settings', { host: `pub.localhost:${PORT}`, cookie: A.cookie })).body));
  136. const rq = await face('gitoriaRequiredAdd', ['pub', idK, 'kunibert']);
  137. check('the owner requires the context "kunibert"', rq && rq.rows && rq.rows.length === 1 && rq.rows[0].name === 'Kunibert · kunibert', J(rq));
  138. check('requiring it twice keeps one row', ((await face('gitoriaRequiredAdd', ['pub', idK, 'kunibert'])).rows || []).length === 1);
  139. const sOwn = (await get('/settings', { host: `pub.localhost:${PORT}`, cookie: A.cookie })).body;
  140. check('Settings page lists it after a reload', />Kunibert · kunibert</.test(sOwn.slice(sOwn.indexOf('id="requiredlist"'))));
  141. html = await pullsHtml();
  142. check('/pulls: the status on the head is failure → the Merge button is off and says what it waits for', mergeClass(html) === 'nomerge' && /Merge waits for: Kunibert · kunibert \(failure\)/.test(html), mergeClass(html));
  143. const m1 = await face('gitoriaMergePull', ['pub', prCommit]);
  144. check('server: Merge is refused while the context is failure, and the refusal names it', m1 && /kunibert \(failure\)/.test(m1.error || '') && /Not merged/.test(m1.error), J(m1));
  145. await put('pub', tPub, h1, st('kunibert', 'pending'));
  146. check('server: pending still refuses', /kunibert \(pending\)/.test(((await face('gitoriaMergePull', ['pub', prCommit])) || {}).error || ''));
  147. await put('pub', tPub, h1, st('kunibert', 'error', { title: 'could not run' }));
  148. html = await pullsHtml();
  149. check('server: error does not count as success; /pulls shows it as its own badge (class "badge error")', /kunibert \(error\)/.test(((await face('gitoriaMergePull', ['pub', prCommit])) || {}).error || '') && /class="badge error"/.test(html) && />could not run</.test(html));
  150. await put('pub', tPub, h1, st('kunibert', 'success', { title: 'all fine' }));
  151. html = await pullsHtml();
  152. check('success on the current head → /pulls: badge "success", the Merge button is on again', /class="badge success"/.test(html) && mergeClass(html) === 'quiet mergepr' && />all fine</.test(html), mergeClass(html));
  153. // a push after success: a new head
  154. g('checkout', '-q', 'feat'); writeFileSync(join(W, 'b.txt'), 'b\n'); g('add', '-A'); g('commit', '-q', '-m', 'more work');
  155. const h2 = sha();
  156. check('alice pushes one more commit to feat (a new head)', push('pub', 'pub.git', 'feat') === true && h2 !== h1);
  157. html = await pullsHtml();
  158. check('after the push the success of the OLD head does not count: no badge, the Merge button is off again', mergeClass(html) === 'nomerge' && !/class="badge success"/.test(html) && /kunibert \(not set\)/.test(html), mergeClass(html));
  159. const m2 = await face('gitoriaMergePull', ['pub', prCommit]);
  160. check('server: Merge is refused on the new head ("not set")', m2 && /kunibert \(not set\)/.test(m2.error || ''), J(m2));
  161. check('a status for the NEW head: 200', (await put('pub', tPub, h2, st('kunibert', 'success'))).status === 200);
  162. html = await pullsHtml();
  163. check('success on the new head: its badge shows, the button is on', /class="badge success"/.test(html) && mergeClass(html) === 'quiet mergepr');
  164. // ---- 3b. keyed by app + context (v1.4) ----------------------------------------------------------------------------------------------
  165. const hk = h2, idM = idOf(kMal, 'Mallory');
  166. const listOn = async (sha_) => JSON.parse((await raw('GET', '/api/statuses/' + sha_, { host: `pub.localhost:${PORT}`, headers: { authorization: 'Bearer ' + tPub } })).body).statuses.filter(x => x.context === 'kunibert');
  167. await put('pub', tPub, hk, st('kunibert', 'success', { title: 'K ok' }));
  168. const mal = await put('pub', tMal, hk, st('kunibert', 'failure', { title: 'M bad' }));
  169. check('a second app (Mallory) PUTs the SAME context: 200, its own row (app Mallory)', mal.status === 200 && ok(mal).app.name === 'Mallory' && ok(mal).state === 'failure', mal.body);
  170. const lst = await listOn(hk);
  171. check('both stored apart: Kunibert success AND Mallory failure on the same (sha, context)', lst.length === 2 && lst.find(x => x.app.name === 'Kunibert').state === 'success' && lst.find(x => x.app.name === 'Mallory').state === 'failure' && lst.find(x => x.app.name === 'Kunibert').title === 'K ok', J(lst));
  172. await put('pub', tMal, hk, st('kunibert', 'pending'));
  173. const lst2 = await listOn(hk);
  174. check('Mallory replaces only its own row (still two; Kunibert unchanged)', lst2.length === 2 && lst2.find(x => x.app.name === 'Mallory').state === 'pending' && lst2.find(x => x.app.name === 'Kunibert').state === 'success');
  175. const rMal = await face('gitoriaRequiredAdd', ['pub', idM, 'kunibert']);
  176. check('the owner requires Mallory + kunibert: listed as "Mallory · kunibert"', (rMal.rows || []).some(x => x.name === 'Mallory · kunibert') && rMal.rows.length === 2, J(rMal));
  177. const mm = await face('gitoriaMergePull', ['pub', prCommit]);
  178. check('server: Kunibert\'s success does not meet "Mallory · kunibert" (pending) → refused, names the app and only it', mm && /Mallory · kunibert \(pending\)/.test(mm.error || '') && !/Kunibert · kunibert/.test(mm.error || ''), J(mm));
  179. await put('pub', tMal, hk, st('lint', 'success'));
  180. check('Mallory\'s success on ANOTHER context does not meet it either', /Mallory · kunibert \(pending\)/.test(((await face('gitoriaMergePull', ['pub', prCommit])) || {}).error || ''));
  181. const badId = await face('gitoriaRequiredAdd', ['pub', 'nope', 'x']);
  182. check('a made-up app id is refused (the app is picked by id)', badId && badId.error != null, J(badId));
  183. // Mallory's success on kunibert while Kunibert's own entry stays met: Kunibert's FAILURE must not be hidden by Mallory's success
  184. await put('pub', tPub, hk, st('kunibert', 'failure'));
  185. await put('pub', tMal, hk, st('kunibert', 'success'));
  186. const mk = await face('gitoriaMergePull', ['pub', prCommit]);
  187. check('Mallory success does NOT meet "Kunibert · kunibert" (failure): refused naming Kunibert only', mk && /Kunibert · kunibert \(failure\)/.test(mk.error || '') && !/Mallory · kunibert/.test(mk.error || ''), J(mk));
  188. await put('pub', tPub, hk, st('kunibert', 'success'));
  189. // remove Mallory: the entry stays, shows "(removed app)", is never met
  190. const gone = await face('gitoriaAppRemove', ['pub', idM]);
  191. const sGone = (await get('/settings', { host: `pub.localhost:${PORT}`, cookie: A.cookie })).body;
  192. check('the removed app\'s entry stays in Settings as "(removed app) · kunibert"', /\(removed app\) · kunibert/.test(sGone.slice(sGone.indexOf('id="requiredlist"'))), J(gone).slice(0, 100));
  193. const mg = await face('gitoriaMergePull', ['pub', prCommit]);
  194. check('server: an entry of a removed app is never met (Merge refused: "(removed app) · kunibert")', mg && /\(removed app\) · kunibert \(app removed\)/.test(mg.error || ''), J(mg));
  195. html = await pullsHtml();
  196. check('/pulls: the Merge button stays off for it', mergeClass(html) === 'nomerge' && /Merge waits for: .*\(removed app\) · kunibert/.test(html), mergeClass(html));
  197. const goneRow = (await face('gitoriaRequiredAdd', ['pub', idK, 'kunibert'])).rows.find(x => x.name === '(removed app) · kunibert');
  198. const dropped = await face('gitoriaRequiredRemove', ['pub', goneRow && goneRow.id]);
  199. check('the owner removes it by its row id; Kunibert\'s own entry stays', dropped.rows && dropped.rows.length === 1 && dropped.rows[0].name === 'Kunibert · kunibert', J(dropped));
  200. // two contexts: both must be success
  201. await face('gitoriaRequiredAdd', ['pub', idK, 'lint']);
  202. const m3 = await face('gitoriaMergePull', ['pub', prCommit]);
  203. check('a second required context ("lint") that was never set refuses the merge too, and names only it', m3 && /lint \(not set\)/.test(m3.error || '') && !/kunibert \(/.test(m3.error || ''), J(m3));
  204. await put('pub', tPub, h2, st('lint', 'success'));
  205. const m4 = await face('gitoriaMergePull', ['pub', prCommit]);
  206. check('every required context success on the current head → the Merge goes through', m4 && m4.error == null && m4.result, J(m4).slice(0, 200));
  207. check('the merge really happened on the server (main moved, feat is in it)', sh(() => { g('fetch', '-q', urlOf('pub', 'pub.git'), 'main:refs/remotes/pub/main'); return g('merge-base', '--is-ancestor', h2, 'refs/remotes/pub/main') === ''; }) === true);
  208. const rm = await face('gitoriaRequiredRemove', ['pub', rq.rows[0].id]);
  209. check('the owner can drop a requirement again', rm && rm.rows && rm.rows.length === 1 && rm.rows[0].name === 'Kunibert · lint', J(rm));
  210. check('the key and a token never appear in the server log', ![kPub.key, kOther.key, tPub, tOther].some(s => log.includes(s)));
  211. await stop();
  212. // ---- 4. a restart: statuses and requirements are stored -----------------------------------------------------------------------------
  213. startServer(ENV); await up();
  214. const rr = await put('pub', tPub, h2, st('kunibert', 'failure'));
  215. const htmlR = await pullsHtml();
  216. check('after a restart the token still works, the PUT replaces the stored row (one badge, now failure)', rr.status === 200 && (htmlR.match(/<span class="label">Kunibert: kunibert<\/span>/g) || []).length === 1 && /class="badge failure"/.test(htmlR) && !/<span class="badge success"><span class="pull-status-state">success<\/span><span class="label">Kunibert: kunibert/.test(htmlR));
  217. const again = await face('gitoriaRequiredAdd', ['pub', idK, 'lint'], A.cookie);
  218. check('after a restart the requirement "lint" is still stored (adding it again keeps one row)', again && again.rows && again.rows.length === 1, J(again));
  219. } catch (e) {
  220. check('the gate ran without an exception', false, String(e && e.stack || e));
  221. } finally {
  222. await stop().catch(() => {});
  223. try { ident && ident.stop && await ident.stop(); } catch {}
  224. console.log(`\n${passes} passed, ${failures} failed`);
  225. process.exit(failures ? 1 : 0);
  226. }

Branches

Latest commits

  • fe209ffeMerge branch 'w56-owner-members' into mainGitoria
  • fa0754c8|||PR repository owner transfer and members API (#55)mre
  • 8862e537Merge branch 'w55-rename-org' into mainGitoria
  • 014d2b7fOne immutable readers snapshot per move for the left-organization event (#53)mre
  • 1859d506Decide who hears a repo left its organization by its readers before the move (#53)mre
  • 499f25f2Review fixes for the Settings organization move (#53)mre
  • ed3b922b|||PR move a repository into an organization in Settings (#53)mre
  • 74ec2af8Merge branch 'w54-repo-rename-pr' into mainGitoria
  • 9f7ce8d8Preserve rename compatibility and live page titlesmre
  • c3d95b6e|||PR separate names and addresses, rename repositories in Settings (#53)mre
  • ce08920dMerge branch 'w52c-header-phone' into mainGitoria
  • 0bab9e46|||PR header: ident status wraps on phones instead of clippingmre
  • e7af3eceMerge branch 'w52b-approval-followup' into mainGitoria
  • c01e66c6|||PR approvals follow-up: live Merge after status writes, helpers (#52)mre
  • 841da497Merge branch 'w53-pulls-speed-pr' into mainGitoria
  • 80307ae2|||PR pulls page cache: live PR numbers, complete scans onlymre
  • 69141f65|||PR pulls page: cache the git part per repo by branch tipsmre
  • 155861f6Merge branch 'w52-person-approval' into mainGitoria
  • b5435de8|||PR person approvals: second Kunibert round (#52)mre
  • 3a8b2fb8|||PR person approvals: Kunibert review fixes (#52)mre