Files
pulse-signage/test/password-strength.test.js
lzstealth 203d0bfc01
Publish Docker Image / build-and-push-existing-registry (./build/Dockerfile, web, pulse-signage-web) (push) Successful in 1m49s
Publish Docker Image / build-and-push-existing-registry (./build/Dockerfile.player, player, pulse-signage-player) (push) Successful in 32s
Release 2.8.0
2026-08-16 17:15:31 +01:00

30 lines
1.7 KiB
JavaScript

const test = require('node:test');
const assert = require('node:assert/strict');
const { validatePasswordStrength } = require('../src/auth');
test('password strength requires a longer mixed-character password', () => {
assert.equal(validatePasswordStrength('weakpass'), 'Password must be at least 10 characters and include 3 of: uppercase, lowercase, number, and symbol.');
assert.equal(validatePasswordStrength('1234567890'), 'Password must be at least 10 characters and include 3 of: uppercase, lowercase, number, and symbol.');
assert.equal(validatePasswordStrength('Password12'), '');
assert.equal(validatePasswordStrength('NewPassword!1'), '');
});
test('password strength supports strong and strict policies', () => {
assert.equal(validatePasswordStrength('Password12', { policy: 'strong' }), 'Password must be at least 12 characters and include 3 of: uppercase, lowercase, number, and symbol.');
assert.equal(validatePasswordStrength('Password12!!', { policy: 'strong' }), '');
assert.equal(validatePasswordStrength('Password12!Abc', { policy: 'strict' }), '');
assert.equal(validatePasswordStrength('Password12!Ab', { policy: 'strict' }), 'Password must be at least 14 characters and include uppercase, lowercase, number, and symbol.');
});
test('password strength supports custom category requirements', () => {
const requirements = {
minimumLength: 8,
minimumCategories: 2,
requireUppercase: true,
requireSymbol: true
};
assert.equal(validatePasswordStrength('password1!', requirements), 'Password must be at least 8 characters and include uppercase, symbol.');
assert.equal(validatePasswordStrength('Password!', requirements), '');
});