mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 01:51:24 +00:00
fix: land NO_REPLY announce suppression and auth scope assertions
Landed follow-up for #27535 and aligned shared-auth gateway expectations after #27498. Co-authored-by: kevinWangSheng <118158941+kevinWangSheng@users.noreply.github.com>
This commit is contained in:
@@ -416,13 +416,14 @@ describe("gateway server auth/connect", () => {
|
||||
opts: Parameters<typeof connectReq>[1];
|
||||
expectConnectOk: boolean;
|
||||
expectConnectError?: string;
|
||||
expectStatusOk?: boolean;
|
||||
expectStatusError?: string;
|
||||
}> = [
|
||||
{
|
||||
name: "operator + valid shared token => connected with zero scopes",
|
||||
name: "operator + valid shared token => connected with preserved scopes",
|
||||
opts: { role: "operator", token, device: null },
|
||||
expectConnectOk: true,
|
||||
expectStatusError: "missing scope",
|
||||
expectStatusOk: true,
|
||||
},
|
||||
{
|
||||
name: "node + valid shared token => rejected without device",
|
||||
@@ -449,12 +450,14 @@ describe("gateway server auth/connect", () => {
|
||||
);
|
||||
continue;
|
||||
}
|
||||
if (scenario.expectStatusError) {
|
||||
if (scenario.expectStatusOk !== undefined) {
|
||||
const status = await rpcReq(ws, "status");
|
||||
expect(status.ok, scenario.name).toBe(false);
|
||||
expect(status.error?.message ?? "", scenario.name).toContain(
|
||||
scenario.expectStatusError,
|
||||
);
|
||||
expect(status.ok, scenario.name).toBe(scenario.expectStatusOk);
|
||||
if (!scenario.expectStatusOk && scenario.expectStatusError) {
|
||||
expect(status.error?.message ?? "", scenario.name).toContain(
|
||||
scenario.expectStatusError,
|
||||
);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
ws.close();
|
||||
@@ -811,8 +814,7 @@ describe("gateway server auth/connect", () => {
|
||||
const res = await connectReq(ws, { token: "secret", device: null });
|
||||
expect(res.ok).toBe(true);
|
||||
const status = await rpcReq(ws, "status");
|
||||
expect(status.ok).toBe(false);
|
||||
expect(status.error?.message).toContain("missing scope");
|
||||
expect(status.ok).toBe(true);
|
||||
const health = await rpcReq(ws, "health");
|
||||
expect(health.ok).toBe(true);
|
||||
ws.close();
|
||||
@@ -896,8 +898,7 @@ describe("gateway server auth/connect", () => {
|
||||
}
|
||||
if (tc.expectStatusChecks) {
|
||||
const status = await rpcReq(ws, "status");
|
||||
expect(status.ok).toBe(false);
|
||||
expect(status.error?.message ?? "").toContain("missing scope");
|
||||
expect(status.ok).toBe(true);
|
||||
const health = await rpcReq(ws, "health");
|
||||
expect(health.ok).toBe(true);
|
||||
}
|
||||
@@ -923,8 +924,7 @@ describe("gateway server auth/connect", () => {
|
||||
});
|
||||
expect(res.ok).toBe(true);
|
||||
const status = await rpcReq(ws, "status");
|
||||
expect(status.ok).toBe(false);
|
||||
expect(status.error?.message ?? "").toContain("missing scope");
|
||||
expect(status.ok).toBe(true);
|
||||
const health = await rpcReq(ws, "health");
|
||||
expect(health.ok).toBe(true);
|
||||
ws.close();
|
||||
@@ -946,8 +946,7 @@ describe("gateway server auth/connect", () => {
|
||||
});
|
||||
expect(res.ok).toBe(true);
|
||||
const status = await rpcReq(ws, "status");
|
||||
expect(status.ok).toBe(false);
|
||||
expect(status.error?.message ?? "").toContain("missing scope");
|
||||
expect(status.ok).toBe(true);
|
||||
const health = await rpcReq(ws, "health");
|
||||
expect(health.ok).toBe(true);
|
||||
ws.close();
|
||||
|
||||
Reference in New Issue
Block a user