// Dummy-only identity audit through the existing application API; no import or Core write. import assert from 'node:assert/strict'; const base='http://127.0.0.1:4173/api/v1'; const get=async path=>{const response=await fetch(base+path);if(!response.ok)throw new Error(path+': '+response.status+' '+await response.text());return response.json();}; const project=await get('/projects/project-7cbcb7ad');assert.equal(project.name,'Dummy'); const assessments=await get('/projects/'+project.id+'/assessments'); const query=new URLSearchParams();assessments.forEach(a=>query.append('assessmentIds',a.id)); const context=await get('/projects/'+project.id+'/assessment-context?'+query); const response=await get('/projects/'+project.id+'/work-packages?'+query);assert.equal(response.status,'ready'); const snapshot=response.result;assert.equal(snapshot.repositoryRevision,context.repositoryRevision); const labels=new Map(context.clusters.map(cluster=>[cluster.clusterId,cluster.label.en])); const primary=new Map([...context.findings.map(f=>['scanner:'+f.occurrenceId,f.clusterIds[0]]), ...context.settings.map(s=>['policy:'+s.scope+':'+s.identityKey,s.clusterIds[0]])]); const assigned=new Set(),counts={};let tasks=0; for(const p of snapshot.packages){ assert.equal(p.clusterLabel,labels.get(p.clusterId),'Cluster label mismatch'); for(const key of p.findingKeys){assert.equal(primary.get(key),p.clusterId,'Wrong cluster for '+key);assert.equal(assigned.has(key),false,'Duplicate package membership');assigned.add(key);} assert.deepEqual([...new Set(p.tasks.flatMap(task=>task.findingKeys))].sort(),[...p.findingKeys].sort(),'Task/package evidence mismatch'); counts[p.clusterId]??={packages:0,findings:0,tasks:0};counts[p.clusterId].packages++;counts[p.clusterId].findings+=p.findingKeys.length;counts[p.clusterId].tasks+=p.tasks.length;tasks+=p.tasks.length; } for(const key of snapshot.unassignedFindingKeys)assert.equal(assigned.has(key),false,'Assigned and Unassigned overlap'); const after=await get('/projects/'+project.id+'/assessment-context?'+query);assert.equal(after.repositoryRevision,context.repositoryRevision); console.log(JSON.stringify({packages:snapshot.packages.length,assigned:assigned.size,tasks,unassigned:snapshot.unassignedFindingKeys.length,allIndividualClusterIdsMatch:true,repositoryRevisionUnchanged:true,counts},null,2));