Files
linkspin/qa/profile-policy.test.cjs
T
martbost bdf1aab06c Link-farm hardening (2026-10-30 incident: 106 free accounts synced from InstantAdPay carried casino bios and website links; Google indexed the text through /wall pages)
Public walls: profile fields (bio, avatar, socials, intro video) render only for a paying member (memberId > 0 or a registered position), on /api/wall and in the OG image; a free account's wall shows the name, the line's ads and the join call. The meta/og description is a fixed site sentence with the handle, never the bio. Outbound profile links are rel="sponsored ugc noopener" target="_blank". A deleted or unknown name is a real 404 with X-Robots-Tag noindex (was a bare "Banner wall" page at 200, a soft 404 that stayed indexed).

Policy (prohibited.js, byte-for-byte copy of InstantAdPay's): bios may not carry a URL or a domain token ("Links go in the social fields, not the bio"); gambling, adult, pharma, weapons and link-selling terms (Unicode aware) are refused in bios, social URLs, line banner targets, wall offers and every campaign field, with the refusal logged. The registry ingest from InstantAdPay drops a bio with a link or a prohibited term instead of storing it; iapsync applies the same on the way out.

Quarantine rule: a brand-new free account (no wallet, no sponsor, under 24 h) whose first profile save plants a link is saved with profileQuarantined (JSON + MySQL column), never rendered publicly, and told "Your profile links will appear after your first ad package"; the admin member card shows the flag.

Daily link-farm scan (spamscan.js, same copy as InstantAdPay): in-app job at 06:30 Central, claimOnce per day, lists memberId-0 walletless accounts with a link plus a farm signal (prohibited term, sign-in over within 15 min, no sponsor), skips the spamScanAllow setting (seeded), writes DATA_DIR/wall-spam-scan.json and sends one "LinkSpin link-farm scan" Telegram to the private admin chat only when there are candidates. Admin > Members > Link-farm list: rows with "also on InstantAdPay" (local registry mirror), Delete selected (existing DELETE /api/admin/member, on-chain refused, no cascade) and Allow.

Terms section 9 "Prohibited content", bio hint in the profile editor, chatbot canned answer + kb-seed entry "What content is not allowed?", KNOWLEDGE_DATE 2026-10-30. Test: qa/profile-policy.test.cjs (unit + local copy, hash check against the InstantAdPay copies; runs in qa/run.sh member and policy).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-30 07:32:07 -05:00

232 lines
23 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Profile policy + link-farm scan (2026-10-30 incident: 106 free accounts used bios and socials as casino backlinks).
// Same file in both repos (InstantAdPay site/qa and LinkSpin site/qa); it works out which site it is in.
// node qa/profile-policy.test.cjs (also part of `bash qa/run.sh member`)
// Part A, no server: prohibited.js (URL bio refused, casino bio refused, clean bio accepted, Unicode terms, no false hit on
// "Essex"), spamscan.classify on a six-account fixture (3 farm patterns, a sponsored member with a link, a buyer with a
// link, an allowlisted farm), the quarantine rule, the 06:30 once-a-day claim, the Telegram text, and the byte-for-byte
// check of prohibited.js + spamscan.js against the sibling checkout when it is there.
// Part B, a LOCAL copy (throwaway DATA_DIR, JSON store, devCode sign-in, the other site pointed at a dead port):
// a fresh sponsorless account's first save with a link is quarantined (200 + notice) and never rendered; a clean bio saves;
// then a URL bio and a casino bio are refused; a free member's wall and JSON carry nothing from the profile and the fixed
// description; a buyer's JSON carries bio + socials and the wall still has the fixed description; a deleted or unknown name
// is a real 404 with X-Robots-Tag noindex; the line banner refuses a casino target; the admin scan lists the quarantined
// account, Allow removes it; the admin member card shows the flag. Exit code 1 on any failure.
'use strict';
const fs = require('fs');
const os = require('os');
const path = require('path');
const http = require('http');
const crypto = require('crypto');
const { spawn } = require('child_process');
const ROOT = path.join(__dirname, '..');
const isLS = fs.existsSync(path.join(ROOT, 'iapsync.js'));
const SITE = isLS ? 'LinkSpin' : 'InstantAdPay';
const SIBLING = isLS ? path.join(ROOT, '..', '..', 'onchain-ad-membership', 'site') : path.join(ROOT, '..', '..', 'linkspin', 'site');
delete process.env.DATABASE_URL;
let fails = 0, n = 0;
async function t(name, fn) { n++; try { await fn(); console.log('ok', name); } catch (e) { fails++; console.log('FAIL', name, '::', e.message); } }
const eq = (a, b, m) => { if (a !== b) throw new Error((m || '') + ' expected ' + JSON.stringify(b) + ' got ' + JSON.stringify(a)); };
const truthy = (v, m) => { if (!v) throw new Error(m || 'expected truthy'); };
const P = require(path.join(ROOT, 'prohibited.js'));
const spamscan = require(path.join(ROOT, 'spamscan.js'));
(async () => {
// ---------------- Part A ----------------
await t('bio with a URL is refused with the bio-link message', () => {
for (const b of ['Visit https://casino-vip.com now', 'see www.example.com', 'my site example.com/offers', 'best deals at nice-shop.xyz', 'mail bob@gmail.com']) {
const r = P.checkBio(b, SITE); eq(r.error, 'Links go in the social fields, not the bio.', b);
}
});
await t('casino bio is refused with the Terms message', () => {
const r = P.checkBio('The best casino bonuses and slots in town', SITE);
eq(r.error, 'That content is not allowed on ' + SITE + ' profiles (see Terms).'); eq(r.reason, 'term:casino');
eq(P.checkBio('NỔ HŨ ĐỔI THƯỞNG uy tín', SITE).reason, 'term:nổ hũ', 'Vietnamese, upper case');
eq(P.checkBio('apostas online', SITE).reason, 'term:apostas');
eq(P.checkBio('we sell backlinks', SITE).reason, 'term:backlinks');
eq(P.checkBio('ca​sino', SITE).reason, 'term:casino', 'zero-width joiner stripped');
});
await t('clean bio is accepted; Essex, Sussex and sloppy punctuation are not links or terms', () => {
for (const b of ['Building a team on Polygon, paid the moment a package clears.', 'Essex marketer, Middlesex born, Sussex raised', 'I love ads.One day I will win', 'Price $9.99 v2.0 Oct.30 no.1', 'e.g. this, i.e. that', ''])
eq(P.checkBio(b, SITE).ok, true, b);
});
await t('campaign fields and social URLs: prohibited terms only, with the field named', () => {
const r = P.checkFields({ name: 'Spring push', title: 'Free slots tonight', targetUrl: 'https://example.com' }, SITE);
eq(r.field, 'title'); eq(r.error, 'That content is not allowed on ' + SITE + ' (see Terms, Prohibited content).');
eq(P.checkFields({ website: 'https://my-casino.bet/' }, SITE, { profile: true }).error, 'That content is not allowed on ' + SITE + ' profiles (see Terms).');
eq(P.checkFields({ name: 'Spring push', targetUrl: 'https://example.com/landing' }, SITE).ok, true);
});
await t('cleanProfile drops a linked or prohibited bio and a prohibited social, keeps the rest', () => {
const c = P.cleanProfile({ avatarUrl: 'https://img.example.com/a.png', bio: 'see casino.com', socials: { website: 'https://good.example.com/', twitter: 'https://x.com/slots_king' } }, SITE);
eq(c.bio, null); eq(c.avatarUrl, 'https://img.example.com/a.png'); eq(c.socials.website, 'https://good.example.com/'); eq(c.socials.twitter, undefined);
truthy(c.dropped.includes('bio:url') && c.dropped.some(d => d.startsWith('socials.twitter:term')), c.dropped.join(','));
});
// the fixture: who the detector must and must not flag
const DAY = 86400000, now = Date.now();
const F = [
{ email: 'farm1@x.test', username: 'farm1', memberId: 0, address: null, sponsorRef: 'someone', created: now - 3 * DAY, lastSeen: now - 3 * DAY + 60 * 60000, bio: 'Best casino bonuses', socials: JSON.stringify({ website: 'https://casino-x.com/' }) },
{ email: 'farm2@x.test', username: 'farm2', memberId: 0, address: null, sponsorRef: 'someone', created: now - 2 * DAY, lastSeen: now - 2 * DAY + 4 * 60000, bio: 'Local plumber in Austin', socials: JSON.stringify({ website: 'https://austin-plumber.example/' }) },
{ email: 'farm3@x.test', username: 'farm3', memberId: 0, address: null, sponsorRef: '', created: now - 1 * DAY, lastSeen: now - 1 * DAY + 3 * 60 * 60000, bio: 'Read my blog at huvip-blog.com', socials: null },
{ email: 'real@x.test', username: 'real', memberId: 0, address: null, sponsorRef: 'someone', created: now - 10 * DAY, lastSeen: now - 60000, bio: 'Team builder, here to learn', socials: JSON.stringify({ website: 'https://real-member.example/' }) },
{ email: 'buyer@x.test', username: 'buyer', memberId: 44, address: null, sponsorRef: '', created: now - 5 * DAY, lastSeen: now - 5 * DAY + 60000, bio: 'see my-site.com', socials: JSON.stringify({ website: 'https://my-site.com/' }) },
{ email: 'cryptogoat76@gmail.com', username: 'goat', memberId: 0, address: null, sponsorRef: '', created: now - 1 * DAY, lastSeen: now - 1 * DAY + 60000, bio: 'poker nights', socials: JSON.stringify({ website: 'https://poker.example/' }) },
];
await t('classify: three farm patterns flagged, sponsored member and buyer not, allowlisted skipped', () => {
const allow = new Set(spamscan.DEFAULT_ALLOW);
const v = Object.fromEntries(F.map(a => [a.username, spamscan.classify(a, allow, now)]));
truthy(v.farm1.candidate && v.farm1.reasons[0] === 'prohibited:casino', 'farm1 ' + v.farm1.reasons);
truthy(v.farm2.candidate && v.farm2.reasons.includes('quick'), 'farm2 ' + v.farm2.reasons);
truthy(v.farm3.candidate && v.farm3.reasons.includes('no-sponsor') && v.farm3.links[0] === 'huvip-blog.com', 'farm3 ' + v.farm3.reasons + ' ' + v.farm3.links);
eq(v.real.candidate, false, 'real member with a link'); eq(v.real.reasons.length, 0);
eq(v.buyer.candidate, false, 'buyer with a link');
eq(v.goat.candidate, false, 'allowlisted'); eq(v.goat.allowlisted, true);
eq(v.farm1.links[0], 'https://casino-x.com/');
});
await t('quarantine rule: brand-new, sponsorless, walletless, first save with a link', () => {
const fresh = { memberId: 0, address: null, sponsorRef: '', created: now - 3600000, bio: null, socials: null };
eq(spamscan.shouldQuarantine(fresh, 'see my-blog.com', null, now), true, 'bio url');
eq(spamscan.shouldQuarantine(fresh, 'hello', { website: 'https://my-blog.com/' }, now), true, 'website social');
eq(spamscan.shouldQuarantine(fresh, 'hello', { twitter: 'https://x.com/me' }, now), true, 'X social');
eq(spamscan.shouldQuarantine(fresh, 'hello', { telegram: 'https://t.me/me' }, now), false, 'telegram is not a farm field');
eq(spamscan.shouldQuarantine(fresh, 'hello world', null, now), false, 'no link');
eq(spamscan.shouldQuarantine(Object.assign({}, fresh, { sponsorRef: 'marty' }), 'see my-blog.com', null, now), false, 'has a sponsor');
eq(spamscan.shouldQuarantine(Object.assign({}, fresh, { created: now - 25 * 3600000 }), 'see my-blog.com', null, now), false, 'older than 24 h');
eq(spamscan.shouldQuarantine(Object.assign({}, fresh, { bio: 'old bio' }), 'see my-blog.com', null, now), false, 'not the first save');
eq(spamscan.shouldQuarantine(Object.assign({}, fresh, { address: '0xabc' }), 'see my-blog.com', null, now), false, 'has a wallet');
eq(spamscan.shouldQuarantine(Object.assign({}, fresh, { memberId: 3 }), 'see my-blog.com', null, now), false, 'bought');
});
function bench(o) {
o = o || {}; const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'spamscan-'));
const sent = []; const site = { spamScanAllow: spamscan.DEFAULT_ALLOW.join(', ') }; const claims = o.claims || new Set();
spamscan.init({ dataDir: dir, site: SITE, siteUrl: 'https://' + SITE.toLowerCase() + '.test', otherSite: isLS ? 'InstantAdPay' : 'LinkSpin',
accounts: { listAll: async () => o.accounts || F }, siteConfig: () => site, saveSite: p => Object.assign(site, p), notify: async text => { sent.push(text); },
marks: { claim: async k => { if (o.claimFalse) return false; if (claims.has(k)) return false; claims.add(k); return true; } }, alsoOn: async e => e === 'farm1@x.test' ? true : false });
return { dir, sent, site, claims };
}
const at = (h, m) => { // a timestamp on today's Central date at h:m Central
const d = new Date(); const ct = new Date(d.toLocaleString('en-US', { timeZone: 'America/Chicago' })); const diff = d.getTime() - ct.getTime();
ct.setHours(h, m, 0, 0); return ct.getTime() + diff;
};
await t('tick: nothing before 06:30, one run from 06:30 on, never twice in a day, result file written, one Telegram with the site name', async () => {
const b = bench();
let r = await spamscan.tick(at(6, 0)); eq(r.skipped, true, 'before 06:30'); eq(b.sent.length, 0);
r = await spamscan.tick(at(6, 31)); truthy(r.candidates, 'ran'); eq(r.candidates.length, 3, 'three candidates'); eq(r.skipped, 1, 'one allowlisted');
eq(b.sent.length, 1, 'one telegram'); truthy(b.sent[0].startsWith(SITE + ' link-farm scan: 3 candidate accounts ('), b.sent[0].split('\n')[0]);
truthy(b.sent[0].includes('Review in Admin > Members > Link-farm list'), 'review line'); truthy(b.sent[0].includes('@farm1 | joined ') && b.sent[0].includes('| https://casino-x.com/ | also on ' + (isLS ? 'InstantAdPay' : 'LinkSpin')), b.sent[0]);
r = await spamscan.tick(at(9, 0)); eq(r.skipped, true, 'second tick same day'); eq(b.sent.length, 1, 'still one telegram');
const file = JSON.parse(fs.readFileSync(path.join(b.dir, 'wall-spam-scan.json'), 'utf8'));
eq(file.candidates.length, 3); eq(file.candidates.find(c => c.email === 'farm1@x.test').alsoOn, true); eq(file.scanned, 6);
truthy(b.claims.has('spamscan:' + spamscan.dayOf(at(6, 31))), 'claim key is the Central day');
});
await t('tick: a second app copy that loses the claim does not run or notify', async () => {
const b = bench({ claimFalse: true });
const r = await spamscan.tick(at(7, 0)); eq(r.skipped, true); eq(r.claimedElsewhere, true); eq(b.sent.length, 0);
});
await t('run: no candidates means no Telegram; Allow removes a candidate on the next run', async () => {
const b = bench({ accounts: F.filter(a => a.username === 'real' || a.username === 'buyer') });
const r = await spamscan.run(); eq(r.candidates.length, 0); eq(b.sent.length, 0);
const b2 = bench(); await spamscan.run(); eq(spamscan.view().last.candidates.length, 3);
spamscan.setAllow('farm2@x.test', true); truthy(spamscan.allowlist().includes('farm2@x.test')); truthy(b2.site.spamScanAllow.includes('farm2@x.test'), 'saved to the site setting');
await spamscan.run({ quiet: true }); eq(spamscan.view().last.candidates.length, 2); eq(spamscan.view().last.skipped, 2);
spamscan.setAllow('farm2@x.test', false); eq(spamscan.allowlist().includes('farm2@x.test'), false);
});
await t('shared modules are byte-for-byte copies of the sibling checkout (prohibited.js, spamscan.js)', () => {
if (!fs.existsSync(SIBLING)) { console.log(' (sibling checkout not found at ' + SIBLING + ', skipped)'); return; }
for (const f of ['prohibited.js', 'spamscan.js', path.join('qa', 'profile-policy.test.cjs')]) {
const h = p => crypto.createHash('sha1').update(fs.readFileSync(p, 'utf8').replace(/\r\n/g, '\n')).digest('hex');
const a = path.join(ROOT, f), b = path.join(SIBLING, f);
if (!fs.existsSync(b)) throw new Error(f + ' missing in sibling');
eq(h(a), h(b), f + ' differs from the sibling copy');
}
});
// ---------------- Part B ----------------
const PORT = Number(process.env.PP_PORT || (isLS ? 8807 : 8806)); const ADMIN = 'localtest';
const DATA = fs.mkdtempSync(path.join(os.tmpdir(), 'pp-' + SITE.toLowerCase() + '-')); fs.mkdirSync(path.join(DATA, 'uploads'), { recursive: true });
// a paying member, seeded straight into the JSON store (memberId > 0): profile must render for them
const seed = { v: 2, byEmail: {}, byAddress: {}, byCode: {}, positions: {}, joins: 0 };
seed.byEmail['buyer@example.com'] = { email: 'buyer@example.com', code: 'buyr01', username: 'buyerwall', memberId: 7, sponsorRef: '', created: now - 30 * DAY, lastSeen: now - DAY,
bio: 'Clean bio from a paying member', socials: JSON.stringify({ website: 'https://example.com/', twitter: 'https://x.com/buyer' }), avatarUrl: 'https://example.com/a.png' };
seed.byCode.buyr01 = 'buyer@example.com';
fs.writeFileSync(path.join(DATA, 'accounts.json'), JSON.stringify(seed));
const env = Object.assign({}, process.env, { PORT: String(PORT), DATA_DIR: DATA, NODE_ENV: 'development', ADMIN_EMAIL: 'qa-admin@example.com', ADMIN_PASSWORD: ADMIN,
LS_URL: 'http://127.0.0.1:1', IAP_URL: 'http://127.0.0.1:1', LS_SYNC_SECRET: '' });
delete env.DATABASE_URL;
const srv = spawn(process.execPath, ['server.js'], { cwd: ROOT, env, stdio: ['ignore', 'pipe', 'pipe'] });
let log = ''; srv.stdout.on('data', d => { log += d; }); srv.stderr.on('data', d => { log += d; });
const req = (method, p, o) => new Promise((resolve, reject) => { o = o || {};
const headers = Object.assign({ 'User-Agent': 'Mozilla/5.0 QA', 'X-Forwarded-For': o.ip || '10.9.0.1' }, o.headers || {}); if (o.cookie) headers.Cookie = o.cookie;
let body = o.body; if (body) { body = Buffer.from(JSON.stringify(body)); headers['Content-Type'] = 'application/json'; headers['Content-Length'] = body.length; }
const r = http.request({ host: '127.0.0.1', port: PORT, path: p, method, headers }, res => { const ch = []; res.on('data', c => ch.push(c)); res.on('end', () => { const text = Buffer.concat(ch).toString(); let json = null; try { json = JSON.parse(text); } catch (e) {} resolve({ status: res.statusCode, headers: res.headers, text, json }); }); });
r.on('error', reject); if (body) r.write(body); r.end(); });
const adminH = { Authorization: 'Bearer ' + ADMIN };
let ipn = 1;
async function signIn(email) {
const ip = '10.9.' + (ipn++) + '.7';
const s = await req('POST', '/api/auth/email/start', { ip, body: { email, fts: Date.now() - 8000, fage: 8000, hp_field_x9: '' } });
if (!s.json || !s.json.devCode) throw new Error('no devCode for ' + email + ': ' + s.text.slice(0, 200));
const v = await req('POST', '/api/auth/email/verify', { ip, body: { email, code: s.json.devCode } });
return [].concat(v.headers['set-cookie'] || []).map(x => x.split(';')[0]).join('; ');
}
const meta = (html, name) => { const m = new RegExp('<meta (?:name|property)="' + name + '" content="([^"]*)"').exec(html); return m ? m[1] : null; };
try {
let up = false; for (let i = 0; i < 60 && !up; i++) { try { up = (await req('GET', '/api/config')).status === 200; } catch (e) { await new Promise(r => setTimeout(r, 500)); } }
if (!up) throw new Error('local server did not come up:\n' + log.slice(-1500));
await req('PATCH', '/api/admin/site', { headers: adminH, body: { fraudMaxSignupsPerIpDay: 20 } });
const fixed = nm => nm + '’s ad wall on ' + SITE + ': the network’s member ads, paid out on Polygon the moment a package clears.';
await t('local: unknown or deleted wall name is a real 404 with X-Robots-Tag noindex', async () => {
const r = await req('GET', '/wall/huvipblog'); eq(r.status, 404); truthy(/noindex/.test(String(r.headers['x-robots-tag'])), 'x-robots-tag ' + r.headers['x-robots-tag']);
truthy(r.text.includes('No wall under that name'), 'body'); eq((await req('GET', '/api/wall/huvipblog')).status, 404);
});
await t('local: fresh sponsorless account, first save with a link: quarantined, saved, notice, nothing public', async () => {
const ck = await signIn('fresh@example.com');
eq((await req('POST', '/api/my/profile', { cookie: ck, body: { username: 'freshlink' } })).status, 200);
const r = await req('POST', '/api/my/profile-details', { cookie: ck, body: { bio: 'Read my blog at huvip-blog.com', socials: { website: 'https://huvip-blog.com/' } } });
eq(r.status, 200, r.text); eq(r.json.quarantined, true); eq(r.json.notice, 'Your profile links will appear after your first ad package.'); eq(r.json.account.profileQuarantined, true);
const w = await req('GET', '/api/wall/freshlink'); eq(w.status, 200); eq(w.json.bought, false); eq(w.json.bio, null); eq(w.json.socials, null); eq(w.json.avatarUrl, null);
const h = await req('GET', '/wall/freshlink'); eq(h.status, 200); eq(meta(h.text, 'description'), fixed('@freshlink')); eq(meta(h.text, 'og:description'), fixed('@freshlink'));
truthy(!h.text.includes('huvip-blog'), 'bio text must not be in the page'); truthy(!/noindex/i.test(h.text) && !r.headers['x-robots-tag'], 'wall stays indexable');
const m = await req('GET', '/api/admin/member?email=fresh@example.com', { headers: adminH }); eq(m.json.account.profileQuarantined, true, 'admin card flag');
});
await t('local: clean bio saves; then a URL bio and a casino bio are refused; a casino social is refused', async () => {
const ck = await signIn('clean@example.com');
await req('POST', '/api/my/profile', { cookie: ck, body: { username: 'cleanmember' } });
let r = await req('POST', '/api/my/profile-details', { cookie: ck, body: { bio: 'Team builder on Polygon, paid when a package clears.' } }); eq(r.status, 200, r.text); eq(r.json.quarantined, undefined);
r = await req('POST', '/api/my/profile-details', { cookie: ck, body: { bio: 'Visit https://my-shop.example.com for deals' } }); eq(r.status, 400); eq(r.json.error, 'Links go in the social fields, not the bio.');
r = await req('POST', '/api/my/profile-details', { cookie: ck, body: { bio: 'Best casino bonuses and slots' } }); eq(r.status, 400); eq(r.json.error, 'That content is not allowed on ' + SITE + ' profiles (see Terms).');
r = await req('POST', '/api/my/profile-details', { cookie: ck, body: { socials: { website: 'https://top-casino.bet/' } } }); eq(r.status, 400); eq(r.json.error, 'That content is not allowed on ' + SITE + ' profiles (see Terms).');
const w = await req('GET', '/api/wall/cleanmember'); eq(w.json.bought, false); eq(w.json.bio, null, 'free member: no bio on the public JSON');
const h = await req('GET', '/wall/cleanmember'); eq(h.status, 200); eq(meta(h.text, 'description'), fixed('@cleanmember')); truthy(!h.text.includes('Team builder on Polygon'), 'free member: no bio in the page');
r = await req('POST', '/api/my/linebanner', { cookie: ck, body: { targetUrl: 'https://casino-royale.example/' } }); eq(r.status, 400); truthy(/not allowed/.test(r.json.error), r.json.error);
});
await t('local: a paying member gets bio, socials and avatar in the JSON; the wall keeps the fixed description and title carries the handle', async () => {
const w = await req('GET', '/api/wall/buyerwall'); eq(w.status, 200, w.text); eq(w.json.bought, true); eq(w.json.bio, 'Clean bio from a paying member'); eq(w.json.socials.website, 'https://example.com/'); eq(w.json.avatarUrl, 'https://example.com/a.png');
const h = await req('GET', '/wall/buyerwall'); eq(h.status, 200); eq(meta(h.text, 'description'), fixed('@buyerwall')); eq(meta(h.text, 'og:image'), 'https://example.com/a.png');
truthy(/<title>@buyerwall’s ad wall \| /.test(h.text), 'title'); truthy(!h.text.includes('Clean bio from a paying member'), 'bio never in the meta');
const js = fs.readFileSync(path.join(ROOT, 'public', 'assets', 'wall.js'), 'utf8');
truthy(js.includes('rel="sponsored ugc noopener"') && !js.includes('rel="noopener nofollow me"'), 'outbound profile links are sponsored ugc');
truthy(/w\.bought && w\.socials/.test(js) && /\(w\.bought && w\.bio\)/.test(js), 'wall.js renders profile only when bought');
truthy(fs.readFileSync(path.join(ROOT, 'public', 'wall.html'), 'utf8').includes('wall.js?v=20261030pp'), 'wall.js version bumped');
});
await t('local: admin scan lists the quarantined account, not the buyer or the clean member; Allow removes it', async () => {
let r = await req('POST', '/api/admin/spamscan/run', { headers: adminH, body: {} }); eq(r.status, 200, r.text);
const emails = r.json.last.candidates.map(c => c.email); truthy(emails.includes('fresh@example.com'), emails.join(',')); truthy(!emails.includes('buyer@example.com') && !emails.includes('clean@example.com'), emails.join(','));
const c = r.json.last.candidates.find(x => x.email === 'fresh@example.com'); truthy(c.reasons.includes('quarantined') && c.reasons.includes('no-sponsor'), c.reasons.join(',')); eq(c.firstLink, 'https://huvip-blog.com/'); truthy('alsoOn' in c, 'also-on column present');
truthy(fs.existsSync(path.join(DATA, 'wall-spam-scan.json')), 'result file');
r = await req('POST', '/api/admin/spamscan/allow', { headers: adminH, body: { email: 'fresh@example.com' } }); truthy(r.json.allow.includes('fresh@example.com'));
r = await req('POST', '/api/admin/spamscan/run', { headers: adminH, body: {} }); truthy(!r.json.last.candidates.some(x => x.email === 'fresh@example.com'), 'allowed account gone');
r = await req('POST', '/api/admin/spamscan/allow', { headers: adminH, body: { email: 'fresh@example.com', remove: true } }); truthy(!r.json.allow.includes('fresh@example.com'));
r = await req('DELETE', '/api/admin/member?email=fresh@example.com', { headers: adminH }); eq(r.status, 200, r.text);
eq((await req('GET', '/wall/freshlink')).status, 404, 'deleted wall is a 404');
eq((await req('DELETE', '/api/admin/member?email=buyer@example.com', { headers: adminH })).status, 400, 'on-chain member refused');
});
} catch (e) { fails++; console.log('FAIL local copy ::', e.message); }
finally { try { srv.kill(); } catch (e) {} await new Promise(r => setTimeout(r, 300)); try { fs.rmSync(DATA, { recursive: true, force: true }); } catch (e) {} }
if (fails && /error|Error/.test(log)) console.log('--- server log tail ---\n' + log.slice(-2500));
console.log(fails ? fails + ' of ' + n + ' checks FAILED' : 'profile policy + link-farm scan: all ' + n + ' checks passed');
process.exit(fails ? 1 : 0);
})();