Files
strata/apps/host/tests/connector-setup.test.mjs
T
Niko1221 0b3299a019 apps/host: the owner's UI and the Node App Host
The UI source from the 14 October handoff (src/, public/, index.html, vite and
tsconfig, tests, audit-fixes, design docs) and the App Host (server/*.mjs): model
import and monitor routes, API-provider catalog and streaming (OpenAI chat, OpenAI Responses,
the Messages API), serving, tunnel, tasks, plus the host routes for Time-skip
(server/timeskip.mjs) and the tuning plan/reports. src/lib/time-skip.ts renders a real
job's own record.

The UI design is unchanged. The rebuild routed #/tuning to a new TunePanel; that is
reverted: src/screens/ModelRun.tsx and src/main.tsx are the handoff's again (#/tuning
goes where the handoff sends it), and src/components/TunePanel.tsx and
src/styles/tuning.css, which only that route used, are not carried over. Left out of
git on purpose: dist/ (build output), node_modules, and docs/evidence + docs/checkpoints
(170 MB of screenshots, kept in StrataSplit\evidence-archive).

From the owner's rebuild branch strata/rebuild-2026-10.
2026-10-15 10:24:09 +02:00

51 lines
2.3 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import { createHash } from 'node:crypto';
import { mkdtemp, readdir, rm } from 'node:fs/promises';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { connectorAsset, createConnectorInstaller, verifyConnector } from '../server/cloudflared-install.mjs';
test('automatic setup selects native executables and rejects unsupported platforms', () => {
assert.equal(connectorAsset('darwin','arm64'),'cloudflared-darwin-arm64.tgz');
assert.equal(connectorAsset('linux','x64'),'cloudflared-linux-amd64');
assert.equal(connectorAsset('win32','x64'),'cloudflared-windows-amd64.exe');
assert.throws(()=>connectorAsset('win32','arm64'),/not available/);
assert.throws(()=>connectorAsset('unknown','x64'),/not available/);
});
test('corrupt or unverified downloads cannot become executable', () => {
const bytes=Buffer.from('official connector fixture');
const digest=`sha256:${createHash('sha256').update(bytes).digest('hex')}`;
assert.doesNotThrow(()=>verifyConnector(bytes,digest));
assert.throws(()=>verifyConnector(Buffer.from('tampered'),digest),/could not be verified/);
assert.throws(()=>verifyConnector(bytes,null),/could not be verified/);
});
test('failed concurrent setup shares one download, cleans up and can be retried', async () => {
const directory=await mkdtemp(join(tmpdir(),'strata-connector-test-'));
let requests=0, release;
const installer=createConnectorInstaller({directory,platform:'linux',arch:'x64',fetchImpl:async()=>{
requests++;
await new Promise(resolve=>{release=resolve;});
return {ok:false};
}});
try {
const first=installer.ensure(),second=installer.ensure();
assert.equal(first,second);
while(!release)await new Promise(resolve=>setImmediate(resolve));
release();
const results=await Promise.allSettled([first,second]);
assert.ok(results.every(result=>result.status==='rejected'));
assert.equal(requests,1);
assert.deepEqual(await readdir(directory),[]);
release=null;
const retry=installer.ensure();
while(!release)await new Promise(resolve=>setImmediate(resolve));
release();
await assert.rejects(retry,/download service/);
assert.equal(requests,2);
assert.deepEqual(await readdir(directory),[]);
} finally {await rm(directory,{recursive:true,force:true});}
});