Compare commits

...

1 Commits

Author SHA1 Message Date
Vincent Koc
7a20de3fdf Tests: clean trusted-proxy pairing seed 2026-03-17 20:16:36 -07:00

View File

@ -251,7 +251,8 @@ export function registerControlUiAndPairingSuite(): void {
test("clears self-declared scopes for trusted-proxy control ui without device identity", async () => { test("clears self-declared scopes for trusted-proxy control ui without device identity", async () => {
await configureTrustedProxyControlUiAuth(); await configureTrustedProxyControlUiAuth();
const { publicKeyRawBase64UrlFromPem } = await import("../infra/device-identity.js"); const { publicKeyRawBase64UrlFromPem } = await import("../infra/device-identity.js");
const { requestDevicePairing } = await import("../infra/device-pairing.js"); const { rejectDevicePairing, requestDevicePairing } =
await import("../infra/device-pairing.js");
const { identity } = await createOperatorIdentityFixture("openclaw-control-ui-trusted-proxy-"); const { identity } = await createOperatorIdentityFixture("openclaw-control-ui-trusted-proxy-");
const pendingRequest = await requestDevicePairing({ const pendingRequest = await requestDevicePairing({
deviceId: identity.deviceId, deviceId: identity.deviceId,
@ -261,26 +262,30 @@ export function registerControlUiAndPairingSuite(): void {
clientId: CONTROL_UI_CLIENT.id, clientId: CONTROL_UI_CLIENT.id,
clientMode: CONTROL_UI_CLIENT.mode, clientMode: CONTROL_UI_CLIENT.mode,
}); });
await withGatewayServer(async ({ port }) => { try {
const ws = await openWs(port, TRUSTED_PROXY_CONTROL_UI_HEADERS); await withGatewayServer(async ({ port }) => {
try { const ws = await openWs(port, TRUSTED_PROXY_CONTROL_UI_HEADERS);
const res = await connectReq(ws, { try {
skipDefaultAuth: true, const res = await connectReq(ws, {
scopes: ["operator.admin"], skipDefaultAuth: true,
device: null, scopes: ["operator.admin"],
client: { ...CONTROL_UI_CLIENT }, device: null,
}); client: { ...CONTROL_UI_CLIENT },
expect(res.ok).toBe(true); });
expect((res.payload as { auth?: unknown } | undefined)?.auth).toBeUndefined(); expect(res.ok).toBe(true);
expect((res.payload as { auth?: unknown } | undefined)?.auth).toBeUndefined();
await expectStatusMissingScopeButHealthOk(ws); await expectStatusMissingScopeButHealthOk(ws);
await expectAdminRpcDenied(ws); await expectAdminRpcDenied(ws);
await expectTalkSecretsDenied(ws); await expectTalkSecretsDenied(ws);
await expectDevicePairApproveDenied(ws, pendingRequest.request.requestId); await expectDevicePairApproveDenied(ws, pendingRequest.request.requestId);
} finally { } finally {
ws.close(); ws.close();
} }
}); });
} finally {
await rejectDevicePairing(pendingRequest.request.requestId);
}
}); });
test("allows localhost control ui without device identity when insecure auth is enabled", async () => { test("allows localhost control ui without device identity when insecure auth is enabled", async () => {