app

Local-first trade for farms and co-ops
git clone https://radroots.dev/git/app.git
Log | Files | Refs | README | LICENSE

privacy-output.test.ts (1895B)


      1 import { test } from 'node:test';
      2 import assert from 'node:assert/strict';
      3 import { readdir, readFile } from 'node:fs/promises';
      4 import path from 'node:path';
      5 import { fileURLToPath } from 'node:url';
      6 import { createStaticHarness } from './harness/static.ts';
      7 
      8 await test('HCP128 actual static Messages response keeps generic noindex metadata and condition copy', async () => {
      9   const server = await createStaticHarness();
     10   try {
     11     const response = await fetch(server.url + '/messages', {
     12       headers: { Accept: 'text/html' }
     13     });
     14     assert.equal(response.status, 200);
     15     const html = await response.text();
     16     assert.match(html, /<title>HarvestCircle<\/title>/);
     17     assert.match(html, /<meta name="robots" content="noindex"/);
     18     assert.ok(
     19       html.includes(
     20         'Messages stay hidden until you connect and explicitly unlock your inbox.'
     21       )
     22     );
     23     assert.ok(!html.includes('unavailable during development'));
     24   } finally {
     25     await server.close();
     26   }
     27 });
     28 
     29 await test('HCP128 every actual static artifact excludes private fixture bodies and production fixture secrets', async () => {
     30   const root = fileURLToPath(new URL('../../build/', import.meta.url));
     31   let checked = 0;
     32   async function inspect(directory: string) {
     33     for (const item of await readdir(directory, { withFileTypes: true })) {
     34       const file = path.join(directory, item.name);
     35       assert.ok(!item.isSymbolicLink());
     36       if (item.isDirectory()) await inspect(file);
     37       else {
     38         assert.ok(item.isFile());
     39         const content = await readFile(file, 'utf8');
     40         assert.doesNotMatch(
     41           content,
     42           /HCP104_UNSENT_MEMORY_ONLY|PRIVATE OWNER B SENTINEL|HC_TEST_ONLY_SECRET|-----BEGIN (?:[A-Z ]*PRIVATE KEY|OPENSSH)/
     43         );
     44         checked++;
     45       }
     46     }
     47   }
     48   await inspect(root);
     49   assert.ok(checked > 0, 'must inspect actual generated static files');
     50 });