Add the Blender flashlight asset with a 600 lm beam and reduced bloom, shared-mode self badge, and compact phone controls. Relocate the summit marker, blend terrain seams, widen walking routes, and align local server configuration on port 2027.
34 lines
1.6 KiB
TypeScript
34 lines
1.6 KiB
TypeScript
import assert from 'node:assert/strict';
|
|
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
import { tmpdir } from 'node:os';
|
|
import { join } from 'node:path';
|
|
import test from 'node:test';
|
|
import { loadServerConfig } from '../server/config.ts';
|
|
|
|
test('server and Mongo verifier can load the documented JSON configuration', () => {
|
|
const example = new URL('../.config.example.json', import.meta.url);
|
|
const config = loadServerConfig(example);
|
|
assert.equal(config.port, 2027);
|
|
assert.equal(config.visitStore, 'mongo');
|
|
assert.equal(config.mongoDatabase, 'sunrise');
|
|
assert.ok(config.allowedOrigins.includes('http://127.0.0.1:2027'));
|
|
});
|
|
|
|
test('missing or invalid configuration fails without exposing its contents', () => {
|
|
const directory = mkdtempSync(join(tmpdir(), 'sunrise-config-'));
|
|
const path = join(directory, '.config.json');
|
|
try {
|
|
assert.throws(() => loadServerConfig(path), /Cannot read/);
|
|
writeFileSync(path, '{"mongoUri":"secret",');
|
|
assert.throws(() => loadServerConfig(path), /^Error: Invalid JSON in .config.json$/);
|
|
const example = JSON.parse(readFileSync(new URL('../.config.example.json', import.meta.url), 'utf8'));
|
|
for (const override of [{ port: '2027' }, { port: 65536 }, { host: '' },
|
|
{ allowedOrigins: 'https://example.com' }, { visitStore: 'invalid' }, { mongoUri: null }]) {
|
|
writeFileSync(path, JSON.stringify({ ...example, ...override }));
|
|
assert.throws(() => loadServerConfig(path), /Invalid .config.json field/);
|
|
}
|
|
} finally {
|
|
rmSync(directory, { recursive: true, force: true });
|
|
}
|
|
});
|