Skip to content

Commit ea36b12

Browse files
ranjeshjCopilotranjeshj
authored
Harden gateway connection and pairing flows (#741)
* Harden gateway connection and pairing flows Consolidate the connection/pairing hardening work into one validated change set. Connection and credential handling: - keep gateway credentials registry-backed and preserve strict credential precedence: device token, shared gateway token, then bootstrap token - force fresh setup-code bootstrap credentials for immediate QR/setup-code pairing while preserving shared gateway tokens for HTTP/dashboard paths - dedupe loopback-equivalent gateway URLs so localhost and 127.0.0.1 records do not split pairing state - validate replacement shared tokens before disconnecting or clearing durable device tokens - clear stale bootstrap tokens only after required role tokens are durably readable - recover stale operator device-token mismatches by falling back to bootstrap when recovery material is still present Operator/node pairing and token lifecycle: - keep operator clients in the operator role during bootstrap while preserving explicit node bootstrap behavior - persist role-specific handoff tokens from hello-ok auth.deviceTokens[] for both operator and node roles - forward WindowsNodeClient node-token receipt through NodeConnector so GatewayConnectionManager can complete bootstrap cleanup after the node token becomes durable - request operator.pairing with normal shared-token operator connects so node trust approvals can be reached - wait for node/device pair approval responses instead of treating a sent frame as success - fall back from node.pair.approve to device.pair.approve only when admin authority is available - guard node connection events by client generation so stale clients cannot mutate current state - abort node handshake when pre-connect capability binding fails, preventing caps=0/cmds=0 registrations Tray, MCP, and browser-control behavior: - expose connection-control MCP tools only through local MCP, not the gateway node transport - route MCP setup-code and shared-token connection tools through GatewayConnectionManager - refresh gateway node state when local node connected/paired events arrive - register browser.proxy only when a live gateway client and shared gateway token are available, and use the shared token for browser-control HTTP auth Setup and reliability: - add bounded retry for transient WSL startup timing when validating /etc/wsl.conf after WSL terminate/apply-config - keep invalid wsl.conf content validation strict after the read succeeds - preserve SSH tunnel behavior for operator and node connection paths Maintainability simplifications: - reuse setup-code gateway lookup state in GatewayConnectionManager - centralize delayed reconnect scheduling with generation/disposal guards - centralize response-aware pair approval RPC handling - consolidate operator scope helper literals and checks Validation: - build.ps1 passed - OpenClaw.Shared.Tests passed - OpenClaw.Tray.Tests passed - OpenClaw.Connection.Tests passed - OpenClaw.SetupEngine.Tests passed - full OpenClaw.E2ETests passed with OPENCLAW_RUN_E2E=1 and win-arm64 runtime - targeted QR/setup-code E2E tests passed after audit follow-up - Copilot autoreview passed with no accepted/actionable findings - dual-model protocol audit completed; accepted multi-role handoff finding fixed Co-authored-by: Copilot <[email protected]> * Harden clean gateway pairing flows Co-authored-by: Copilot <[email protected]> * Checkpoint connection page test changes Co-authored-by: Copilot <[email protected]> * Clean up setup and connect E2E tests Co-authored-by: Copilot <[email protected]> * Move app capability handlers to partial class Co-authored-by: Copilot <[email protected]> * Remove invalid external QR E2E The removed test used an admin fixture to approve node pairing, so it did not represent the QR-only external scenario it claimed to cover and could leave pending node approvals that broke later setup/connect tests. Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: ranjeshj <ranjeshj@DESKTOP-D683G7P>
1 parent 913ba4e commit ea36b12

40 files changed

Lines changed: 4450 additions & 378 deletions

‎.github/workflows/ci.yml‎

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,17 @@ jobs:
282282
needs: repo-hygiene
283283
if: ${{ !cancelled() }}
284284
runs-on: windows-latest
285-
timeout-minutes: 15
285+
timeout-minutes: 25
286+
strategy:
287+
fail-fast: false
288+
matrix:
289+
include:
290+
- name: setup-connect
291+
filter: FullyQualifiedName~OpenClaw.E2ETests.Setup.SetupAndConnectTests
292+
- name: revocation-recovery
293+
filter: FullyQualifiedName~OpenClaw.E2ETests.Setup.RevocationAndRecoveryTests
294+
- name: network-recovery
295+
filter: FullyQualifiedName~OpenClaw.E2ETests.Setup.NetworkRecoveryTests
286296
steps:
287297
- name: Fail if repo hygiene failed
288298
if: ${{ needs.repo-hygiene.result != 'success' }}
@@ -323,7 +333,7 @@ jobs:
323333
- name: Build E2E Tests
324334
run: dotnet build tests/OpenClaw.E2ETests -c Debug -r win-x64
325335

326-
- name: Run E2E Tests
336+
- name: Run E2E Tests (${{ matrix.name }})
327337
env:
328338
OPENCLAW_RUN_E2E: 1
329339
shell: pwsh
@@ -334,22 +344,23 @@ jobs:
334344
-r win-x64 `
335345
--verbosity normal `
336346
--results-directory TestResults/E2E `
337-
--logger "trx;LogFileName=OpenClaw.E2ETests.trx" `
338-
--logger "console;verbosity=detailed"
347+
--logger "trx;LogFileName=OpenClaw.E2ETests.${{ matrix.name }}.trx" `
348+
--logger "console;verbosity=detailed" `
349+
--filter "${{ matrix.filter }}"
339350
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
340351
341-
[xml]$trx = Get-Content TestResults\E2E\OpenClaw.E2ETests.trx
352+
[xml]$trx = Get-Content "TestResults\E2E\OpenClaw.E2ETests.${{ matrix.name }}.trx"
342353
$executed = [int]$trx.TestRun.ResultSummary.Counters.executed
343354
if ($executed -lt 1) {
344-
Write-Error "E2E test run executed zero tests. Check OPENCLAW_RUN_E2E gating before merging."
355+
Write-Error "E2E shard '${{ matrix.name }}' executed zero tests. Check OPENCLAW_RUN_E2E gating/filter before merging."
345356
exit 1
346357
}
347358
348359
- name: Upload E2E Test Results & Logs
349360
if: always()
350361
uses: actions/upload-artifact@v7
351362
with:
352-
name: e2e-test-results
363+
name: e2e-test-results-${{ matrix.name }}
353364
path: |
354365
TestResults/E2E/
355366
if-no-files-found: warn

0 commit comments

Comments
 (0)