test CORS preflight handling
This commit is contained in:
@@ -26,7 +26,10 @@ before(async()=>{
|
||||
});
|
||||
after(async()=>{if(child){child.kill();await new Promise(r=>child.once('exit',r));}rmSync(dir,{recursive:true,force:true});});
|
||||
test('HTTP preparation requires auth, persists draft and rejects stale revisions',async()=>{
|
||||
const unauthorized=await request('/api/me/tender-state','GET',null,null);
|
||||
const preflight=await fetch(base+'/api/me/plan',{method:'OPTIONS',headers:{Origin:'https://client.example', 'Access-Control-Request-Method':'GET', 'Access-Control-Request-Headers':'authorization,content-type'}});
|
||||
assert.equal(preflight.status,204);
|
||||
assert.equal(preflight.headers.get('access-control-allow-headers'),'Authorization,Content-Type');
|
||||
const unauthorized=await request('/api/me/tender-state','GET',null,null);
|
||||
assert.equal(unauthorized.status,401);
|
||||
assert.equal(unauthorized.headers.get('x-content-type-options'),'nosniff');
|
||||
assert.equal(unauthorized.headers.get('referrer-policy'),'no-referrer');
|
||||
|
||||
Reference in New Issue
Block a user