Add site-scoped file manager navigation and original file downloads
DC CMS qualification / qualify (push) Successful in 1m53s
DC CMS qualification / qualify (push) Successful in 1m53s
This commit is contained in:
+30
-1
@@ -81,6 +81,35 @@ test('independent sites, rendering, secrets and publication ownership', async t
|
||||
assert.equal(await readFile(join(original,'index.html'),'utf8'),'<h1>Original</h1>');
|
||||
assert.equal(await (await fetch(base+'/s/mission-core/index.html')).text(),'<h1>Mission edited</h1>');
|
||||
});
|
||||
await t.test('media downloads keep original bytes, filename and selected-site ownership',async()=>{
|
||||
for (const [site,expected] of [['nodedc','original-asset'],['mission-core','mission-asset']]) {
|
||||
const response=await fetch(`${base}/s/${site}/api/media/download?path=assets%2Fproof.txt`);
|
||||
assert.equal(response.status,200);
|
||||
assert.match(response.headers.get('content-disposition'),/^attachment; filename="proof.txt"/);
|
||||
assert.equal(response.headers.get('cache-control'),'no-store');
|
||||
assert.equal(Number(response.headers.get('content-length')),Buffer.byteLength(expected));
|
||||
assert.equal(await response.text(),expected);
|
||||
}
|
||||
const name='Сессия 1 (оригинал).mp4',bytes=Buffer.from([0,1,2,255,128,0]);
|
||||
const missionRoot=join(projects,'sites/mission-core');
|
||||
await writeFile(join(missionRoot,'assets',name),bytes);
|
||||
const response=await fetch(`${base}/s/mission-core/api/media/download?path=${encodeURIComponent('assets/'+name)}`);
|
||||
assert.equal(response.status,200);
|
||||
assert.equal(decodeURIComponent(response.headers.get('content-disposition').split("filename*=UTF-8''")[1]),name);
|
||||
assert.deepEqual(Buffer.from(await response.arrayBuffer()),bytes);
|
||||
assert.equal((await fetch(`${base}/s/nodedc/api/media/download?path=${encodeURIComponent('assets/'+name)}`)).status,404);
|
||||
for (const path of ['../nodedc.json','assets/../../nodedc.json','content/pages/home.json','assets/.trash/private','assets/.env','/assets/proof.txt']) {
|
||||
assert.equal((await fetch(`${base}/s/mission-core/api/media/download?path=${encodeURIComponent(path)}`)).status,403,path);
|
||||
}
|
||||
await symlink(original,join(missionRoot,'assets/other-site'));
|
||||
await symlink(join(original,'assets/proof.txt'),join(missionRoot,'assets/linked.txt'));
|
||||
for (const path of ['assets/other-site/assets/proof.txt','assets/linked.txt']) {
|
||||
assert.equal((await fetch(`${base}/s/mission-core/api/media/download?path=${encodeURIComponent(path)}`)).status,403,path);
|
||||
}
|
||||
assert.equal((await fetch(`${base}/s/mission-core/api/media/download?path=assets/missing.jpg`)).status,404);
|
||||
assert.equal((await fetch(`${base}/s/mission-core/api/media/download?path=assets`)).status,403);
|
||||
for (const path of ['assets/other-site','assets/linked.txt','assets/'+name]) await rm(join(missionRoot,path));
|
||||
});
|
||||
await t.test('preview root links stay within their selected site',async()=>{
|
||||
const page=await (await fetch(base+'/s/mission-core/knowledge/')).text();
|
||||
assert.match(page,/href="\/s\/mission-core\/knowledge\/fleet\/"/);
|
||||
@@ -164,7 +193,7 @@ test('independent sites, rendering, secrets and publication ownership', async t
|
||||
});
|
||||
await stop();await start(true);
|
||||
await t.test('registry, scoped content and preview retain authentication',async()=>{
|
||||
for(const path of ['/api/sites','/s/mission-core/api/page/home','/s/mission-core/api/project/backup']){const response=await fetch(base+path,{redirect:'manual'});assert.equal(response.status,401,path);assert.match(response.headers.get('content-type'),/json/);}
|
||||
for(const path of ['/api/sites','/s/mission-core/api/page/home','/s/mission-core/api/project/backup','/s/mission-core/api/media/download?path=assets/proof.txt']){const response=await fetch(base+path,{redirect:'manual'});assert.equal(response.status,401,path);assert.match(response.headers.get('content-type'),/json/);}
|
||||
assert.equal((await fetch(base+'/s/mission-core/api/project/backup',{method:'POST',redirect:'manual'})).status,401);
|
||||
assert.equal((await fetch(base+'/s/mission-core/index.html',{redirect:'manual'})).status,302);
|
||||
assert.equal((await fetch(base+'/healthz')).status,200);
|
||||
|
||||
Reference in New Issue
Block a user