gitoria

calendar

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitdf2e4fa0df2e4fa0calendar#12: test push rate limit (1 per 30 s per device), owner-only gate checksmredf2e4fa0/tests/push.mjs

22.0 KB

  1. // tests/push.mjs — calendar#9 part 2 (mission 008): WEB PUSH, a reminder reaches a device whose calendar is CLOSED.
  2. // node tests/push.mjs [app dir] env: PUSH_GATE_PORT (app, default 8700; ident +1; the fake push service +2; Chrome +4),
  3. // PUSH_GATE_SCRATCH. A real headless Chrome as a 390 px phone, own ident, own server + storage, VAPID keys made here.
  4. // The FAKE PUSH SERVICE is a local http server that decrypts like a user agent (ECDH with the subscription's private key,
  5. // RFC 8291; the approach of hybriel tests/core-ast/web-tickets.mjs #173): it answers 201 at /ok/*, 410 at /gone/*.
  6. // Headless Chrome cannot reach a real push service, so the browser's `PushManager.subscribe` is replaced by one that answers
  7. // the subscription made here (the page's own code — subscribePush, the button, the server emit — is the real one).
  8. // 1 ok tap "Turn on notifications" → the page says it is subscribed; the browser is then CLOSED; at the reminder time
  9. // the fake service gets ONE encrypted push: VAPID header with the app's key, payload = event title + "Starts in 1 minute"
  10. // 2 gone a device whose service answers 410 gets the first push, and none after it (the subscription is dropped)
  11. // 4 test a subscribed device taps "Send a test notification": ONE push, ~10 s later, to that device only (calendar#12)
  12. // 3 shown + off a device that allowed notifications before is subscribed when the app is shown again (no touch); "Turn off on this device" unsubscribes it and the server drops it: no push, a reload does not subscribe it again (PUSH_GATE_ONLY3=1 runs only this)
  13. import { spawn } from 'node:child_process';
  14. import { writeFileSync, existsSync, mkdirSync, rmSync } from 'node:fs';
  15. import { createServer as httpServer } from 'node:http';
  16. import { generateKeyPairSync, createECDH, hkdfSync, createDecipheriv, randomBytes, verify } from 'node:crypto';
  17. import { dirname, join, resolve } from 'node:path';
  18. import { fileURLToPath } from 'node:url';
  19. const HERE = dirname(fileURLToPath(import.meta.url));
  20. const APP = resolve(process.argv[2] || resolve(HERE, '..'));
  21. const PORT = Number(process.env.PUSH_GATE_PORT || 8700);
  22. const FPORT = PORT + 2, CPORT = PORT + 4;
  23. const BASE = `http://127.0.0.1:${PORT}`;
  24. const SCRATCH = resolve(process.env.PUSH_GATE_SCRATCH || join(APP, '.scratch', 'push-gate'));
  25. rmSync(SCRATCH, { recursive: true, force: true });
  26. mkdirSync(join(SCRATCH, 'chrome'), { recursive: true });
  27. process.env.TMPDIR = join(SCRATCH, 'chrome');
  28. if (!process.env.HL_CHROME && existsSync('/opt/google/chrome/chrome')) process.env.HL_CHROME = '/opt/google/chrome/chrome';
  29. const { launchBrowser } = await import('./cdp.mjs');
  30. const { startIdent } = await import('./identkit.mjs');
  31. const IDENT_DIR = process.env.CALENDAR_GATE_IDENT_DIR || [resolve(APP, '../ident.worldapi.org'), '/media/STORAGE/projects/WorldAPI/ident.worldapi.org'].find(d => existsSync(join(d, 'project.hl')));
  32. const sleep = (ms) => new Promise(r => setTimeout(r, ms));
  33. const J = JSON.stringify;
  34. const pad = (n) => String(n).padStart(2, '0');
  35. const b64 = (b) => Buffer.from(b).toString('base64url');
  36. let failures = 0, passes = 0;
  37. function check(label, ok, detail = '') { console.log(`${ok ? 'ok ' : 'FAIL'} ${label}${ok ? '' : ' — ' + detail}`); if (ok) passes++; else failures++; }
  38. const say = (what) => console.log(`${new Date().toTimeString().slice(0, 8)} ${what}`);
  39. // the app's VAPID pair
  40. const app = generateKeyPairSync('ec', { namedCurve: 'P-256' });
  41. const jwk = app.privateKey.export({ format: 'jwk' });
  42. const PUB = b64(Buffer.concat([Buffer.from([4]), Buffer.from(jwk.x, 'base64url'), Buffer.from(jwk.y, 'base64url')]));
  43. const PRIV = jwk.d;
  44. // the fake push service: a user agent per subscription (its ECDH key and auth secret), decrypting what arrives
  45. const agents = {};
  46. function newAgent(path) { const ua = createECDH('prime256v1'); ua.generateKeys(); agents[path] = { ua, auth: randomBytes(16) }; return { endpoint: `http://127.0.0.1:${FPORT}${path}`, keys: { p256dh: b64(ua.getPublicKey()), auth: b64(agents[path].auth) } }; }
  47. const received = [];
  48. function decrypt(path, b) {
  49. const { ua, auth } = agents[path]; const uaPub = ua.getPublicKey();
  50. const salt = b.subarray(0, 16); const idlen = b[20]; const asPub = b.subarray(21, 21 + idlen);
  51. const ikm = Buffer.from(hkdfSync('sha256', ua.computeSecret(asPub), auth, Buffer.concat([Buffer.from('WebPush: info\0'), uaPub, asPub]), 32));
  52. const cek = Buffer.from(hkdfSync('sha256', ikm, salt, Buffer.from('Content-Encoding: aes128gcm\0'), 16));
  53. const nonce = Buffer.from(hkdfSync('sha256', ikm, salt, Buffer.from('Content-Encoding: nonce\0'), 12));
  54. const rec = b.subarray(21 + idlen);
  55. const d = createDecipheriv('aes-128-gcm', cek, nonce); d.setAuthTag(rec.subarray(rec.length - 16));
  56. const pt = Buffer.concat([d.update(rec.subarray(0, rec.length - 16)), d.final()]);
  57. return pt.subarray(0, pt.lastIndexOf(2)).toString('utf8');
  58. }
  59. const fake = httpServer((q, r) => {
  60. const c = []; q.on('data', d => c.push(d));
  61. q.on('end', () => {
  62. const body = Buffer.concat(c); let plain = null, err = null;
  63. try { plain = decrypt(q.url, body); } catch (e) { err = String(e.message); }
  64. received.push({ at: Date.now(), url: q.url, headers: q.headers, plain, err });
  65. r.statusCode = q.url.startsWith('/gone') ? 410 : 201; r.end('');
  66. });
  67. });
  68. const ANDROID_UA = 'Mozilla/5.0 (Linux; Android 14; Pixel 7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Mobile Safari/537.36';
  69. let ident = null, server = null, log = '', APPKEY = null, browser = null;
  70. async function stopAll() {
  71. if (browser) { try { await browser.close(); } catch {} browser = null; }
  72. if (ident) { try { await ident.stop(); } catch {} ident = null; }
  73. try { fake.close(); } catch {}
  74. if (server) { try { server.kill('SIGTERM'); } catch {} await new Promise(r => { if (server.exitCode !== null || server.signalCode !== null) return r(); server.once('exit', r); setTimeout(r, 3000); }); server = null; }
  75. }
  76. const shot = async (page, name) => { const { data } = await page.send('Page.captureScreenshot', { format: 'png' }); writeFileSync(join(SCRATCH, `${name}.png`), Buffer.from(data, 'base64')); };
  77. async function tap(page, sel) {
  78. const at = await page.evaluate(`(() => { const e = document.querySelector(${J(sel)}); if (!e) return null; const r = e.getBoundingClientRect(); return { x: Math.round(r.x + r.width / 2), y: Math.round(r.y + r.height / 2) }; })()`);
  79. if (!at) throw new Error('tap: no ' + sel);
  80. await page.send('Input.dispatchTouchEvent', { type: 'touchStart', touchPoints: [{ x: at.x, y: at.y }] });
  81. await page.send('Input.dispatchTouchEvent', { type: 'touchEnd', touchPoints: [] });
  82. }
  83. const hydrated = (page) => page.waitFor('!!window.__hl && window.__hl.socket && window.__hl.socket.readyState === 1', { timeout: 120000, label: 'hydrated' });
  84. // a signed-in phone of `who`; `sub` is what the (replaced) browser subscribe answers
  85. async function phone(who, sub) {
  86. browser = await launchBrowser({ debugPortRange: [CPORT, CPORT] });
  87. const page = await browser.newPage();
  88. await page.addInitScript(`(() => { const want = ${J({ endpoint: sub.endpoint, expirationTime: null, keys: sub.keys })}; let held = JSON.parse(sessionStorage.getItem('__held') || 'null');
  89. const mk = () => ({ endpoint: want.endpoint, toJSON: () => want, unsubscribe: () => { sessionStorage.setItem('__held', 'null'); held = null; window.__unsub = (window.__unsub || 0) + 1; return Promise.resolve(true); } });
  90. PushManager.prototype.subscribe = function (o) { window.__subKey = String(o.applicationServerKey) + '|' + o.userVisibleOnly; sessionStorage.setItem('__held', '1'); held = 1; return Promise.resolve(mk()); };
  91. PushManager.prototype.getSubscription = function () { return Promise.resolve(held ? mk() : null); }; })();`);
  92. await page.send('Emulation.setDeviceMetricsOverride', { width: 390, height: 800, deviceScaleFactor: 2, mobile: true });
  93. await page.send('Emulation.setTouchEmulationEnabled', { enabled: true, maxTouchPoints: 5 });
  94. await page.send('Emulation.setUserAgentOverride', { userAgent: ANDROID_UA, platform: 'Linux armv8l' });
  95. const code = await ident.selectorCode(who, APPKEY, BASE);
  96. await page.goto(BASE + '/login/callback?ident_code=' + code, { timeout: 120000 });
  97. await page.waitForSelector('#logout', { timeout: 60000 });
  98. await hydrated(page);
  99. await page.waitFor(`navigator.serviceWorker.getRegistration().then(r => !!(r && r.active))`, { label: 'service worker active', timeout: 60000 });
  100. return page;
  101. }
  102. // an event starting `ahead` ms from now (rounded up to a whole minute), own reminder 1 minute before → the reminder's instant
  103. async function addEvent(page, title, ahead) {
  104. const zone = await page.evaluate('Intl.DateTimeFormat().resolvedOptions().timeZone');
  105. const now = Date.now();
  106. const start = new Date(Math.ceil((now + ahead) / 60000) * 60000);
  107. const dateOf = (d) => `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`;
  108. const cookie = (await page.cookies([BASE])).map(c => c.name + '=' + c.value).join('; ');
  109. const fields = { title, allDay: false, startDate: dateOf(start), startTime: `${pad(start.getHours())}:${pad(start.getMinutes())}`, endDate: '', endTime: '', place: '', notes: '', zone, custom: true, reminders: [{ unit: 'minutes', n: '1', time: '09:00' }] };
  110. const r = await fetch(BASE + '/__hl/emit', { method: 'POST', headers: { 'content-type': 'application/json', cookie }, body: J({ t: 'emit', i: 1, event: 'calSave', payload: [fields, dateOf(new Date(now - 259200000)), dateOf(new Date(now + 777600000))] }) });
  111. const j = JSON.parse(await r.text());
  112. if (!j.value || j.value.error) throw new Error('calSave: ' + r.status + ' ' + J(j));
  113. return start.getTime() - 60000;
  114. }
  115. const until = async (t) => { const w = t - Date.now(); if (w > 0) await sleep(w); };
  116. const pushText = (page) => page.evaluate(`(document.querySelector('#push-state') || {}).textContent || ''`);
  117. async function main() {
  118. mkdirSync(join(SCRATCH, 'store', 'sessions'), { recursive: true });
  119. await new Promise(res => fake.listen(FPORT, '127.0.0.1', res));
  120. ident = await startIdent({ identDir: IDENT_DIR, workDir: join(SCRATCH, 'store', 'ident'), port: PORT + 1 });
  121. const alice = await ident.signIn('[email protected]'), bob = await ident.signIn('[email protected]');
  122. APPKEY = await ident.registerApp(alice, 'calendar (push gate)', [BASE]);
  123. server = spawn(join(APP, 'bin/hybriel'), ['project.hl'], { cwd: APP, env: { ...process.env, CALENDAR_PORT: String(PORT), HL_HOST: '127.0.0.1', CALENDAR_SESSIONS: join(SCRATCH, 'store', 'sessions') + '/',
  124. CALENDAR_STORAGE: join(SCRATCH, 'store', 'mpackdb'), CALENDAR_WATCH: '0', CALENDAR_PUBLIC_URL: BASE, IDENT_URL: ident.base, IDENT_EXCHANGE_URL: ident.base,
  125. IDENT_API_KEY: APPKEY.key, IDENT_API_SECRET: APPKEY.secret, CALENDAR_PUSH_PUBLIC: PUB, CALENDAR_PUSH_PRIVATE: PRIV, CALENDAR_PUSH_SUBJECT: 'mailto:[email protected]',
  126. CALENDAR_PUSH_EVERY: '0.5', CALENDAR_PUSH_ALLOW_HTTP: '1' }, stdio: ['ignore', 'pipe', 'pipe'] });
  127. server.stdout.on('data', d => log += d); server.stderr.on('data', d => log += d);
  128. for (let i = 0; ; i++) { try { if ((await fetch(BASE + '/')).ok) break; } catch {} if (i > 600) throw new Error('server did not come up\n' + log); await sleep(250); }
  129. say('app up');
  130. let page, text = '';
  131. if (!process.env.PUSH_GATE_ONLY3 && !process.env.PUSH_GATE_ONLY4) {
  132. // ---- 1 ok: subscribed by a real tap, browser closed, the push arrives with the title ----
  133. const sub1 = newAgent('/ok/dev1');
  134. page = await phone(alice, sub1);
  135. await page.send('Browser.grantPermissions', { origin: BASE, permissions: ['notifications'] }).catch(() => {});
  136. await tap(page, '#month-title'); await sleep(800);
  137. await shot(page, 'ok-1-before-tap');
  138. const askShown = await page.evaluate(`!document.querySelector('#notify-ask').classList.contains('hidden')`);
  139. say('button offered: ' + askShown + ' (permission ' + await page.evaluate('Notification.permission') + ')');
  140. if (askShown) await tap(page, '#notify-ask');
  141. text = '';
  142. for (let i = 0; i < 40 && !/closed/.test(text); i++) { await sleep(500); text = await pushText(page); }
  143. await shot(page, 'ok-2-subscribed');
  144. if (!/closed/.test(text)) console.log('---- page console\n' + page.dumpConsole().slice(-1500));
  145. check('1 the tap subscribes: the page says reminders also reach it when the calendar is closed', /also reach this device when the calendar is closed/.test(text), J(text));
  146. check('1 subscribe got the app\'s VAPID key and userVisibleOnly', (await page.evaluate('window.__subKey')) === PUB + '|true', await page.evaluate('window.__subKey'));
  147. if (process.env.PUSH_GATE_STOP1 && !/closed/.test(text)) return;
  148. const at1 = await addEvent(page, 'Zahnarzt Push', 150000);
  149. say('reminder at ' + new Date(at1).toTimeString().slice(0, 8) + '; closing the browser');
  150. await browser.close(); browser = null; // the phone's browser is gone: only the server can reach the device now
  151. await until(at1 + 20000);
  152. const got1 = received.filter(x => x.url === '/ok/dev1');
  153. say('fake push service got: ' + J(got1.map(x => ({ late: Math.round((x.at - at1) / 1000), plain: x.plain }))));
  154. check('1 the reminder was pushed to the closed device, once', got1.length === 1, J(got1.map(x => x.plain)));
  155. const p1 = got1[0] && got1[0].plain ? JSON.parse(got1[0].plain) : {};
  156. check('1 the payload (decrypted like a user agent) is the event title and "Starts in 1 minute"', p1.title === 'Zahnarzt Push' && p1.body === 'Starts in 1 minute' && /^[\w-]+:\d+$/.test(p1.tag || ''), J(p1));
  157. check('1 it came at the reminder time (within 15 s)', got1[0] && got1[0].at >= at1 - 1000 && got1[0].at - at1 < 15000, got1[0] && (got1[0].at - at1) + ' ms');
  158. const h = got1[0] ? got1[0].headers : {};
  159. const mm = /^vapid t=([\w-]+)\.([\w-]+)\.([\w-]+), k=([\w-]+)$/.exec(h.authorization || '');
  160. check('1 VAPID: k is the app\'s public key and the JWT verifies; aes128gcm', !!mm && mm[4] === PUB && verify('sha256', Buffer.from(mm[1] + '.' + mm[2]), { key: app.publicKey, dsaEncoding: 'ieee-p1363' }, Buffer.from(mm[3], 'base64url')) && h['content-encoding'] === 'aes128gcm', J(h));
  161. await sleep(4000);
  162. check('1 nothing is sent twice for the same reminder', received.filter(x => x.url === '/ok/dev1').length === 1, String(received.length));
  163. // ---- 2 gone: the service answers 410 → the subscription is dropped (no second push for the next reminder) ----
  164. const sub2 = newAgent('/gone/dev2');
  165. page = await phone(bob, sub2);
  166. await page.send('Browser.grantPermissions', { origin: BASE, permissions: ['notifications'] }).catch(() => {});
  167. await tap(page, '#month-title'); await sleep(800);
  168. await tap(page, '#notify-ask');
  169. text = ''; for (let i = 0; i < 40 && !/closed/.test(text); i++) { await sleep(500); text = await pushText(page); }
  170. const a = await addEvent(page, 'Gone one', 150000);
  171. const b = await addEvent(page, 'Gone two', 150000 + 70000);
  172. await browser.close(); browser = null;
  173. await until(b + 20000);
  174. const got2 = received.filter(x => x.url === '/gone/dev2');
  175. say('gone device saw: ' + J(got2.map(x => x.plain)));
  176. check('2 the first reminder went to the dead subscription (410)', got2.length >= 1 && JSON.parse(got2[0].plain).title === 'Gone one', J(got2.map(x => x.plain)));
  177. check('2 after the 410 the subscription is dropped: the next reminder is not sent to it', got2.length === 1, J(got2.map(x => x.plain)));
  178. }
  179. // ---- 3 shown again + off: a device that already allowed notifications is subscribed when the app is shown again (no tap); "Turn off on this device"
  180. // unsubscribes it and the server drops it: the reminder is not pushed to it, and a reload does not subscribe it again ----
  181. if (!process.env.PUSH_GATE_ONLY4) {
  182. if (process.env.PUSH_GATE_ONLY3) received.push({ url: '/ok/dev1', plain: 'Off device' });
  183. const sub3 = newAgent('/ok/dev3');
  184. page = await phone(alice, sub3);
  185. await page.send('Browser.grantPermissions', { origin: BASE, permissions: ['notifications'] }).catch(() => {});
  186. await page.goto(BASE + '/', { timeout: 120000 }); await hydrated(page); // permission is there before the page loads: no touch at all
  187. await sleep(3000);
  188. // the first `pageshow` comes before the page's components are hydrated (measured: no subscription at load, Hybriel's `on client shown`
  189. // only hears later shows); a tab shown again (visibilitychange → visible) subscribes without any touch
  190. const atLoad = await pushText(page);
  191. await page.evaluate(`document.dispatchEvent(new Event('visibilitychange'))`);
  192. text = ''; for (let i = 0; i < 40 && !/closed/.test(text); i++) { await sleep(500); text = await pushText(page); }
  193. check('3 permission already given: the app shown again subscribes the device without any touch (not yet at first load: "' + atLoad + '")', /also reach this device when the calendar is closed/.test(text), J(text));
  194. await shot(page, 'off-1-on');
  195. const offVisible = await page.evaluate(`(() => { const e = document.querySelector('#push-off'); if (!e || e.classList.contains('hidden')) return null; const r = e.getBoundingClientRect(); return { h: r.height, w: r.width, text: e.textContent }; })()`);
  196. check('3 "Turn off on this device" is shown next to the on-state text, a 44 px tap', !!offVisible && offVisible.h >= 44 && /Turn off on this device/.test(offVisible.text), J(offVisible));
  197. await tap(page, '#push-off'); await sleep(2500);
  198. await shot(page, 'off-2-off');
  199. const unsubs = await page.evaluate('window.__unsub || 0'); text = await pushText(page);
  200. check('3 the tap unsubscribes the browser and the page says reminders show only while open', unsubs === 1 && /while the calendar is open/.test(text), unsubs + ' ' + J(text));
  201. check('3 the control is gone and "Turn on notifications" is offered again', await page.evaluate(`document.querySelector('#push-off').classList.contains('hidden') && !document.querySelector('#notify-ask').classList.contains('hidden')`));
  202. await page.goto(BASE + '/', { timeout: 120000 }); await hydrated(page); await sleep(6000);
  203. check('3 a reload does not subscribe the device again', !/closed/.test(await pushText(page)) && (await page.evaluate('window.__subKey')) == null, J(await pushText(page)));
  204. const c = await addEvent(page, 'Off device', 150000);
  205. await browser.close(); browser = null;
  206. await until(c + 20000);
  207. const got3 = received.filter(x => x.url === '/ok/dev3');
  208. check('3 after "off" no push reaches that device (its server row is gone)', got3.length === 0, J(got3.map(x => x.plain)));
  209. check('3 the same reminder still reached the owner\'s other device', received.some(x => x.url === '/ok/dev1' && /Off device/.test(x.plain || '')), J(received.map(x => x.url)));
  210. }
  211. // ---- 4 test notification (calendar#12): "Send a test notification" on a subscribed device → ONE push to that device only, ~10 s later,
  212. // with the calendar closed: title "Calendar test", body "Push works on this device" ----
  213. const sub4 = newAgent('/ok/dev4'), sub1 = { endpoint: `http://127.0.0.1:${FPORT}/ok/dev1` };
  214. page = await phone(bob, sub4);
  215. await page.send('Browser.grantPermissions', { origin: BASE, permissions: ['notifications'] }).catch(() => {});
  216. await tap(page, '#month-title'); await sleep(800);
  217. if (await page.evaluate(`!document.querySelector('#notify-ask').classList.contains('hidden')`)) await tap(page, '#notify-ask'); // a device that allowed notifications before is subscribed by the first touch already
  218. text = ''; for (let i = 0; i < 40 && !/closed/.test(text); i++) { await sleep(500); text = await pushText(page); }
  219. const testBtn = await page.evaluate(`(() => { const e = document.querySelector('#push-test'); if (!e || e.classList.contains('hidden')) return null; const r = e.getBoundingClientRect(); return { h: r.height, text: e.textContent }; })()`);
  220. await shot(page, 'test-1-button');
  221. check('4 a subscribed device offers "Send a test notification" (44 px tap)', !!testBtn && testBtn.h >= 44 && /Send a test notification/.test(testBtn.text), J(testBtn));
  222. const before4 = received.filter(x => x.url === '/ok/dev4').length;
  223. await tap(page, '#push-test'); const t4 = Date.now();
  224. text = ''; for (let i = 0; i < 20 && !/on its way/.test(text); i++) { await sleep(500); text = await pushText(page); }
  225. await shot(page, 'test-2-sent');
  226. check('4 the page says the test is on its way', /on its way/.test(text), J(text));
  227. await sleep(1500);
  228. check('4 not at once: the phone has time to leave the app (nothing yet after 1.5 s)', received.filter(x => x.url === '/ok/dev4').length === before4);
  229. // abuse: a second tap within 30 s is refused (rate limit per device); bob cannot test alice's device (/ok/dev1) — owner only
  230. await tap(page, '#push-test'); await sleep(1500); text = await pushText(page);
  231. check('4 a second test within 30 s is refused ("wait 30 seconds")', /wait 30 seconds/.test(text), J(text));
  232. const cookie4 = (await page.cookies([BASE])).map(c => c.name + '=' + c.value).join('; ');
  233. const emitTest = async (ep, i) => JSON.parse(await (await fetch(BASE + '/__hl/emit', { method: 'POST', headers: { 'content-type': 'application/json', cookie: cookie4 }, body: J({ t: 'emit', i, event: 'calPushTest', payload: [ep] }) })).text());
  234. const foreign = await emitTest(sub1.endpoint, 7), none = await emitTest('https://example.org/x', 8);
  235. check('4 a test for a device that is not the signed-in user\'s is refused', !!foreign.value && !!foreign.value.error && !!none.value && !!none.value.error, J([foreign, none]));
  236. await browser.close(); browser = null;
  237. await until(t4 + 25000);
  238. const got4 = received.filter(x => x.url === '/ok/dev4').slice(before4);
  239. const p4 = got4[0] && got4[0].plain ? JSON.parse(got4[0].plain) : {};
  240. check('4 ONE test push reached the closed device, 8-20 s after the tap, with title "Calendar test" and body "Push works on this device"', got4.length === 1 && p4.title === 'Calendar test' && p4.body === 'Push works on this device' && got4[0].at - t4 > 8000 && got4[0].at - t4 < 20000, J(got4.map(x => [x.at - t4, x.plain])));
  241. check('4 no other device got a test (alice\'s dev1 neither)', !received.some(x => x.at >= t4 && x.url !== '/ok/dev4' && /Calendar test/.test(x.plain || '')), J(received.filter(x => x.at >= t4).map(x => x.url)));
  242. }
  243. try { await main(); } catch (e) { check('gate ran', false, String(e && e.stack || e)); }
  244. if (failures) console.log('---- server log (tail)\n' + log.slice(-2500));
  245. await stopAll();
  246. console.log(`${passes} passed, ${failures} failed (app ${APP})`);
  247. process.exit(failures ? 1 : 0);

Branches

Latest commits

  • df2e4fa0calendar#12: test push rate limit (1 per 30 s per device), owner-only gate checksmre
  • acb957cfcalendar#12: Send a test notification on a subscribed device (one push in ~10 s, owner's own device), push gate part 4mre
  • 0b222eb8tests: e2e-theme CDP port default from E2E_THEME_CDP_PORT (8756 unchanged)mre
  • 8b8a5abare-vendor Hybriel 6f8a0689 (int 6–11: streaming cursors, #203 index heal + close() fix, fd403 listDir/cursor fds, hl:time browser side, hl:web batches 5+6)mre
  • a69b27f9docker-compose: nofile 65536 (Hybriel int 6+ boot opened >1024 files in the tracker)mre
  • 1a97edfdcalendar mission 010: reminder rows at 390 px (the 7-column month grid no longer catches the reminder lists), gate checks, settings-shots, reportmre
  • 61b21404calendar mission 009: reminder times on hl:time in the browser (lib/push-plan.hl and the Intl code removed), DST gate tests/dst.mjs, E2E script, reportmre
  • 875353c1calendar mission 009: re-vendor Hybriel master 022a3ac1 (int 6 6b396322 hl:time browser side, int 7 65e8ec21; bin sha256 6e0f77d7, plugins whole)mre
  • ce16a4efdeploy: backup copies index files first and *.mpack data last (hot-copy skew, hybriel #203)mre
  • f490bc8cdeploy: Web Push gate tests/push.mjs (PUSH_GATE_PORT)mre
  • 3af29fc8calendar mission 008 (A8): report, README, LOG, push-shots.mjsmre
  • f91f3663calendar mission 008 (A8): push only asked of the browser when the app has the VAPID settings (pushAvailable); real-FCM E2E scripts (push-real-app.mjs, push-real.mjs)mre
  • bf571badcalendar mission 008 (A8): Turn off on this device (unsubscribes the browser, server drops the device, choice kept), subscribe/refresh when the app is shown again; push gate part 3mre
  • 50985708calendar mission 008 (A7): Web Push report, README, mission, LOGmre
  • ee318774calendar mission 008 (A7): push-real.mjs, push sent log linemre
  • ebda0fd1calendar mission 008 (A7): server-side reminder plan on hl:time (push-plan.hl; hl:time fromLocal in a browser static is refused: repro .scratch/hltime-client), push gate 9/9mre
  • d063dad3calendar mission 008 (A7): Web Push (WIP): lib/push.hl subscriptions + sender clock, faces calPushSave/calPushOff, button subscribes, VAPID tool, tests/push.mjs; instantOf on hl:timemre
  • cf175c80calendar mission 008 (A7): re-vendor Hybriel master 0e3c9830 (bin 9d957fed, plugins whole: hl:crypto Web Push primitives, hl:web sendPush)mre
  • 9bf3c38bcalendar mission 008: re-vendor Hybriel f9833544 (gates old = new); Web Push stopped: hl:crypto half missing on mastermre
  • 186f969bcalendar mission 007: signed-in gate for the first-pointer race (fails on 3c5604f), README theme section, reportmre