mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-14 15:24:52 +09:00
Remove tlsCa option
The migration from phin to fetch in #755 was hampred by the lack of an option to set the CA when using fetch. This meant places that used phin to talk to the controller with the tlsCa option could not be migrated to use fetch. Remove the tlsCa option to unblock this dependency. The replacement for this option is to set the NODE_EXTRA_CA_CERTS environment variable to a path to the certificate file instead, which works with fetch.
This commit is contained in:
1 parent
a106851cdc
commit
fb3fe09466
21 files changed
+66
-120
No files matched your search
+2
-2
@@ -127,8 +127,8 @@ describe("Host testing", function() {
|
||||
version: hostVersion,
|
||||
}];
|
||||
const hostConfig = new lib.HostConfig("host", { "host.version": hostVersion });
|
||||
const hostConnector = new HostConnector(hostConfig, undefined, pluginInfos);
|
||||
host = new Host(hostConnector, hostConfig, undefined, pluginInfos);
|
||||
const hostConnector = new HostConnector(hostConfig, pluginInfos);
|
||||
host = new Host(hostConnector, hostConfig, pluginInfos);
|
||||
});
|
||||
it("returns false when no changes are present", async function() {
|
||||
host.pluginInfos[0].hostEntrypoint = true;
|
||||
|
||||
@@ -41,7 +41,6 @@ async function startAltHost() {
|
||||
await fs.remove(path.join("temp", "test", "alt-instances"));
|
||||
await fs.remove(path.join("temp", "test", "alt-mods"));
|
||||
await execCtl(`host create-config --id 5 --name alt-host --generate-token --output ${config}`);
|
||||
await execHost(`--config ${config} config set host.tls_ca ../../test/file/tls/cert.pem`);
|
||||
await execHost(`--config ${config} config set host.instances_directory alt-instances`);
|
||||
const dir = path.isAbsolute(factorioDir) ? factorioDir : path.join("..", "..", factorioDir);
|
||||
await execHost(`--config ${config} config set host.factorio_directory ${dir}`);
|
||||
@@ -168,8 +167,7 @@ describe("Integration of Clusterio", function() {
|
||||
describe("run", function() {
|
||||
it("should handle resume of an active connection", async function() {
|
||||
slowTest(this);
|
||||
let tlsCa = await fs.readFile("test/file/tls/cert.pem");
|
||||
let connectorA = new TestControlConnector(url, 2, tlsCa);
|
||||
let connectorA = new TestControlConnector(url, 2);
|
||||
connectorA.token = controlToken;
|
||||
let controlA = new TestControl(connectorA);
|
||||
await connectorA.connect();
|
||||
@@ -177,7 +175,7 @@ describe("Integration of Clusterio", function() {
|
||||
connectorA.stopHeartbeat();
|
||||
connectorA.on("error", () => {});
|
||||
|
||||
let connectorB = new TestControlConnector(url, 2, tlsCa);
|
||||
let connectorB = new TestControlConnector(url, 2);
|
||||
connectorB.token = controlToken;
|
||||
connectorB.src = connectorA.src;
|
||||
let controlB = new TestControl(connectorB);
|
||||
@@ -1679,8 +1677,7 @@ describe("Integration of Clusterio", function() {
|
||||
it("should kick existing sessions for the user", async function() {
|
||||
slowTest(this);
|
||||
await getControl().send(new lib.UserCreateRequest("revokee"));
|
||||
let tlsCa = await fs.readFile("test/file/tls/cert.pem");
|
||||
let connector = new TestControlConnector(url, 2, tlsCa);
|
||||
let connector = new TestControlConnector(url, 2);
|
||||
connector.token = jwt.sign(
|
||||
{ aud: "user", user: "revokee" }, Buffer.from("TestSecretDoNotUse", "base64")
|
||||
);
|
||||
@@ -1709,8 +1706,7 @@ describe("Integration of Clusterio", function() {
|
||||
await execCtl("user set-roles temp Player");
|
||||
let tempControl;
|
||||
try {
|
||||
let tlsCa = await fs.readFile("test/file/tls/cert.pem");
|
||||
let connector = new TestControlConnector(url, 2, tlsCa);
|
||||
let connector = new TestControlConnector(url, 2);
|
||||
connector.token = jwt.sign(
|
||||
{ aud: "user", user: "temp" }, Buffer.from("TestSecretDoNotUse", "base64")
|
||||
);
|
||||
|
||||
@@ -194,11 +194,23 @@ let controllerConfigPath = path.join("temp", "test", "config-controller.json");
|
||||
let hostConfigPath = path.join("temp", "test", "config-host.json");
|
||||
let controlConfigPath = path.join("temp", "test", "config-control.json");
|
||||
|
||||
function childOptions(options) {
|
||||
return {
|
||||
cwd: path.join("temp", "test"),
|
||||
env: {
|
||||
...process.env,
|
||||
NODE_EXTRA_CA_CERTS: process.env.NODE_EXTRA_CA_CERTS
|
||||
? path.resolve(process.env.NODE_EXTRA_CA_CERTS)
|
||||
: undefined,
|
||||
},
|
||||
...options,
|
||||
};
|
||||
}
|
||||
|
||||
function exec(command, options = {}) {
|
||||
// Uncomment to show commands run in tests
|
||||
// console.log(command);
|
||||
options = { cwd: path.join("temp", "test"), ...options };
|
||||
return util.promisify(child_process.exec)(command, options);
|
||||
return util.promisify(child_process.exec)(command, childOptions(options));
|
||||
}
|
||||
|
||||
function execController(...args) {
|
||||
@@ -264,7 +276,7 @@ function spawn(name, cmd, waitFor, options = {}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
log(cmd);
|
||||
let parts = cmd.split(" ");
|
||||
let process = child_process.spawn(parts[0], parts.slice(1), { cwd: path.join("temp", "test"), ...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 => {
|
||||
@@ -354,7 +366,6 @@ before(async function() {
|
||||
console.log("Bootstrapping");
|
||||
await execController("bootstrap create-admin test");
|
||||
await execController("bootstrap create-ctl-config test");
|
||||
await execCtlProcess("control-config set control.tls_ca ../../test/file/tls/cert.pem");
|
||||
|
||||
controllerProcess = await spawnNode("controller:", "../../packages/controller run", /Started controller/);
|
||||
|
||||
@@ -362,12 +373,10 @@ before(async function() {
|
||||
const relativeFactorioDir = path.isAbsolute(factorioDir) ? factorioDir : path.join("..", "..", factorioDir);
|
||||
await execCtlProcess("host create-config --id 4 --name host --generate-token");
|
||||
await execHost(`config set host.factorio_directory ${relativeFactorioDir}`);
|
||||
await execHost("config set host.tls_ca ../../test/file/tls/cert.pem");
|
||||
|
||||
hostProcess = await spawnNode("host:", "../../packages/host run", /Started host/);
|
||||
|
||||
const tlsCa = await fs.readFile("test/file/tls/cert.pem");
|
||||
const controlConnector = new TestControlConnector(url, 2, tlsCa);
|
||||
const controlConnector = new TestControlConnector(url, 2);
|
||||
controlConnector.token = controlToken;
|
||||
control = new TestControl(controlConnector);
|
||||
await controlConnector.connect();
|
||||
@@ -375,7 +384,6 @@ before(async function() {
|
||||
const initArgs = await initializeCtl(`--plugin-list ${pluginListPath} control-config list`, undefined, true);
|
||||
control.config = initArgs.controlConfig;
|
||||
control.plugins = initArgs.ctlPlugins;
|
||||
control.tlsCa = tlsCa;
|
||||
|
||||
const testPack = lib.ModPack.fromJSON({});
|
||||
testPack.id = 12;
|
||||
|
||||
@@ -11,18 +11,14 @@ let token = jwt.sign({ aud: "user", user: "test" }, Buffer.from("TestSecretDoNot
|
||||
let tokenHost = jwt.sign({ aud: "host", host: 0 }, Buffer.from("TestSecretDoNotUse", "base64"));
|
||||
|
||||
describe("Integration of lib/link", function() {
|
||||
let tlsCa;
|
||||
let control;
|
||||
let controlConnector;
|
||||
let hostConnector;
|
||||
before(async function() {
|
||||
tlsCa = await fs.readFile("test/file/tls/cert.pem");
|
||||
});
|
||||
beforeEach(async function() {
|
||||
controlConnector = new TestControlConnector(url, 0.2, tlsCa);
|
||||
controlConnector = new TestControlConnector(url, 0.2);
|
||||
controlConnector.token = token;
|
||||
control = new TestControl(controlConnector, false);
|
||||
hostConnector = new TestHostConnector(url, 0.2, tlsCa);
|
||||
hostConnector = new TestHostConnector(url, 0.2);
|
||||
hostConnector.token = tokenHost;
|
||||
hostConnector.hostId = 0;
|
||||
});
|
||||
@@ -123,7 +119,7 @@ describe("Integration of lib/link", function() {
|
||||
|
||||
it("should close old connections from the same address", async function() {
|
||||
slowTest(this);
|
||||
const hostConnectorFirst = new TestHostConnector(url, 0.2, tlsCa);
|
||||
const hostConnectorFirst = new TestHostConnector(url, 0.2);
|
||||
hostConnectorFirst.token = hostConnector.token;
|
||||
hostConnectorFirst.hostId = hostConnector.hostId;
|
||||
const onceClose = events.once(hostConnectorFirst, "close");
|
||||
|
||||
@@ -23,7 +23,7 @@ function connectHost(controller, hostId, plugins) {
|
||||
controller.wsServer.hostConnections.set(hostId, hostConnection);
|
||||
const hostConfig = new lib.HostConfig("host");
|
||||
hostConfig.set("host.id", hostId);
|
||||
return new Host(hostSide, hostConfig, undefined, []);
|
||||
return new Host(hostSide, hostConfig, []);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,7 +14,7 @@ describe("messages/host", function() {
|
||||
lib.Address.fromShorthand({ hostId: 1 }),
|
||||
lib.Address.fromShorthand("controller"),
|
||||
);
|
||||
host = new Host(hostConnector, hostConfig, undefined, []);
|
||||
host = new Host(hostConnector, hostConfig, []);
|
||||
});
|
||||
|
||||
describe("HostUpdateRequest", function() {
|
||||
|
||||
@@ -28,7 +28,7 @@ describe("messages/plugin", function() {
|
||||
lib.Address.fromShorthand({ hostId: 1 }),
|
||||
lib.Address.fromShorthand("controller"),
|
||||
);
|
||||
host = new Host(hostConnector, hostConfig, undefined, []);
|
||||
host = new Host(hostConnector, hostConfig, []);
|
||||
});
|
||||
|
||||
describe("PluginDetails", function() {
|
||||
|
||||
Reference in new issue
Block a user