Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save webmandman/14590280a85f6eea8bfd57042b126c3d to your computer and use it in GitHub Desktop.
Save webmandman/14590280a85f6eea8bfd57042b126c3d to your computer and use it in GitHub Desktop.
TryCF Gist
<cfscript>
function run() {
describe("some password validation tests", () => {
passwords = [
{password="", ok=false},
{password="Bad1!", ok=false},
{password="Fine1!", ok=true},
{password="AAAAAA", ok=false},
{password="aaaaaa", ok=false},
{password="111111", ok=false},
{password="Aa1Aa1", ok=false},
{password="Aa1Aa!", ok=true},
{password="Aa1Aa!" & repeatString("x", 249), ok=true},
{password="Aa1Aa!" & repeatString("x", 250), ok=false}
]
passwords.each((testCase) => {
it("should consider [#testCase.password#] to be valid: [#testCase.ok#]", () => {
expect(testCase.password.reFind("^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*\W).{6,255}$") > 0).toBe(testCase.ok)
})
})
})
}
tinyTest.runTests()
</cfscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment