Settings: the servers settings (install defaults, port range, central IP) are saved

Found in the VM test: they were never added to the known settings, so
saving them was silently ignored and every install got the template's
defaults. A test now saves and reads them back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 15:44:27 +02:00
co-authored by Claude Opus 5.5
parent 016d1ea17e
commit 674a691d85
2 changed files with 16 additions and 0 deletions
+7
View File
@@ -71,6 +71,13 @@ const DEFAULTS = {
invoice_footer: 'Thank you for using Cross Events.',
// Replies to billing emails go here (blank: business_email).
billing_reply_to: '',
// Servers and the agent (2.1.0). The port list hands out ports in this range (match frps's
// allow_ports); install_defaults is the .env defaults layer (JSON, NAME → value); the central
// server's IP is used to check a new install's DNS.
port_range_start: '20000',
port_range_end: '29999',
install_defaults: '{"HUB_URL":"https://hub.crosscode.co.za"}',
central_server_ip: '',
};
// Stored encrypted and never sent to the browser: only "is one saved" (<key>_set).
+9
View File
@@ -285,3 +285,12 @@ describe('reusing a short name (found in the VM test)', () => {
await expect(jobs.newInstall({ customerId: 'cust-1', serverId: server.id, shortName: 'hope', domain: 'events.other.co.za' }, admin, NOW)).rejects.toMatchObject({ code: 'SHORT_NAME_TAKEN' });
});
});
describe('settings for servers (found in the VM test)', () => {
test('install defaults, the port range and the central IP are saved', async () => {
const { setSettings } = require('../src/utils/settings');
await setSettings({ install_defaults: '{"HUB_URL":"https://hub.test","SENTRY_DSN":"x"}', port_range_start: '21000', port_range_end: '21100', central_server_ip: '203.0.113.10' });
expect(await servers.installDefaults()).toEqual({ HUB_URL: 'https://hub.test', SENTRY_DSN: 'x' });
expect(await servers.portRange()).toEqual({ from: 21000, to: 21100 });
});
});