diff --git a/packages/composer-admin/lib/adminconnection.js b/packages/composer-admin/lib/adminconnection.js index 82a17d4e56..4fd3ac9353 100644 --- a/packages/composer-admin/lib/adminconnection.js +++ b/packages/composer-admin/lib/adminconnection.js @@ -90,6 +90,9 @@ class AdminConnection { return connectionManager.removeIdentity(connectionProfileData.name, connectionProfileData, card.getUserName()); } }) + .then(() => { + return this.cardStore.put(name, card); + }) .then(() => { // if we have a certificate and optionally a privateKey we should ask the connection manager to import let certificate = card.getCredentials().certificate; @@ -98,9 +101,6 @@ class AdminConnection { return connectionManager.importIdentity(connectionProfileData.name, connectionProfileData, card.getUserName(), certificate, privateKey); } }) - .then(() => { - return this.cardStore.put(name, card); - }) .then(() => { return updated; }); diff --git a/packages/composer-admin/test/adminconnection.js b/packages/composer-admin/test/adminconnection.js index 016a6e4467..c1730aa614 100644 --- a/packages/composer-admin/test/adminconnection.js +++ b/packages/composer-admin/test/adminconnection.js @@ -1091,17 +1091,6 @@ describe('AdminConnection', () => { ); }); }); - - it('should not add card to card store if importIdentity fails', function() { - const cardName = 'conga'; - const certificate = 'CERTIFICATE_DATA'; - const privateKey = 'PRIVATE_KEY_DATA'; - userCard.setCredentials({certificate : certificate, privateKey : privateKey}); - mockConnectionManager.importIdentity.rejects(new Error('importIdentity')); - return adminConnection.importCard(cardName, userCard).should.be.rejected.then(() => { - return cardStore.has(cardName).should.become(false); - }); - }); }); describe('#getAllCards', function () {