Checking whether the service is up required an account, so the answer lived where the people asking could not reach it. The page is rendered on the server with no script at all and refreshes through a meta tag: a status page that needs a working browser is useless at the moment it is read. Two rules follow from it being public. A repository the forge does not list as public keeps its environment visible but loses its name, and the banner always states the worst true thing — a failed deployment forbids the green headline even while the bot answers. WEB_PUBLIC_STATUS=false removes page and route together. /api/status gives the same in JSON, which is what a monitor should watch rather than /api/health — the latter only says the process is alive. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
47 lines
1.5 KiB
JavaScript
47 lines
1.5 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import { createServer } from 'node:http';
|
|
import { after, before, describe, it } from 'node:test';
|
|
|
|
/**
|
|
* `WEB_PUBLIC_STATUS=false` (M19).
|
|
*
|
|
* The switch decides what an anonymous visitor may learn about the
|
|
* infrastructure, so it gets a file of its own: the flag is read when the
|
|
* configuration module loads, and a suite cannot hold both answers at once.
|
|
*/
|
|
|
|
process.env.WEB_PUBLIC_STATUS = 'false';
|
|
|
|
const { closeDatabase, initDatabase } = await import('../src/database/index.js');
|
|
const { createHandler } = await import('../src/web/server.js');
|
|
|
|
describe('status page turned off', () => {
|
|
let app;
|
|
|
|
before(async () => {
|
|
initDatabase(':memory:');
|
|
app = createServer(createHandler({ client: null, setupOnly: false }));
|
|
await new Promise((resolve) => app.listen(0, '127.0.0.1', resolve));
|
|
});
|
|
after(async () => {
|
|
await new Promise((resolve) => app.close(resolve));
|
|
closeDatabase();
|
|
});
|
|
|
|
const call = (path) => fetch(`http://127.0.0.1:${app.address().port}${path}`);
|
|
|
|
it('does not serve the page', async () => {
|
|
const response = await call('/status');
|
|
assert.equal(response.status, 404);
|
|
assert.doesNotMatch(await response.text(), /État des services/);
|
|
});
|
|
|
|
it('does not answer in JSON either', async () => {
|
|
assert.equal((await call('/api/status')).status, 404);
|
|
});
|
|
|
|
it('leaves the health probe alone', async () => {
|
|
assert.equal((await call('/api/health')).status, 200);
|
|
});
|
|
});
|