import test from 'node:test'; import assert from 'node:assert/strict'; import {createRequire} from 'node:module'; import {productionServer,PRODUCTION_PUBLIC_URL,PRODUCTION_INTERNAL_URL,internalUrl} from '../src/core/network.ts'; const require=createRequire(import.meta.url); const {internal}=require('../config/environment.cjs'); test('production connection choices are fixed to trusted endpoints',()=>{ assert.equal(productionServer(PRODUCTION_PUBLIC_URL),PRODUCTION_PUBLIC_URL); assert.equal(productionServer(PRODUCTION_INTERNAL_URL),PRODUCTION_INTERNAL_URL); for(const value of ['http://wms.svc.cmvr-iot.icu/prod-api','https://wms.svc.cmvr-iot.icu.evil.test/prod-api','https://wms.svc.cmvr-iot.icu/other','https://wms.svc.cmvr-iot.icu/prod-api?x=1','http://192.168.0.1/prod-api']) assert.throws(()=>productionServer(value)); assert.throws(()=>internalUrl(PRODUCTION_PUBLIC_URL,true)); assert.equal(internal('https://wms.svc.cmvr-iot.icu',false,true),'https://wms.svc.cmvr-iot.icu'); assert.throws(()=>internal('https://wms.svc.cmvr-iot.icu',true,false)); assert.throws(()=>internal('http://wms.svc.cmvr-iot.icu',false,true)); assert.throws(()=>internal('https://wms.svc.cmvr-iot.icu.evil.test',false,true)); });