|
7 | 7 | resolveAttachGrant, |
8 | 8 | resolveMcpLoopbackClientGrant, |
9 | 9 | revokeAttachGrant, |
| 10 | + revokeAttachGrantsForSession, |
10 | 11 | revokeMcpLoopbackClientGrant, |
11 | 12 | revokeMcpLoopbackClientGrantsForRuntime, |
12 | 13 | } from "./mcp-grant-store.js"; |
@@ -58,6 +59,17 @@ describe("mcp-grant-store", () => { |
58 | 59 | expect(revokeAttachGrant(g.token)).toBe(false); |
59 | 60 | }); |
60 | 61 |
|
| 62 | + it("revokes every attach grant for one session", () => { |
| 63 | + const first = mintAttachGrant({ sessionKey: "agent:main:first", nowMs: T0 }); |
| 64 | + const second = mintAttachGrant({ sessionKey: "agent:main:first", nowMs: T0 }); |
| 65 | + const other = mintAttachGrant({ sessionKey: "agent:main:other", nowMs: T0 }); |
| 66 | + |
| 67 | + expect(revokeAttachGrantsForSession(" agent:main:first ")).toBe(2); |
| 68 | + expect(resolveAttachGrant(first.token, T0)).toBeUndefined(); |
| 69 | + expect(resolveAttachGrant(second.token, T0)).toBeUndefined(); |
| 70 | + expect(resolveAttachGrant(other.token, T0)?.sessionKey).toBe("agent:main:other"); |
| 71 | + }); |
| 72 | + |
61 | 73 | it("clamps TTL: default for non-positive, ceiling at 12h", () => { |
62 | 74 | const def = mintAttachGrant({ sessionKey: "s", nowMs: T0 }); |
63 | 75 | expect(def.expiresAtMs).toBe(T0 + 60 * 60 * 1000); |
|
0 commit comments