mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-03 03:03:24 -04:00
refactor(test): dedupe ios/android gateway client id tests
This commit is contained in:
@@ -61,30 +61,14 @@ function connectReq(
|
||||
);
|
||||
}
|
||||
|
||||
test("accepts openclaw-ios as a valid gateway client id", async () => {
|
||||
test.each([
|
||||
{ clientId: "openclaw-ios", platform: "ios" },
|
||||
{ clientId: "openclaw-android", platform: "android" },
|
||||
])("accepts $clientId as a valid gateway client id", async ({ clientId, platform }) => {
|
||||
const ws = new WebSocket(`ws://127.0.0.1:${port}`);
|
||||
await new Promise<void>((resolve) => ws.once("open", resolve));
|
||||
|
||||
const res = await connectReq(ws, { clientId: "openclaw-ios", platform: "ios" });
|
||||
// We don't care if auth fails here; we only care that schema validation accepts the client id.
|
||||
// A schema rejection would close the socket before sending a response.
|
||||
if (!res.ok) {
|
||||
// allow unauthorized error when gateway requires auth
|
||||
// but reject schema validation errors
|
||||
const message = String(res.error?.message ?? "");
|
||||
if (message.includes("invalid connect params")) {
|
||||
throw new Error(message);
|
||||
}
|
||||
}
|
||||
|
||||
ws.close();
|
||||
});
|
||||
|
||||
test("accepts openclaw-android as a valid gateway client id", async () => {
|
||||
const ws = new WebSocket(`ws://127.0.0.1:${port}`);
|
||||
await new Promise<void>((resolve) => ws.once("open", resolve));
|
||||
|
||||
const res = await connectReq(ws, { clientId: "openclaw-android", platform: "android" });
|
||||
const res = await connectReq(ws, { clientId, platform });
|
||||
// We don't care if auth fails here; we only care that schema validation accepts the client id.
|
||||
// A schema rejection would close the socket before sending a response.
|
||||
if (!res.ok) {
|
||||
|
||||
Reference in New Issue
Block a user