mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-07 12:32:52 +00:00
* refactor: extract gateway client package * chore: drop generated gateway package artifacts * refactor: move gateway protocol package * refactor: remove old gateway protocol tree * test: keep auth compat split in run mode * test: expose gateway wrapper options for internals * fix: watch moved gateway package sources * test: normalize slash command import guard * chore: teach knip gateway package entries * ci: route gateway client package checks * fix: reuse ipaddr for gateway client hosts * fix: sync gateway protocol usage schema
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import { describe, expect, test } from "vitest";
|
|
import {
|
|
GATEWAY_CLIENT_IDS,
|
|
GATEWAY_CLIENT_MODES,
|
|
} from "../../packages/gateway-protocol/src/client-info.js";
|
|
import { validateConnectParams } from "../../packages/gateway-protocol/src/index.js";
|
|
|
|
function makeConnectParams(clientId: string) {
|
|
return {
|
|
minProtocol: 1,
|
|
maxProtocol: 1,
|
|
client: {
|
|
id: clientId,
|
|
version: "dev",
|
|
platform: "ios",
|
|
mode: GATEWAY_CLIENT_MODES.NODE,
|
|
},
|
|
role: "node",
|
|
scopes: [],
|
|
caps: ["canvas"],
|
|
commands: ["system.notify"],
|
|
permissions: {},
|
|
};
|
|
}
|
|
|
|
describe("connect params client id validation", () => {
|
|
test.each([GATEWAY_CLIENT_IDS.IOS_APP, GATEWAY_CLIENT_IDS.ANDROID_APP])(
|
|
"accepts %s as a valid gateway client id",
|
|
(clientId) => {
|
|
const ok = validateConnectParams(makeConnectParams(clientId));
|
|
expect(ok).toBe(true);
|
|
expect(validateConnectParams.errors ?? []).toHaveLength(0);
|
|
},
|
|
);
|
|
|
|
test("rejects unknown client ids", () => {
|
|
const ok = validateConnectParams(makeConnectParams("openclaw-mobile"));
|
|
expect(ok).toBe(false);
|
|
});
|
|
});
|