Browse Source

make generatePassword retro compatible

pull/342/head
Guillaume Vincent 8 years ago
parent
commit
d350c9c7f2
7 changed files with 546 additions and 237 deletions
  1. +30
    -2
      dist/lesspass.js
  2. +30
    -2
      index.js
  3. +0
    -0
      tests/pbkdf2.tests.js
  4. +453
    -214
      tests/v1/api.tests.js
  5. +31
    -17
      tests/v1/deriveEncryptedLogin.tests.js
  6. +1
    -1
      tests/v1/getPasswordTemplate.tests.js
  7. +1
    -1
      tests/v1/prettyPrint.js

+ 30
- 2
dist/lesspass.js View File

@@ -2,6 +2,7 @@
var v1 = require('./src/v1'); var v1 = require('./src/v1');
var v2 = require('./src/v2'); var v2 = require('./src/v2');
var pbkdf2 = require('./src/pbkdf2'); var pbkdf2 = require('./src/pbkdf2');
var objectAssign = require('object-assign');


module.exports = { module.exports = {
encryptLogin: v1.encryptLogin, encryptLogin: v1.encryptLogin,
@@ -15,7 +16,7 @@ module.exports = {
_getPasswordChar: v1._getPasswordChar, _getPasswordChar: v1._getPasswordChar,
_createHmac: v1._createHmac, _createHmac: v1._createHmac,


generatePassword: v2.generatePassword,
generatePassword: generatePassword,
_calcEntropy: v2._calcEntropy, _calcEntropy: v2._calcEntropy,
_consumeEntropy: v2._consumeEntropy, _consumeEntropy: v2._consumeEntropy,
_getSetOfCharacters: v2._getSetOfCharacters, _getSetOfCharacters: v2._getSetOfCharacters,
@@ -26,7 +27,34 @@ module.exports = {


pbkdf2: pbkdf2 pbkdf2: pbkdf2
}; };
},{"./src/pbkdf2":48,"./src/v1":49,"./src/v2":50}],2:[function(require,module,exports){

var defaultPasswordProfile = {
version: 1
};

function generatePassword(site, login, masterPassword, passwordProfile) {
var _passwordProfile = objectAssign({}, defaultPasswordProfile, passwordProfile);
if (_passwordProfile.version === 1) {
var options = {
counter: _passwordProfile.index,
length: _passwordProfile.length,
lowercase: _passwordProfile.lowercase,
uppercase: _passwordProfile.uppercase,
numbers: _passwordProfile.digits,
symbols: _passwordProfile.symbols
};
return v1.encryptLogin(login, masterPassword)
.then(function (encryptedLogin) {
return v1.renderPassword(encryptedLogin, site, options).then(generatedPassword => {
return generatedPassword
});
});
}
if (_passwordProfile.version === 2) {
return v2.generatePassword(site, login, masterPassword, passwordProfile);
}
}
},{"./src/pbkdf2":48,"./src/v1":49,"./src/v2":50,"object-assign":18}],2:[function(require,module,exports){
'use strict' 'use strict'


exports.byteLength = byteLength exports.byteLength = byteLength


+ 30
- 2
index.js View File

@@ -1,6 +1,7 @@
var v1 = require('./src/v1'); var v1 = require('./src/v1');
var v2 = require('./src/v2'); var v2 = require('./src/v2');
var pbkdf2 = require('./src/pbkdf2'); var pbkdf2 = require('./src/pbkdf2');
var objectAssign = require('object-assign');


module.exports = { module.exports = {
encryptLogin: v1.encryptLogin, encryptLogin: v1.encryptLogin,
@@ -14,7 +15,7 @@ module.exports = {
_getPasswordChar: v1._getPasswordChar, _getPasswordChar: v1._getPasswordChar,
_createHmac: v1._createHmac, _createHmac: v1._createHmac,


generatePassword: v2.generatePassword,
generatePassword: generatePassword,
_calcEntropy: v2._calcEntropy, _calcEntropy: v2._calcEntropy,
_consumeEntropy: v2._consumeEntropy, _consumeEntropy: v2._consumeEntropy,
_getSetOfCharacters: v2._getSetOfCharacters, _getSetOfCharacters: v2._getSetOfCharacters,
@@ -24,4 +25,31 @@ module.exports = {
_renderPassword: v2._renderPassword, _renderPassword: v2._renderPassword,


pbkdf2: pbkdf2 pbkdf2: pbkdf2
};
};

var defaultPasswordProfile = {
version: 1
};

function generatePassword(site, login, masterPassword, passwordProfile) {
var _passwordProfile = objectAssign({}, defaultPasswordProfile, passwordProfile);
if (_passwordProfile.version === 1) {
var options = {
counter: _passwordProfile.index,
length: _passwordProfile.length,
lowercase: _passwordProfile.lowercase,
uppercase: _passwordProfile.uppercase,
numbers: _passwordProfile.digits,
symbols: _passwordProfile.symbols
};
return v1.encryptLogin(login, masterPassword)
.then(function (encryptedLogin) {
return v1.renderPassword(encryptedLogin, site, options).then(generatedPassword => {
return generatedPassword
});
});
}
if (_passwordProfile.version === 2) {
return v2.generatePassword(site, login, masterPassword, passwordProfile);
}
}

tests/v1/pbkdf2.tests.js → tests/pbkdf2.tests.js View File


+ 453
- 214
tests/v1/api.tests.js View File

@@ -1,6 +1,6 @@
var assert = chai.assert; var assert = chai.assert;


describe('LessPass', function () {
describe('LessPass v1', function () {
describe('encryptLogin', function () { describe('encryptLogin', function () {
it('should use pbkdf2 with 8192 iterations and sha256', function (done) { it('should use pbkdf2 with 8192 iterations and sha256', function (done) {
LessPass.encryptLogin('test@example.org', 'password').then(function (encryptedLogin) { LessPass.encryptLogin('test@example.org', 'password').then(function (encryptedLogin) {
@@ -39,81 +39,73 @@ describe('LessPass', function () {
}); });
}); });


it('auto generated encrypt login tests', function () {
this.timeout(10000);
var promises = [];
var passwords = [
{
login: 'contact@lesspass.com',
masterPassword: 'password',
encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
},
{
login: 'contact@lesspass.com',
masterPassword: 'password',
encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
},
{
login: 'contact@lesspass.com',
masterPassword: 'password',
encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
},
{
login: 'contact@lesspass.com',
masterPassword: 'password',
encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
},
{
login: 'contact@lesspass.com',
masterPassword: 'password',
encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
},
{
login: 'contact@lesspass.com',
masterPassword: 'password',
encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
},
{
login: 'contact@lesspass.com',
masterPassword: 'password',
encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
},
{
login: 'contact@lesspass.com',
masterPassword: 'password',
encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
},
{
login: 'contact@lesspass.com',
masterPassword: 'password',
encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
},
{
login: 'lesspass',
masterPassword: 'password',
encryptedLogin: '7d05ee25597dcc3ac16d082aa910e7707f75be620ed8db5bef7245e2a8579116',
},
{
login: 'contact@lesspass.com',
masterPassword: 'password2',
encryptedLogin: 'ce853092fc54fe88c281e38df97bd5826d64e6bee315dc94939cbba8930df0e4',
}
];
it('encryptLogin auto generated test 0', function () {
return LessPass.encryptLogin('contact@lesspass.com', 'password').then(function (encryptedLogin) {
assert.equal('63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0', encryptedLogin);
});
});


passwords.forEach(function (entry) {
promises.push(LessPass.encryptLogin(entry.login, entry.masterPassword));
it('encryptLogin auto generated test 1', function () {
return LessPass.encryptLogin('contact@lesspass.com', 'password').then(function (encryptedLogin) {
assert.equal('63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0', encryptedLogin);
}); });
});


return Promise.all(promises).then(function (values) {
for (var i = 0; i < values.length; i++) {
assert.equal(passwords[i].encryptedLogin, values[i]);
}
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('LessPass', function () {
describe('renderPassword', function () { describe('renderPassword', function () {
it('render password', function (done) { it('render password', function (done) {
var site = 'lesspass.com'; var site = 'lesspass.com';
@@ -186,154 +178,184 @@ describe('LessPass', function () {
}) })
}); });


it('auto generated render password tests', function () {
var promises = [];
var passwords = [
{
encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
site: 'lesspass.com',
counter: 1,
length: 12,
lowercase: true,
uppercase: true,
numbers: true,
symbols: true,
generatedPassword: 'azYS7,olOL2]'
},
{
encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
site: 'lesspass.com',
counter: 1,
length: 14,
lowercase: true,
uppercase: true,
numbers: true,
symbols: true,
generatedPassword: 'azYS7,olOL2]iz'
},
{
encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
site: 'lesspass.com',
counter: 1,
length: 12,
lowercase: true,
uppercase: false,
numbers: false,
symbols: false,
generatedPassword: 'azyseqololat'
},
{
encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
site: 'lesspass.com',
counter: 1,
length: 12,
lowercase: false,
uppercase: true,
numbers: true,
symbols: true,
generatedPassword: 'AZ3[EQ7@OL2]'
},
{
encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
site: 'lesspass.com',
counter: 1,
length: 12,
lowercase: false,
uppercase: false,
numbers: true,
symbols: true,
generatedPassword: '4?3[7,7@7@2]'
},
{
encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
site: 'lesspass.com',
counter: 1,
length: 12,
lowercase: false,
uppercase: false,
numbers: false,
symbols: true,
generatedPassword: '[?=[&,:@:@[]'
},
{
encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
site: 'lesspass.com',
counter: 1,
length: 12,
lowercase: true,
uppercase: true,
numbers: true,
symbols: false,
generatedPassword: 'azYS7uwAW8at'
},
{
encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
site: 'lesspass.com',
counter: 1,
length: 12,
lowercase: true,
uppercase: true,
numbers: false,
symbols: false,
generatedPassword: 'azYSeqOLolAT'
},
{
encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
site: 'lesspass.com',
counter: 2,
length: 12,
lowercase: true,
uppercase: true,
numbers: true,
symbols: true,
generatedPassword: 'obYT2=olOV9='
},
{
encryptedLogin: '7d05ee25597dcc3ac16d082aa910e7707f75be620ed8db5bef7245e2a8579116',
site: 'lesspass.com',
counter: 1,
length: 12,
lowercase: true,
uppercase: true,
numbers: true,
symbols: true,
generatedPassword: 'erOC1%imIW3,'
},
{
encryptedLogin: 'ce853092fc54fe88c281e38df97bd5826d64e6bee315dc94939cbba8930df0e4',
site: 'lesspass.com',
counter: 1,
length: 12,
lowercase: true,
uppercase: true,
numbers: true,
symbols: true,
generatedPassword: 'uvUM5_ucUP5='
}
];

passwords.forEach(function (entry) {
var passwordOption = {
counter: entry.counter,
length: entry.length,
lowercase: entry.lowercase,
uppercase: entry.uppercase,
numbers: entry.numbers,
symbols: entry.symbols,
};
promises.push(LessPass.renderPassword(entry.encryptedLogin, entry.site, passwordOption));
});
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);
})
});


return Promise.all(promises).then(function(values) {
for (var i = 0; i < values.length; i++) {
assert.equal(passwords[i].generatedPassword, values[i]);
}
});
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);
})
}); });
});
});


describe('LessPass', function () {
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 () { describe('fingerprint', function () {
it('createFingerprint', function () { it('createFingerprint', function () {
return LessPass.createFingerprint('password').then(function (fingerprint) { return LessPass.createFingerprint('password').then(function (fingerprint) {
@@ -341,5 +363,222 @@ describe('LessPass', function () {
}) })
}); });
}); });

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);
});
});
});
}); });



+ 31
- 17
tests/v1/deriveEncryptedLogin.tests.js View File

@@ -1,6 +1,6 @@
var assert = chai.assert; var assert = chai.assert;


describe('LessPass', function () {
describe('LessPass v1', function () {
describe('deriveEncryptedLogin', function () { describe('deriveEncryptedLogin', function () {
it('should createHmac', function () { it('should createHmac', function () {
var encryptedLogin = '9f505f3a95fe0485da3242cb81c9fe25c2f400d8399737655a8dad2b52778d88'; var encryptedLogin = '9f505f3a95fe0485da3242cb81c9fe25c2f400d8399737655a8dad2b52778d88';
@@ -9,7 +9,14 @@ describe('LessPass', function () {
assert.equal('be00f942fc8aa67d8e76fc2456862b9d66d166ebfdd3dc2f0116e278209532ed', hmac); assert.equal('be00f942fc8aa67d8e76fc2456862b9d66d166ebfdd3dc2f0116e278209532ed', hmac);
}); });
}); });
it('should derive encrypted login with default options', function () {
it('should derive encrypted login with default options 1', function () {
const encryptedLogin = '90cff82b8847525370a8f29a59ecf45db62c719a535788ad0df58d32304e925d';
const site = 'lesspass.com';
return LessPass._deriveEncryptedLogin(encryptedLogin, site).then(function (generatedPassword) {
assert.equal('ecd16aefc7e5', generatedPassword);
});
});
it('should derive encrypted login with default options 2', function () {
const encryptedLogin = '90cff82b8847525370a8f29a59ecf45db62c719a535788ad0df58d32304e925d'; const encryptedLogin = '90cff82b8847525370a8f29a59ecf45db62c719a535788ad0df58d32304e925d';
const site = 'lesspass.com'; const site = 'lesspass.com';
const option = { const option = {
@@ -20,10 +27,8 @@ describe('LessPass', function () {
numbers: true, numbers: true,
symbols: true, symbols: true,
}; };
var p1 = LessPass._deriveEncryptedLogin(encryptedLogin, site);
var p2 = LessPass._deriveEncryptedLogin(encryptedLogin, site, option);
Promise.all([p1, p2]).then(function (generatedPasswords) {
assert.equal(generatedPasswords[0], generatedPasswords[1])
return LessPass._deriveEncryptedLogin(encryptedLogin, site, option).then(function (generatedPassword) {
assert.equal('ecd16aefc7e5', generatedPassword);
}); });
}); });
it('should derive encrypted login with defined length', function () { it('should derive encrypted login with defined length', function () {
@@ -37,25 +42,34 @@ describe('LessPass', function () {
assert.equal(10, generatedPassword.length); assert.equal(10, generatedPassword.length);
}); });
}); });
it('should return two different passwords if site different', function () {
it('should return two different passwords if site different 1', function () {
const encryptedLogin = 'f4fd3885fb70085f2285c3382e2d9adb4c2553285fc45dd896791aa5e79070a9'; const encryptedLogin = 'f4fd3885fb70085f2285c3382e2d9adb4c2553285fc45dd896791aa5e79070a9';
const site = 'google.com'; const site = 'google.com';
const site2 = 'facebook.com';
var p1 = LessPass._deriveEncryptedLogin(encryptedLogin, site);
var p2 = LessPass._deriveEncryptedLogin(encryptedLogin, site2);
return Promise.all([p1, p2]).then(function (derivedEncryptedLogins) {
assert.notEqual(derivedEncryptedLogins[0], derivedEncryptedLogins[1])
return LessPass._deriveEncryptedLogin(encryptedLogin, site).then(function (derivedEncryptedLogin) {
assert.equal('a957c3a459ec', derivedEncryptedLogin)
});
});
it('should return two different passwords if site different 2', function () {
const encryptedLogin = 'f4fd3885fb70085f2285c3382e2d9adb4c2553285fc45dd896791aa5e79070a9';
const site = 'facebook.com';
return LessPass._deriveEncryptedLogin(encryptedLogin, site).then(function (derivedEncryptedLogin) {
assert.equal('d9f3a918c34b', derivedEncryptedLogin)
}); });
}); });
it('should return two different passwords if counter different', function () {
it('should return two different passwords if counter different 1', function () {
const encryptedLogin = 'dfba06278c9aa24d992bc2d390a53efef482788859455875f72015335d085fcd'; const encryptedLogin = 'dfba06278c9aa24d992bc2d390a53efef482788859455875f72015335d085fcd';
const site = 'lesspass.com'; const site = 'lesspass.com';
const option = {counter: 1}; const option = {counter: 1};
return LessPass._deriveEncryptedLogin(encryptedLogin, site, option).then(function (derivedEncryptedLogins) {
assert.equal('bb2e0b34036d', derivedEncryptedLogins)
});
});
it('should return two different passwords if counter different 2', function () {
const encryptedLogin = 'dfba06278c9aa24d992bc2d390a53efef482788859455875f72015335d085fcd';
const site = 'lesspass.com';
const option2 = {counter: 2}; const option2 = {counter: 2};
var p1 = LessPass._deriveEncryptedLogin(encryptedLogin, site, option);
var p2 = LessPass._deriveEncryptedLogin(encryptedLogin, site, option2);
return Promise.all([p1, p2]).then(function (derivedEncryptedLogins) {
assert.notEqual(derivedEncryptedLogins[0], derivedEncryptedLogins[1])
return LessPass._deriveEncryptedLogin(encryptedLogin, site, option2).then(function (derivedEncryptedLogins) {
assert.equal('67fe8c05a248', derivedEncryptedLogins)
}); });
}); });
it('should derive encrypted login with sha 256', function () { it('should derive encrypted login with sha 256', function () {


+ 1
- 1
tests/v1/getPasswordTemplate.tests.js View File

@@ -1,6 +1,6 @@
var assert = chai.assert; var assert = chai.assert;


describe('LessPass', function () {
describe('Lessass v1', function () {
describe('getPasswordTemplate', function () { describe('getPasswordTemplate', function () {
it('should get default template', function () { it('should get default template', function () {
assert.equal('vcVCns', LessPass._getPasswordTemplate({ assert.equal('vcVCns', LessPass._getPasswordTemplate({


+ 1
- 1
tests/v1/prettyPrint.js View File

@@ -1,6 +1,6 @@
var assert = chai.assert; var assert = chai.assert;


describe('LessPass', function () {
describe('LessPass v1', function () {
describe('prettyPrint', function () { describe('prettyPrint', function () {
it('should print different password if templates different', function () { it('should print different password if templates different', function () {
var encryptedLogin = '78ae5892055ab59fdd54489ae30928d322841a27590b65cf875fcfdd083f7c32'; var encryptedLogin = '78ae5892055ab59fdd54489ae30928d322841a27590b65cf875fcfdd083f7c32';


Loading…
Cancel
Save