Explorar el Código

add transformProfilesFromV1ToV2 and first tests

pull/342/head
Guillaume Vincent hace 7 años
padre
commit
734733924e
Se han modificado 3 ficheros con 102 adiciones y 0 borrados
  1. +26
    -0
      migration.js
  2. +22
    -0
      package.json
  3. +54
    -0
      test.js

+ 26
- 0
migration.js Ver fichero

@@ -0,0 +1,26 @@
module.exports = {
transformProfilesFromV1ToV2: function(profiles) {
const newProfiles = [];
profiles.forEach(profile => {
const newProfile = {
"site": profile.site,
"login": profile.login,
"lowercase": profile.lowercase,
"uppercase": profile.uppercase,
"number": profile.number,
"symbol": profile.symbol,
"counter": profile.counter,
"length": profile.length,
"version": profile.version,
};
if (profile.version === 1) {
newProfile.version = 2;
if (profile.length === 12) {
newProfile.length = 16;
}
}
newProfiles.push(newProfile)
});
return newProfiles
}
};

+ 22
- 0
package.json Ver fichero

@@ -0,0 +1,22 @@
{
"name": "lesspass-move",
"version": "0.1.0",
"description": "A tool to change your LessPass passwords",
"main": "index.js",
"scripts": {
"test": "ava"
},
"repository": {
"type": "git",
"url": "git+https://github.com/lesspass/move.git"
},
"author": "Guillaume Vincent <guillaume@oslab.fr>",
"license": "GPL-3.0",
"bugs": {
"url": "https://github.com/lesspass/move/issues"
},
"homepage": "https://github.com/lesspass/move#readme",
"devDependencies": {
"ava": "^0.19.1"
}
}

+ 54
- 0
test.js Ver fichero

@@ -0,0 +1,54 @@
import test from 'ava';
import migration from './migration'

test('transformProfilesFromV1ToV2', t => {
var profiles = [
{
"site": "example.org",
"login": "test@example.org",
"lowercase": true,
"uppercase": true,
"number": true,
"symbol": true,
"counter": 1,
"length": 12,
"version": 1
},
{
"site": "bank.example.org",
"login": "test@example.org",
"lowercase": false,
"uppercase": false,
"number": true,
"symbol": false,
"counter": 2,
"length": 6,
"version": 1
}
];
var expectedProfiles = [
{
"site": "example.org",
"login": "test@example.org",
"lowercase": true,
"uppercase": true,
"number": true,
"symbol": true,
"counter": 1,
"length": 16,
"version": 2
},
{
"site": "bank.example.org",
"login": "test@example.org",
"lowercase": false,
"uppercase": false,
"number": true,
"symbol": false,
"counter": 2,
"length": 6,
"version": 2
}
];
t.deepEqual(migration.transformProfilesFromV1ToV2(profiles), expectedProfiles);
});

Cargando…
Cancelar
Guardar