DC-130 rev2: fail-fast bridge bindings (host), /status gateway-error mapping (401/403/unreachable -> 502, probe-failure stays ok:false) + 3 new tests (13 total)
CI / Test & Lint (push) Waiting to run
CI / Security audit (push) Waiting to run

This commit is contained in:
DashCaddy Polish Loop
2026-09-14 04:11:30 -07:00
parent 0ab1dfe6e5
commit 121caef488
2 changed files with 60 additions and 3 deletions
@@ -140,6 +140,45 @@ describe('routes/deploys — proxied endpoints', () => {
expect(body.output).toContain('[FAIL]');
});
test('GET /status maps bridge auth failure (401) to 502, not a probe result', async () => {
const f = jsonFetcher({
'GET /api/status?service=helloworld': { status: 401, body: { ok: false, error: 'invalid token' } },
});
const app = buildApp(f.fetchT);
const server = app.listen(0);
const port = server.address().port;
const r = await fetch(`http://127.0.0.1:${port}/api/v1/deploys/status?service=helloworld`);
const body = await r.json();
server.close();
expect(r.status).toBe(502);
expect(body.success).toBe(false);
expect(body.error).toMatch(/bridge/i);
});
test('GET /status maps unexpected bridge statuses to 502', async () => {
const f = jsonFetcher({
'GET /api/status?service=helloworld': { status: 404, body: { ok: false, error: 'not found' } },
});
const app = buildApp(f.fetchT);
const server = app.listen(0);
const port = server.address().port;
const r = await fetch(`http://127.0.0.1:${port}/api/v1/deploys/status?service=helloworld`);
server.close();
expect(r.status).toBe(502);
});
test('GET /status maps bridge connection failure to 502', async () => {
const fetchT = jest.fn(async () => { throw new Error('ECONNREFUSED'); });
const app = buildApp(fetchT);
const server = app.listen(0);
const port = server.address().port;
const r = await fetch(`http://127.0.0.1:${port}/api/v1/deploys/status?service=helloworld`);
const body = await r.json();
server.close();
expect(r.status).toBe(502);
expect(body.error).toMatch(/unreachable/);
});
test('POST /deploy proxies dir and audits', async () => {
const f = jsonFetcher({
'POST /api/deploy': { status: 200, body: { ok: true, exit: 0, output: 'DEPLOYED helloworld in 30.0s' } },