gitoria
All repositories: gitoria
25.3 KB
import { requiredPort } from './gate-ports.mjs';// tests/private.mjs — GATE OF PRIVATE REPOS AND ORGANIZATIONS (ticket gitoria#34, GO34). Real HTTP against a real local gitoria + its own ident// (tests/identkit.mjs), the real `git` binary for clone / push, the move tool (tools/move-repo.hl) on a copy. A private repo, and every repo of a// private organization, does not exist for anybody who is not in it: homepage list, repo page, every code path, API, git over HTTP, the ssh// access check. An organization's address lists its repos and /<repo>/… behave like repo pages. A public repo is unchanged.// node tests/private.mjs (GITORIA_PRIV_PORT required, GITORIA_PRIV_IDENT_PORT required)import { spawn, execFileSync } from 'node:child_process';import { request } from 'node:http';import { mkdirSync, rmSync, writeFileSync, existsSync, readdirSync, lstatSync, readlinkSync } from 'node:fs';import { dirname, join, resolve } from 'node:path';import { fileURLToPath } from 'node:url';import { startIdent } from './identkit.mjs';const HERE = dirname(fileURLToPath(import.meta.url));const APP = resolve(HERE, '..');const PORT = requiredPort('GITORIA_PRIV_PORT'), IDENT_PORT = requiredPort('GITORIA_PRIV_IDENT_PORT');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')));const STORE = join(APP, '.scratch/priv-store');const SSH_SECRET = 'sshsecret-for-the-private-gate';const J = JSON.stringify, sleep = (ms) => new Promise(r => setTimeout(r, ms));let passes = 0, failures = 0;const check = (label, ok, detail = '') => { console.log(`${ok ? 'ok ' : 'FAIL'} ${label}${ok ? '' : ' — ' + detail}`); if (ok) passes++; else failures++; };function raw(method, path, { host = `localhost:${PORT}`, headers = {}, body = null, cookie = null } = {}) {return new Promise((res, rej) => {const h = { host, ...headers }; if (cookie) h.cookie = cookie;if (body !== null) h['content-length'] = Buffer.byteLength(body);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('latin1') })); });r.on('error', rej); if (body !== null) r.write(body); r.end();});}const get = (path, o = {}) => raw('GET', path, o);const g404 = (r) => r.status === 404 || /No such repository/.test(r.body);const at = (label, path = '/', o = {}) => get(path, { host: `${label}.localhost:${PORT}`, ...o });let server = null, log = '';function startServer(env) {log = '';const p = spawn(join(APP, 'bin/hybriel'), ['project.hl'], { cwd: APP, stdio: ['ignore', 'pipe', 'pipe'],env: { ...process.env, GITORIA_PORT: String(PORT), GITORIA_WATCH: '0', GITORIA_PUBLIC_URL: `http://localhost:${PORT}`, GITORIA_SSH_SECRET: SSH_SECRET, GITORIA_TICKETS_URL: 'http://127.0.0.1:1', ...env } });p.stdout.on('data', d => log += d); p.stderr.on('data', d => log += d);server = p; return p;}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); }const stop = async () => { if (server) { const p = server; server = null; p.kill(); await new Promise(r => p.once('exit', r)); } };let ident;try {rmSync(STORE, { recursive: true, force: true }); mkdirSync(STORE, { recursive: true });ident = await startIdent({ identDir: IDENT_DIR, workDir: join(STORE, 'ident'), port: IDENT_PORT });const alice = await ident.signIn('[email protected]'), bob = await ident.signIn('[email protected]'), carol = await ident.signIn('[email protected]');const BASE = `http://localhost:${PORT}`;const app = await ident.registerApp(alice, 'gitoria (private gate)', [BASE]);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 };startServer(ENV); await up();const cookieOf = (r) => (r.headers['set-cookie'] || []).map(c => c.split(';')[0])[0] || null;const login = async (who) => {const ck = cookieOf(await get('/'));const code = await ident.selectorCode(who, app, BASE);const cb = await get('/login/callback?ident_code=' + code + '&next=%2F', { cookie: ck });return { cookie: cookieOf(cb) || ck };};let n = 0;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 { status: r.status, value: j && j.value, error: j && j.error };};const A = await login(alice), B = await login(bob), C = await login(carol);await face(A, 'gitoriaSaveName', ['Alice']); await face(B, 'gitoriaSaveName', ['Bob']); await face(C, 'gitoriaSaveName', ['Carol']);const tok = async (who, name) => (await face(who, 'gitoriaMakeToken', [name])).value.token;const tA = await tok(A, 'a'), tB = await tok(B, 'b'), tC = await tok(C, 'c');// ---- the working copy to push ----------------------------------------------------------------------------------------------const W = join(STORE, 'work'); mkdirSync(W, { recursive: true });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' };const g = (...a) => execFileSync('git', a, { cwd: W, encoding: 'utf8', env: genv, stdio: ['ignore', 'pipe', 'pipe'] });g('init', '-q', '-b', 'main');writeFileSync(join(W, 'README.md'), '# Hidden\n\nSECRETREADME-7f3a\n');writeFileSync(join(W, 'file.txt'), 'SECRETFILE-9c1d\n');g('add', '-A'); g('commit', '-q', '-m', 'init SECRETCOMMIT-5b2e');const SHA = g('rev-parse', 'HEAD').trim();const urlOf = (t, host, path) => `http://u:${t}@${host}.localhost:${PORT}/${path}`;const pushTo = (t, host, path) => { try { g('push', '-q', urlOf(t, host, path), 'main'); return true; } catch { return false; } };const lsRemote = (t, host, path) => { try { return g('ls-remote', t ? urlOf(t, host, path) : `http://${host}.localhost:${PORT}/${path}`); } catch { return null; } };// ---- 1. a PUBLIC repo is unchanged ---------------------------------------------------------------------------------------const pub = await face(A, 'gitoriaCreate', ['pubrepo', 'a public one']);check('public: created through the old face', !!(pub.value && pub.value.repo && pub.value.repo.slug === 'pubrepo' && pub.value.repo.address === `http://pubrepo.localhost:${PORT}/`), J(pub.value));check('public: pushed with the owner token', pushTo(tA, 'pubrepo', 'pubrepo.git'));const pubPage = await at('pubrepo');check('public: signed out sees the README on <slug>.host', pubPage.status === 200 && pubPage.body.includes('SECRETREADME-7f3a'), pubPage.status);check('public: signed out lists it and the API shows it', (await get('/')).body.includes('pubrepo') && JSON.parse((await get('/api/repos')).body).repos.some(r => r.slug === 'pubrepo'));check('public: anonymous git clone works', !!lsRemote(null, 'pubrepo', 'pubrepo.git'));check('public: /code/file.txt readable signed out', (await at('pubrepo', '/code/file.txt')).body.includes('SECRETFILE-9c1d'));// ---- 2. a PRIVATE repo ---------------------------------------------------------------------------------------------------const sec = await face(A, 'gitoriaCreateRepo', ['secretrepo', 'hush hush DESCSECRET', '', true]);check('private: the owner creates it', !!(sec.value && sec.value.repo && sec.value.repo.isPrivate), J(sec.value));check('private: the owner pushes', pushTo(tA, 'secretrepo', 'secretrepo.git'));const paths = ['/', '/code', '/code/file.txt', '/code/README.md', '/branch/main', `/commit/${SHA}`, '/pulls', '/releases', '/tickets', '/settings'];const strip = (b, s) => b.replace(/<script type="application\/json" id="hl-seed">[\s\S]*?<\/script>/g, '').split(s).join('X');const hidden = async (label, who, host, ps, slugText) => {for (const p of ps) {const r = await at(host, p, who ? { cookie: who.cookie } : {});const ref = { [p]: await at('nosuchrepo', p, who ? { cookie: who.cookie } : {}) };const bad = /SECRETREADME|SECRETFILE|SECRETCOMMIT|DESCSECRET|hush hush/.test(r.body);check(`${label}: ${p} shows nothing of it`, !bad && /No such repository/.test(r.body), r.status + ' ' + r.body.slice(0, 80));check(`${label}: ${p} is the answer for a name that does not exist (same status, same page)`, r.status === ref[p].status && strip(r.body, slugText) === strip(ref[p].body, 'nosuchrepo'), `${r.status} vs ${ref[p].status}`);}};await hidden('private signed out', null, 'secretrepo', paths, 'secretrepo');await hidden('private stranger', C, 'secretrepo', ['/', '/code/file.txt', '/settings'], 'secretrepo');await hidden('private non-member', B, 'secretrepo', ['/', '/code/file.txt'], 'secretrepo');for (const [w, wn] of [[null, 'signed out'], [C, 'a stranger'], [B, 'a non-member']]) {const home = (await get('/', w ? { cookie: w.cookie } : {})).body;check(`private: the repo list of ${wn} does not name it`, !home.includes('secretrepo') && !home.includes('DESCSECRET'));const list = (await get('/api/repos', w ? { cookie: w.cookie } : {})).body;check(`private: /api/repos of ${wn} does not name it`, !list.includes('secretrepo') && !list.includes('DESCSECRET'));const one = await get('/api/repos/secretrepo', w ? { cookie: w.cookie } : {});check(`private: /api/repos/secretrepo for ${wn} is 404`, one.status === 404, one.status);}check('private: the owner sees it in the list and on its page', (await get('/', { cookie: A.cookie })).body.includes('secretrepo') && (await at('secretrepo', '/', { cookie: A.cookie })).body.includes('SECRETREADME-7f3a'));check('private: the owner reads a file', (await at('secretrepo', '/code/file.txt', { cookie: A.cookie })).body.includes('SECRETFILE-9c1d'));// git over HTTP: 404 (not 401/403) for everybody outsidefor (const [svc, who] of [['git-upload-pack', null], ['git-upload-pack', tC], ['git-upload-pack', tB], ['git-receive-pack', null], ['git-receive-pack', tC], ['git-receive-pack', tB]]) {const hd = who ? { headers: { authorization: 'Basic ' + Buffer.from('u:' + who).toString('base64') } } : {};const r = await at('secretrepo', `/secretrepo.git/info/refs?service=${svc}`, hd);const none = await at('nosuchrepo', `/nosuchrepo.git/info/refs?service=${svc}`, hd);// git sends no credentials before a challenge: anonymous gets the 401 a missing name gets too; a token without access gets 404 (like a missing name)check(`private git: ${svc} ${who ? 'with a foreign token → 404' : 'anonymous → 401'}, the same as a missing repo`, r.status === (who ? 404 : 401) && r.status === none.status, r.status + ' vs ' + none.status);}check('private git: clone anonymous fails', lsRemote(null, 'secretrepo', 'secretrepo.git') === null);check('private git: clone with a stranger token fails', lsRemote(tC, 'secretrepo', 'secretrepo.git') === null);check('private git: push by a stranger fails', !pushTo(tC, 'secretrepo', 'secretrepo.git'));check('private git: the owner clones', /refs\/heads\/main/.test(lsRemote(tA, 'secretrepo', 'secretrepo.git') || ''));const acc = (user, slug, write) => get(`/__git/access?user=${user}&slug=${encodeURIComponent(slug)}&write=${write}`, { headers: { 'x-gitoria-secret': SSH_SECRET } });// members: add Bob by his display name → sees, clones, pushes; Carol still notconst add = await face(A, 'gitoriaChangeMember', ['secretrepo', 'Bob', true]);check('members: the owner adds Bob by display name', !!(add.value && add.value.members && add.value.members.length === 1 && add.value.members[0].name === 'Bob'), J(add.value));check('members: a stranger cannot add herself', !!(await face(C, 'gitoriaChangeMember', ['secretrepo', 'Carol', true])).value.error);const bobUid = add.value.members[0].id;check('ssh access: Bob (member) may read and write secretrepo, a stranger gets 404', (await acc(bobUid, 'secretrepo', 1)).status === 200 && (await acc('nobody', 'secretrepo', 0)).status === 404);check('members: Bob sees the page and the file', (await at('secretrepo', '/code/file.txt', { cookie: B.cookie })).body.includes('SECRETFILE-9c1d'));check('members: Bob clones', /refs\/heads\/main/.test(lsRemote(tB, 'secretrepo', 'secretrepo.git') || ''));g('commit', '-q', '--allow-empty', '-m', 'bob was here');check('members: Bob pushes', pushTo(tB, 'secretrepo', 'secretrepo.git'));check('members: Carol still sees nothing', (await at('secretrepo', '/', { cookie: C.cookie })).body.includes('No such repository'));const bobId = JSON.parse((await get('/api/repos/secretrepo', { cookie: B.cookie })).body);check('members: the API gives Bob the row, without secrets', bobId.slug === 'secretrepo' && !('tktKey' in bobId));const rm = await face(A, 'gitoriaChangeMember', ['secretrepo', 'Bob', false]);check('members: removed, Bob is out again', (rm.value.members || []).length === 0 && (await acc(bobUid, 'secretrepo', 0)).status === 404 && (await at('secretrepo', '/', { cookie: B.cookie })).body.includes('No such repository') && !pushTo(tB, 'secretrepo', 'secretrepo.git'));// visibility switch of one repoconst flip = await face(A, 'gitoriaSetPrivate', ['pubrepo', true]);check('visibility: the owner makes a public repo private', !!(flip.value && flip.value.repo && flip.value.repo.isPrivate), J(flip.value));check('visibility: …and a stranger no longer sees it', (await at('pubrepo', '/', { cookie: C.cookie })).body.includes('No such repository') && lsRemote(null, 'pubrepo', 'pubrepo.git') === null);check('visibility: a stranger cannot flip it back', !!(await face(C, 'gitoriaSetPrivate', ['pubrepo', false])).value.error);await face(A, 'gitoriaSetPrivate', ['pubrepo', false]);check('visibility: public again, readable signed out', (await at('pubrepo')).body.includes('SECRETREADME-7f3a'));// ---- 3. ORGANIZATIONS ----------------------------------------------------------------------------------------------------const org = await face(A, 'gitoriaCreateOrg', ['acme', true]);check('org: created private', !!(org.value && org.value.org && org.value.org.slug === 'acme' && org.value.org.isPrivate), J(org.value));check('org: its name cannot be taken by a repo, nor a repo name by an org', !!(await face(A, 'gitoriaCreateRepo', ['acme', 'x', '', false])).value.error && !!(await face(A, 'gitoriaCreateOrg', ['pubrepo', false])).value.error);check('org: a stranger cannot create a repo in it', !!(await face(C, 'gitoriaCreateRepo', ['intruder', 'x', 'acme', false])).value.error);const tool = await face(A, 'gitoriaCreateRepo', ['tool', 'ORGDESC the tool', 'acme', false]);check('org: the owner creates acme/tool (asked public, but its organization is private)', !!(tool.value && tool.value.repo && tool.value.repo.slug === 'acme/tool' && tool.value.repo.isPrivate && tool.value.repo.address === `http://acme.localhost:${PORT}/tool/`), J(tool.value));check('org: a repo named like a page of the organization is refused', !!(await face(A, 'gitoriaCreateRepo', ['code', 'x', 'acme', false])).value.error);check('org: pushing over HTTP at <org>.host/<repo>.git', pushTo(tA, 'acme', 'tool.git'));const opaths = ['/', '/tool', '/tool/code', '/tool/code/file.txt', '/tool/branch/main', `/tool/commit/${SHA}`, '/tool/pulls', '/tool/releases', '/tool/tickets', '/tool/settings'];for (const p of opaths) {for (const [w, wn] of [[null, 'signed out'], [C, 'a stranger']]) {const r = await at('acme', p, w ? { cookie: w.cookie } : {});const omissing = { [p]: await at('nosuchorg', p, w ? { cookie: w.cookie } : {}) };check(`private org, ${wn}: ${p} shows nothing`, !/SECRETREADME|SECRETFILE|SECRETCOMMIT|ORGDESC/.test(r.body), r.status);check(`private org, ${wn}: ${p} is the answer for a name that does not exist`, r.status === omissing[p].status && strip(r.body, 'acme') === strip(omissing[p].body, 'nosuchorg'), `${r.status} vs ${omissing[p].status}`);}}const mainA = (await get('/', { cookie: A.cookie })).body, mainC = (await get('/')).body;check('private org: the main list shows acme/tool to the owner only', mainA.includes('acme/tool') && !mainC.includes('acme'));check('private org: /api/repos hides it from strangers', !(await get('/api/repos', { cookie: C.cookie })).body.includes('acme'));check('private org git: stranger and anonymous get 404, clone fails', (await at('acme', '/tool.git/info/refs?service=git-upload-pack')).status === 401 && lsRemote(tC, 'acme', 'tool.git') === null);check('private org git: the owner clones', /refs\/heads\/main/.test(lsRemote(tA, 'acme', 'tool.git') || ''));check('ssh access: an unknown user is told 404 for acme/tool', (await acc('nobody', 'acme/tool', 0)).status === 404);// the owner sees the organization's address and the repo pages like a normal repoconst orgHome = await at('acme', '/', { cookie: A.cookie });check('org address lists its repos (owner)', orgHome.status === 200 && /id="repos"/.test(orgHome.body) && orgHome.body.includes('acme/tool') && orgHome.body.includes('ORGDESC'), orgHome.status);const toolHome = await at('acme', '/tool', { cookie: A.cookie });check('org repo page /tool = a repo page (README, tabs inside /tool)', toolHome.status === 200 && toolHome.body.includes('SECRETREADME-7f3a') && /href="\/tool\/code"/.test(toolHome.body) && /href="\/tool\/pulls"/.test(toolHome.body) && /href="\/tool\/settings"/.test(toolHome.body), toolHome.status + ' ' + toolHome.body.slice(0, 400));if (toolHome.status !== 200) console.log('server log: ' + log.slice(-1200));const code = await at('acme', '/tool/code', { cookie: A.cookie });check('org repo /tool/code lists the files, links stay inside /tool', code.body.includes('file.txt') && /href="\/tool\/code\/file.txt"/.test(code.body) && /href="\/tool\/commit\//.test(code.body) && !/href="\/code[\/"]/.test(code.body), code.status);check('org repo /tool/code/file.txt shows the file', (await at('acme', '/tool/code/file.txt', { cookie: A.cookie })).body.includes('SECRETFILE-9c1d'));const wrong = await at('pubrepo', '/tool/code');check('a repo address has no /<repo>/… pages (a first segment on a non-org host is "No such repository")', /No such repository/.test(wrong.body) && !wrong.body.includes('SECRETFILE'));const mainWrong = await get('/tool/code');check('the main address has none either', /No such repository/.test(mainWrong.body));// org membercheck('org members: owner adds Bob to the organization', !!(await face(A, 'gitoriaChangeOrgMember', ['acme', 'Bob', true])).value.members);check('org members: Bob reads, clones and pushes inside it', (await at('acme', '/tool', { cookie: B.cookie })).body.includes('SECRETREADME-7f3a') && /refs\/heads\/main/.test(lsRemote(tB, 'acme', 'tool.git') || '') && pushTo(tB, 'acme', 'tool.git'));check('org members: Bob can create a repo in it', !!(await face(B, 'gitoriaCreateRepo', ['second', 'by bob', 'acme', false])).value.repo);check('org members: Carol still nothing', (g404(await at('acme', '/tool', { cookie: C.cookie }))));// the organization goes public: its repos followcheck('org visibility: a stranger cannot flip it', !!(await face(C, 'gitoriaSetOrgPrivate', ['acme', false])).value.error);check('org visibility: the owner makes it public', !!(await face(A, 'gitoriaSetOrgPrivate', ['acme', false])).value.ok);const pubOrg = await at('acme', '/', { cookie: C.cookie });check('public org: a stranger sees the list and the repo page and clones', pubOrg.body.includes('acme/tool') && (await at('acme', '/tool')).body.includes('SECRETREADME-7f3a') && /refs\/heads\/main/.test(lsRemote(null, 'acme', 'tool.git') || ''));check('public org: …but pushing needs the owner or a member (stranger 403)', (await at('acme', '/tool.git/info/refs?service=git-receive-pack', { headers: { authorization: 'Basic ' + Buffer.from('u:' + tC).toString('base64') } })).status === 403);await face(A, 'gitoriaSetOrgPrivate', ['acme', true]);check('org private again: a stranger sees nothing again', g404(await at('acme', '/tool', { cookie: C.cookie })));// ---- 4. THE MOVE TOOL on a copy: routger → acme-org/hyper-conductor (private), old address forwards ----------------------await face(A, 'gitoriaCreate', ['routger', 'the router']);check('move: routger pushed', pushTo(tA, 'routger', 'routger.git'));await face(A, 'gitoriaChangeMember', ['routger', 'Bob', true]);await stop();const mv = (...a) => { try { return { ok: true, out: execFileSync(join(APP, 'bin/hybriel'), ['tools/move-repo.hl', ...a], { cwd: APP, env: { ...process.env, ...ENV, GITORIA_STORAGE: ENV.GITORIA_STORAGE }, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] }) }; } catch (e) { return { ok: false, out: String(e.stderr || '') + String(e.stdout || '') }; } };const cr = (...a) => { try { return { ok: true, out: execFileSync(join(APP, 'bin/hybriel'), ['tools/create-repo.hl', ...a], { cwd: APP, env: { ...process.env, ...ENV }, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] }) }; } catch (e) { return { ok: false, out: String(e.stderr || '') + String(e.stdout || '') }; } };const crBad = cr('acme-org/seppy-phone', 'private', 'Alice', 'Nobody');check('create-repo tool: an unknown member is refused, nothing made', !crBad.ok);const crOk = cr('acme-org/seppy-phone', 'private', 'Alice', 'Bob');check('create-repo tool: acme-org/seppy-phone private with Bob as member', crOk.ok && /created acme-org\/seppy-phone \(private\), member Bob/.test(crOk.out), crOk.out);check('create-repo tool: the bare repo exists, empty', existsSync(join(STORE, 'git/acme-org/seppy-phone.git')));const bad1 = mv('routger', 'acme-org/hyper-conductor');check('move tool: the visibility is required', !bad1.ok, bad1.out);const bad2 = mv('nosuch', 'acme-org/x', 'public');check('move tool: an unknown repo is refused', !bad2.ok, bad2.out);const bad3 = mv('routger', 'acme/code', 'public');check('move tool: a reserved name inside an organization is refused', !bad3.ok, bad3.out);const before = execFileSync('git', ['--git-dir', join(STORE, 'git/routger.git'), 'rev-parse', 'main'], { encoding: 'utf8' }).trim();const moved = mv('routger', 'acme-org/hyper-conductor', 'private');check('move tool: routger → acme-org/hyper-conductor (private) runs', moved.ok && /moved routger -> acme-org\/hyper-conductor/.test(moved.out), moved.out);check('move tool: the SAME bare repo was moved (history, no re-push)', existsSync(join(STORE, 'git/acme-org/hyper-conductor.git')) && lstatSync(join(STORE, 'git/routger.git')).isSymbolicLink() && readlinkSync(join(STORE, 'git/routger.git')) === 'acme-org/hyper-conductor.git' && execFileSync('git', ['--git-dir', join(STORE, 'git/acme-org/hyper-conductor.git'), 'rev-parse', 'main'], { encoding: 'utf8' }).trim() === before);startServer(ENV); await up();const A2 = await login(alice), B2 = await login(bob), C2 = await login(carol);const nu = await at('acme-org', '/hyper-conductor', { cookie: A2.cookie });check('moved: acme-org.host/hyper-conductor is the repo (owner)', nu.status === 200 && /id="reponame"/.test(nu.body) && nu.body.includes('acme-org/hyper-conductor'), nu.status);check('moved: it is private now — a stranger and anonymous see nothing', g404(await at('acme-org', '/hyper-conductor', { cookie: C2.cookie })) && g404(await at('acme-org', '/hyper-conductor')));check('moved: the member list went with it (Bob reads)', (await at('acme-org', '/hyper-conductor', { cookie: B2.cookie })).body.includes('acme-org/hyper-conductor'));const oldp = await at('routger', '/', { cookie: A2.cookie });check('moved: the old address says where it moved', oldp.status === 200 && /id="movedlink"/.test(oldp.body) && oldp.body.includes('acme-org/hyper-conductor'), oldp.status);check('moved: git on the OLD path still works for the owner (same history)', (lsRemote(tA, 'routger', 'routger.git') || '').includes(before));check('moved: …and stays private on the old path (anonymous, stranger → no)', lsRemote(null, 'routger', 'routger.git') === null && lsRemote(tC, 'routger', 'routger.git') === null);check('moved: git on the new path clones', (lsRemote(tA, 'acme-org', 'hyper-conductor.git') || '').includes(before));check('moved: a push through the OLD path lands in the moved repo', (() => { g('commit', '-q', '--allow-empty', '-m', 'after the move'); return pushTo(tA, 'routger', 'routger.git'); })() && (lsRemote(tA, 'acme-org', 'hyper-conductor.git') || '').includes(g('rev-parse', 'HEAD').trim()));check('create-repo tool: Bob (member) pushes to seppy-phone, Carol cannot, anonymous cannot read', pushTo(tB, 'acme-org', 'seppy-phone.git') && !pushTo(tC, 'acme-org', 'seppy-phone.git') && lsRemote(null, 'acme-org', 'seppy-phone.git') === null);check('moved: the name routger cannot be taken again', !!(await face(A2, 'gitoriaCreate', ['routger', 'again'])).value.error);const acc2 = await acc('nobody', 'routger', 0);check('ssh access: an unknown user is told 404 for the private repo', acc2.status === 404, acc2.status);} catch (e) {check('the gate ran without an exception', false, String(e && e.stack || e));} finally {await stop().catch(() => {});try { ident && ident.stop && await ident.stop(); } catch {}console.log(`\n${passes} passed, ${failures} failed`);process.exit(failures ? 1 : 0);}
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