mirror of
https://github.com/KuekHaoYang/KVideo.git
synced 2026-08-13 15:53:44 +08:00
Keep every post-59948b5 change inside verification/. The verifier owns its npm working directory and sanitized Docker context, so no release metadata or root Docker configuration is modified.
51 lines
1.8 KiB
TypeScript
51 lines
1.8 KiB
TypeScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
|
|
import {
|
|
DEFAULT_LAN_ALLOWED_DEV_ORIGINS,
|
|
getLanAllowedDevOrigins,
|
|
isLanAccessEnabled,
|
|
parseBooleanEnv,
|
|
parseLanAllowedDevOrigins,
|
|
} from '../../../lib/config/lan-access';
|
|
|
|
// GH-ISSUE: 195
|
|
|
|
test('parseBooleanEnv only enables explicit truthy values', () => {
|
|
assert.equal(parseBooleanEnv('true'), true);
|
|
assert.equal(parseBooleanEnv(' ON '), true);
|
|
assert.equal(parseBooleanEnv('1'), true);
|
|
assert.equal(parseBooleanEnv('false'), false);
|
|
assert.equal(parseBooleanEnv('0'), false);
|
|
assert.equal(parseBooleanEnv(undefined), false);
|
|
});
|
|
|
|
test('isLanAccessEnabled supports server and public env names', () => {
|
|
assert.equal(isLanAccessEnabled({}), false);
|
|
assert.equal(isLanAccessEnabled({ ALLOW_LAN_ACCESS: 'true' }), true);
|
|
assert.equal(isLanAccessEnabled({ NEXT_PUBLIC_ALLOW_LAN_ACCESS: 'yes' }), true);
|
|
});
|
|
|
|
test('parseLanAllowedDevOrigins accepts hostnames, URLs, ports, and comma lists', () => {
|
|
assert.deepEqual(
|
|
parseLanAllowedDevOrigins('http://192.168.1.10:3000, local.kvideo.test:8080 *.lan.test'),
|
|
['192.168.1.10', 'local.kvideo.test', '*.lan.test']
|
|
);
|
|
});
|
|
|
|
test('getLanAllowedDevOrigins returns defaults and custom origins only when enabled', () => {
|
|
assert.deepEqual(getLanAllowedDevOrigins({ LAN_ALLOWED_DEV_ORIGINS: '192.168.50.10' }), []);
|
|
|
|
const origins = getLanAllowedDevOrigins({
|
|
ALLOW_LAN_ACCESS: 'true',
|
|
LAN_ALLOWED_DEV_ORIGINS: '192.168.50.10',
|
|
});
|
|
|
|
assert.ok(origins.includes('10.*.*.*'));
|
|
assert.ok(origins.includes('172.16.*.*'));
|
|
assert.ok(origins.includes('172.31.*.*'));
|
|
assert.ok(origins.includes('192.168.*.*'));
|
|
assert.ok(origins.includes('192.168.50.10'));
|
|
assert.equal(origins.length, DEFAULT_LAN_ALLOWED_DEV_ORIGINS.length + 1);
|
|
});
|