From 4e1f7841151494ec176cbbdb530120a2b750923c Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 8 Nov 2026 13:17:51 -0800 Subject: [PATCH] Plug-ins: a module without a grant gets no settings or cache kept for its id The test for a changed module under a granted id now checks that the next start, a folder load and a refused install leave the id's settings and cache unattached. --- crates/engine/src/tests/plugins.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/engine/src/tests/plugins.rs b/crates/engine/src/tests/plugins.rs index 61d864142..096d6e5d1 100644 --- a/crates/engine/src/tests/plugins.rs +++ b/crates/engine/src/tests/plugins.rs @@ -1030,18 +1030,25 @@ fn a_grant_covers_only_the_module_it_was_given_to() { std::fs::write(&stored[0], &other).unwrap(); vectorcraft_plugins::registry::remove(id); vectorcraft_plugins::registry::revoke(id); + vectorcraft_plugins::registry::set_storage(id, None); + let no_storage = |how: &str| { + assert!(vectorcraft_plugins::registry::storage(id).is_none(), "{how} gives another module the id's settings and cache"); + }; let mut next = session(); next.attach_plugin_store(folder.0.clone()); assert!(vectorcraft_plugins::registry::get(id).is_none(), "another module isn't loaded under the grant"); + no_storage("the next start"); let dir = crate::tests_links::Folder::new("plugin-folder-grant-hash"); std::fs::write(dir.0.join("other.wasm"), &other).unwrap(); let r = run(&mut next, "plugin.reload", json!({"path": dir.0.display().to_string()})); assert_eq!(r["loaded"], json!([])); let why = r["failed"][0]["error"].as_str().unwrap(); assert!(why.contains("needs approval"), "{why}"); + no_storage("a folder load"); let data = vectorcraft_format::base64_encode(&other); let e = next.execute("plugin.install", &json!({"dataBase64": data, "replace": true})).unwrap_err().to_string(); assert!(e.contains("`grant`"), "{e}"); + no_storage("a refused install"); // Granted, it reads the settings the first module set. run(&mut next, "plugin.install", json!({"dataBase64": data, "grant": ["settings", "cache"], "replace": true})); run(&mut next, "plugin.run", json!({"id": id, "ids": []}));