Skip to content

Commit

Permalink
[FAB-11059] complete ca-client mocha tests
Browse files Browse the repository at this point in the history
This change:
- add unit tests for remaning 'core' fabric-ca-client files
- Extracts FabricCAClient from being an inner class within `FabricCAClientImpl`
- Renames the `FabricClientCAImpl` to match the export name `FabricClientServices`
- Updates the main export in index.js
- Fixes tested functions where bugs found
- Removes tape unit test now covered by Mocha
- Updates all references to newly named file in tests

Change-Id: I23ecda6cd22d3ce69ef7a73ab687491e6777d5ad
Signed-off-by: nkl199@yahoo.co.uk <nkl199@yahoo.co.uk>
  • Loading branch information
nklincoln committed Jul 26, 2018
1 parent ef27a40 commit b7e528d
Show file tree
Hide file tree
Showing 25 changed files with 4,000 additions and 2,195 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ docs/gen
node_modules/*
fabric-client/node_modules/*
fabric-ca-client/node_modules/*
fabric-ca-client/.nyc_output
fabric-ca-client/lib/api.js
fabric-ca-client/lib/utils.js
fabric-ca-client/lib/BaseClient.js
Expand Down
20 changes: 10 additions & 10 deletions fabric-ca-client/index.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
/**
* Copyright 2016 IBM All Rights Reserved.
*
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

/**
* This is the main module for the "fabric-ca-client" package. It communicates with the
* "fabric-ca" server to manage user certificates lifecycle including register, enroll,
* renew and revoke, so that the application can use the properly signed certificates to
* authenticate with the fabric
*/
module.exports = require('./lib/FabricCAClientImpl.js');
module.exports = require('./lib/FabricCAServices.js');
6 changes: 5 additions & 1 deletion fabric-ca-client/lib/CertificateService.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

const querystring = require('querystring');
const logger = require('./utils.js').getLogger('CertificateService');
const checkRegistrar = require('./helper').checkRegistrar;

class CertificateService {
constructor(client) {
Expand Down Expand Up @@ -46,6 +47,9 @@ class CertificateService {
*/
async getCertificates(request, registrar) {
logger.debug('getCertificates by %j', request);

checkRegistrar(registrar);

let url = 'certificates';
if (request) {
const query = {};
Expand Down Expand Up @@ -79,7 +83,7 @@ class CertificateService {
if(request.ca && typeof request.ca === 'string'){
query.ca = request.ca;
}
let qStr = querystring.stringify(query);
const qStr = querystring.stringify(query);
if(qStr) {
url += `?${qStr}`;
}
Expand Down
Loading

0 comments on commit b7e528d

Please sign in to comment.