From 4356663e7442bb8e426489653e543189b248e1cd Mon Sep 17 00:00:00 2001 From: Dave Kelsey <25582377+davidkel@users.noreply.github.com> Date: Fri, 11 Mar 2022 18:15:18 +0000 Subject: [PATCH] improve message to help when file not found (#1262) closes #1202 Signed-off-by: D Co-authored-by: D --- .../lib/identity-management/IdentityManager.js | 2 +- .../test/identity-management/IdentityManager.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/caliper-fabric/lib/identity-management/IdentityManager.js b/packages/caliper-fabric/lib/identity-management/IdentityManager.js index 26c7eeb66..a306877b7 100644 --- a/packages/caliper-fabric/lib/identity-management/IdentityManager.js +++ b/packages/caliper-fabric/lib/identity-management/IdentityManager.js @@ -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; } diff --git a/packages/caliper-fabric/test/identity-management/IdentityManager.js b/packages/caliper-fabric/test/identity-management/IdentityManager.js index 5506cee01..75477256e 100644 --- a/packages/caliper-fabric/test/identity-management/IdentityManager.js +++ b/packages/caliper-fabric/test/identity-management/IdentityManager.js @@ -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 () => {