From de8da9ddf67f36977e43d2168c4847fd9923c875 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Tue, 22 Nov 2016 15:54:51 -0800 Subject: Simplify Encryptor API Surface At least, the portion of it that we use. Moved salting within the encryptor, so it does not need to be managed externally. KeyringController now caches the password instead of a passwordDerivedKey, since it is ignorant of the salt. Encryptor payload is now in a JSON format, so its portions are both base64 encoded *and* labeled appropriately. The format is `{ "data": "0x0", "iv": "0x0", "salt": "string" }`. Fixes #843 Fixes #859 --- test/unit/keyring-controller-test.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/unit/keyring-controller-test.js b/test/unit/keyring-controller-test.js index 437441e0e..c32141cc6 100644 --- a/test/unit/keyring-controller-test.js +++ b/test/unit/keyring-controller-test.js @@ -82,13 +82,15 @@ describe('KeyringController', function() { }) - describe('#migrateAndGetKey', function() { + describe('#migrateOldVaultIfAny', function() { it('should return the key for that password', function(done) { - keyringController.migrateAndGetKey(password) - .then((key) => { - assert(key, 'a key is returned') + keyringController.migrateOldVaultIfAny(password) + .then(() => { done() }) + .catch((reason) => { + assert.ifError(reason) + }) }) }) -- cgit v1.2.3 From 607a474c3fef10aa6a50b27015263d874d25aa69 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Tue, 22 Nov 2016 16:05:37 -0800 Subject: Improve vault migration unit test --- test/unit/keyring-controller-test.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/unit/keyring-controller-test.js b/test/unit/keyring-controller-test.js index c32141cc6..2d1064f40 100644 --- a/test/unit/keyring-controller-test.js +++ b/test/unit/keyring-controller-test.js @@ -83,9 +83,10 @@ describe('KeyringController', function() { }) describe('#migrateOldVaultIfAny', function() { - it('should return the key for that password', function(done) { + it('should return and init a new vault', function(done) { keyringController.migrateOldVaultIfAny(password) .then(() => { + assert(Boolean(localStorage['vault'])) done() }) .catch((reason) => { -- cgit v1.2.3 From 358440384c769c82fec148e7a24e3e4f6366b4b4 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Tue, 22 Nov 2016 16:07:35 -0800 Subject: Fix vault migration unit test --- test/unit/keyring-controller-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/unit/keyring-controller-test.js b/test/unit/keyring-controller-test.js index 2d1064f40..a58043c7a 100644 --- a/test/unit/keyring-controller-test.js +++ b/test/unit/keyring-controller-test.js @@ -86,7 +86,7 @@ describe('KeyringController', function() { it('should return and init a new vault', function(done) { keyringController.migrateOldVaultIfAny(password) .then(() => { - assert(Boolean(localStorage['vault'])) + assert(keyringController.configManager.getVault(), 'now has a vault') done() }) .catch((reason) => { -- cgit v1.2.3