mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 02:40:24 +00:00
test: move android policy fixtures into test helpers
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import type { OpenClawConfig } from "../../../src/config/config.js";
|
||||
|
||||
function asRecord(value: unknown): Record<string, unknown> {
|
||||
return typeof value === "object" && value !== null ? (value as Record<string, unknown>) : {};
|
||||
}
|
||||
|
||||
export function unwrapRemoteConfigSnapshot(raw: unknown): OpenClawConfig {
|
||||
const rawObj = asRecord(raw);
|
||||
const resolved = asRecord(rawObj.resolved);
|
||||
if (Object.keys(resolved).length > 0) {
|
||||
return resolved as OpenClawConfig;
|
||||
}
|
||||
|
||||
const wrapped = asRecord(rawObj.config);
|
||||
if (Object.keys(wrapped).length > 0) {
|
||||
return wrapped as OpenClawConfig;
|
||||
}
|
||||
|
||||
const legacyPayload = asRecord(rawObj.payload);
|
||||
const legacyResolved = asRecord(legacyPayload.resolved);
|
||||
if (Object.keys(legacyResolved).length > 0) {
|
||||
return legacyResolved as OpenClawConfig;
|
||||
}
|
||||
|
||||
const legacyConfig = asRecord(legacyPayload.config);
|
||||
if (Object.keys(legacyConfig).length > 0) {
|
||||
return legacyConfig as OpenClawConfig;
|
||||
}
|
||||
|
||||
if (Object.keys(rawObj).length > 0 && !Object.prototype.hasOwnProperty.call(rawObj, "payload")) {
|
||||
return rawObj as OpenClawConfig;
|
||||
}
|
||||
|
||||
throw new Error("remote gateway config.get returned empty config payload");
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import type { GatewayConnectionDetails } from "../../../src/gateway/call.js";
|
||||
|
||||
export function shouldFetchRemotePolicyConfig(details: GatewayConnectionDetails): boolean {
|
||||
return details.urlSource !== "local loopback";
|
||||
}
|
||||
Reference in New Issue
Block a user