Skip to content

Commit 8682a9a

Browse files
committed
Reproduce revoked grant re-seeding from corrupt path-trust store
1 parent a76f1c6 commit 8682a9a

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

‎tests/unit/path-trust.test.ts‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,35 @@ describe("path-trust (global)", () => {
278278
}
279279
});
280280

281+
test("revoke then corrupt: migration refuses to re-grant and leaves the store invalid", async () => {
282+
const { home, cleanup } = await scratch();
283+
try {
284+
const plugin = join(home, "shared", "plugin");
285+
await trustPathPlugin(plugin, home);
286+
await revokePathPlugin(plugin, home);
287+
expect((await readPathTrustStore(home)).state).toBe("valid");
288+
289+
await writeStoreFile(home, "{not json");
290+
expect((await readPathTrustStore(home)).state).toBe("invalid");
291+
292+
let resolveCalls = 0;
293+
const store = await migratePathTrustFromPluginPaths(
294+
[plugin],
295+
async (p) => {
296+
resolveCalls += 1;
297+
return [p];
298+
},
299+
home,
300+
);
301+
expect(isPathPluginTrusted(store, plugin)).toBe(false);
302+
expect(store.trustedPluginPaths).toEqual([]);
303+
expect(resolveCalls).toBe(0);
304+
expect((await readPathTrustStore(home)).state).toBe("invalid");
305+
} finally {
306+
await cleanup();
307+
}
308+
});
309+
281310
test("non-absolute stored entries are rejected at load", async () => {
282311
const { home, cleanup } = await scratch();
283312
try {

0 commit comments

Comments
 (0)