Skip to content

Commit

Permalink
move ca to ca folder
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkhala committed Jan 8, 2024
1 parent 895dfee commit 82f74df
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 18 deletions.
2 changes: 1 addition & 1 deletion config/caCryptoGen.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion dockerode-bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
61 changes: 45 additions & 16 deletions test/caTest.js
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -30,39 +31,67 @@ describe('caCryptoGen', () => {
});
});


describe('caService', () => {
describe('ca service', () => {
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);

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'}));

});
});

0 comments on commit 82f74df

Please sign in to comment.