import { test } from 'node:test'; import assert from 'node:assert/strict'; import { onRequest } from '../functions/_middleware.js'; test('installer and appcast requests are gone even with storage bound', async () => { for (const path of ['/downloads/Jobley-0.1.1.dmg', '/downloads/Jobley%2Dlegacy.zip', '/appcast.xml', '/appcast-legacy.xml']) { for (const method of ['GET', 'HEAD']) { const response = await onRequest({ request: new Request('https://jobley.ai' + path, { method, headers: { Range: 'bytes=0-8' } }), env: { DOWNLOADS: { get() { throw new Error('Storage must not be accessed'); } } }, next() { throw new Error('Must not fall through'); }, }); assert.equal(response.status, 410, path); assert.equal(response.headers.get('cache-control'), 'no-store'); assert.equal(response.headers.get('content-type'), 'text/plain; charset=utf-8'); if (method === 'HEAD') assert.equal(await response.text(), ''); } } });