Skip to content

Commit

Permalink
Fix and rename cloudant and couchdb-fabriccop-tests
Browse files Browse the repository at this point in the history
User.setEnrollment now returns a Promise, but no
value, so test case needs to be updated.

Includes renaming of cop to ca in both the code as
well as the file names and .gitignore hfc/hfc-cop
to fabric-client/fabric-ca-client.

Change-Id: Ie387bde51003549416acd747c9ce962a9a7f17a3
Signed-off-by: cdaughtr <cdaughtr@us.ibm.com>
  • Loading branch information
cdaughtr committed Feb 3, 2017
1 parent 954ea4b commit d871138
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 32 deletions.
20 changes: 10 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
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
npm-debug.log
tmp
.project
.DS_Store
hfc/.DS_Store
hfc-cop/.DS_Store
fabric-client/.DS_Store
fabric-ca-client/.DS_Store
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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'
});
Expand All @@ -97,15 +97,15 @@ 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) {
t.fail('Failed to use obtained private key and certificate to construct a User object. Error: ' + err);
t.end();
}
).then(
function(member) {
function() {
if (member.isEnrolled()) {
t.pass('Member isEnrolled successfully.');
} else {
Expand Down Expand Up @@ -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();
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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'
});
Expand All @@ -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 {
Expand Down Expand Up @@ -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();
}
);
Expand Down

0 comments on commit d871138

Please sign in to comment.