Skip to content

Commit

Permalink
Cleanup remaining references to COP
Browse files Browse the repository at this point in the history
Mostly comments, but also renames a couple of classes.

Change-Id: Iafb1032eb2961211ab4f5ffd1b6652d31943c5f3
Signed-off-by: Christopher Ferris <[email protected]>
  • Loading branch information
christo4ferris committed Jan 31, 2017
1 parent 6ef5737 commit 3dc987f
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 86 deletions.
2 changes: 1 addition & 1 deletion examples/balance-transfer/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module.exports.getSubmitter = function(client) {
return user;
} else {
var ca_client = new copService(config.caserver.ca_url);
// need to enroll it with COP server
// need to enroll it with CA server
return ca_client.enroll({
enrollmentID: username,
enrollmentSecret: password
Expand Down
41 changes: 20 additions & 21 deletions fabric-ca-client/lib/FabricCAClientImpl.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,30 +30,30 @@ var urlParser = require('url');
var logger = utils.getLogger('FabricCAClientImpl.js');

/**
* This is an implementation of the member service client which communicates with the Fabric COP server.
* This is an implementation of the member service client which communicates with the Fabric CA server.
* @class
*/
var FabricCOPServices = class {
var FabricCAServices = class {

/**
* constructor
*
* @param {string} url The endpoint URL for Fabric COP services of the form: "http://host:port" or "https://host:port"
* @param {string} url The endpoint URL for Fabric CA services of the form: "http://host:port" or "https://host:port"
* @param {KeyValueStore} kvs KeyValueStore for CryptoSuite
*/
constructor(url, kvs) {

var endpoint = FabricCOPServices._parseURL(url);
var endpoint = FabricCAServices._parseURL(url);

this._fabricCOPClient = new FabricCOPClient({
this._fabricCAClient = new FabricCAClient({
protocol: endpoint.protocol,
hostname: endpoint.hostname,
port: endpoint.port
});

this.cryptoPrimitives = utils.getCryptoSuite(kvs);

logger.info('Successfully constructed Fabric COP service client: endpoint - %j', endpoint);
logger.info('Successfully constructed Fabric CA service client: endpoint - %j', endpoint);

}

Expand Down Expand Up @@ -104,7 +104,7 @@ var FabricCOPServices = class {
//generate CSR using enrollmentID for the subject
try {
var csr = privateKey.generateCSR('CN=' + req.enrollmentID);
self._fabricCOPClient.enroll(req.enrollmentID, req.enrollmentSecret, csr)
self._fabricCAClient.enroll(req.enrollmentID, req.enrollmentSecret, csr)
.then(
function (csrPEM) {
return resolve({
Expand All @@ -130,7 +130,7 @@ var FabricCOPServices = class {
}

/**
* @typedef {Object} FabricCOPServices-HTTPEndpoint
* @typedef {Object} FabricCAServices-HTTPEndpoint
* @property {string} hostname
* @property {number} port
* @property {string} protocol
Expand All @@ -139,7 +139,7 @@ var FabricCOPServices = class {
/**
* Utility function which parses an HTTP URL into its component parts
* @param {string} url HTTP or HTTPS url including protocol, host and port
* @returns {...FabricCOPServices-HTTPEndpoint}
* @returns {...FabricCAServices-HTTPEndpoint}
* @throws InvalidURL for malformed URLs
* @ignore
*/
Expand Down Expand Up @@ -178,22 +178,22 @@ var FabricCOPServices = class {
* return a printable representation of this object
*/
toString() {
return ' FabricCOPServices : {' +
'hostname: ' + this._fabricCOPClient._hostname +
', port: ' + this._fabricCOPClient._port +
return ' FabricCAServices : {' +
'hostname: ' + this._fabricCAClient._hostname +
', port: ' + this._fabricCAClient._port +
'}';
}
};

/**
* Client for communciating with the Fabric COP APIs
* Client for communciating with the Fabric CA APIs
*
* @class
*/
var FabricCOPClient = class {
var FabricCAClient = class {

/**
* @typedef {Object} FabricCOPServices-HTTPEndpoint
* @typedef {Object} FabricCAServices-HTTPEndpoint
* @property {string} hostname
* @property {number} port
* @property {boolean} isSecure
Expand All @@ -202,10 +202,10 @@ var FabricCOPClient = class {
/**
* constructor
*
* @param {object} connect_opts Connection options for communciating with the Fabric COP server
* @param {object} connect_opts Connection options for communciating with the Fabric CA server
* @param {string} connect_opts.protocol The protocol to use (either HTTP or HTTPS)
* @param {string} connect_opts.hostname The hostname of the Fabric COP server endpoint
* @param {number} connect_opts.port The port of the Fabric COP server endpoint
* @param {string} connect_opts.hostname The hostname of the Fabric CA server endpoint
* @param {number} connect_opts.port The port of the Fabric CA server endpoint
* @param {Buffer[]} connect_opts.ca An array of trusted certificates in PEM format
* @throws Will throw an error if connection options are missing or invalid
*
Expand Down Expand Up @@ -463,6 +463,5 @@ var FabricCOPClient = class {
}
};

module.exports = FabricCOPServices;
module.exports.FabricCOPClient = FabricCOPClient;

module.exports = FabricCAServices;
module.exports.FabricCAClient = FabricCAClient;
2 changes: 1 addition & 1 deletion fabric-client/lib/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ var Client = class {
* in the storage which can be accessed by authorized users of the application (authentication is done by
* the application outside of the SDK). This function attempts to load the user by name from the local storage
* (via the KeyValueStore interface). The loaded user object must represent an enrolled user with a valid
* enrollment certificate signed by a trusted CA (such as the COP server).
* enrollment certificate signed by a trusted CA (such as the CA server).
*
* @param {String} name Optional. If not specified, will only return the in-memory user context object, or null
* if not found in memory. If "name" is specified, will also attempt to load it from the state store if search
Expand Down
2 changes: 1 addition & 1 deletion fabric-client/lib/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var MSP = require('./msp/msp.js');
* transactions and queries with the Chain.
*
* User ECerts can be obtained from a CA beforehand as part of deploying the application,
* or it can be obtained from the optional Fabric COP service via its enrollment process.
* or it can be obtained from the optional Fabric CA service via its enrollment process.
*
* Sometimes User identities are confused with Peer identities. User identities represent
* signing capability because it has access to the private key, while Peer identities in
Expand Down
8 changes: 4 additions & 4 deletions test/unit/chain-fabriccop-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var _test = require('tape-promise');
var test = _test(tape);

var hfc = require('fabric-client');
var FabricCOPServices = require('fabric-ca-client/lib/FabricCAClientImpl');
var FabricCAServices = require('fabric-ca-client/lib/FabricCAClientImpl');

var utils = require('fabric-client/lib/utils.js');
var User = require('fabric-client/lib/User.js');
Expand All @@ -33,7 +33,7 @@ var keyValStorePath = testUtil.KVS;
// saves the enrollment materials into a key value store.
// then uses the Client class to load the member from the
// key value store
test('Attempt to use FabricCOPServices',function(t){
test('Attempt to use FabricCAServices',function(t){

var client = new Client();

Expand All @@ -46,15 +46,15 @@ test('Attempt to use FabricCOPServices',function(t){
function(kvs) {
client.setStateStore(kvs);

var copService = new FabricCOPServices('http://localhost:7054');
var copService = new FabricCAServices('http://localhost:7054');
var member;
copService.enroll({
enrollmentID: 'notadmin',
enrollmentSecret: 'pass'
})
.then(
function(testUser) {
t.pass('Successfully enrolled testUser with COP server');
t.pass('Successfully enrolled testUser with CA server');

member = new User('testUser', client);
return member.setEnrollment(testUser.key, testUser.certificate);
Expand Down
16 changes: 8 additions & 8 deletions test/unit/cloudant-fabriccop-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var test = _test(tape);
var hfc = require('fabric-client');
var Client = hfc;
var User = require('fabric-client/lib/User.js');
var FabricCOPServices = require('fabric-ca-client/lib/FabricCAClientImpl');
var FabricCAServices = require('fabric-ca-client/lib/FabricCAClientImpl');

var utils = require('fabric-client/lib/utils.js');
var couchdbUtil = require('./couchdb-util.js');
Expand All @@ -37,7 +37,7 @@ console.log('Key Value Store = ' + keyValueStore);
// FabricCAClientImpl to enroll a user, and saves the enrollment materials into the
// CouchDB KeyValueStore. Then the test uses the Chain class to load the member
// from the key value store.
test('Use FabricCOPServices wih a Cloudant CouchDB KeyValueStore', function(t) {
test('Use FabricCAServices wih a Cloudant CouchDB KeyValueStore', function(t) {

//var user = new User();
var client = new Client();
Expand Down Expand Up @@ -65,8 +65,8 @@ test('Use FabricCOPServices wih a Cloudant CouchDB KeyValueStore', function(t) {
t.end();
process.exit(1);
}
t.comment('Initialize the COP server connection and KeyValueStore');
return new FabricCOPServices('http://localhost:7054', kvs);
t.comment('Initialize the CA server connection and KeyValueStore');
return new FabricCAServices('http://localhost:7054', kvs);
},
function(err) {
console.log(err);
Expand All @@ -77,7 +77,7 @@ test('Use FabricCOPServices wih a Cloudant CouchDB KeyValueStore', function(t) {
.then(
function(copService) {
console.log('ADD: copService - ' + copService);
t.pass('Successfully initialized the Fabric COP service.');
t.pass('Successfully initialized the Fabric CA service.');

client.setCryptoSuite(copService.getCrypto());
t.comment('Set cryptoSuite on client');
Expand All @@ -88,13 +88,13 @@ test('Use FabricCOPServices wih a Cloudant CouchDB KeyValueStore', function(t) {
});
},
function(err) {
t.fail('Failed to initilize the Fabric COP service: ' + err);
t.fail('Failed to initilize the Fabric CA service: ' + err);
t.end();
}
)
.then(
function(admin2) {
t.pass('Successfully enrolled admin2 with COP server');
t.pass('Successfully enrolled admin2 with CA server');

// Persist the user state
var member = new User('admin2', client);
Expand All @@ -114,7 +114,7 @@ test('Use FabricCOPServices wih a Cloudant CouchDB KeyValueStore', function(t) {
return client.setUserContext(member);
},
function(err) {
t.fail('Failed to enroll admin2 with COP server. Error: ' + err);
t.fail('Failed to enroll admin2 with CA server. Error: ' + err);
t.end();
})
.then(
Expand Down
16 changes: 8 additions & 8 deletions test/unit/couchdb-fabriccop-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var test = _test(tape);
var hfc = require('fabric-client');
var Client = hfc;
var User = require('fabric-client/lib/User.js');
var FabricCOPServices = require('fabric-ca-client/lib/FabricCAClientImpl');
var FabricCAServices = require('fabric-ca-client/lib/FabricCAClientImpl');

var utils = require('fabric-client/lib/utils.js');
var couchdbUtil = require('./couchdb-util.js');
Expand All @@ -37,7 +37,7 @@ console.log('Key Value Store = ' + keyValueStore);
// FabricCAClientImpl to enroll a user, and saves the enrollment materials into the
// CouchDB KeyValueStore. Then the test uses the Chain class to load the member
// from the key value store.
test('Use FabricCOPServices with a CouchDB KeyValueStore', function(t) {
test('Use FabricCAServices with a CouchDB KeyValueStore', function(t) {

//var user = new User();
var client = new Client();
Expand All @@ -63,8 +63,8 @@ test('Use FabricCOPServices with a CouchDB KeyValueStore', function(t) {
t.end();
process.exit(1);
}
t.comment('Initialize the COP server connection and KeyValueStore');
return new FabricCOPServices('http://localhost:7054', kvs);
t.comment('Initialize the CA server connection and KeyValueStore');
return new FabricCAServices('http://localhost:7054', kvs);
},
function(err) {
console.log(err);
Expand All @@ -75,7 +75,7 @@ test('Use FabricCOPServices with a CouchDB KeyValueStore', function(t) {
.then(
function(copService) {
console.log('ADD: copService - ' + copService);
t.pass('Successfully initialized the Fabric COP service.');
t.pass('Successfully initialized the Fabric CA service.');

client.setCryptoSuite(copService.getCrypto());
t.comment('Set cryptoSuite on client');
Expand All @@ -86,13 +86,13 @@ test('Use FabricCOPServices with a CouchDB KeyValueStore', function(t) {
});
},
function(err) {
t.fail('Failed to initilize the Fabric COP service: ' + err);
t.fail('Failed to initilize the Fabric CA service: ' + err);
t.end();
}
)
.then(
function(admin2) {
t.pass('Successfully enrolled admin2 with COP server');
t.pass('Successfully enrolled admin2 with CA server');

// Persist the user state
var member = new User('admin2', client);
Expand All @@ -105,7 +105,7 @@ test('Use FabricCOPServices with a CouchDB KeyValueStore', function(t) {
return client.setUserContext(member);
},
function(err) {
t.fail('Failed to enroll admin2 with COP server. Error: ' + err);
t.fail('Failed to enroll admin2 with CA server. Error: ' + err);
t.end();
})
.then(
Expand Down
31 changes: 15 additions & 16 deletions test/unit/fabriccopservices-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ var utils = require('fabric-client/lib/utils.js');
var keyValStorePath = testUtil.KVS;


var FabricCOPServices = require('fabric-ca-client/lib/FabricCAClientImpl');
var FabricCOPClient = FabricCOPServices.FabricCOPClient;
var FabricCAServices = require('fabric-ca-client/lib/FabricCAClientImpl');
var FabricCAClient = FabricCAServices.FabricCAClient;

/**
* FabricCOPClient enroll tests
* FabricCAClient enroll tests
*/
test('FabricCOPClient: Test enroll with missing parameters', function (t) {
test('FabricCAClient: Test enroll with missing parameters', function (t) {

var client = new FabricCOPClient({
var client = new FabricCAClient({
protocol: 'http',
hostname: '127.0.0.1',
port: 7054
Expand All @@ -65,9 +65,9 @@ var enrollmentSecret = 'user1';
var csr = fs.readFileSync(path.resolve(__dirname, '../fixtures/fabriccop/enroll-csr.pem'));


test('FabricCOPClient: Test enroll With Static CSR', function (t) {
test('FabricCAClient: Test enroll With Static CSR', function (t) {

var client = new FabricCOPClient({
var client = new FabricCAClient({
protocol: 'http',
hostname: '127.0.0.1',
port: 7054
Expand All @@ -90,18 +90,18 @@ test('FabricCOPClient: Test enroll With Static CSR', function (t) {
});

/**
* FabricCOPServices class tests
* FabricCAServices class tests
*/

//run the enroll test

test('FabricCOPServices: Test enroll() With Dynamic CSR', function (t) {
test('FabricCAServices: Test enroll() With Dynamic CSR', function (t) {

// need to override the default key size 384 to match the member service backend
// otherwise the client will not be able to decrypt the enrollment challenge
utils.setConfigSetting('crypto-keysize', 256);

var cop = new FabricCOPServices('http://localhost:7054');
var cop = new FabricCAServices('http://localhost:7054');

var req = {
enrollmentID: 'admin',
Expand All @@ -128,11 +128,11 @@ test('FabricCOPServices: Test enroll() With Dynamic CSR', function (t) {
});

/**
* FabricCOPClient register tests
* FabricCAClient register tests
*/
test('FabricCOPClient: Test register with missing parameters', function (t) {
test('FabricCAClient: Test register with missing parameters', function (t) {

var client = new FabricCOPClient({
var client = new FabricCAClient({
protocol: 'http',
hostname: '127.0.0.1',
port: 7054
Expand All @@ -151,9 +151,9 @@ test('FabricCOPClient: Test register with missing parameters', function (t) {
});
});

test('FabricCOPClient: Test register', function (t) {
test('FabricCAClient: Test register', function (t) {

var client = new FabricCOPClient({
var client = new FabricCAClient({
protocol: 'http',
hostname: '127.0.0.1',
port: 7054
Expand All @@ -172,4 +172,3 @@ test('FabricCOPClient: Test register', function (t) {
t.fail('Failed to register \'' + enrollmentID + '\'. ' + err);
});
});

Loading

0 comments on commit 3dc987f

Please sign in to comment.