| 12345678910111213141516 |
- import test from 'node:test';
- import assert from 'node:assert/strict';
- import { internalRoutingConfig } from '../lib/admin-internal-routing.mjs';
- const fixture=()=>({proxy:{enabled:true},parse:{appId:'7pIbDBJmKx_main',port:10337,serverURL:'https://server.xiaoshu.pro/parse',publicServerURL:'https://server.xiaoshu.pro/parse',masterKey:'fixture-only',databaseURI:'fixture-database',protectedFields:{_User:['secret']}},liveQuery:{enabled:false}});
- test('changes only the Xiaoshu internal URL and preserves public URLs and all other settings',()=>{
- const before=fixture(),after=internalRoutingConfig(before);
- assert.equal(after.parse.serverURL,'http://127.0.0.1:10337/parse');
- assert.deepEqual({...after,parse:{...after.parse,serverURL:before.parse.serverURL}},before);
- assert.equal(before.parse.serverURL,'https://server.xiaoshu.pro/parse');
- assert.deepEqual(internalRoutingConfig(after),after);
- });
- test('rejects other applications, ports and unexpected public endpoints',()=>{
- for(const change of [{appId:'other'},{port:7337},{serverURL:'https://other.example/parse'},{publicServerURL:'https://other.example/parse'}]){
- assert.throws(()=>internalRoutingConfig({...fixture(),parse:{...fixture().parse,...change}}));
- }
- });
|