diff --git a/website/ops/publish-cp-v2-preview.mjs b/website/ops/publish-cp-v2-preview.mjs index 07e8514f..65fe5251 100644 --- a/website/ops/publish-cp-v2-preview.mjs +++ b/website/ops/publish-cp-v2-preview.mjs @@ -20,7 +20,7 @@ export async function publishPreview({ciRoot='/home/dunedeploy/ci-deploy',previe const revision=await marker('built-commit');if(!markerPattern.test(revision)||revision!==await marker('pending-commit'))throw Error('No matching CI-approved build'); const source=path.join(ciRoot,'artifacts',revision,'website','control-panel','public','cp-v2'); if(await realpath(source)!==source)throw Error('Symlinked artifact paths are refused'); - const entries=await readdir(source,{withFileTypes:true});if(entries.length>50)throw Error('Too many preview assets'); + const entries=await readdir(source,{withFileTypes:true});if(entries.length>80)throw Error('Too many preview assets'); const files=new Map();let total=0; for(const entry of entries){ if(!entry.isFile()||!assetPattern.test(entry.name)||/git/i.test(entry.name)||entry.name==='revision.json')throw Error('Unsupported preview asset: '+entry.name); diff --git a/website/tests/cp-v2-preview-publication.test.mjs b/website/tests/cp-v2-preview-publication.test.mjs index cdb0106e..929cba30 100644 --- a/website/tests/cp-v2-preview-publication.test.mjs +++ b/website/tests/cp-v2-preview-publication.test.mjs @@ -22,3 +22,6 @@ test('missing required assets fail closed',()=>fixture(async options=>{const sou test('symlinked assets are refused',{skip:process.platform==='win32'},()=>fixture(async options=>{const source=await artifact(options);await writeFile(path.join(options.ciRoot,'private'),'private');await symlink(path.join(options.ciRoot,'private'),path.join(source,'extra.mjs'));await assert.rejects(publishPreview(options),/Unsupported preview asset/);})); test('changed files cannot overwrite an immutable published release',{skip:process.platform==='win32'},()=>fixture(async options=>{const source=await artifact(options);await publishPreview(options);await writeFile(path.join(source,'v2.js'),'changed');await assert.rejects(publishPreview(options),/Immutable preview release differs/);})); test('preview publication contains no service restart or database operation',async()=>{const source=await readFile(new URL('../ops/publish-cp-v2-preview.mjs',import.meta.url),'utf8');assert.doesNotMatch(source,/child_process|execFile|spawn\(|systemctl|pm2 |mysql|openDatabase/);const config=await readFile(new URL('../ops/cp-v2-preview.nginx.conf',import.meta.url),'utf8');assert.match(config,/auth_request \/_cp_v2_owner_check/);assert.match(config,/location = \/_cp_v2_owner_check \{\s+internal;/);assert.match(config,/proxy_pass http:\/\/127\.0\.0\.1:3003\/v2\/v2.css/);assert.match(config,/text\/javascript js mjs/);}); + +test('larger CP releases retain a strict eighty-file bound',()=>fixture(async options=>{const source=await artifact(options);for(let i=0;i<76;i++)await writeFile(path.join(source,'page-'+i+'.mjs'),'export {};');await assert.rejects(publishPreview(options),/Too many preview assets/);})); +test('bank expansion above the previous fifty-file bound publishes intact',{skip:process.platform==='win32'},()=>fixture(async options=>{const source=await artifact(options);for(let i=0;i<47;i++)await writeFile(path.join(source,'page-'+i+'.mjs'),'export {};');assert.equal((await publishPreview(options)).files,52);}));