import test from 'node:test'; import assert from 'node:assert/strict'; import fs from 'node:fs'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; const root=path.resolve(path.dirname(fileURLToPath(import.meta.url)),'../..'); const read = path => fs.readFileSync(`${root}/${path}`,'utf8'); const registry=read('SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/JsonHandlerRegistry.java'); const api=read('shine-UI/js/services/registration-v2-api.js'); const ops=['GetNamespaces','CheckRegistrationLogin','CheckRegistrationEmail', 'StartFreeRegistration','ConfirmFreeRegistration','GetRegistrationStatus']; test('в серверном реестре ровно согласованные шесть операций, каждый op имеет request type',()=>{ for(const op of ops) { assert.ok(registry.includes(`Map.entry("${op}", new Net_Registration_Handler`)); assert.ok(registry.includes(`Map.entry("${op}", Net_Registration_Request.class`)); } assert.doesNotMatch(registry,/Map\.entry\("CheckRegistrationAvailability"/); }); test('проверки login и email независимы и не отправляют лишних данных',()=>{ assert.match(api,/checkRegistrationLogin = .*call\('CheckRegistrationLogin', \{ fullLogin:/); assert.match(api,/checkRegistrationEmail = .*call\('CheckRegistrationEmail', \{ email \}/); }); test('free-регистрация передаёт ровно три публичных ключа, не пароли и не секреты',()=>{ const request=api.match(/export const startFreeRegistration = \([\s\S]*?\n\}\);/); assert.ok(request); assert.match(request[0],/rootPublicKeyB64/); assert.match(request[0],/blockchainPublicKeyB64/); assert.match(request[0],/clientPublicKeyB64/); assert.doesNotMatch(request[0],/password|masterSecret|privatePkcs8|seed32/); }); test('free экран вводит код из письма и ждёт Turbo, платный upgrade проверяет ключи',()=>{ const email=read('shine-UI/js/pages/registration-email-view.js'); assert.match(email,/Введите код из письма/);assert.match(email,/confirmFreeRegistration/); assert.doesNotMatch(email,/код 1111/); assert.match(email,/completeRegistrationLogin/); const upgrade=read('shine-UI/js/pages/registration-upgrade-view.js'); assert.match(upgrade,/keys\.rootPair/);assert.match(upgrade,/bytesToBase58/); assert.match(upgrade,/upgradeFreeUserOnSolana/); }); test('никто не выкладывает регистрационный email в debug log',()=>{ const processor=read('SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/JsonInboundProcessor.java'); assert.match(processor,/registration payload redacted/); });