-
Notifications
You must be signed in to change notification settings - Fork 405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extracts identities from a wallet and stores in the in memory wallet #1051
Conversation
Signed-off-by: RosieMurphy0 <[email protected]>
@@ -184,7 +184,14 @@ class IdentityManager { | |||
* @private | |||
*/ | |||
async _extractIdentitiesFromWallet(mspId, wallet) { | |||
// TODO: To be implemented | |||
const walletFacade = await this.walletFacadeFactory.create(wallet.path); | |||
const allIDNames = await walletFacade.getAllIdentityNames(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
allIDNames --> allIdentityNames for this line and the next line
// TODO: To be implemented | ||
const walletFacade = await this.walletFacadeFactory.create(wallet.path); | ||
const allIDNames = await walletFacade.getAllIdentityNames(); | ||
for (const identityNames in allIDNames){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
identityNames --> identityName
const allIDNames = await walletFacade.getAllIdentityNames(); | ||
for (const identityNames in allIDNames){ | ||
const identity = await walletFacade.export(identityNames); | ||
if (identity){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can remove this check as we should expect something to be returned as the wallet has given the list of all available identity names
const walletFacade = await this.walletFacadeFactory.create(wallet.path); | ||
const allIDNames = await walletFacade.getAllIdentityNames(); | ||
for (const identityNames in allIDNames){ | ||
const identity = await walletFacade.export(identityNames); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
identityNames --> identityName
@@ -386,4 +405,56 @@ describe('An Identity Manager', () => { | |||
const identityManager = await identityManagerFactory.create(stubWalletFacadeFactory, [org1MSP, org2MSP]); | |||
await identityManager.getWallet().should.equal('IamAwallet'); | |||
}); | |||
|
|||
describe('when extracting identities from a specific wallet and store in the in memory wallet', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can just say when extracting identities from a specific wallet
|
||
describe('when extracting identities from a specific wallet and store in the in memory wallet', () => { | ||
|
||
it('if not identities available should not add anything to wallet', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should not add anything to the wallet when no identities are available
const stubWalletFacadeFactory = sinon.createStubInstance(IWalletFacadeFactory); | ||
const spyWalletFacade = sinon.createStubInstance(IWalletFacade); | ||
stubWalletFacadeFactory.create.resolves(spyWalletFacade); | ||
spyWalletFacade.getAllIdentityNames.resolves([]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't a spy, it's a stub
const identityManagerFactory = new IdentityManagerFactory(); | ||
|
||
const identityManager = await identityManagerFactory.create(stubWalletFacadeFactory, [org4MSP]); | ||
await identityManager._extractIdentitiesFromWallet(org4MSP, spyWalletFacade); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately the _
indicates a private method so the tests should not be calling that method directly but it should be driven through the use of appropriate external configurations.
const identityManagerFactory = new IdentityManagerFactory(); | ||
|
||
const identityManager = await identityManagerFactory.create(stubWalletFacadeFactory, [org4MSP]); | ||
await identityManager._extractIdentitiesFromWallet(org4MSP, stubWalletFacade); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again, this method should not be called directly by the test
const stubAddToWallet = sinon.stub(); | ||
identityManager._addToWallet = stubAddToWallet; | ||
|
||
await identityManager._extractIdentitiesFromWallet(org4MSP, stubWalletFacade); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should not be called directly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry the tests will need to remove the use of _extractIdentitiesFromWallet
and the code driven using appropriate configurations and stubs.
… memory wallet Signed-off-by: RosieMurphy0 <[email protected]>
… memory wallet Signed-off-by: RosieMurphy0 <[email protected]>
Signed-off-by: RosieMurphy0 <[email protected]>
Signed-off-by: RosieMurphy0 [email protected]
Implemented the
_extractIdentitiesFromWallet
method in the identity manager and the associated tests for the method. Takes identities from a wallet and stores them in the in memory wallet using an existing method.contributes to #940