From f37507cac2b18d12fbfe699ce15c087e2e6b1420 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 9 Aug 2026 23:36:22 -0700 Subject: [PATCH] test(macos): keep mocked gateway probe routes off the operator identity store (#121398) --- .../Sources/OpenClaw/GatewayConnection.swift | 16 ++++++++++++++++ .../OnboardingConfiguredGatewayProbeTests.swift | 4 +++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/apps/macos/Sources/OpenClaw/GatewayConnection.swift b/apps/macos/Sources/OpenClaw/GatewayConnection.swift index b52a439063b7..efe6a16af5c8 100644 --- a/apps/macos/Sources/OpenClaw/GatewayConnection.swift +++ b/apps/macos/Sources/OpenClaw/GatewayConnection.swift @@ -225,6 +225,22 @@ actor GatewayConnection { sessionProvider: sessionProvider) self.clientShutdown = clientShutdown } + + init( + testEndpointProvider: @escaping EndpointProvider, + sessionBox: WebSocketSessionBox? = nil) + { + self.endpointProvider = testEndpointProvider + self.supportsSharedEndpointRecovery = false + self.activationBindingKeyProvider = { GatewayConnection.testingActivationBindingKey } + // Mock WebSocket routes do not exercise device authentication and must not + // depend on the process-global persisted identity store. + self.includeDeviceIdentity = false + self.sessionProvider = Self.resolveSessionProvider( + sessionBox: sessionBox, + sessionProvider: nil) + self.clientShutdown = { client in await client.shutdown() } + } #endif private static func resolveSessionProvider( diff --git a/apps/macos/Tests/OpenClawIPCTests/OnboardingConfiguredGatewayProbeTests.swift b/apps/macos/Tests/OpenClawIPCTests/OnboardingConfiguredGatewayProbeTests.swift index faf27489df3f..b56c82e16c0d 100644 --- a/apps/macos/Tests/OpenClawIPCTests/OnboardingConfiguredGatewayProbeTests.swift +++ b/apps/macos/Tests/OpenClawIPCTests/OnboardingConfiguredGatewayProbeTests.swift @@ -234,8 +234,10 @@ private func onboardingProbeFixture( reply: OnboardingProbeReply = .configured) -> OnboardingProbeFixture { let session = GatewayTestWebSocketSession(taskFactory: onboardingProbeTaskFactory(reply: reply)) + // The production endpointProvider init reads the process-global persisted + // identity store; mocked routes must stay off the operator's real state. let gateway = GatewayConnection( - endpointProvider: endpointProvider, + testEndpointProvider: endpointProvider, sessionBox: WebSocketSessionBox(session: session)) return OnboardingProbeFixture( session: session,