aiBudgetEnforcement.test.ts and deleteOrg.test.ts create a workdir with
mkdtempSync (temp SQLite DB, config and symlinks into the repo) and never
remove it, so every npm test run leaves two pangolin-* directories in the
OS temp dir. Remove the workdir in a finally block, the same way
migrationsSqlite.backup.test.ts already does. rmSync does not follow the
symlinks, so the repo's server/, test/ and node_modules/ are untouched.
Signed-off-by: anant <170962632+antcybersec@users.noreply.github.com>
deleteOrgById fetched the org's sites with .limit(1), so the per-site
cleanup loop ran for at most one site: the WireGuard deletePeer call,
the Newt terminate collection, and cleanupSiteAssociations were all
skipped for every other site in the org.
Drop the limit so every site is loaded, and mirror deleteSite.ts in the
loop: run cleanupSiteAssociations for newt sites so clients of other
orgs do not keep stale associations for the deleted sites.
Covered by a standalone regression test that seeds two wireguard and
two newt sites plus a stale association-cache row, runs deleteOrgById
against a stubbed exit node, and asserts all four sites were cleaned.
On the previous code the test fails with exactly the reported symptom:
one peer removal instead of two.
Fixes#3863