File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed
Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,12 @@ const gatewayClientState = vi.hoisted(() => ({
44 options : null as Record < string , unknown > | null ,
55} ) ) ;
66
7+ const mockDeviceIdentity = vi . hoisted ( ( ) => ( {
8+ deviceId : "dev-123" ,
9+ publicKeyPem : "pub" ,
10+ privateKeyPem : "priv" ,
11+ } ) ) ;
12+
713class MockGatewayClient {
814 private readonly opts : Record < string , unknown > ;
915
@@ -33,6 +39,10 @@ class MockGatewayClient {
3339 }
3440}
3541
42+ vi . mock ( "../infra/device-identity.js" , ( ) => ( {
43+ loadOrCreateDeviceIdentity : vi . fn ( ( ) => mockDeviceIdentity ) ,
44+ } ) ) ;
45+
3646vi . mock ( "./client.js" , ( ) => ( {
3747 GatewayClient : MockGatewayClient ,
3848} ) ) ;
@@ -48,6 +58,7 @@ describe("probeGateway", () => {
4858 } ) ;
4959
5060 expect ( gatewayClientState . options ?. scopes ) . toEqual ( [ "operator.read" ] ) ;
61+ expect ( gatewayClientState . options ?. deviceIdentity ) . toEqual ( mockDeviceIdentity ) ;
5162 expect ( result . ok ) . toBe ( true ) ;
5263 } ) ;
5364} ) ;
Original file line number Diff line number Diff line change 11import { randomUUID } from "node:crypto" ;
2+ import { loadOrCreateDeviceIdentity } from "../infra/device-identity.js" ;
23import { formatErrorMessage } from "../infra/errors.js" ;
34import type { SystemPresence } from "../infra/system-presence.js" ;
45import { GATEWAY_CLIENT_MODES , GATEWAY_CLIENT_NAMES } from "../utils/message-channel.js" ;
@@ -60,6 +61,7 @@ export async function probeGateway(opts: {
6061 clientVersion : "dev" ,
6162 mode : GATEWAY_CLIENT_MODES . PROBE ,
6263 instanceId,
64+ deviceIdentity : loadOrCreateDeviceIdentity ( ) ,
6365 onConnectError : ( err ) => {
6466 connectError = formatErrorMessage ( err ) ;
6567 } ,
You can’t perform that action at this time.
0 commit comments