Address review of host pairing

Revoking a host now unassigns its instances instead of being refused
while it has any, and removes its system metrics.

Approving and revoking no longer force a save. Hosts are saved by
autosave and on exit like everything else, which also removes the
approving state from pairing requests.

The approval code and link are logged as warnings so they show up in
the systemd service, which only prints warnings and above. The pairing
limits are now the controller.host_pairing_timeout and
controller.host_pairing_max_pending config values, 0 removes the limit.

Subscribers take an optional permitted function, used for the pairing
requests instead of overrides in a subclass.
This commit is contained in:
Danielv123 committed 2026-10-31 16:31:45 +01:00
1 parent e5701a8dae
commit 49a0b27d29
29 files changed
+356 -418

No files matched your search

+30
View File
@@ -1250,6 +1250,36 @@ describe("lib/subscriptions", function() {
});
});
describe("permitted", function() {
let permitted;
let subscriber;
beforeEach(function() {
mockControl = new MockControl(new MockConnector(addr({ controlId: 0 }), addr("controller")));
permitted = false;
subscriber = new lib.EventSubscriber(RegisteredEvent, mockControl, undefined, () => permitted);
});
it("should send nothing while not permitted", async function() {
subscriber.subscribe(() => {});
mockControl.connector.emit("connect");
subscriber.handleConnectionEvent("resume");
subscriber.handleAccountEvent();
await new Promise(r => setImmediate(r));
assertNoMessageSent();
});
it("should subscribe when the account becomes permitted", async function() {
subscriber.subscribe(() => {});
permitted = true;
subscriber.handleAccountEvent();
await onceConnectorSend();
assertLastMessage(new lib.SubscriptionRequest(
RegisteredEvent.name, "replace", -1, lib.SubscriptionFilters.all()
));
});
});
describe(".handleAccountEvent()", function() {
it("should send replace(all) if subscribed", async function() {
eventSubscriber.subscribe(() => {});