[Repo Assist] test: add HandleRequestError coverage for auth/scope/unknown-method paths#202
Merged
shanselman merged 1 commit intomasterfrom Apr 23, 2026
Conversation
…aths Add 13 new tests to OpenClawGatewayClientTests covering the HandleRequestError private method via reflection: Pairing required (3 tests): - SetsPairingBlockFlag: verifies _pairingRequiredAwaitingApproval = true - LogsWarning: verifies auto-reconnect-paused warning is emitted - RaisesErrorStatus: verifies ConnectionStatus.Error is raised Device signature invalid (2 tests): - CyclesSignatureMode: verifies mode steps V3AuthToken -> V3EmptyToken - LogsWarningWithMode: verifies rejection warning is logged Missing operator.read scope (1 Theory x 4 cases): - sessions.list, usage.status, usage.cost, node.list all set _operatorReadScopeUnavailable = true Unknown method fallbacks (4 tests): - usage.status, usage.cost, sessions.preview, node.list each set their respective _*Unsupported flags Also adds GatewayClientTestHelper overloads: - Constructor accepting IOpenClawLogger (for log capture) - TrackPendingRequest, GetPairingRequiredFlag, GetSignatureTokenMode, GetOperatorReadScopeUnavailable, CaptureStatusChanges helpers Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
13 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This is an automated draft PR from Repo Assist.
Summary
Adds 13 new tests to
OpenClawGatewayClientTestscovering the privateHandleRequestErrorpath, which had zero test coverage. This code handles critical connection-lifecycle scenarios: authentication failures, device signature fallback chains, scope access errors, and unsupported-method detection.Motivation
Issue #198 highlighted that the reconnect/auth-failure logic can behave incorrectly (specifically:
_pairingRequiredAwaitingApprovalblocking reconnect, and_signatureTokenModecycling). Writing tests forHandleRequestErrordirectly verifies these behaviours and will guard against regressions when fixing #198.Changes
tests/OpenClaw.Shared.Tests/OpenClawGatewayClientTests.csNew helper methods on
GatewayClientTestHelper:GatewayClientTestHelper(IOpenClawLogger)— constructor for log-capture testsTrackPendingRequest(requestId, method)— pre-registers a pending request soProcessRawMessagecan resolve the method and reach the correctHandleRequestErrorbranchGetPairingRequiredFlag()— reads_pairingRequiredAwaitingApprovalGetSignatureTokenMode()— reads_signatureTokenModeas a stringGetOperatorReadScopeUnavailable()— reads_operatorReadScopeUnavailableCaptureStatusChanges()— subscribes toStatusChangedfor event-assertion testsNew tests (13):
HandleRequestError_PairingRequired_SetsPairingBlockFlag_pairingRequiredAwaitingApproval = trueon"pairing required"connect errorHandleRequestError_PairingRequired_LogsWarningHandleRequestError_PairingRequired_RaisesErrorStatusConnectionStatus.ErrorraisedHandleRequestError_DeviceSignatureInvalid_CyclesSignatureModeHandleRequestError_DeviceSignatureInvalid_LogsWarningWithModeHandleRequestError_MissingOperatorReadScope_SetsUnavailableFlag(×4 Theory)_operatorReadScopeUnavailableset forsessions.list,usage.status,usage.cost,node.listHandleRequestError_UnknownMethod_UsageStatus_SetsUnsupportedFlag_usageStatusUnsupportedsetHandleRequestError_UnknownMethod_UsageCost_SetsUnsupportedFlag_usageCostUnsupportedsetHandleRequestError_UnknownMethod_SessionsPreview_SetsUnsupportedFlag_sessionPreviewUnsupportedsetHandleRequestError_UnknownMethod_NodeList_SetsUnsupportedFlag_nodeListUnsupportedsetTest Status
dotnet build OpenClaw.Shared.Tests— succeeded, 0 warnings