Skip to content

Commit

Permalink
improve message to help when file not found (#1262)
Browse files Browse the repository at this point in the history
closes #1202

Signed-off-by: D <d_kelsey@uk.ibm.com>

Co-authored-by: D <d_kelsey@uk.ibm.com>
  • Loading branch information
davidkel and D committed Mar 11, 2022
1 parent ba1ffcf commit 4356663
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ class IdentityManager {
await fs.stat(configPath);
} catch(err) {
if (err.errno === -2 || err.errno === -4058) {
throw new Error(`path property does not point to a file that exists for ${propertyNameBeingProcessed} for name ${identityName} in organization ${mspId}`);
throw new Error(`path property ${configPath} does not point to a file that exists for ${propertyNameBeingProcessed} for name ${identityName} in organization ${mspId}`);
}
throw err;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,16 +288,16 @@ describe('An Identity Manager', () => {

it('should throw an error if path specified for clientSignCert or clientPrivateKey does not exist', async () => {
let badOrg1MSP = JSON.parse(JSON.stringify(org1MSPWithCertificates));
badOrg1MSP.identities.certificates[0].clientSignedCert.path = '/to/some/known/path/file';
badOrg1MSP.identities.certificates[0].clientSignedCert.path = '/to/some/known/path/cert';
delete badOrg1MSP.identities.certificates[0].clientPrivateKey.path;
badOrg1MSP.identities.certificates[0].clientPrivateKey.pem = '-----BEGIN PRIVATE KEY-----\n-----END PRIVATE KEY-----';
await identityManagerFactory.create(stubWalletFacadeFactory, [badOrg1MSP]).should.be.rejectedWith(/path property does not point to a file that exists for clientSignedCert for name User1 in organization Org1MSP/);
await identityManagerFactory.create(stubWalletFacadeFactory, [badOrg1MSP]).should.be.rejectedWith(/path property \/to\/some\/known\/path\/cert does not point to a file that exists for clientSignedCert for name User1 in organization Org1MSP/);

badOrg1MSP = JSON.parse(JSON.stringify(org1MSPWithCertificates));
badOrg1MSP.identities.certificates[0].clientPrivateKey.path = '/to/some/known/path/file';
badOrg1MSP.identities.certificates[0].clientPrivateKey.path = '/to/some/known/path/key';
delete badOrg1MSP.identities.certificates[0].clientSignedCert.path;
badOrg1MSP.identities.certificates[0].clientSignedCert.pem = '-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----';
await identityManagerFactory.create(stubWalletFacadeFactory, [badOrg1MSP]).should.be.rejectedWith(/path property does not point to a file that exists for clientPrivateKey for name User1 in organization Org1MSP/);
await identityManagerFactory.create(stubWalletFacadeFactory, [badOrg1MSP]).should.be.rejectedWith(/path property \/to\/some\/known\/path\/key does not point to a file that exists for clientPrivateKey for name User1 in organization Org1MSP/);
});

it('should throw an error if path specified for clientSignCert or clientPrivateKey does not appear to have valid PEM contents', async () => {
Expand Down

0 comments on commit 4356663

Please sign in to comment.