[
{"name": "the right current password and a good new one", "args": ["correct horse battery staple", "a much longer passphrase here", true, "ada@example.com", "Ada Lovelace", {"name": "nist-800-63b-4-single-factor", "minLength": 15, "maxLength": 128, "minCharacterClasses": 0, "blockCommon": true, "blockPersonal": true}], "expect": {"valid": true, "fields": {}}},
{"name": "the current password is wrong", "args": ["correct horse battery stapel", "a much longer passphrase here", false, "ada@example.com", "Ada Lovelace", {"name": "nist-800-63b-4-single-factor", "minLength": 15, "maxLength": 128, "minCharacterClasses": 0, "blockCommon": true, "blockPersonal": true}], "expect": {"valid": false, "fields": {"currentPassword": "That is not your current password."}}},
{"name": "the current password is empty", "args": ["", "a much longer passphrase here", false, "ada@example.com", "Ada Lovelace", {"name": "nist-800-63b-4-single-factor", "minLength": 15, "maxLength": 128, "minCharacterClasses": 0, "blockCommon": true, "blockPersonal": true}], "expect": {"valid": false, "fields": {"currentPassword": "Enter your current password."}}},
{"name": "an empty current password never counts as matching, whatever the flag says", "args": ["", "a much longer passphrase here", true, "ada@example.com", "Ada Lovelace", {"name": "nist-800-63b-4-single-factor", "minLength": 15, "maxLength": 128, "minCharacterClasses": 0, "blockCommon": true, "blockPersonal": true}], "expect": {"valid": false, "fields": {"currentPassword": "Enter your current password."}}},
{"name": "the new password is empty", "args": ["correct horse battery staple", "", true, "ada@example.com", "Ada Lovelace", {"name": "nist-800-63b-4-single-factor", "minLength": 15, "maxLength": 128, "minCharacterClasses": 0, "blockCommon": true, "blockPersonal": true}], "expect": {"valid": false, "fields": {"newPassword": "Enter a new password."}}},
{"name": "both empty: current first, then new", "args": ["", "", false, "ada@example.com", "Ada Lovelace", {"name": "nist-800-63b-4-single-factor", "minLength": 15, "maxLength": 128, "minCharacterClasses": 0, "blockCommon": true, "blockPersonal": true}], "expect": {"valid": false, "fields": {"currentPassword": "Enter your current password.", "newPassword": "Enter a new password."}}},
{"name": "the new password is too short", "args": ["correct horse battery staple", "short", true, "ada@example.com", "Ada Lovelace", {"name": "nist-800-63b-4-single-factor", "minLength": 15, "maxLength": 128, "minCharacterClasses": 0, "blockCommon": true, "blockPersonal": true}], "expect": {"valid": false, "fields": {"newPassword": "Use at least 15 characters."}}},
{"name": "the new password is short and common: every failure, joined", "args": ["correct horse battery staple", "password", true, "ada@example.com", "Ada Lovelace", {"name": "nist-800-63b-4-single-factor", "minLength": 15, "maxLength": 128, "minCharacterClasses": 0, "blockCommon": true, "blockPersonal": true}], "expect": {"valid": false, "fields": {"newPassword": "Use at least 15 characters. This password is too common. Choose something harder to guess."}}},
{"name": "the new password contains the account's email local part and name", "args": ["correct horse battery staple", "ada-lovelace-rules-ok", true, "ada@example.com", "Ada Lovelace", {"name": "nist-800-63b-4-single-factor", "minLength": 15, "maxLength": 128, "minCharacterClasses": 0, "blockCommon": true, "blockPersonal": true}], "expect": {"valid": false, "fields": {"newPassword": "Do not include your email address in your password. Do not include your name in your password."}}},
{"name": "the new password is the current one", "args": ["correct horse battery staple", "correct horse battery staple", true, "ada@example.com", "Ada Lovelace", {"name": "nist-800-63b-4-single-factor", "minLength": 15, "maxLength": 128, "minCharacterClasses": 0, "blockCommon": true, "blockPersonal": true}], "expect": {"valid": false, "fields": {"newPassword": "Choose a password that is different from your current one."}}},
{"name": "the same and too short: the policy's failures come first", "args": ["shortpass", "shortpass", true, "ada@example.com", "Ada Lovelace", {"name": "nist-800-63b-4-single-factor", "minLength": 15, "maxLength": 128, "minCharacterClasses": 0, "blockCommon": true, "blockPersonal": true}], "expect": {"valid": false, "fields": {"newPassword": "Use at least 15 characters. Choose a password that is different from your current one."}}},
{"name": "a trailing space makes a different password: nothing is trimmed", "args": ["correct horse battery staple", "correct horse battery staple ", true, "ada@example.com", "Ada Lovelace", {"name": "nist-800-63b-4-single-factor", "minLength": 15, "maxLength": 128, "minCharacterClasses": 0, "blockCommon": true, "blockPersonal": true}], "expect": {"valid": true, "fields": {}}},
{"name": "a wrong current password and a bad new one: both fields", "args": ["nope", "short", false, "ada@example.com", "Ada Lovelace", {"name": "nist-800-63b-4-single-factor", "minLength": 15, "maxLength": 128, "minCharacterClasses": 0, "blockCommon": true, "blockPersonal": true}], "expect": {"valid": false, "fields": {"currentPassword": "That is not your current password.", "newPassword": "Use at least 15 characters."}}},
{"name": "values that are not strings (a malformed JSON body) are treated as empty", "args": [null, 12345, false, "ada@example.com", "Ada Lovelace", {"name": "nist-800-63b-4-single-factor", "minLength": 15, "maxLength": 128, "minCharacterClasses": 0, "blockCommon": true, "blockPersonal": true}], "expect": {"valid": false, "fields": {"currentPassword": "Enter your current password.", "newPassword": "Enter a new password."}}},
{"name": "a nonsensical policy is the caller's mistake", "args": ["correct horse battery staple", "a much longer passphrase here", true, "ada@example.com", "Ada Lovelace", {"name": "nist-800-63b-4-single-factor", "minLength": 0, "maxLength": 128, "minCharacterClasses": 0, "blockCommon": true, "blockPersonal": true}], "expectError": "policy minLength must be a whole number of at least 1"}
]