Skip to content

Commit

Permalink
Wip: #31 add a temporary password preset and test to check for it.
Browse files Browse the repository at this point in the history
  • Loading branch information
hepabolu committed Mar 17, 2024
1 parent d2119cd commit 893a071
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
17 changes: 17 additions & 0 deletions src/lib/presets.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,23 @@ const thePresets = {
allow_accents: 0,
},
},
TEMPORARY: {
description: 'A preset for creating temporary phone friendly passwords.' +
' WARNING - They are not secure and should be changed immediately.',
config: {
word_length_min: 4,
word_length_max: 4,
num_words: 2,
case_transform: 'CAPITALISE',
separator_type: 'FIXED',
separator_character: '-',
padding_digits_before: 0,
padding_digits_after: 2,
padding_type: 'NONE',
allow_accents: 0,
},
},

};


Expand Down
2 changes: 1 addition & 1 deletion src/lib/presets.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ describe('Test class Presets', () => {

test('getPresets returns list of keys', () => {
const expected = ['DEFAULT', 'WEB32', 'WEB16', 'WIFI',
'APPLEID', 'NTLM', 'SECURITYQ', 'XKCD'];
'APPLEID', 'NTLM', 'SECURITYQ', 'XKCD', 'TEMPORARY'];

const newPreset = new Presets();
expect(newPreset.getPresets()).toEqual(expected);
Expand Down
11 changes: 11 additions & 0 deletions src/lib/xkpasswd.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,17 @@ describe('Test XKPassword class', () => {

expect(password).toMatch(re);
});

test('Test TEMPORARY preset', () => {
me.setPreset('TEMPORARY');
const password = me.password();

// eslint-disable-next-line max-len
const re = /([A-Z][a-z]{3}[-]){2}\d\d/;

expect(password).toMatch(re);
});

});

describe('Test internal __padWithChar', () => {
Expand Down

0 comments on commit 893a071

Please sign in to comment.