完成全项目响应式审核与换机交接
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
const assert = require("assert");
|
||||
const fs = require("fs");
|
||||
const vm = require("vm");
|
||||
|
||||
const filename = "utils/validation.js";
|
||||
const source = `${fs.readFileSync(filename, "utf8")
|
||||
.replace(/export const /g, "const ")}\nmodule.exports = { PASSWORD_POLICY_MESSAGE, validatePassword };`;
|
||||
const sandbox = { module: { exports: {} } };
|
||||
vm.runInNewContext(source, sandbox, { filename });
|
||||
const { validatePassword } = sandbox.module.exports;
|
||||
|
||||
for (const value of ["", "abc1234", "abcdefgh", "12345678", "a".repeat(33) + "1"]) {
|
||||
assert.equal(validatePassword(value).valid, false, `${value || "empty"} must fail`);
|
||||
}
|
||||
for (const value of ["abc12345", "Family2026!"]) {
|
||||
assert.equal(validatePassword(value).valid, true, `${value} must pass`);
|
||||
}
|
||||
|
||||
console.log("PASSWORD-POLICY-RUNTIME-SMOKE PASS");
|
||||
Reference in New Issue
Block a user