mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-16 15:30:41 +09:00
Add update all for the controller, hosts and plugins
Updating a single plugin can leave the installation with multiple versions of @clusterio/lib. Passing the core package and every npm installed plugin to a single npm update call lets npm resolve them together. UpdateAllRequest targets the controller or a host, requires both the core update permission and core.plugin.update, and is gated by both allow_remote_updates and allow_plugin_updates. The web UI Updates modal gets an Update All action and ctl gets --all on the update commands. Closes #910 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
7987a5d925
commit
7ff2092547
11 files changed
+158
-7
No files matched your search
@@ -29,6 +29,20 @@ describe("rce_ops", function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe("handleUpdateAll", function() {
|
||||
it("updates the core package and all npm plugins in one command", async function() {
|
||||
const _audit = lib.logger.audit;
|
||||
const messages = [];
|
||||
lib.logger.audit = (msg) => { messages.push(msg); };
|
||||
try {
|
||||
await lib.handleUpdateAll("core", [{ npmPackage: "foo" }, { name: "local" }, { npmPackage: "bar" }]);
|
||||
} finally {
|
||||
lib.logger.audit = _audit;
|
||||
}
|
||||
assert.deepEqual(messages, ["RCE | npm update --save core foo bar"]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("handlePluginInstall", function() {
|
||||
const _fetch = global.fetch;
|
||||
before(function() {
|
||||
|
||||
@@ -134,6 +134,61 @@ describe("messages/plugin", function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe("UpdateAllRequest", function() {
|
||||
function checkedPermissions(dst) {
|
||||
const permissions = [];
|
||||
const user = { checkPermission(permission) { permissions.push(permission); } };
|
||||
lib.UpdateAllRequest.permission(user, { dst: lib.Address.fromShorthand(dst) });
|
||||
return permissions;
|
||||
}
|
||||
it("requires controller and plugin update permissions on the controller", function() {
|
||||
assert.deepEqual(checkedPermissions("controller"), ["core.controller.update", "core.plugin.update"]);
|
||||
});
|
||||
it("requires host and plugin update permissions on a host", function() {
|
||||
assert.deepEqual(checkedPermissions({ hostId: 1 }), ["core.host.update", "core.plugin.update"]);
|
||||
});
|
||||
it("runs on the controller", async function() {
|
||||
controller.pluginInfos = [{ npmPackage: "foo" }];
|
||||
controller.config.set("controller.allow_remote_updates", true);
|
||||
controller.config.set("controller.allow_plugin_updates", true);
|
||||
await controlConnection.handleUpdateAllRequest(new lib.UpdateAllRequest());
|
||||
});
|
||||
it("rejects if remote updates are disabled on the controller", async function() {
|
||||
controller.config.set("controller.allow_remote_updates", false);
|
||||
await assert.rejects(
|
||||
controlConnection.handleUpdateAllRequest(new lib.UpdateAllRequest()),
|
||||
/Remote updates are disabled on this machine/
|
||||
);
|
||||
});
|
||||
it("rejects if plugin updates are disabled on the controller", async function() {
|
||||
controller.config.set("controller.allow_plugin_updates", false);
|
||||
await assert.rejects(
|
||||
controlConnection.handleUpdateAllRequest(new lib.UpdateAllRequest()),
|
||||
/Plugin updates are disabled on this machine/
|
||||
);
|
||||
});
|
||||
it("runs on a host", async function() {
|
||||
host.pluginInfos = [{ npmPackage: "foo" }];
|
||||
host.config.set("host.allow_remote_updates", true);
|
||||
host.config.set("host.allow_plugin_updates", true);
|
||||
await host.handleUpdateAllRequest(new lib.UpdateAllRequest());
|
||||
});
|
||||
it("rejects if remote updates are disabled on the host", async function() {
|
||||
host.config.set("host.allow_remote_updates", false);
|
||||
await assert.rejects(
|
||||
host.handleUpdateAllRequest(new lib.UpdateAllRequest()),
|
||||
/Remote updates are disabled on this machine/
|
||||
);
|
||||
});
|
||||
it("rejects if plugin updates are disabled on the host", async function() {
|
||||
host.config.set("host.allow_plugin_updates", false);
|
||||
await assert.rejects(
|
||||
host.handleUpdateAllRequest(new lib.UpdateAllRequest()),
|
||||
/Plugin updates are disabled on this machine/
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("PluginInstallRequest", function() {
|
||||
const _fetch = global.fetch;
|
||||
before(function() {
|
||||
|
||||
Reference in new issue
Block a user