fix(gateway): restore session attach grant revocation (#106487)

This commit is contained in:
Peter Steinberger
2026-07-13 09:08:51 -07:00
committed by GitHub
parent 8898118422
commit ec2f0c6861
+12
View File
@@ -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);