diff --git a/.gitignore b/.gitignore index 03720d3cda..6bc978916e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,14 +1,14 @@ coverage docs/gen node_modules/* -hfc/node_modules/* -hfc-cop/node_modules/* -hfc-cop/lib/api.js -hfc-cop/lib/utils.js -hfc-cop/lib/Config.js -hfc-cop/lib/Remote.js -hfc-cop/lib/hash.js -hfc-cop/lib/impl/* +fabric-client/node_modules/* +fabric-ca-client/node_modules/* +fabric-ca-client/lib/api.js +fabric-ca-client/lib/utils.js +fabric-ca-client/lib/Config.js +fabric-ca-client/lib/Remote.js +fabric-ca-client/lib/hash.js +fabric-ca-client/lib/impl/* test/fixtures/src/github.com/example_cc/Dockerfile test/fixtures/src/github.com/marbles_cc/Dockerfile npm-shrinkwrap.json @@ -16,5 +16,5 @@ npm-debug.log tmp .project .DS_Store -hfc/.DS_Store -hfc-cop/.DS_Store +fabric-client/.DS_Store +fabric-ca-client/.DS_Store diff --git a/test/unit/cloudant-fabriccop-tests.js b/test/unit/cloudant-fabricca-tests.js similarity index 85% rename from test/unit/cloudant-fabriccop-tests.js rename to test/unit/cloudant-fabricca-tests.js index 05647ed53c..327c2a3324 100644 --- a/test/unit/cloudant-fabriccop-tests.js +++ b/test/unit/cloudant-fabricca-tests.js @@ -45,23 +45,23 @@ test('Use FabricCAServices wih a Cloudant CouchDB KeyValueStore', function(t) { // Set the relevant configuration values utils.setConfigSetting('crypto-keysize', 256); - // Clean up the couchdb test database + // Clean up the cloudant couchdb test database var dbname = 'member_db'; - //ccd next needs to be changed + var member; couchdbUtil.destroy(dbname, dbClient) .then( function(status) { t.comment('Cleanup of existing ' + dbname + ' returned '+status); - t.comment('Initilize the CouchDB KeyValueStore'); + t.comment('Initilize the Cloudant CouchDB KeyValueStore'); utils.newKeyValueStore({name: dbname, path: dbClient}) .then( function(kvs) { t.comment('Setting client keyValueStore to: ' + kvs); client.setStateStore(kvs); if (client.getStateStore() === kvs) { - t.pass('Successfully set CouchDB KeyValueStore for client'); + t.pass('Successfully set Cloudant CouchDB KeyValueStore for client'); } else { - t.pass('CouchDB KeyValStore is not set successfully on this client!'); + t.pass('Cloudant CouchDB KeyValStore is not set successfully on this client!'); t.end(); process.exit(1); } @@ -70,19 +70,19 @@ test('Use FabricCAServices wih a Cloudant CouchDB KeyValueStore', function(t) { }, function(err) { console.log(err); - t.fail('Error initializing CouchDB KeyValueStore. Exiting.'); + t.fail('Error initializing Cloudant KeyValueStore. Exiting.'); t.end(); process.exit(1); }) .then( - function(copService) { - console.log('ADD: copService - ' + copService); + function(caService) { + console.log('ADD: caService - ' + caService); t.pass('Successfully initialized the Fabric CA service.'); - client.setCryptoSuite(copService.getCrypto()); + client.setCryptoSuite(caService.getCrypto()); t.comment('Set cryptoSuite on client'); - t.comment('Begin copService.enroll'); - return copService.enroll({ + t.comment('Begin caService.enroll'); + return caService.enroll({ enrollmentID: 'admin2', enrollmentSecret: 'adminpw2' }); @@ -97,7 +97,7 @@ test('Use FabricCAServices wih a Cloudant CouchDB KeyValueStore', function(t) { t.pass('Successfully enrolled admin2 with CA server'); // Persist the user state - var member = new User('admin2', client); + member = new User('admin2', client); return member.setEnrollment(admin2.key, admin2.certificate); }, function(err) { @@ -105,7 +105,7 @@ test('Use FabricCAServices wih a Cloudant CouchDB KeyValueStore', function(t) { t.end(); } ).then( - function(member) { + function() { if (member.isEnrolled()) { t.pass('Member isEnrolled successfully.'); } else { @@ -137,7 +137,7 @@ test('Use FabricCAServices wih a Cloudant CouchDB KeyValueStore', function(t) { } ).catch( function(err) { - t.fail('Failed couchdb-fabriccop-test with error:' + err.stack ? err.stack : err); + t.fail('Failed cloudant-fabricca-test with error:' + err.stack ? err.stack : err); t.end(); } ); diff --git a/test/unit/couchdb-fabriccop-tests.js b/test/unit/couchdb-fabricca-tests.js similarity index 87% rename from test/unit/couchdb-fabriccop-tests.js rename to test/unit/couchdb-fabricca-tests.js index 767d20e7c9..d2ecf62124 100644 --- a/test/unit/couchdb-fabriccop-tests.js +++ b/test/unit/couchdb-fabricca-tests.js @@ -47,6 +47,8 @@ test('Use FabricCAServices with a CouchDB KeyValueStore', function(t) { // Clean up the couchdb test database var dbname = 'member_db'; + + var member; couchdbUtil.destroy(dbname, dbClient) .then( function(status) { t.comment('Cleanup of existing ' + dbname + ' returned '+status); @@ -73,14 +75,14 @@ test('Use FabricCAServices with a CouchDB KeyValueStore', function(t) { process.exit(1); }) .then( - function(copService) { - console.log('ADD: copService - ' + copService); + function(caService) { + console.log('ADD: caService - ' + caService); t.pass('Successfully initialized the Fabric CA service.'); - client.setCryptoSuite(copService.getCrypto()); + client.setCryptoSuite(caService.getCrypto()); t.comment('Set cryptoSuite on client'); - t.comment('Begin copService.enroll'); - return copService.enroll({ + t.comment('Begin caService.enroll'); + return caService.enroll({ enrollmentID: 'admin2', enrollmentSecret: 'adminpw2' }); @@ -95,8 +97,15 @@ test('Use FabricCAServices with a CouchDB KeyValueStore', function(t) { t.pass('Successfully enrolled admin2 with CA server'); // Persist the user state - var member = new User('admin2', client); - member.setEnrollment(admin2.key, admin2.certificate); + member = new User('admin2', client); + return member.setEnrollment(admin2.key, admin2.certificate); + }, + function(err) { + t.fail('Failed to use obtained private key and certificate to construct a User object. Error: ' + err); + t.end(); + } + ).then( + function() { if (member.isEnrolled()) { t.pass('Member isEnrolled successfully.'); } else { @@ -128,7 +137,7 @@ test('Use FabricCAServices with a CouchDB KeyValueStore', function(t) { } ).catch( function(err) { - t.fail('Failed couchdb-fabriccop-test with error:' + err.stack ? err.stack : err); + t.fail('Failed couchdb-fabricca-test with error:' + err.stack ? err.stack : err); t.end(); } );