mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 22:04:30 +00:00
refactor(test): dedupe gateway and web scaffolding
This commit is contained in:
@@ -19,6 +19,24 @@ type TestCase = {
|
||||
expected: ExpectedCredentialSet;
|
||||
};
|
||||
|
||||
const gatewayEnv = {
|
||||
OPENCLAW_GATEWAY_TOKEN: "env-token",
|
||||
OPENCLAW_GATEWAY_PASSWORD: "env-password",
|
||||
} as NodeJS.ProcessEnv;
|
||||
|
||||
function makeRemoteGatewayConfig(remote: { token?: string; password?: string }): OpenClawConfig {
|
||||
return {
|
||||
gateway: {
|
||||
mode: "remote",
|
||||
remote,
|
||||
auth: {
|
||||
token: "local-token",
|
||||
password: "local-password",
|
||||
},
|
||||
},
|
||||
} as OpenClawConfig;
|
||||
}
|
||||
|
||||
function withGatewayAuthEnv<T>(env: NodeJS.ProcessEnv, fn: () => T): T {
|
||||
const keys = [
|
||||
"OPENCLAW_GATEWAY_TOKEN",
|
||||
@@ -76,23 +94,11 @@ describe("gateway credential precedence parity", () => {
|
||||
},
|
||||
{
|
||||
name: "remote mode with remote token configured",
|
||||
cfg: {
|
||||
gateway: {
|
||||
mode: "remote",
|
||||
remote: {
|
||||
token: "remote-token",
|
||||
password: "remote-password",
|
||||
},
|
||||
auth: {
|
||||
token: "local-token",
|
||||
password: "local-password",
|
||||
},
|
||||
},
|
||||
} as OpenClawConfig,
|
||||
env: {
|
||||
OPENCLAW_GATEWAY_TOKEN: "env-token",
|
||||
OPENCLAW_GATEWAY_PASSWORD: "env-password",
|
||||
} as NodeJS.ProcessEnv,
|
||||
cfg: makeRemoteGatewayConfig({
|
||||
token: "remote-token",
|
||||
password: "remote-password",
|
||||
}),
|
||||
env: gatewayEnv,
|
||||
expected: {
|
||||
call: { token: "remote-token", password: "env-password" },
|
||||
probe: { token: "remote-token", password: "env-password" },
|
||||
@@ -102,22 +108,10 @@ describe("gateway credential precedence parity", () => {
|
||||
},
|
||||
{
|
||||
name: "remote mode without remote token keeps remote probe/status strict",
|
||||
cfg: {
|
||||
gateway: {
|
||||
mode: "remote",
|
||||
remote: {
|
||||
password: "remote-password",
|
||||
},
|
||||
auth: {
|
||||
token: "local-token",
|
||||
password: "local-password",
|
||||
},
|
||||
},
|
||||
} as OpenClawConfig,
|
||||
env: {
|
||||
OPENCLAW_GATEWAY_TOKEN: "env-token",
|
||||
OPENCLAW_GATEWAY_PASSWORD: "env-password",
|
||||
} as NodeJS.ProcessEnv,
|
||||
cfg: makeRemoteGatewayConfig({
|
||||
password: "remote-password",
|
||||
}),
|
||||
env: gatewayEnv,
|
||||
expected: {
|
||||
call: { token: "env-token", password: "env-password" },
|
||||
probe: { token: undefined, password: "env-password" },
|
||||
|
||||
Reference in New Issue
Block a user