diff --git a/docs/quality/uygulama-durumu.md b/docs/quality/uygulama-durumu.md index 8a01489..397834f 100644 --- a/docs/quality/uygulama-durumu.md +++ b/docs/quality/uygulama-durumu.md @@ -2024,3 +2024,9 @@ Doğrulama: 288 test geçti, üretim derlemesi başarılı. API artık `CORS_ORIGINS` ile virgülle verilen izinli origin listesini destekliyor. Liste yapılandırıldığında yalnızca eşleşen origin CORS başlığı alıyor; değişken boş bırakıldığında mevcut yerel/geriye dönük davranış korunuyor. Doğrulama: 288 test geçti, üretim derlemesi başarılı. + +### 2026-09-06 · CORS allowlist kabul testi + +HTTP test sunucusu artık yapılandırılmış iki izinli origin ile başlatılıyor; izinli origin preflight yanıtında geri dönerken tanımsız origin CORS başlığı alamıyor. Böylece allowlist davranışı gerçek süreç üzerinden doğrulanıyor. + +Doğrulama: HTTP testleri 19/19, toplam 288 test geçti; üretim derlemesi başarılı. diff --git a/tests/http-state.test.mjs b/tests/http-state.test.mjs index 740e9d5..40aa58c 100644 --- a/tests/http-state.test.mjs +++ b/tests/http-state.test.mjs @@ -20,7 +20,7 @@ const request=async(path,method='GET',body,auth=token)=>{ before(async()=>{ const socket=createServer();await new Promise(r=>socket.listen(0,'127.0.0.1',r));const port=socket.address().port;await new Promise(r=>socket.close(r)); base='http://127.0.0.1:'+port; - child=spawn(process.execPath,['server/index.js'],{cwd:new URL('..',import.meta.url),env:{...process.env,NODE_ENV:'test',TELEGRAM_BOT_TOKEN:'',PORT:String(port),IHALEIST_USER_DATA_DIR:dir,IHALEIST_SHARED_DATA_DIR:join(dir,'shared'),UYUM_GOMME:'0'},stdio:'ignore'}); + child=spawn(process.execPath,['server/index.js'],{cwd:new URL('..',import.meta.url),env:{...process.env,NODE_ENV:'test',CORS_ORIGINS:'https://client.example,https://admin.example',TELEGRAM_BOT_TOKEN:'',PORT:String(port),IHALEIST_USER_DATA_DIR:dir,IHALEIST_SHARED_DATA_DIR:join(dir,'shared'),UYUM_GOMME:'0'},stdio:'ignore'}); for(let i=0;i<100;i++){try{await fetch(base+'/api/auth/google/config');return;}catch{await new Promise(r=>setTimeout(r,50));}} throw new Error('QA API did not start'); }); @@ -28,7 +28,10 @@ after(async()=>{if(child){child.kill();await new Promise(r=>child.once('exit',r) test('HTTP preparation requires auth, persists draft and rejects stale revisions',async()=>{ 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-origin'),'https://client.example'); assert.equal(preflight.headers.get('access-control-allow-headers'),'Authorization,Content-Type'); + const denied=await fetch(base+'/api/me/plan',{method:'OPTIONS',headers:{Origin:'https://untrusted.example','Access-Control-Request-Method':'GET'}}); + assert.equal(denied.status,204);assert.equal(denied.headers.get('access-control-allow-origin'),null); 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');