Files
Shadowbroker/frontend/src/__tests__/desktop/desktopControlRouting.test.ts
T
anoracleofra-code 668ce16dc7 v0.9.6: InfoNet hashchain, Wormhole gate encryption, mesh reputation, 16 community contributors
Gate messages now propagate via the Infonet hashchain as encrypted blobs — every node syncs them
through normal chain sync while only Gate members with MLS keys can decrypt. Added mesh reputation
system, peer push workers, voluntary Wormhole opt-in for node participation, fork recovery,
killwormhole scripts, obfuscated terminology, and hardened the self-updater to protect encryption
keys and chain state during updates.

New features: Shodan search, train tracking, Sentinel Hub imagery, 8 new intelligence layers,
CCTV expansion to 11,000+ cameras across 6 countries, Mesh Terminal CLI, prediction markets,
desktop-shell scaffold, and comprehensive mesh test suite (215 frontend + backend tests passing).

Community contributors: @wa1id, @AlborzNazari, @adust09, @Xpirix, @imqdcr, @csysp, @suranyami,
@chr0n1x, @johan-martensson, @singularfailure, @smithbh, @OrfeoTerkuci, @deuza, @tm-const,
@Elhard1, @ttulttul
2026-03-26 05:58:04 -06:00

105 lines
2.8 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import {
commandToHttpRequest,
httpRequestToInvokeRequest,
} from '@/lib/desktopControlRouting';
describe('desktopControlRouting', () => {
it('maps invoke commands to HTTP requests', () => {
expect(commandToHttpRequest('wormhole.connect')).toEqual({
path: '/api/wormhole/connect',
method: 'POST',
});
expect(commandToHttpRequest('wormhole.gate.key.get', { gate_id: 'infonet' })).toEqual({
path: '/api/wormhole/gate/infonet/key',
method: 'GET',
});
expect(commandToHttpRequest('settings.news.reset')).toEqual({
path: '/api/settings/news-feeds/reset',
method: 'POST',
});
expect(commandToHttpRequest('wormhole.gate.proof', { gate_id: 'infonet' })).toEqual({
path: '/api/wormhole/gate/proof',
method: 'POST',
payload: { gate_id: 'infonet' },
});
expect(
commandToHttpRequest('wormhole.gate.message.post', {
gate_id: 'ops',
plaintext: 'hello',
}),
).toEqual({
path: '/api/wormhole/gate/message/post',
method: 'POST',
payload: { gate_id: 'ops', plaintext: 'hello' },
});
});
it('maps HTTP settings writes back to invoke requests', () => {
expect(
httpRequestToInvokeRequest(
'/api/settings/privacy-profile',
'PUT',
JSON.stringify({ profile: 'high' }),
),
).toEqual({
command: 'settings.privacy.set',
payload: { profile: 'high' },
});
expect(
httpRequestToInvokeRequest(
'/api/wormhole/gate/key/rotate',
'POST',
JSON.stringify({ gate_id: 'infonet', reason: 'operator_reset' }),
),
).toEqual({
command: 'wormhole.gate.key.rotate',
payload: { gate_id: 'infonet', reason: 'operator_reset' },
});
expect(
httpRequestToInvokeRequest(
'/api/wormhole/gate/proof',
'POST',
JSON.stringify({ gate_id: 'infonet' }),
),
).toEqual({
command: 'wormhole.gate.proof',
payload: { gate_id: 'infonet' },
});
expect(
httpRequestToInvokeRequest(
'/api/wormhole/gate/messages/decrypt',
'POST',
JSON.stringify({
messages: [
{
gate_id: 'infonet',
epoch: 3,
ciphertext: 'ct',
nonce: 'n',
sender_ref: 'ref',
},
],
}),
),
).toEqual({
command: 'wormhole.gate.messages.decrypt',
payload: {
messages: [
{
gate_id: 'infonet',
epoch: 3,
ciphertext: 'ct',
nonce: 'n',
sender_ref: 'ref',
},
],
},
});
});
it('returns null for unsupported paths', () => {
expect(httpRequestToInvokeRequest('/api/mesh/status', 'GET')).toBeNull();
});
});