feat(web): add bilingual website and central account frontend
This commit is contained in:
commit
622f396364
20 changed files with 1315 additions and 0 deletions
16
tests/server.test.js
Normal file
16
tests/server.test.js
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { spawn } from 'node:child_process';
|
||||
import { once } from 'node:events';
|
||||
import http from 'node:http';
|
||||
function fetchRaw(port,path){return new Promise((resolve,reject)=>{http.get({host:'127.0.0.1',port,path},response=>{let body='';response.on('data',chunk=>body+=chunk);response.on('end',()=>resolve({status:response.statusCode,body}));}).on('error',reject);});}
|
||||
test('preview serves only public/source assets and blocks encoded traversal',async t=>{
|
||||
const port=24176;
|
||||
const process=spawn(globalThis.process.execPath,['scripts/serve.mjs'],{env:{...globalThis.process.env,PORT:String(port)},stdio:['ignore','pipe','pipe']});
|
||||
t.after(()=>process.kill('SIGTERM'));
|
||||
await Promise.race([once(process.stdout,'data'),once(process,'exit').then(()=>{throw new Error('preview failed to start');})]);
|
||||
for(const path of ['/','/account','/account/','/src/app.js','/assets/vnox-mark.png']) assert.equal((await fetchRaw(port,path)).status,200,path);
|
||||
for(const path of ['/src/%2e%2e%2fpackage.json','/src/%2e%2e%2f.env','/src/%2e%2e%2fLICENSE']) assert.equal((await fetchRaw(port,path)).status,403,path);
|
||||
assert.equal((await fetchRaw(port,'/package.json')).status,404);
|
||||
assert.equal((await fetchRaw(port,'/v1/auth/session')).status,503);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue