From 82f74dfa013bf121cd1b84f1fa61c71046ab98c1 Mon Sep 17 00:00:00 2001 From: david Date: Mon, 8 Jan 2024 16:38:14 +0800 Subject: [PATCH] move ca to ca folder --- config/caCryptoGen.js | 2 +- dockerode-bootstrap.js | 2 +- test/caTest.js | 61 +++++++++++++++++++++++++++++++----------- 3 files changed, 47 insertions(+), 18 deletions(-) diff --git a/config/caCryptoGen.js b/config/caCryptoGen.js index 04b9889..03fc451 100644 --- a/config/caCryptoGen.js +++ b/config/caCryptoGen.js @@ -6,7 +6,7 @@ import {adminName, adminPwd} from '../common/nodejs/formatter/user.js'; import {loadFromLocal} from '../common/nodejs/user.js'; import {importFrom} from '@davidkhala/light/es6.mjs'; import CA from '../common/nodejs/admin/ca.js'; -import CaCryptoGen from '../common/nodejs/ca-crypto-gen.js'; +import CaCryptoGen from '../common/nodejs/ca/ca-crypto-gen.js'; import * as pathUtil from '../common/nodejs/path.js'; const logger = consoleLogger('caCryptoGen'); diff --git a/dockerode-bootstrap.js b/dockerode-bootstrap.js index 65d743a..b81b4b4 100644 --- a/dockerode-bootstrap.js +++ b/dockerode-bootstrap.js @@ -7,7 +7,7 @@ import {importFrom, filedirname} from '@davidkhala/light/es6.mjs'; import * as peerUtil from './common/nodejs/peer.js'; import {FabricDockerode} from './common/nodejs/fabric-dockerode.js'; import {CryptoPath, ContainerCryptoPath} from './common/nodejs/path.js'; -import {container} from './common/nodejs/ca.js'; +import {container} from './common/nodejs/ca/ca.js'; import * as caCrypoGenUtil from './config/caCryptoGen.js'; diff --git a/test/caTest.js b/test/caTest.js index cf374ab..ad588a7 100644 --- a/test/caTest.js +++ b/test/caTest.js @@ -1,14 +1,15 @@ import assert from 'assert'; import * as helper from '../app/helper.js'; -import IDService from '../common/nodejs/identityService.js'; -import AffiliationService from '../common/nodejs/affiliationService.js'; +import IDService from '../common/nodejs/ca/identityService.js'; +import AffiliationService from '../common/nodejs/ca/affiliationService.js'; import CAService from '../common/nodejs/admin/ca.js'; import {consoleLogger} from '@davidkhala/logger/log4.js'; import * as caCryptoGen from '../config/caCryptoGen.js'; import {importFrom} from '@davidkhala/light/es6.mjs'; +import {ping} from '../common/nodejs/ca/ca.js'; const logger = consoleLogger('ca service'); -const {TLS} = importFrom(import.meta,'../config/orgs.json'); +const {TLS} = importFrom(import.meta, '../config/orgs.json'); describe('caCryptoGen', () => { const org = 'icdd'; @@ -30,8 +31,7 @@ describe('caCryptoGen', () => { }); }); - -describe('caService', () => { +describe('ca service', () => { const org = 'icdd'; const admin = helper.getOrgAdmin(org); const protocol = `http${TLS ? 's' : ''}`; @@ -39,30 +39,59 @@ describe('caService', () => { const port = 8054; const caService = new CAService({protocol, hostname, port}); - const idService = new IDService(caService, admin); - - it('identity service', async () => { - const allIDs = await idService.getAll(admin); - logger.info(allIDs); + it('ping', async () => { + logger.info(caService.url); + const returned = await ping(caService.url); + logger.info(returned); }); +}); + + +describe('AffiliationService', () => { + const org = 'icdd'; + const admin = helper.getOrgAdmin(org); + const protocol = `http${TLS ? 's' : ''}`; + const hostname = 'localhost'; + const port = 8054; + + const caService = new CAService({protocol, hostname, port}); const affiliationService = new AffiliationService(caService, admin); - it('AffiliationService GetAll', async () => { + it('GetAll', async () => { const [allDepartments] = await affiliationService.getAll(); logger.info(allDepartments); }); - it('AffiliationService GetOne', async () => { + it('GetOne', async () => { const result = await affiliationService.getOne('icdd1'); assert.ifError(result); }); - it('AffiliationService create, delete dummy', async () => { + it('create and delete dummy', async () => { const name = 'dummy'; await affiliationService.createIfNotExist(name); await affiliationService.delete(name); }); - it.skip('idemix', async () => { - const result = await caService.idemixEnroll(admin); - logger.info(result); + +}); +describe('identity service', function () { + const org = 'icdd'; + const admin = helper.getOrgAdmin(org); + const protocol = `http${TLS ? 's' : ''}`; + const hostname = 'localhost'; + const port = 8054; + + const caService = new CAService({protocol, hostname, port}); + const idService = new IDService(caService, admin, logger); + it('getAll', async () => { + const allIDs = await idService.getAll(); + logger.info(allIDs); + }); + it('getOne', async () => { + const one = await idService.getOne({enrollmentID: 'Admin'}); + logger.info(one); + }); + it('getOne: on not exist', async () => { + assert.ifError(await idService.getOne({enrollmentID: 'admin'})); + }); });