diff --git a/docs/quality/uygulama-durumu.md b/docs/quality/uygulama-durumu.md index a70c355..78614d0 100644 --- a/docs/quality/uygulama-durumu.md +++ b/docs/quality/uygulama-durumu.md @@ -1970,3 +1970,9 @@ Doğrulama: 285 test geçti, üretim derlemesi başarılı. Firma profilindeki sağlık ürün/hizmet portföyü artık sunucuya yazılmadan önce kayıt kimliği, tekrar kayıt, alan uzunluğu, kapsam ve ÜTS beyanı açısından doğrulanıyor. Hatalı portföy verisi kalıcı kaydı veya uygunluk akışını bozamıyor. Doğrulama: 286 test geçti, üretim derlemesi başarılı. + +### 2026-09-06 · Portföy kimlik normalizasyonu + +Sağlık portföyü kayıt kimlikleri artık kırpılarak tekilleştiriliyor ve 200 karakterle sınırlandırılıyor; yalnızca boşluk farkıyla oluşturulan kopya ürün kayıtları reddediliyor. + +Doğrulama: HTTP profil testleri 19/19 geçti, üretim derlemesi başarılı. diff --git a/server/index.js b/server/index.js index e4820f0..cf5402d 100644 --- a/server/index.js +++ b/server/index.js @@ -81,9 +81,9 @@ function validateHealthPortfolio(value) { if (!Array.isArray(portfolio) || portfolio.length > 200) throw new Error('Sağlık ürün portföyü geçersiz veya çok uzun.'); const ids = new Set(); for (const item of portfolio) { - if (!item || typeof item !== 'object' || Array.isArray(item) || typeof item.id !== 'string' || !item.id.trim() || ids.has(item.id)) + if (!item || typeof item !== 'object' || Array.isArray(item) || typeof item.id !== 'string' || !item.id.trim() || item.id.length > 200 || ids.has(item.id.trim())) throw new Error('Sağlık ürün portföyünde geçersiz veya yinelenen kayıt var.'); - ids.add(item.id); + ids.add(item.id.trim()); for (const key of ['group','brand','model','utsReference','serviceCapacity']) if (item[key] !== undefined && (typeof item[key] !== 'string' || item[key].length > 1000)) throw new Error('Sağlık ürün portföyü alanı geçersiz.'); if (!['consumable','device','staffedService'].includes(item.kind || 'consumable')) throw new Error('Sağlık ürün portföyü kapsamı geçersiz.'); diff --git a/tests/http-state.test.mjs b/tests/http-state.test.mjs index fde4ffd..740e9d5 100644 --- a/tests/http-state.test.mjs +++ b/tests/http-state.test.mjs @@ -230,7 +230,7 @@ test('health portfolio writes reject malformed records before persistence',async const base={company:'QA sağlık',scrapedCapabilities:{healthPortfolio:[{id:'hp-1',group:'Mikroskop',kind:'device',utsStatus:'declared'}]}}; assert.equal((await request('/api/me/data','PUT',{anahtar:'firma_profil',deger:base,revision})).status,200); const next=(await request('/api/me/data')).data.revisions.firma_profil; - for (const healthPortfolio of [[{id:'hp-1'},{id:'hp-1'}],[{id:'hp-1',kind:'other'}],[{id:'hp-1',model:'x'.repeat(1001)}]]) { + for (const healthPortfolio of [[{id:'hp-1'},{id:'hp-1'}],[{id:'hp-1'},{id:' hp-1 '}],[{id:'hp-1',kind:'other'}],[{id:'hp-1',model:'x'.repeat(1001)}]]) { const response=await request('/api/me/data','PUT',{anahtar:'firma_profil',deger:{...base,scrapedCapabilities:{healthPortfolio}},revision:next}); assert.equal(response.status,400); }