import test from 'node:test'; import assert from 'node:assert/strict'; import { readFileSync } from 'node:fs'; const auth = readFileSync(new URL('../js/services/auth-service.js', import.meta.url), 'utf8'); const vault = readFileSync(new URL('../js/services/key-vault.js', import.meta.url), 'utf8'); const handler = readFileSync(new URL('../../SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/messages/Net_SendSignal_Handler.java', import.meta.url), 'utf8'); test('SendSignal берёт ключ только с текущим sessionId и подписывает канонический login адресата', () => { assert.match(auth, /loadSessionMaterial\(cleanLogin, cleanSessionId\)/); assert.match(auth, /resolveCanonicalDisplayLogin\(requestedToLogin\)/); assert.match(auth, /ключ активной сессии не найден/); }); test('key vault хранит независимый материал для каждой сессии одного login', () => { assert.match(vault, /session-keys-by-id/); assert.match(vault, /normalizeSessionStorageKey\(login, sessionId\)/); assert.match(vault, /loadSessionMaterial\(login, sessionId = ''\)/); assert.match(vault, /String\(legacyRow\?\.sessionId \|\| ''\)\.trim\(\) === cleanSessionId/); }); test('для call_invite без онлайн-сессии сервер возвращает NO_TARGET_SESSIONS', () => { assert.match(handler, /if \(targets\.isEmpty\(\)\) \{/); assert.doesNotMatch(handler, /sendIncomingCallPushToOfflineSessions/); });