Securely generate rcon password

Replace Math.random() based password generation for the rcon interface
with a more secure method based crypto.randomBytes.
This commit is contained in:
Hornwitser committed 2019-09-14 01:18:51 +02:00
1 parent eb1b863cec
commit bcb22d2af7
3 files changed
+58 -2

No files matched your search

+17
View File
@@ -20,4 +20,21 @@ describe("Client testing", function() {
}
});
});
describe("generatePassword()", function() {
it("should return a string", async function() {
let password = await client._generatePassword(1);
assert.equal(typeof password, "string");
});
it("should return a string of the given length", async function() {
let password = await client._generatePassword(10);
assert.equal(password.length, 10);
});
it("should contain only a-z, A-Z, 0-9", async function() {
let password = await client._generatePassword(10);
assert(/^[a-zA-Z0-9]+$/.test(password), `${password} failed test`);
});
});
});