mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-20 15:43:13 +09:00
Clean up generateSSLcert test
Remove dependency to fileOps in generateSSLcert test file and clean up the code to follow a higher standard.
This commit is contained in:
1 parent
65f75d86e6
commit
bc41f7afa6
1 file changed
+21
-16
+21
-16
@@ -1,27 +1,32 @@
|
|||||||
var assert = require("assert");
|
const assert = require("assert");
|
||||||
var fs = require("fs-extra");
|
const fs = require("fs-extra");
|
||||||
|
const path = require("path");
|
||||||
|
|
||||||
var fileOps = require("lib/fileOps");
|
const generateSSLcert = require("lib/generateSSLcert")
|
||||||
var generateSSLcert = require("lib/generateSSLcert")
|
|
||||||
|
|
||||||
describe("generateSSLcert.js(options)", ()=>{
|
describe("generateSSLcert.js(options)", ()=>{
|
||||||
|
let testDir = "test/temp/certTest";
|
||||||
|
before(async function() {
|
||||||
|
await fs.remove(testDir);
|
||||||
|
});
|
||||||
|
|
||||||
it("Creates a folder with a .crt and .key file in it", async function() {
|
it("Creates a folder with a .crt and .key file in it", async function() {
|
||||||
/* istanbul ignore if */ if (process.env.FAST_TEST) this.skip();
|
this.timeout(1000);
|
||||||
let certPath = "lib/certTestPlsDelete/cert.crt";
|
if (process.env.FAST_TEST) {
|
||||||
let privKeyPath = "lib/certTestPlsDelete/cert.key";
|
this.skip();
|
||||||
assert(!await fs.exists(certPath)); // if it already exsits, the test might pass because of leftover data (which is bad)
|
}
|
||||||
|
|
||||||
|
let certPath = path.join(testDir, "cert.crt");
|
||||||
|
let privKeyPath = path.join(testDir, "cert.key");
|
||||||
|
|
||||||
await generateSSLcert({
|
await generateSSLcert({
|
||||||
bits: 512, // This is too small for real world usage, but faster to test
|
bits: 512, // This is too small for real world usage, but faster to test
|
||||||
sslCertPath: certPath,
|
sslCertPath: certPath,
|
||||||
sslPrivKeyPath: privKeyPath,
|
sslPrivKeyPath: privKeyPath,
|
||||||
doLogging: false,
|
doLogging: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
assert(await fs.exists(certPath)); // private key
|
assert(await fs.exists(certPath), "cert file was not created");
|
||||||
assert(await fs.exists(privKeyPath)); // certificate file
|
assert(await fs.exists(privKeyPath), "key file was not created");
|
||||||
|
});
|
||||||
// remove certificates and data from the test
|
|
||||||
fileOps.deleteFolderRecursiveSync("lib/certTestPlsDelete");
|
|
||||||
}).timeout(10000);
|
|
||||||
});
|
});
|
||||||
Reference in new issue
Block a user