fixed phonetic password generation

pull/1856/head
antelle 2 years ago
parent 966d814281
commit 0ce436c2e9
No known key found for this signature in database
GPG Key ID: 63C9777AAB7C563C
  1. 3
      app/scripts/util/generators/phonetic.js
  2. 8
      test/src/util/generators/password-generator.js

@ -312,7 +312,8 @@ function generate(options) {
word: '',
opts: options
};
while (wordObj.word.length < length) {
const safeMaxLength = length + 5;
while (wordObj.word.length < safeMaxLength) {
addSyllable(wordObj);
}
return postProcess(wordObj).substr(0, length);

@ -41,9 +41,11 @@ describe('PasswordGenerator', () => {
});
it('should generate a pronounceable password', () => {
expect(PasswordGenerator.generate({ length: 10, name: 'Pronounceable' })).to.match(
/^[a-zA-Z]{10}$/
);
for (let i = 0; i < 1000; i++) {
expect(PasswordGenerator.generate({ length: 10, name: 'Pronounceable' })).to.match(
/^[a-zA-Z]{10}$/
);
}
});
it('should generate a password with pattern', () => {

Loading…
Cancel
Save