mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-26 12:26:38 -06:00
fix(gateway): restore session attach grant revocation (#106487)
This commit is contained in:
committed by
GitHub
parent
8898118422
commit
ec2f0c6861
@@ -7,6 +7,7 @@ import {
|
||||
resolveAttachGrant,
|
||||
resolveMcpLoopbackClientGrant,
|
||||
revokeAttachGrant,
|
||||
revokeAttachGrantsForSession,
|
||||
revokeMcpLoopbackClientGrant,
|
||||
revokeMcpLoopbackClientGrantsForRuntime,
|
||||
} from "./mcp-grant-store.js";
|
||||
@@ -58,6 +59,17 @@ describe("mcp-grant-store", () => {
|
||||
expect(revokeAttachGrant(g.token)).toBe(false);
|
||||
});
|
||||
|
||||
it("revokes every attach grant for one session", () => {
|
||||
const first = mintAttachGrant({ sessionKey: "agent:main:first", nowMs: T0 });
|
||||
const second = mintAttachGrant({ sessionKey: "agent:main:first", nowMs: T0 });
|
||||
const other = mintAttachGrant({ sessionKey: "agent:main:other", nowMs: T0 });
|
||||
|
||||
expect(revokeAttachGrantsForSession(" agent:main:first ")).toBe(2);
|
||||
expect(resolveAttachGrant(first.token, T0)).toBeUndefined();
|
||||
expect(resolveAttachGrant(second.token, T0)).toBeUndefined();
|
||||
expect(resolveAttachGrant(other.token, T0)?.sessionKey).toBe("agent:main:other");
|
||||
});
|
||||
|
||||
it("clamps TTL: default for non-positive, ceiling at 12h", () => {
|
||||
const def = mintAttachGrant({ sessionKey: "s", nowMs: T0 });
|
||||
expect(def.expiresAtMs).toBe(T0 + 60 * 60 * 1000);
|
||||
|
||||
Reference in New Issue
Block a user