|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584 |
- var assert = chai.assert;
-
- describe('LessPass v1', function () {
- describe('encryptLogin', function () {
- it('should use pbkdf2 with 8192 iterations and sha256', function (done) {
- LessPass.encryptLogin('test@example.org', 'password').then(function (encryptedLogin) {
- assert.equal('d8af5f918db6b65b1db3d3984e5a400e39e1dbb19462220e4431de283809f472', encryptedLogin);
- done();
- });
- });
-
- it('should allow to customize number of iterations', function (done) {
- LessPass.encryptLogin('test@example.org', 'password', {iterations: 4096}).then(function (encryptedLogin) {
- assert.equal('0a91208545e3aa4935d3a22984ca097a7669259a04d261ac16361bdc1a2e960f', encryptedLogin);
- done();
- });
- });
-
- it('should allow to customize key length', function (done) {
- LessPass.encryptLogin('test@example.org', 'password', {keylen: 16}).then(function (encryptedLogin) {
- assert.equal('d8af5f918db6b65b1db3d3984e5a400e', encryptedLogin);
- done();
- });
- });
-
- it('should allow to customize iterations and key length', function (done) {
- LessPass.encryptLogin('test@example.org', 'password', {
- iterations: 4096,
- keylen: 16
- }).then(function (encryptedLogin) {
- assert.equal('0a91208545e3aa4935d3a22984ca097a', encryptedLogin);
- done();
- });
- });
-
- it('should allow utf8 parameter', function () {
- return LessPass.encryptLogin('test@example.org', '♥ LessPass ♥').then(function (encryptedLogin) {
- assert.equal('997fe81d3d0db236e039c75efdb487f17a902fdf94f9dacaa9884329c85d9651', encryptedLogin);
- });
- });
-
- it('encryptLogin auto generated test 0', function () {
- return LessPass.encryptLogin('contact@lesspass.com', 'password').then(function (encryptedLogin) {
- assert.equal('63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0', encryptedLogin);
- });
- });
-
- it('encryptLogin auto generated test 1', function () {
- return LessPass.encryptLogin('contact@lesspass.com', 'password').then(function (encryptedLogin) {
- assert.equal('63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0', encryptedLogin);
- });
- });
-
- it('encryptLogin auto generated test 2', function () {
- return LessPass.encryptLogin('contact@lesspass.com', 'password').then(function (encryptedLogin) {
- assert.equal('63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0', encryptedLogin);
- });
- });
-
- it('encryptLogin auto generated test 3', function () {
- return LessPass.encryptLogin('contact@lesspass.com', 'password').then(function (encryptedLogin) {
- assert.equal('63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0', encryptedLogin);
- });
- });
-
- it('encryptLogin auto generated test 4', function () {
- return LessPass.encryptLogin('contact@lesspass.com', 'password').then(function (encryptedLogin) {
- assert.equal('63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0', encryptedLogin);
- });
- });
-
- it('encryptLogin auto generated test 5', function () {
- return LessPass.encryptLogin('contact@lesspass.com', 'password').then(function (encryptedLogin) {
- assert.equal('63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0', encryptedLogin);
- });
- });
-
- it('encryptLogin auto generated test 6', function () {
- return LessPass.encryptLogin('contact@lesspass.com', 'password').then(function (encryptedLogin) {
- assert.equal('63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0', encryptedLogin);
- });
- });
-
- it('encryptLogin auto generated test 7', function () {
- return LessPass.encryptLogin('contact@lesspass.com', 'password').then(function (encryptedLogin) {
- assert.equal('63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0', encryptedLogin);
- });
- });
-
- it('encryptLogin auto generated test 8', function () {
- return LessPass.encryptLogin('contact@lesspass.com', 'password').then(function (encryptedLogin) {
- assert.equal('63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0', encryptedLogin);
- });
- });
-
- it('encryptLogin auto generated test 9', function () {
- return LessPass.encryptLogin('lesspass', 'password').then(function (encryptedLogin) {
- assert.equal('7d05ee25597dcc3ac16d082aa910e7707f75be620ed8db5bef7245e2a8579116', encryptedLogin);
- });
- });
-
- it('encryptLogin auto generated test 10', function () {
- return LessPass.encryptLogin('contact@lesspass.com', 'password2').then(function (encryptedLogin) {
- assert.equal('ce853092fc54fe88c281e38df97bd5826d64e6bee315dc94939cbba8930df0e4', encryptedLogin);
- });
- });
- });
-
- describe('renderPassword', function () {
- it('render password', function (done) {
- var site = 'lesspass.com';
- var encryptedLogin = '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0';
- var passwordOptions = {
- counter: 1,
- length: 12,
- lowercase: true,
- uppercase: true,
- numbers: true,
- symbols: true
- };
- LessPass.renderPassword(encryptedLogin, site, passwordOptions).then(function (generatedPassword) {
- assert.equal('azYS7,olOL2]', generatedPassword);
- done();
- })
- });
-
- it('render password with a custom template', function () {
- var site = 'lesspass.com';
- var encryptedLogin = '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0';
- var passwordOptions = {
- counter: 1,
- length: 12,
- lowercase: true,
- uppercase: true,
- numbers: true,
- symbols: true,
- template: 'n'
- };
- return LessPass.renderPassword(encryptedLogin, site, passwordOptions).then(function (generatedPassword) {
- var i = generatedPassword.length;
- while (i--) {
- assert('0123456789'.indexOf(generatedPassword[i]) !== -1)
- }
- })
- });
-
- it('render password with a custom template too short', function () {
- var site = 'lesspass.com';
- var encryptedLogin = '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0';
- var passwordOptions = {
- counter: 1,
- length: 12,
- lowercase: true,
- uppercase: true,
- numbers: true,
- symbols: true,
- template: 'CvcnCVsn'
- };
- return LessPass.renderPassword(encryptedLogin, site, passwordOptions).then(function (generatedPassword) {
- assert.equal('Sor4WU:8Wad5', generatedPassword);
- })
- });
-
- it('render password with a custom template too long', function () {
- var site = 'lesspass.com';
- var encryptedLogin = '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0';
- var passwordOptions = {
- counter: 1,
- length: 6,
- lowercase: true,
- uppercase: true,
- numbers: true,
- symbols: true,
- template: 'CvcnCVsn'
- };
- return LessPass.renderPassword(encryptedLogin, site, passwordOptions).then(function (generatedPassword) {
- assert.equal('Sor4WU', generatedPassword);
- })
- });
-
- it('render password auto generated test 0', function () {
- var site = 'lesspass.com';
- var encryptedLogin = '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0';
- var passwordOptions = {
- counter: 1,
- length: 12,
- lowercase: true,
- uppercase: true,
- numbers: true,
- symbols: true
- };
- return LessPass.renderPassword(encryptedLogin, site, passwordOptions).then(function (generatedPassword) {
- assert.equal('azYS7,olOL2]', generatedPassword);
- })
- });
-
- it('render password auto generated test 1', function () {
- var site = 'lesspass.com';
- var encryptedLogin = '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0';
- var passwordOptions = {
- counter: 1,
- length: 14,
- lowercase: true,
- uppercase: true,
- numbers: true,
- symbols: true
- };
- return LessPass.renderPassword(encryptedLogin, site, passwordOptions).then(function (generatedPassword) {
- assert.equal('azYS7,olOL2]iz', generatedPassword);
- })
- });
-
- it('render password auto generated test 2', function () {
- var site = 'lesspass.com';
- var encryptedLogin = '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0';
- var passwordOptions = {
- counter: 1,
- length: 12,
- lowercase: true,
- uppercase: false,
- numbers: false,
- symbols: false,
- };
- return LessPass.renderPassword(encryptedLogin, site, passwordOptions).then(function (generatedPassword) {
- assert.equal('azyseqololat', generatedPassword);
- })
- });
-
- it('render password auto generated test 3', function () {
- var site = 'lesspass.com';
- var encryptedLogin = '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0';
- var passwordOptions = {
- counter: 1,
- length: 12,
- lowercase: false,
- uppercase: true,
- numbers: true,
- symbols: true
- };
- return LessPass.renderPassword(encryptedLogin, site, passwordOptions).then(function (generatedPassword) {
- assert.equal('AZ3[EQ7@OL2]', generatedPassword);
- })
- });
-
- it('render password auto generated test 4', function () {
- var site = 'lesspass.com';
- var encryptedLogin = '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0';
- var passwordOptions = {
- counter: 1,
- length: 12,
- lowercase: false,
- uppercase: false,
- numbers: true,
- symbols: true
- };
- return LessPass.renderPassword(encryptedLogin, site, passwordOptions).then(function (generatedPassword) {
- assert.equal('4?3[7,7@7@2]', generatedPassword);
- })
- });
-
- it('render password auto generated test 5', function () {
- var site = 'lesspass.com';
- var encryptedLogin = '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0';
- var passwordOptions = {
- counter: 1,
- length: 12,
- lowercase: false,
- uppercase: false,
- numbers: false,
- symbols: true
- };
- return LessPass.renderPassword(encryptedLogin, site, passwordOptions).then(function (generatedPassword) {
- assert.equal('[?=[&,:@:@[]', generatedPassword);
- })
- });
-
- it('render password auto generated test 6', function () {
- var site = 'lesspass.com';
- var encryptedLogin = '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0';
- var passwordOptions = {
- counter: 1,
- length: 12,
- lowercase: true,
- uppercase: true,
- numbers: true,
- symbols: false
- };
- return LessPass.renderPassword(encryptedLogin, site, passwordOptions).then(function (generatedPassword) {
- assert.equal('azYS7uwAW8at', generatedPassword);
- })
- });
-
- it('render password auto generated test 7', function () {
- var site = 'lesspass.com';
- var encryptedLogin = '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0';
- var passwordOptions = {
- counter: 1,
- length: 12,
- lowercase: true,
- uppercase: true,
- numbers: false,
- symbols: false
- };
- return LessPass.renderPassword(encryptedLogin, site, passwordOptions).then(function (generatedPassword) {
- assert.equal('azYSeqOLolAT', generatedPassword);
- })
- });
-
- it('render password auto generated test 8', function () {
- var site = 'lesspass.com';
- var encryptedLogin = '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0';
- var passwordOptions = {
- counter: 2,
- length: 12,
- lowercase: true,
- uppercase: true,
- numbers: true,
- symbols: true
- };
- return LessPass.renderPassword(encryptedLogin, site, passwordOptions).then(function (generatedPassword) {
- assert.equal('obYT2=olOV9=', generatedPassword);
- })
- });
-
- it('render password auto generated test 9', function () {
- var site = 'lesspass.com';
- var encryptedLogin = '7d05ee25597dcc3ac16d082aa910e7707f75be620ed8db5bef7245e2a8579116';
- var passwordOptions = {
- counter: 1,
- length: 12,
- lowercase: true,
- uppercase: true,
- numbers: true,
- symbols: true
- };
- return LessPass.renderPassword(encryptedLogin, site, passwordOptions).then(function (generatedPassword) {
- assert.equal('erOC1%imIW3,', generatedPassword);
- })
- });
-
- it('render password auto generated test 10', function () {
- var site = 'lesspass.com';
- var encryptedLogin = 'ce853092fc54fe88c281e38df97bd5826d64e6bee315dc94939cbba8930df0e4';
- var passwordOptions = {
- counter: 1,
- length: 12,
- lowercase: true,
- uppercase: true,
- numbers: true,
- symbols: true
- };
- return LessPass.renderPassword(encryptedLogin, site, passwordOptions).then(function (generatedPassword) {
- assert.equal('uvUM5_ucUP5=', generatedPassword);
- })
- });
-
-
- });
- describe('fingerprint', function () {
- it('createFingerprint', function () {
- return LessPass.createFingerprint('password').then(function (fingerprint) {
- assert.equal('e56a207acd1e6714735487c199c6f095844b7cc8e5971d86c003a7b6f36ef51e', fingerprint);
- })
- });
- });
-
- describe('generatePassword', function () {
- it('generate password', function () {
- var site = 'example.org';
- var login = 'contact@example.org';
- var masterPassword = 'password';
- var passwordProfile = {
- lowercase: true,
- uppercase: true,
- digits: true,
- symbols: true,
- length: 12,
- index: 1,
- version: 1,
- };
- return LessPass.generatePassword(site, login, masterPassword, passwordProfile).then(function (generatedPassword) {
- assert.equal('izIS5@ozYM2?', generatedPassword);
- });
- });
- it('generate password auto generated test 0', function () {
- var site = 'lesspass.com';
- var login = 'contact@lesspass.com';
- var masterPassword = 'password';
- var passwordProfile = {
- lowercase: true,
- uppercase: true,
- digits: true,
- symbols: true,
- length: 12,
- index: 1,
- version: 1,
- };
- return LessPass.generatePassword(site, login, masterPassword, passwordProfile).then(function (generatedPassword) {
- assert.equal('azYS7,olOL2]', generatedPassword);
- });
- });
-
- it('generate password auto generated test 1', function () {
- var site = 'lesspass.com';
- var login = 'contact@lesspass.com';
- var masterPassword = 'password';
- var passwordProfile = {
- lowercase: true,
- uppercase: true,
- digits: true,
- symbols: true,
- length: 14,
- index: 1,
- version: 1,
- };
- return LessPass.generatePassword(site, login, masterPassword, passwordProfile).then(function (generatedPassword) {
- assert.equal('azYS7,olOL2]iz', generatedPassword);
- });
- });
-
- it('generate password auto generated test 2', function () {
- var site = 'lesspass.com';
- var login = 'contact@lesspass.com';
- var masterPassword = 'password';
- var passwordProfile = {
- lowercase: true,
- uppercase: false,
- digits: false,
- symbols: false,
- length: 12,
- index: 1,
- version: 1,
- };
- return LessPass.generatePassword(site, login, masterPassword, passwordProfile).then(function (generatedPassword) {
- assert.equal('azyseqololat', generatedPassword);
- });
- });
-
- it('generate password auto generated test 3', function () {
- var site = 'lesspass.com';
- var login = 'contact@lesspass.com';
- var masterPassword = 'password';
- var passwordProfile = {
- lowercase: false,
- uppercase: true,
- digits: true,
- symbols: true,
- length: 12,
- index: 1,
- version: 1,
- };
- return LessPass.generatePassword(site, login, masterPassword, passwordProfile).then(function (generatedPassword) {
- assert.equal('AZ3[EQ7@OL2]', generatedPassword);
- });
- });
-
- it('generate password auto generated test 4', function () {
- var site = 'lesspass.com';
- var login = 'contact@lesspass.com';
- var masterPassword = 'password';
- var passwordProfile = {
- lowercase: false,
- uppercase: false,
- digits: true,
- symbols: true,
- length: 12,
- index: 1,
- version: 1,
- };
- return LessPass.generatePassword(site, login, masterPassword, passwordProfile).then(function (generatedPassword) {
- assert.equal('4?3[7,7@7@2]', generatedPassword);
- });
- });
-
- it('generate password auto generated test 5', function () {
- var site = 'lesspass.com';
- var login = 'contact@lesspass.com';
- var masterPassword = 'password';
- var passwordProfile = {
- lowercase: false,
- uppercase: false,
- digits: false,
- symbols: true,
- length: 12,
- index: 1,
- version: 1,
- };
- return LessPass.generatePassword(site, login, masterPassword, passwordProfile).then(function (generatedPassword) {
- assert.equal('[?=[&,:@:@[]', generatedPassword);
- });
- });
-
- it('generate password auto generated test 6', function () {
- var site = 'lesspass.com';
- var login = 'contact@lesspass.com';
- var masterPassword = 'password';
- var passwordProfile = {
- lowercase: true,
- uppercase: true,
- digits: true,
- symbols: false,
- length: 12,
- index: 1,
- version: 1,
- };
- return LessPass.generatePassword(site, login, masterPassword, passwordProfile).then(function (generatedPassword) {
- assert.equal('azYS7uwAW8at', generatedPassword);
- });
- });
-
- it('generate password auto generated test 7', function () {
- var site = 'lesspass.com';
- var login = 'contact@lesspass.com';
- var masterPassword = 'password';
- var passwordProfile = {
- lowercase: true,
- uppercase: true,
- digits: false,
- symbols: false,
- length: 12,
- index: 1,
- version: 1,
- };
- return LessPass.generatePassword(site, login, masterPassword, passwordProfile).then(function (generatedPassword) {
- assert.equal('azYSeqOLolAT', generatedPassword);
- });
- });
-
- it('generate password auto generated test 8', function () {
- var site = 'lesspass.com';
- var login = 'contact@lesspass.com';
- var masterPassword = 'password';
- var passwordProfile = {
- lowercase: true,
- uppercase: true,
- digits: true,
- symbols: true,
- length: 12,
- index: 2,
- version: 1,
- };
- return LessPass.generatePassword(site, login, masterPassword, passwordProfile).then(function (generatedPassword) {
- assert.equal('obYT2=olOV9=', generatedPassword);
- });
- });
-
- it('generate password auto generated test 9', function () {
- var site = 'lesspass.com';
- var login = 'lesspass';
- var masterPassword = 'password';
- var passwordProfile = {
- lowercase: true,
- uppercase: true,
- digits: true,
- symbols: true,
- length: 12,
- index: 1,
- version: 1,
- };
- return LessPass.generatePassword(site, login, masterPassword, passwordProfile).then(function (generatedPassword) {
- assert.equal('erOC1%imIW3,', generatedPassword);
- });
- });
-
- it('generate password auto generated test 10', function () {
- var site = 'lesspass.com';
- var login = 'contact@lesspass.com';
- var masterPassword = 'password2';
- var passwordProfile = {
- lowercase: true,
- uppercase: true,
- digits: true,
- symbols: true,
- length: 12,
- index: 1,
- version: 1,
- };
- return LessPass.generatePassword(site, login, masterPassword, passwordProfile).then(function (generatedPassword) {
- assert.equal('uvUM5_ucUP5=', generatedPassword);
- });
- });
- });
- });
-
|