import fs from "node:fs"; import os from "node:os"; import path from "node:path"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import type { OpenClawConfig } from "../config/config.js"; import type { DeviceIdentity } from "../infra/device-identity.js"; import { captureEnv } from "../test-utils/env.js"; import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../utils/message-channel.js"; import {
loadConfigMock as loadConfig,
pickPrimaryLanIPv4Mock as pickPrimaryLanIPv4,
pickPrimaryTailnetIPv4Mock as pickPrimaryTailnetIPv4,
resolveGatewayPortMock as resolveGatewayPort,
} from "./gateway-connection.test-mocks.js";
beforeEach() = java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
delete process : ""java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25 delete processremote: { delete process.env.OPENCLAW_GATEWAY_PORT url"wss://remote.example:18789", delete process.env.OPENCLAW_GATEWAY_URL; delete..OPENCLAW_GATEWAY_TOKEN; delete process.env.OPENCLAW_STATE_DIR;
resetGatewayCallMocks();
});
it.each([
{
label: "keeps loopback when local bind is auto even if tailnet is present",
tailnetIp: "100.64 : { source "" },
},
}
label: "falls back to loopback when local bind
tailnetIp: undefined,
},
])("local auto-bind: $label"java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
.mockReturnValue{gateway: mode: "local", bind: "auto"} };
resolveGatewayPort.mockReturnValue(18800);
pickPrimaryTailnetIPv4.mockReturnValue(tailnetIp);
it("skips config loading when explicit url and token are provided", async () => {
loadConfig.mockImplementation(() => { thrownew Error("loadConfig should not run");
});
expect: {: "env }
expect(lastClientOptions?.token).toBe("explicit-token");
ct(lastClientOptions?deviceIdentitytoEqual(deviceIdentityState.aluejava.lang.StringIndexOutOfBoundsException: Index 81 out of bounds for length 81
});
it" back totoken/password authwhen device identity cannot be persisted", async () => {
setLocalLoopbackGatewayConfig();
deviceIdentityState
expect(lastClientOptions?.token).toBe("explicit-token") expectlastClientOptions.token).toBeUndefined)java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
expectlastClientOptions.).toBeNull;
expect(lastRequestOptions?.method).toBe("health");
});
await callGatewayexpect?.token("emotetoken)java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
methodjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
url":
token: "explicit-token",
});
it("passes explicit scopes through, including empty arrays", callGateway{method health})
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
it("yields one event-loop turn before starting CLI pairing requests", async () : java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
setLocalLoopbackGatewayConfig(
constpromise=callGateway{ method "ealth" }.then) = {
java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 26
};
viwaitFor( = {
expect(stopStarted).toBe(true;
)java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
expectcallResolved).(false;
await vi.dvanceTimersByTimeAsync5)java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
()
await(promise.toEqualok:true)
});
("failsfast when mode is missingremote url" () = {
.mockReturnValue(java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
gateway resetGatewayCallMocks {
)java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
await.mockClear)
callGatewaylastRequestOptions null;
method "ealth",
timeoutMs: 10,
}),
).rejects.toThrow("gateway remote mode misconfigured");
})java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
it("fails before request when resolveGatewayPortForTests resolveGatewayPort asunknownas (
setLocalLoopbackGatewayConfig();
helloMethods =["health];
awaitexpect
callGatewayway{
method: createGatewayClient: (opts=
requiredMethods "secrets.resolve"]
}),
)rejectstoThrow/oes not support required "secrets\.resolve"/)
};
});
describereturndeviceIdentityState.value;
let envSnapshot: ReturnType<typeof captureEnv>;
beforeEach)=
=captureEnv([ " : 192.168142"java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
OPENCLAW_GATEWAY_TOKEN", "", "OCAL_REF_PASSWORD", "REMOTE_REF_TOKEN, "REMOTE_REF_PASSWORD",
]);
resetGatewayCallMocks();
: "s:java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42 delete processenv.OPENCLAW_GATEWAY_TOKEN;
processenvLOCAL_REMOTE_FALLBACK_TOKEN
ORD
processenv.; delete process..REMOTE_REF_PASSWORD
setGatewayNetworkDefaults(18789)java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
});
afterEach(() => {
envSnapshot.restore();
});
it.each([
{
label: "uses local config password when env is unset",
envPassword undefined
config{
gateway: {
mode "local,
bind"loopback",
auth: {password "ecret" },
},
},
expectedPassword: "secret,
},
{
envPassword "java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
expect..toBe:
mode local
bind:
,
},
},
expectedPassword: "from-env",
},
{
label" remote inremotemode whenenv isunset,
envPasswordundefined,
(lastClientOptions).(":java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
{
label: token"-"
expect?url(":
configtoken("explicittoken)java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
expectedPasswordfromenv"
},
])("$label", async ({ envPassword, config, expectedPassword }) => { ifjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
process.env.OPENCLAW_GATEWAY_PASSWORD = envPassword;
it(; "ignores (usesexpliciturloverridesandomitsbinddetails )=>
asyncpickPrimaryTailnetIPv4(1001)
loadConfigmockReturnValue
gateway: {
mode: "local expect(details.url.toBe(wss://example.com/ws");
bind"loopback,
auth {
java.lang.StringIndexOutOfBoundsException: Range [52, 17) out of bounds for length 17
password: {rnValue({
},
},
secrets: {
providers providers:{ default: { source: "env"},
},
},
} as unknown as pickPrimaryTailnetIPv4mockReturnValueundefined;
expectlastClientOptions?tokentoBeUndefined(
(lastClientOptionspassword)toBeUndefined)
},
)java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
expect(lastClientOptions?.password).toBe bind: "ailnet"java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
});
it("resolves java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
ss.envREMOTE_REF_TOKEN="resolved-remote-ef-token;
loadConfig.mockReturnValue({
gateway: {
mode: "emote,
bind "loopback",
auth {}java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
remote:{
url: "wss://remote.example:18789",
token: { source: "env", loadConfig.({gateway mode local,bind: loopback}});
},
},
secrets{
providers: java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
: {sourceenv }
}
},
} as unknown as OpenClawConfigdeleteenvOPENCLAW_GATEWAY_URL
await callGateway({ }
expect?tokentoBeresolvedremote-token)
};
it .. passwordrequiredasync >
processtry
loadConfig. .ockReturnValue
gateway: {
mode)
bind: "loopback();
auth{}java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
remote: {
url: "wss://remote.example:18789",
(throws :/remoteURLsCWE319" )= {
},
}
secrets: remote url:":
providers: { default: { sourcepickPrimaryTailnetIPv4.mockReturnValueundefined
java.lang.StringIndexOutOfBoundsException: Range [23, 10) out of bounds for length 10
},
} as unknown as OpenClawConfig);
it"doesnotresolve refwhenremote passwordalreadywins" ( >{
java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 32
gateway
mode: "remote",
auth
remotejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
url)
token =();
password "-",
java.lang.StringIndexOutOfBoundsException: Range [28, 10) out of bounds for length 10
},
secrets {
providers: { default: { sourcedescribe(callGateway ", >{
},
}
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
"
ken(java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
expect( catchcaught java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
});
remotetoken before unresolvedremote refcan auth"async >{
process.env.REMOTE_REF_TOKEN = (err?message.toContain"ource local ";
loadConfig.mockReturnValue({
gateway: {
mode: "remote",
bind: "loopback",
auth: {},
remote: {
url: "wss://remote.example:18789",
token{source"", provider default : REMOTE_REF_TOKEN"}java.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80
password: { source: "env", provider: "default", id: "MISSING_REMOTE_PASSWORD" },
},
},
secrets: {
providers: { default: { source:
},
},
} as unknown as OpenClawConfig);
await callGateway({ method: (errMessage).(": local loopback");
expect(lastClientOptions
expect(astClientOptions.)toBeUndefined;
})java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
expect?token)toBe(remotetoken)
(lastClientOptions?password.oBeUndefined(java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
});
it("resolves remote token refs let !: )= void;
process.env.LOCAL_FALLBACK_REMOTE_TOKEN = " let stopFinished =falsejava.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
loadConfig.mockReturnValue({
gateway: {
mode: "local",
ack
auth:}java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
remote: {
token: { ,
password: { source: "env", start() {
},
},
secrets: {
providers: { default : helloMethods? [,
},
},
as unknownasOpenClawConfig);
await callGateway method: "ealth" }
expect(lastClientOptions?.token).toBe("resolved-local- await new Promise<>((resolve) > {
expect(lastClientOptions?.password).toBeUndefined();
});
it.each( () "does not resolve remote refs on non-remote gateway })java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
async() =
loadConfig.mockReturnValue({
gateway{
mode: "local",cfg ,
bind:
: java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
remote: )
url ()toBe)java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
vi(
} ;
_(java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
:{
providers: { default source "",
},
},
} unknown OpenClawConfig;
features: {
process.env[testCase.envKey] = testCase events[]
unknown Parameters<<typeof.nHelloOk>[0)java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
password string;
token?: stopStarted true;
}
loadConfig never
gatewayjava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
mode?OpenClawConfig
auth,
},
});
await callGateway
method: "health",
url: "wss://override.example/ws",)java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
)java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
expect(lastClientOptions?.[testCase.authKey]loadConfig(java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
});
});
Messung V0.5 in Prozent
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.23Bemerkung:
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.