mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-18 15:33:12 +09:00
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:
29 files changed
+356
-418
No files matched your search
@@ -326,16 +326,9 @@ describe("controller/src/ControlConnection", function() {
|
||||
await connection.handleHostRevokeRequest(new lib.HostRevokeRequest(hostId));
|
||||
}
|
||||
|
||||
it("deletes and saves the host record", async function() {
|
||||
let savedWithoutHost;
|
||||
const originalSave = controller.hosts.save;
|
||||
controller.hosts.save = async function() {
|
||||
savedWithoutHost = !this.has(10);
|
||||
return await originalSave.call(this);
|
||||
};
|
||||
it("deletes the host record", async function() {
|
||||
await revoke();
|
||||
assert.equal(controller.hosts.has(10), false);
|
||||
assert.equal(savedWithoutHost, true, "hosts were not saved after deleting the record");
|
||||
assert.deepEqual(broadcasts, [{ id: 10, isDeleted: true }]);
|
||||
assert.equal(audits.length, 1);
|
||||
assert.match(audits[0], /User admin revoked host host-10 \(10\)/);
|
||||
@@ -356,15 +349,6 @@ describe("controller/src/ControlConnection", function() {
|
||||
await revoke();
|
||||
assert.equal(terminated, true);
|
||||
});
|
||||
it("terminates the connection of the host when saving fails", async function() {
|
||||
let terminated = false;
|
||||
controller.wsServer.hostConnections.set(10, { connector: { terminate() { terminated = true; } } });
|
||||
controller.hosts.save = async () => { throw new Error("EPERM: operation not permitted"); };
|
||||
await assert.rejects(revoke(), /EPERM/);
|
||||
assert.equal(terminated, true, "revoked host kept its connection");
|
||||
assert.equal(controller.hosts.has(10), false);
|
||||
assert.equal(controller.notes.get("host/10"), undefined);
|
||||
});
|
||||
it("does not leave a host record behind when the connection closes", async function() {
|
||||
const connector = new MockConnector(addr("controller"), addr({ hostId: 10 }));
|
||||
connector.terminate = () => { connector.emit("close"); };
|
||||
@@ -378,27 +362,31 @@ describe("controller/src/ControlConnection", function() {
|
||||
assert.equal(controller.hosts.has(10), false, "host record was recreated");
|
||||
assert.deepEqual(broadcasts.at(-1), { id: 10, isDeleted: true });
|
||||
});
|
||||
it("refuses to revoke a host with assigned instances", async function() {
|
||||
controller.setNote("host", "10", "rack 3", "someone");
|
||||
let terminated = false;
|
||||
controller.wsServer.hostConnections.set(10, { connector: { terminate() { terminated = true; } } });
|
||||
it("unassigns the instances of the host without waiting for it", async function() {
|
||||
let closing = false;
|
||||
controller.wsServer.hostConnections.set(10, {
|
||||
connector: { terminate() { closing = true; }, get closing() { return closing; } },
|
||||
send: () => new Promise(() => {}),
|
||||
});
|
||||
assignInstance(101, "alpha", 10);
|
||||
assignInstance(102, "beta", 10);
|
||||
assignInstance(201, "gamma", 20);
|
||||
|
||||
await assert.rejects(
|
||||
revoke(),
|
||||
new lib.ConflictError("Cannot revoke host host-10 while instances are assigned to it: alpha, beta"),
|
||||
);
|
||||
assert.equal(controller.hosts.get(10), record);
|
||||
assert.equal(controller.notes.get("host/10").isDeleted, false);
|
||||
assert.equal(terminated, false);
|
||||
assert.deepEqual(broadcasts, []);
|
||||
});
|
||||
it("ignores instances assigned to other hosts", async function() {
|
||||
assignInstance(201, "gamma", 20);
|
||||
await revoke();
|
||||
assert.equal(controller.hosts.has(10), false);
|
||||
for (const id of [101, 102]) {
|
||||
const instance = controller.instances.get(id);
|
||||
assert.equal(instance.config.get("instance.assigned_host"), null);
|
||||
assert.equal(instance.status, "unassigned");
|
||||
}
|
||||
assert.equal(controller.instances.get(201).config.get("instance.assigned_host"), 20);
|
||||
});
|
||||
it("removes the system metrics of the host", async function() {
|
||||
controller.systems.set(await lib.gatherSystemInfo(10, false, false, 0));
|
||||
controller.systems.set(await lib.gatherSystemInfo("controller", false, false, 0));
|
||||
await revoke();
|
||||
assert.equal(controller.systems.has(10), false);
|
||||
assert.equal(controller.systems.has("controller"), true);
|
||||
});
|
||||
it("throws NotFoundError for an unknown host", async function() {
|
||||
await assert.rejects(revoke(99), new lib.NotFoundError("Unknown host id (99)"));
|
||||
@@ -421,7 +409,7 @@ describe("controller/src/ControlConnection", function() {
|
||||
const rejected = controller.hostPairing.create("Host C", "", "10.0.0.3");
|
||||
const pending = controller.hostPairing.create("Host D", "", "10.0.0.4");
|
||||
controller.hostPairing._bySecret.get(expired.requestId).lastPollMs -= 60e3;
|
||||
await controller.hostPairing.approve(approved.code, undefined, "admin");
|
||||
controller.hostPairing.approve(approved.code, undefined, "admin");
|
||||
controller.hostPairing.reject(rejected.code, "admin");
|
||||
|
||||
const list = await connection.handleHostPairingListRequest(new lib.HostPairingListRequest());
|
||||
@@ -440,7 +428,7 @@ describe("controller/src/ControlConnection", function() {
|
||||
it("rejects a request", async function() {
|
||||
const { requestId, code } = controller.hostPairing.create("Host A", "", "10.0.0.1");
|
||||
await connection.handleHostPairingRejectRequest(new lib.HostPairingRejectRequest(code.toLowerCase()));
|
||||
assert.equal(controller.hostPairing.requests.has(code), false);
|
||||
assert.equal(controller.hostPairing.records.has(code), false);
|
||||
assert.throws(() => controller.hostPairing.poll(requestId), /Request was rejected/);
|
||||
assert.equal(controller.hosts.size, 0);
|
||||
assert(audits.some(msg => msg.startsWith(`User admin rejected host Host A with code ${code}`)));
|
||||
|
||||
@@ -5,8 +5,7 @@ import jwt from "jsonwebtoken";
|
||||
import * as lib from "@clusterio/lib";
|
||||
import { Controller, HostPairingManager, HostPairingError, HostRecord } from "@clusterio/controller";
|
||||
import {
|
||||
pollTimeoutMs, maxPendingMs, maxPending, maxPendingPerAddress,
|
||||
maxNameLength,
|
||||
pollTimeoutMs, maxPendingPerAddress, maxNameLength,
|
||||
} from "@clusterio/controller/dist/node/src/HostPairingManager.js";
|
||||
|
||||
import "../setup_logging.js";
|
||||
@@ -31,12 +30,6 @@ function stubRandomInt(values) {
|
||||
return () => { crypto.randomInt = original; };
|
||||
}
|
||||
|
||||
function deferred() {
|
||||
let resolve, reject;
|
||||
const promise = new Promise((res, rej) => { resolve = res; reject = rej; });
|
||||
return { promise, resolve, reject };
|
||||
}
|
||||
|
||||
function assertPairingError(fn, status, message) {
|
||||
assert.throws(fn, err => {
|
||||
assert(err instanceof HostPairingError, `expected HostPairingError, got ${err}`);
|
||||
@@ -95,7 +88,7 @@ describe("controller/src/HostPairingManager", function() {
|
||||
controller = makeController();
|
||||
manager = controller.hostPairing;
|
||||
updates = [];
|
||||
manager.requests.on("update", changed => {
|
||||
manager.records.on("update", changed => {
|
||||
updates.push(...changed.map(details => ({ code: details.code, isDeleted: details.isDeleted })));
|
||||
});
|
||||
restoreRandomInt = undefined;
|
||||
@@ -111,15 +104,15 @@ describe("controller/src/HostPairingManager", function() {
|
||||
return manager._bySecret.get(requestId);
|
||||
}
|
||||
|
||||
// Pretend the installer last polled the request ms milliseconds earlier.
|
||||
// Pretend the host last polled the request ms milliseconds earlier.
|
||||
function idle(requestId, ms) {
|
||||
internal(requestId).lastPollMs -= ms;
|
||||
}
|
||||
|
||||
describe(".createHost()", function() {
|
||||
it("should create a host record with a valid token", async function() {
|
||||
it("should create a host record with a valid token", function() {
|
||||
const before = Math.floor(Date.now() / 1000);
|
||||
const result = await manager.createHost("Host A");
|
||||
const result = manager.createHost("Host A");
|
||||
|
||||
assert.equal(result.name, "Host A");
|
||||
assert(Number.isInteger(result.hostId), "hostId is not an integer");
|
||||
@@ -136,31 +129,10 @@ describe("controller/src/HostPairingManager", function() {
|
||||
assert.equal(payload.host, result.hostId);
|
||||
assert(payload.iat >= record.tokenValidAfter, "token is not valid for the new record");
|
||||
});
|
||||
it("should save the hosts before returning", async function() {
|
||||
const save = deferred();
|
||||
let saveCalls = 0;
|
||||
controller.hosts.save = () => { saveCalls += 1; return save.promise; };
|
||||
|
||||
let done = false;
|
||||
const promise = manager.createHost("Host A").then(result => { done = true; return result; });
|
||||
await new Promise(resolve => setImmediate(resolve));
|
||||
assert.equal(saveCalls, 1);
|
||||
assert.equal(done, false, "createHost returned before the hosts were saved");
|
||||
save.resolve();
|
||||
const result = await promise;
|
||||
assert(controller.hosts.has(result.hostId));
|
||||
});
|
||||
it("should remove the record if saving fails", async function() {
|
||||
restoreRandomInt = stubRandomInt([1234]);
|
||||
controller.hosts.save = async () => { throw new Error("disk full"); };
|
||||
await assert.rejects(manager.createHost("Host A"), /disk full/);
|
||||
assert.equal(controller.hosts.has(1234), false);
|
||||
assert.equal(controller.hosts.size, 0);
|
||||
});
|
||||
it("should not reuse the id of an existing host", async function() {
|
||||
it("should not reuse the id of an existing host", function() {
|
||||
controller.hosts.set(new HostRecord(5, "existing", "", new Map()));
|
||||
restoreRandomInt = stubRandomInt([5, 5, 6]);
|
||||
const result = await manager.createHost("Host A");
|
||||
const result = manager.createHost("Host A");
|
||||
assert.equal(result.hostId, 6);
|
||||
assert.equal(controller.hosts.get(5).name, "existing");
|
||||
assert.equal(controller.hosts.get(6).name, "Host A");
|
||||
@@ -177,7 +149,7 @@ describe("controller/src/HostPairingManager", function() {
|
||||
assert.match(code, codePattern);
|
||||
assert.notEqual(requestId, code);
|
||||
|
||||
const details = manager.requests.get(code);
|
||||
const details = manager.records.get(code);
|
||||
assert(details instanceof lib.HostPairingDetails);
|
||||
assert.equal(details.code, code);
|
||||
assert.equal(details.name, "Host A");
|
||||
@@ -191,23 +163,23 @@ describe("controller/src/HostPairingManager", function() {
|
||||
});
|
||||
it("should create unique codes", function() {
|
||||
const codes = new Set();
|
||||
for (let i = 0; i < maxPending; i++) {
|
||||
for (let i = 0; i < 50; i++) {
|
||||
const { code } = manager.create(`Host ${i}`, "", `10.1.${i}.1`);
|
||||
assert.match(code, codePattern);
|
||||
codes.add(code);
|
||||
}
|
||||
assert.equal(codes.size, maxPending);
|
||||
assert.equal(codes.size, 50);
|
||||
});
|
||||
it("should not reuse the code of a pending request", function() {
|
||||
restoreRandomInt = stubRandomInt([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1]);
|
||||
assert.equal(manager.create("Host A", "", "10.0.0.1").code, "222-222");
|
||||
assert.equal(manager.create("Host B", "", "10.0.0.2").code, "333-333");
|
||||
});
|
||||
it("should not reuse the code of an approved request not yet picked up", async function() {
|
||||
it("should not reuse the code of an approved request not yet picked up", function() {
|
||||
restoreRandomInt = stubRandomInt([0, 0, 0, 0, 0, 0, 1234, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1]);
|
||||
const { code } = manager.create("Host A", "", "10.0.0.1");
|
||||
assert.equal(code, "222-222");
|
||||
assert.equal(await manager.approve(code, undefined, "admin"), 1234);
|
||||
assert.equal(manager.approve(code, undefined, "admin"), 1234);
|
||||
assert.equal(manager.create("Host B", "", "10.0.0.2").code, "333-333");
|
||||
});
|
||||
});
|
||||
@@ -227,7 +199,7 @@ describe("controller/src/HostPairingManager", function() {
|
||||
});
|
||||
// Other addresses are not affected
|
||||
manager.create("Host", "", "10.0.0.2");
|
||||
assert.equal(manager.requests.size, maxPendingPerAddress + 1);
|
||||
assert.equal(manager.records.size, maxPendingPerAddress + 1);
|
||||
});
|
||||
it("should count IPv4 mapped addresses as the IPv4 address", function() {
|
||||
manager.create("Host", "", "10.0.0.1");
|
||||
@@ -245,7 +217,7 @@ describe("controller/src/HostPairingManager", function() {
|
||||
);
|
||||
manager.create("Host", "", "2001:db8:0:2::1");
|
||||
});
|
||||
it("should free the slot when a request is no longer pending", async function() {
|
||||
it("should free the slot when a request is no longer pending", function() {
|
||||
const first = manager.create("Host", "", "10.0.0.1");
|
||||
const second = manager.create("Host", "", "10.0.0.1");
|
||||
const third = manager.create("Host", "", "10.0.0.1");
|
||||
@@ -256,14 +228,15 @@ describe("controller/src/HostPairingManager", function() {
|
||||
assertPairingError(() => manager.create("Host", "", "10.0.0.1"), 429);
|
||||
|
||||
// Approved and rejected results waiting to be picked up do not count
|
||||
await manager.approve(second.code, undefined, "admin");
|
||||
manager.approve(second.code, undefined, "admin");
|
||||
manager.reject(third.code, "admin");
|
||||
manager.create("Host", "", "10.0.0.1");
|
||||
manager.create("Host", "", "10.0.0.1");
|
||||
assertPairingError(() => manager.create("Host", "", "10.0.0.1"), 429);
|
||||
assert(manager.requests.has(fourth.code));
|
||||
assert(manager.records.has(fourth.code));
|
||||
});
|
||||
it("should limit the total number of pending requests", function() {
|
||||
const maxPending = controller.config.get("controller.host_pairing_max_pending");
|
||||
assert.equal(maxPending, 50);
|
||||
for (let i = 0; i < maxPending; i++) {
|
||||
manager.create(`Host ${i}`, "", `10.1.${i}.1`);
|
||||
@@ -275,7 +248,14 @@ describe("controller/src/HostPairingManager", function() {
|
||||
assert.equal(err.message, "Too many pending requests");
|
||||
return true;
|
||||
});
|
||||
assert.equal(manager.requests.size, maxPending);
|
||||
assert.equal(manager.records.size, maxPending);
|
||||
});
|
||||
it("should not limit the total number of pending requests when set to 0", function() {
|
||||
controller.config.set("controller.host_pairing_max_pending", 0);
|
||||
for (let i = 0; i < 60; i++) {
|
||||
manager.create(`Host ${i}`, "", `10.1.${i}.1`);
|
||||
}
|
||||
assert.equal(manager.records.size, 60);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -292,9 +272,9 @@ describe("controller/src/HostPairingManager", function() {
|
||||
const { code } = manager.create("Host A", "", "10.0.0.1");
|
||||
assertPairingError(() => manager.poll(code), 404);
|
||||
});
|
||||
it("should hand over an approved result once", async function() {
|
||||
it("should hand over an approved result once", function() {
|
||||
const { requestId, code } = manager.create("Host A", "", "10.0.0.1");
|
||||
const hostId = await manager.approve(code, undefined, "admin");
|
||||
const hostId = manager.approve(code, undefined, "admin");
|
||||
const result = manager.poll(requestId);
|
||||
assert.deepEqual(Object.keys(result).sort(), ["hostId", "name", "token"]);
|
||||
assert.equal(result.hostId, hostId);
|
||||
@@ -317,7 +297,7 @@ describe("controller/src/HostPairingManager", function() {
|
||||
it("should remove a pending request", function() {
|
||||
const { requestId, code } = manager.create("Host A", "", "10.0.0.1");
|
||||
manager.cancel(requestId);
|
||||
assert.equal(manager.requests.has(code), false);
|
||||
assert.equal(manager.records.has(code), false);
|
||||
assertPairingError(() => manager.poll(requestId), 404);
|
||||
assert.deepEqual(updates, [{ code, isDeleted: false }, { code, isDeleted: true }]);
|
||||
assert.throws(() => manager.reject(code, "admin"), lib.NotFoundError);
|
||||
@@ -325,9 +305,9 @@ describe("controller/src/HostPairingManager", function() {
|
||||
it("should ignore unknown requests", function() {
|
||||
manager.cancel("invalid");
|
||||
});
|
||||
it("should not throw away an approved result", async function() {
|
||||
it("should not throw away an approved result", function() {
|
||||
const { requestId, code } = manager.create("Host A", "", "10.0.0.1");
|
||||
const hostId = await manager.approve(code, undefined, "admin");
|
||||
const hostId = manager.approve(code, undefined, "admin");
|
||||
manager.cancel(requestId);
|
||||
assert.equal(manager.poll(requestId).hostId, hostId);
|
||||
});
|
||||
@@ -340,92 +320,58 @@ describe("controller/src/HostPairingManager", function() {
|
||||
});
|
||||
|
||||
describe(".approve()", function() {
|
||||
it("should create the host with the requested name", async function() {
|
||||
it("should create the host with the requested name", function() {
|
||||
const { code } = manager.create("Host A", "", "10.0.0.1");
|
||||
const hostId = await manager.approve(code, undefined, "admin");
|
||||
const hostId = manager.approve(code, undefined, "admin");
|
||||
assert.equal(controller.hosts.get(hostId).name, "Host A");
|
||||
assert.equal(manager.requests.has(code), false);
|
||||
assert.equal(manager.records.has(code), false);
|
||||
assert.deepEqual(updates, [{ code, isDeleted: false }, { code, isDeleted: true }]);
|
||||
});
|
||||
it("should accept codes in any case and without the dash", async function() {
|
||||
it("should accept codes in any case and without the dash", function() {
|
||||
const { code } = manager.create("Host A", "", "10.0.0.1");
|
||||
const hostId = await manager.approve(code.toLowerCase().replace("-", ""), undefined, "admin");
|
||||
const hostId = manager.approve(code.toLowerCase().replace("-", ""), undefined, "admin");
|
||||
assert(controller.hosts.has(hostId));
|
||||
});
|
||||
it("should use and trim the name given", async function() {
|
||||
it("should use and trim the name given", function() {
|
||||
const { requestId, code } = manager.create("Host A", "", "10.0.0.1");
|
||||
const hostId = await manager.approve(code, " Renamed ", "admin");
|
||||
const hostId = manager.approve(code, " Renamed ", "admin");
|
||||
assert.equal(controller.hosts.get(hostId).name, "Renamed");
|
||||
assert.equal(manager.poll(requestId).name, "Renamed");
|
||||
});
|
||||
it("should reject an invalid name and keep the request pending", async function() {
|
||||
it("should reject an invalid name and keep the request pending", function() {
|
||||
const { requestId, code } = manager.create("Host A", "", "10.0.0.1");
|
||||
await assert.rejects(
|
||||
manager.approve(code, "", "admin"),
|
||||
assert.throws(
|
||||
() => manager.approve(code, "", "admin"),
|
||||
new lib.ValidationError("Host name is required"),
|
||||
);
|
||||
await assert.rejects(
|
||||
manager.approve(code, "x".repeat(maxNameLength + 1), "admin"),
|
||||
assert.throws(
|
||||
() => manager.approve(code, "x".repeat(maxNameLength + 1), "admin"),
|
||||
new lib.ValidationError("Host name must be at most 100 characters"),
|
||||
);
|
||||
assert.equal(controller.hosts.size, 0);
|
||||
assert.equal(manager.poll(requestId), null);
|
||||
await manager.approve(code, undefined, "admin");
|
||||
manager.approve(code, undefined, "admin");
|
||||
assert.equal(controller.hosts.size, 1);
|
||||
});
|
||||
it("should throw NotFoundError for an unknown code", async function() {
|
||||
await assert.rejects(
|
||||
manager.approve("ZZZ-ZZZ", undefined, "admin"),
|
||||
it("should throw NotFoundError for an unknown code", function() {
|
||||
assert.throws(
|
||||
() => manager.approve("ZZZ-ZZZ", undefined, "admin"),
|
||||
new lib.NotFoundError("No pending host request with code ZZZ-ZZZ"),
|
||||
);
|
||||
});
|
||||
it("should only approve a request once", async function() {
|
||||
it("should only approve a request once", function() {
|
||||
const { code } = manager.create("Host A", "", "10.0.0.1");
|
||||
await manager.approve(code, undefined, "admin");
|
||||
await assert.rejects(manager.approve(code, undefined, "admin"), lib.NotFoundError);
|
||||
manager.approve(code, undefined, "admin");
|
||||
assert.throws(() => manager.approve(code, undefined, "admin"), lib.NotFoundError);
|
||||
assert.equal(controller.hosts.size, 1);
|
||||
});
|
||||
it("should not create two hosts when approved twice at the same time", async function() {
|
||||
const save = deferred();
|
||||
controller.hosts.save = () => save.promise;
|
||||
const { requestId, code } = manager.create("Host A", "", "10.0.0.1");
|
||||
|
||||
const first = manager.approve(code, undefined, "admin");
|
||||
await assert.rejects(manager.approve(code, undefined, "admin"), lib.NotFoundError);
|
||||
assert.throws(() => manager.reject(code, "admin"), lib.NotFoundError);
|
||||
|
||||
// The request stays while approving, the installer sees it as pending
|
||||
manager.cancel(requestId);
|
||||
idle(requestId, pollTimeoutMs + 1);
|
||||
manager.prune();
|
||||
assert.equal(manager.poll(requestId), null);
|
||||
assert(manager.requests.has(code), "request removed while approving");
|
||||
|
||||
save.resolve();
|
||||
const hostId = await first;
|
||||
assert.equal(controller.hosts.size, 1);
|
||||
assert.equal(manager.poll(requestId).hostId, hostId);
|
||||
});
|
||||
it("should keep the request pending if creating the host fails", async function() {
|
||||
const { requestId, code } = manager.create("Host A", "", "10.0.0.1");
|
||||
const originalSave = controller.hosts.save;
|
||||
controller.hosts.save = async () => { throw new Error("disk full"); };
|
||||
await assert.rejects(manager.approve(code, undefined, "admin"), /disk full/);
|
||||
assert.equal(controller.hosts.size, 0);
|
||||
assert(manager.requests.has(code));
|
||||
assert.equal(manager.poll(requestId), null);
|
||||
|
||||
controller.hosts.save = originalSave;
|
||||
const hostId = await manager.approve(code, undefined, "admin");
|
||||
assert.equal(manager.poll(requestId).hostId, hostId);
|
||||
});
|
||||
});
|
||||
|
||||
describe(".reject()", function() {
|
||||
it("should remove the request from the pending list", function() {
|
||||
const { code } = manager.create("Host A", "", "10.0.0.1");
|
||||
manager.reject(code.toLowerCase(), "admin");
|
||||
assert.equal(manager.requests.has(code), false);
|
||||
assert.equal(manager.records.has(code), false);
|
||||
assert.deepEqual(updates, [{ code, isDeleted: false }, { code, isDeleted: true }]);
|
||||
assert.equal(controller.hosts.size, 0);
|
||||
});
|
||||
@@ -435,9 +381,9 @@ describe("controller/src/HostPairingManager", function() {
|
||||
new lib.NotFoundError("No pending host request with code ZZZ-ZZZ"),
|
||||
);
|
||||
});
|
||||
it("should not reject an approved request", async function() {
|
||||
it("should not reject an approved request", function() {
|
||||
const { requestId, code } = manager.create("Host A", "", "10.0.0.1");
|
||||
const hostId = await manager.approve(code, undefined, "admin");
|
||||
const hostId = manager.approve(code, undefined, "admin");
|
||||
assert.throws(() => manager.reject(code, "admin"), lib.NotFoundError);
|
||||
assert.equal(manager.poll(requestId).hostId, hostId);
|
||||
});
|
||||
@@ -455,11 +401,11 @@ describe("controller/src/HostPairingManager", function() {
|
||||
lib.logger.warn = originalWarn;
|
||||
});
|
||||
|
||||
it("should expire a request the installer stopped polling", function() {
|
||||
it("should expire a request the host stopped polling", function() {
|
||||
const { requestId, code } = manager.create("Host A", "", "10.0.0.1");
|
||||
idle(requestId, pollTimeoutMs + 1);
|
||||
manager.prune();
|
||||
assert.equal(manager.requests.has(code), false);
|
||||
assert.equal(manager.records.has(code), false);
|
||||
assert.deepEqual(updates, [{ code, isDeleted: false }, { code, isDeleted: true }]);
|
||||
assertPairingError(() => manager.poll(requestId), 404);
|
||||
assert.throws(() => manager.reject(code, "admin"), lib.NotFoundError);
|
||||
@@ -472,22 +418,31 @@ describe("controller/src/HostPairingManager", function() {
|
||||
assert.equal(manager.poll(requestId), null);
|
||||
idle(requestId, pollTimeoutMs - 1000);
|
||||
manager.prune();
|
||||
assert(manager.requests.has(code));
|
||||
assert(manager.records.has(code));
|
||||
});
|
||||
it("should expire a request that has been pending for too long", function() {
|
||||
assert.equal(maxPendingMs, 60 * 60e3);
|
||||
const timeoutMs = controller.config.get("controller.host_pairing_timeout") * 1000;
|
||||
assert.equal(timeoutMs, 60 * 60e3);
|
||||
const { requestId, code } = manager.create("Host A", "", "10.0.0.1");
|
||||
internal(requestId).details.createdAtMs -= maxPendingMs - 1000;
|
||||
internal(requestId).details.createdAtMs -= timeoutMs - 1000;
|
||||
manager.prune();
|
||||
assert.equal(manager.poll(requestId), null);
|
||||
internal(requestId).details.createdAtMs -= 1001;
|
||||
manager.prune();
|
||||
assert.equal(manager.requests.has(code), false);
|
||||
assert.equal(manager.records.has(code), false);
|
||||
assertPairingError(() => manager.poll(requestId), 404);
|
||||
});
|
||||
it("should drop and warn about an approved host never picked up", async function() {
|
||||
it("should not limit how long a request is pending when the timeout is 0", function() {
|
||||
controller.config.set("controller.host_pairing_timeout", 0);
|
||||
const { requestId, code } = manager.create("Host A", "", "10.0.0.1");
|
||||
const hostId = await manager.approve(code, undefined, "admin");
|
||||
internal(requestId).details.createdAtMs -= 365 * 24 * 60 * 60e3;
|
||||
manager.prune();
|
||||
assert(manager.records.has(code));
|
||||
assert.equal(manager.poll(requestId), null);
|
||||
});
|
||||
it("should drop and warn about an approved host never picked up", function() {
|
||||
const { requestId, code } = manager.create("Host A", "", "10.0.0.1");
|
||||
const hostId = manager.approve(code, undefined, "admin");
|
||||
idle(requestId, pollTimeoutMs + 1);
|
||||
manager.prune();
|
||||
assertPairingError(() => manager.poll(requestId), 404);
|
||||
@@ -526,7 +481,7 @@ describe("controller/src/HostPairingManager", function() {
|
||||
assert(event instanceof lib.HostPairingUpdatesEvent);
|
||||
assert.deepEqual(event.updates.map(details => details.code), [code]);
|
||||
|
||||
const lastUpdate = manager.requests.get(code).updatedAtMs;
|
||||
const lastUpdate = manager.records.get(code).updatedAtMs;
|
||||
assert.equal(await controller.handleHostPairingSubscription(
|
||||
new lib.SubscriptionRequest(lib.HostPairingUpdatesEvent.name, true, lastUpdate)
|
||||
), null);
|
||||
|
||||
+13
-13
@@ -254,7 +254,7 @@ describe("controller/src/routes", function() {
|
||||
}
|
||||
|
||||
function assertNothingCreated() {
|
||||
assert.equal(controller.hostPairing.requests.size, 0, "a pending request was created");
|
||||
assert.equal(controller.hostPairing.records.size, 0, "a pending request was created");
|
||||
assert.equal(controller.hosts.size, 0, "a host was created");
|
||||
}
|
||||
|
||||
@@ -267,7 +267,7 @@ describe("controller/src/routes", function() {
|
||||
assert.deepEqual(Object.keys(body).sort(), ["code", "requestId"]);
|
||||
assert.match(body.code, /^[2-9A-HJKMNP-Z]{3}-[2-9A-HJKMNP-Z]{3}$/);
|
||||
|
||||
const details = controller.hostPairing.requests.get(body.code);
|
||||
const details = controller.hostPairing.records.get(body.code);
|
||||
assert.equal(details.name, "Host A");
|
||||
assert.equal(details.version, "2.0.0");
|
||||
assert.match(details.remoteAddress, /127\.0\.0\.1|::1/);
|
||||
@@ -275,12 +275,12 @@ describe("controller/src/routes", function() {
|
||||
});
|
||||
it("should trim the name and limit the version", async function() {
|
||||
let { code } = await (await post("", { name: " Host A ", version: "x".repeat(100) })).json();
|
||||
let details = controller.hostPairing.requests.get(code);
|
||||
let details = controller.hostPairing.records.get(code);
|
||||
assert.equal(details.name, "Host A");
|
||||
assert.equal(details.version, "x".repeat(64));
|
||||
|
||||
({ code } = await (await post("", { name: "Host B", version: 5 })).json());
|
||||
details = controller.hostPairing.requests.get(code);
|
||||
details = controller.hostPairing.records.get(code);
|
||||
assert.equal(details.version, "");
|
||||
});
|
||||
it("should respond with 400 for a missing or invalid name", async function() {
|
||||
@@ -316,7 +316,7 @@ describe("controller/src/routes", function() {
|
||||
const response = await post("", { name: "Host A" });
|
||||
assert.equal(response.headers.get("retry-after"), "30");
|
||||
await assertResponse(response, 429, { error: "Too many pending requests from this address" });
|
||||
assert.equal(controller.hostPairing.requests.size, 3);
|
||||
assert.equal(controller.hostPairing.records.size, 3);
|
||||
});
|
||||
it("should respond with 503 in recovery mode", async function() {
|
||||
controller.recoveryMode = true;
|
||||
@@ -344,7 +344,7 @@ describe("controller/src/routes", function() {
|
||||
assert.equal(payload.host, body.hostId);
|
||||
}
|
||||
assert.equal(controller.hosts.size, 3);
|
||||
assert.equal(controller.hostPairing.requests.size, 0, "a pending request was created");
|
||||
assert.equal(controller.hostPairing.records.size, 0, "a pending request was created");
|
||||
});
|
||||
it("should validate the name before approving directly", async function() {
|
||||
await assertResponse(
|
||||
@@ -393,7 +393,7 @@ describe("controller/src/routes", function() {
|
||||
});
|
||||
it("should hand over the result of an approved request once", async function() {
|
||||
const { requestId, code } = await createRequest();
|
||||
const hostId = await controller.hostPairing.approve(code, "Renamed", "test");
|
||||
const hostId = controller.hostPairing.approve(code, "Renamed", "test");
|
||||
|
||||
const response = await post("/poll", { requestId });
|
||||
assert.equal(response.status, 200);
|
||||
@@ -438,14 +438,14 @@ describe("controller/src/routes", function() {
|
||||
it("should cancel a pending request", async function() {
|
||||
const { requestId, code } = await createRequest();
|
||||
await assertResponse(await post("/cancel", { requestId }), 204);
|
||||
assert.equal(controller.hostPairing.requests.has(code), false);
|
||||
assert.equal(controller.hostPairing.records.has(code), false);
|
||||
await assertResponse(await post("/poll", { requestId }), 404, { error: "Request not found" });
|
||||
});
|
||||
it("should respond with 204 for an unknown request", async function() {
|
||||
const { code } = await createRequest();
|
||||
await assertResponse(await post("/cancel", { requestId: "invalid" }), 204);
|
||||
await assertResponse(await post("/cancel", { requestId: code }), 204);
|
||||
assert(controller.hostPairing.requests.has(code), "cancelled by the code");
|
||||
assert(controller.hostPairing.records.has(code), "cancelled by the code");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -470,7 +470,7 @@ describe("controller/src/routes", function() {
|
||||
|
||||
describe("GET /api/host-pairing/check", function() {
|
||||
it("should respond with 200 for a valid host token", async function() {
|
||||
const { hostId, token } = await controller.hostPairing.createHost("Host A");
|
||||
const { hostId, token } = controller.hostPairing.createHost("Host A");
|
||||
for (const headers of [
|
||||
{ "Authorization": `Bearer ${token}` },
|
||||
{ "X-Access-Token": token },
|
||||
@@ -480,18 +480,18 @@ describe("controller/src/routes", function() {
|
||||
assert(controller.hosts.has(hostId));
|
||||
});
|
||||
it("should respond with 200 for a host token from before the slave rename", async function() {
|
||||
const { hostId } = await controller.hostPairing.createHost("Host A");
|
||||
const { hostId } = controller.hostPairing.createHost("Host A");
|
||||
const token = jwt.sign({ aud: "slave", slave: hostId }, controller.authSecret);
|
||||
await assertResponse(await check({ "Authorization": `Bearer ${token}` }), 200, { valid: true });
|
||||
});
|
||||
it("should respond with 401 without a valid host token", async function() {
|
||||
await controller.hostPairing.createHost("Host A");
|
||||
controller.hostPairing.createHost("Host A");
|
||||
assert.equal((await check({})).status, 401);
|
||||
assert.equal((await check({ "Authorization": "Bearer invalid" })).status, 401);
|
||||
assert.equal((await check({ "Authorization": `Bearer ${adminToken}` })).status, 401);
|
||||
});
|
||||
it("should respond with 401 once the host is revoked", async function() {
|
||||
const { hostId, token } = await controller.hostPairing.createHost("Host A");
|
||||
const { hostId, token } = controller.hostPairing.createHost("Host A");
|
||||
await assertResponse(await check({ "Authorization": `Bearer ${token}` }), 200, { valid: true });
|
||||
controller.hosts.delete(controller.hosts.get(hostId));
|
||||
assert.equal((await check({ "Authorization": `Bearer ${token}` })).status, 401);
|
||||
|
||||
+9
-2
@@ -179,7 +179,6 @@ describe("create installer CLI", function() {
|
||||
it("writes the host config and leaves joining the cluster to the host", async function() {
|
||||
const { stdout } = await run(hostArgs());
|
||||
assert.match(stdout, /Successfully installed host/);
|
||||
assert.match(stdout, /Start the host with run-host/);
|
||||
|
||||
const recorded = await commands();
|
||||
assert.match(recorded[0], /^npm(?:\.cmd)? install @clusterio\/host$/);
|
||||
@@ -208,7 +207,6 @@ describe("create installer CLI", function() {
|
||||
"--factorio-dir", "factorio", "--remote-npm", "--plugins",
|
||||
]);
|
||||
assert.match(stdout, /Successfully installed standalone/);
|
||||
assert.match(stdout, /Start the host with run-host/);
|
||||
|
||||
const recorded = await commands();
|
||||
for (const expected of [
|
||||
@@ -225,5 +223,14 @@ describe("create installer CLI", function() {
|
||||
}
|
||||
assert(!recorded.some(command => command.includes("host.controller_token")));
|
||||
});
|
||||
|
||||
it("uses the host name given for a standalone install", async function() {
|
||||
await fs.writeFile(path.join(directory, "config-controller.json"), "{}");
|
||||
await run([
|
||||
"--mode", "standalone", "--admin", "admin", "--http-port", "8123", "--public-address", "localhost",
|
||||
"--factorio-dir", "factorio", "--remote-npm", "--plugins", "--host-name", "Test Host",
|
||||
]);
|
||||
assert((await commands()).includes(hostSet("host.name", "Test Host")));
|
||||
});
|
||||
});
|
||||
});
|
||||
+40
-1
@@ -162,6 +162,22 @@ describe("host/src/pairing", function() {
|
||||
stub = await startStub();
|
||||
});
|
||||
|
||||
it("keeps polling while the controller is busy", async function() {
|
||||
const handler = approveAfter(0);
|
||||
let busy = 2;
|
||||
stub.handler = entry => {
|
||||
if (entry.url === "/api/host-pairing/poll" && busy > 0) {
|
||||
busy -= 1;
|
||||
return [503, { error: "Recovery mode" }];
|
||||
}
|
||||
return handler(entry);
|
||||
};
|
||||
const retries = [];
|
||||
const result = await pair({ onRetry: err => { retries.push(err.message); } });
|
||||
assert.deepEqual(result, approved);
|
||||
assert.deepEqual(retries, ["Recovery mode", "Recovery mode"]);
|
||||
});
|
||||
|
||||
it("throws when the request is rejected", async function() {
|
||||
const handler = approveAfter(Infinity);
|
||||
stub.handler = entry => (entry.url === "/api/host-pairing/poll" && stub.requests.length > 2
|
||||
@@ -248,8 +264,17 @@ describe("host/src/pairing", function() {
|
||||
it("waits for approval and saves the host when not paired", async function() {
|
||||
this.timeout(5000); // Polls at the default interval of 2 seconds
|
||||
stub.handler = approveAfter(0);
|
||||
await ensurePaired(config, { version: "2.1.0" });
|
||||
const warnings = [];
|
||||
const originalWarn = lib.logger.warn;
|
||||
lib.logger.warn = message => { warnings.push(message); };
|
||||
try {
|
||||
await ensurePaired(config, { version: "2.1.0" });
|
||||
} finally {
|
||||
lib.logger.warn = originalWarn;
|
||||
}
|
||||
assert.deepEqual(stub.requests[0].body, { name: "My Host", version: "2.1.0" });
|
||||
// The systemd service created by the installer only prints warnings and above.
|
||||
assert(warnings.includes(`${stub.url}hosts?approve=ABC-DE1`), "approval link is not a warning");
|
||||
const saved = await savedConfig();
|
||||
assert.equal(saved["host.id"], 1234);
|
||||
assert.equal(saved["host.name"], "Approved");
|
||||
@@ -284,6 +309,20 @@ describe("host/src/pairing", function() {
|
||||
assert(!JSON.stringify(saved).includes("user-token"), "user token must not be saved");
|
||||
});
|
||||
|
||||
it("stops when aborted while checking the saved token", async function() {
|
||||
config.set("host.controller_token", "some-token");
|
||||
const abort = new AbortController();
|
||||
stub.handler = () => {
|
||||
abort.abort();
|
||||
return new Promise(() => {});
|
||||
};
|
||||
await assert.rejects(
|
||||
ensurePaired(config, { version: "2.1.0", signal: abort.signal }),
|
||||
{ name: "AbortError" },
|
||||
);
|
||||
assert.equal(config.get("host.controller_token"), "some-token");
|
||||
});
|
||||
|
||||
it("keeps the saved token when it can't be checked", async function() {
|
||||
config.set("host.controller_token", "some-token");
|
||||
stub.handler = () => [404, undefined];
|
||||
|
||||
@@ -851,7 +851,7 @@ describe("Integration of Clusterio", function() {
|
||||
assert(!notes.some(note => note.id === `host/${pairing.hostId}`), "Note of the host was not removed");
|
||||
});
|
||||
|
||||
it("should refuse while instances are assigned to the host", async function() {
|
||||
it("should unassign the instances of the host", async function() {
|
||||
const pairing = await pairTestHost("assigned-host");
|
||||
// Instances can only be assigned to connected hosts, a link that accepts the assignment is enough.
|
||||
const connector = new TestHostConnector(url, 0.2);
|
||||
@@ -863,19 +863,17 @@ describe("Integration of Clusterio", function() {
|
||||
await execCtl("instance create revoke-assigned --id 45");
|
||||
try {
|
||||
await execCtl(`instance assign revoke-assigned ${pairing.hostId}`);
|
||||
await assert.rejects(
|
||||
execCtl(`host revoke ${pairing.hostId}`),
|
||||
/Cannot revoke host assigned-host while instances are assigned to it: revoke-assigned/,
|
||||
);
|
||||
connector.setClosing(); // Stops it from reconnecting after being revoked
|
||||
await execCtl(`host revoke ${pairing.hostId}`);
|
||||
|
||||
const hosts = await getControl().send(new lib.HostListRequest());
|
||||
assert(!hosts.some(host => host.id === pairing.hostId), "Host was not removed");
|
||||
const instance = await getControl().send(new lib.InstanceDetailsGetRequest(45));
|
||||
assert.equal(instance.assignedHost, undefined);
|
||||
assert.equal(instance.status, "unassigned");
|
||||
} finally {
|
||||
await connector.disconnect();
|
||||
await execCtl("instance assign revoke-assigned");
|
||||
await execCtl("instance delete revoke-assigned");
|
||||
}
|
||||
|
||||
await execCtl(`host revoke ${pairing.hostId}`);
|
||||
const hosts = await getControl().send(new lib.HostListRequest());
|
||||
assert(!hosts.some(host => host.id === pairing.hostId), "Host was not removed");
|
||||
});
|
||||
|
||||
it("should stop a running host and have it ask to join again when started", async function() {
|
||||
|
||||
@@ -311,22 +311,19 @@ export function spawn(name, cmd, waitFor, options = {}) {
|
||||
let process = child_process.spawn(parts[0], parts.slice(1), childOptions(options));
|
||||
let stdout = new LineSplitter({ readableObjectMode: true });
|
||||
let stderr = new LineSplitter({ readableObjectMode: true });
|
||||
let onDataOut = line => {
|
||||
let onData = line => {
|
||||
line = line.toString("utf8");
|
||||
if (waitFor.test(line)) {
|
||||
if (silent) {
|
||||
stdout.off("data", onDataOut);
|
||||
stderr.off("data", onDataErr);
|
||||
stdout.off("data", onData);
|
||||
stderr.off("data", onData);
|
||||
}
|
||||
resolve(process);
|
||||
}
|
||||
log(name, line);
|
||||
};
|
||||
let onDataErr = line => {
|
||||
log(name, line.toString("utf8"));
|
||||
};
|
||||
stdout.on("data", onDataOut);
|
||||
stderr.on("data", onDataErr);
|
||||
stdout.on("data", onData);
|
||||
stderr.on("data", onData);
|
||||
process.stdout.pipe(stdout);
|
||||
process.stderr.pipe(stderr);
|
||||
});
|
||||
|
||||
@@ -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(() => {});
|
||||
|
||||
@@ -176,6 +176,8 @@ export class MockController {
|
||||
["controller.auth_secret", "TestSecretDoNotUse"],
|
||||
["controller.proxy_stream_timeout", 1],
|
||||
["controller.metrics_timeout", 1],
|
||||
["controller.host_pairing_timeout", 3600],
|
||||
["controller.host_pairing_max_pending", 50],
|
||||
]);
|
||||
this.config = {
|
||||
get: (name) => {
|
||||
|
||||
@@ -12,13 +12,11 @@ const addr = lib.Address.fromShorthand;
|
||||
describe("web_ui/util/host_pairing", function() {
|
||||
describe("class HostPairingSubscriber", function() {
|
||||
let mockControl;
|
||||
let permitted;
|
||||
let subscriber;
|
||||
|
||||
beforeEach(function() {
|
||||
mockControl = new MockControl(new MockConnector(addr({ controlId: 0 }), addr("controller")));
|
||||
permitted = true;
|
||||
subscriber = new HostPairingSubscriber(mockControl, () => permitted);
|
||||
subscriber = new HostPairingSubscriber(mockControl, () => true);
|
||||
});
|
||||
|
||||
function pairing(code, updatedAtMs) {
|
||||
@@ -33,65 +31,6 @@ describe("web_ui/util/host_pairing", function() {
|
||||
return mockControl.connector.sentMessages.filter(message => message.name === "SubscriptionRequest");
|
||||
}
|
||||
|
||||
it("should not send requests on connect or account updates without permission", async function() {
|
||||
permitted = false;
|
||||
mockControl.connector.emit("connect");
|
||||
subscriber.handleConnectionEvent("resume");
|
||||
subscriber.handleAccountEvent();
|
||||
await settle();
|
||||
assert.deepEqual(sentRequests(), []);
|
||||
});
|
||||
|
||||
it("should resubscribe on connect with permission", async function() {
|
||||
subscriber.subscribe(() => {});
|
||||
await events.once(mockControl.connector, "send");
|
||||
mockControl.connector.sentMessages.length = 0;
|
||||
|
||||
mockControl.connector.emit("connect");
|
||||
await settle();
|
||||
assert.equal(sentRequests().length, 1);
|
||||
assert.deepEqual(sentRequests()[0].data, new lib.SubscriptionRequest(
|
||||
lib.HostPairingUpdatesEvent.name, "replace", -1, lib.SubscriptionFilters.all()
|
||||
));
|
||||
});
|
||||
|
||||
it("should resubscribe on account updates with permission", async function() {
|
||||
subscriber.subscribe(() => {});
|
||||
await events.once(mockControl.connector, "send");
|
||||
mockControl.connector.sentMessages.length = 0;
|
||||
|
||||
permitted = false;
|
||||
subscriber.handleAccountEvent();
|
||||
await settle();
|
||||
assert.deepEqual(sentRequests(), []);
|
||||
|
||||
permitted = true;
|
||||
subscriber.handleAccountEvent();
|
||||
await settle();
|
||||
assert.equal(sentRequests().length, 1);
|
||||
});
|
||||
|
||||
it("should clear requests when a new session starts", async function() {
|
||||
await subscriber._handleEvent(new lib.HostPairingUpdatesEvent([pairing("ABC-DEF", 10)]));
|
||||
assert.equal(subscriber.values.size, 1);
|
||||
const [before] = subscriber.getSnapshot();
|
||||
|
||||
mockControl.connector.emit("connect");
|
||||
assert.equal(subscriber.values.size, 0);
|
||||
assert.equal(subscriber.lastUpdatedMs, -1);
|
||||
const [after] = subscriber.getSnapshot();
|
||||
assert.notEqual(after, before);
|
||||
assert.equal(after.size, 0);
|
||||
});
|
||||
|
||||
it("should keep requests when a session is resumed", async function() {
|
||||
await subscriber._handleEvent(new lib.HostPairingUpdatesEvent([pairing("ABC-DEF", 10)]));
|
||||
subscriber.handleConnectionEvent("drop");
|
||||
subscriber.handleConnectionEvent("resume");
|
||||
assert.equal(subscriber.values.size, 1);
|
||||
assert.equal(subscriber.lastUpdatedMs, 10);
|
||||
});
|
||||
|
||||
it("should clear requests when subscribing again after the last unsubscribe", async function() {
|
||||
const unsubscribe = subscriber.subscribe(() => {});
|
||||
await events.once(mockControl.connector, "send");
|
||||
|
||||
Reference in new issue
Block a user