Generates a password of given length and complexity based on optional inputs for the inclusion of symbols and numbers.

This commit is contained in:
Niall 2024-08-21 22:16:23 +00:00
parent d635cca210
commit 54d6c7b506
4 changed files with 132 additions and 0 deletions

View file

@ -71,6 +71,7 @@ import "./tests/Fork.mjs";
import "./tests/FromDecimal.mjs";
import "./tests/GenerateAllHashes.mjs";
import "./tests/GenerateDeBruijnSequence.mjs";
import "./tests/GeneratePassword.mjs";
import "./tests/GetAllCasings.mjs";
import "./tests/GOST.mjs";
import "./tests/Gunzip.mjs";

View file

@ -0,0 +1,57 @@
/**
* GeneratePassword tests.
*
* @author 0xff1ce [github.com/0xff1ce]
* @copyright Crown Copyright 2024
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "Generate random string of length 10 without symbols or numbers",
input: "",
expectedMatch: /^[A-Za-z]{10}$/,
recipeConfig: [
{
"op": "Generate Password",
"args": [10, false, false]
},
],
},
{
name: "Generate random string of length 15 with symbols but without numbers",
input: "",
expectedMatch: /^[A-Za-z!@#$%^&*()\-=+_|\\"']{15}$/,
recipeConfig: [
{
"op": "Generate Password",
"args": [15, true, false]
},
],
},
{
name: "Generate random string of length 20 with numbers but without symbols",
input: "",
expectedMatch: /^[A-Za-z0-9]{20}$/,
recipeConfig: [
{
"op": "Generate Password",
"args": [20, false, true]
},
],
},
{
name: "Generate random string of length 25 with both symbols and numbers",
input: "",
expectedMatch: /^[A-Za-z0-9!@#$%^&*()\-=+_|\\"']{25}$/,
recipeConfig: [
{
"op": "Generate Password",
"args": [25, true, true]
},
],
}
]);