From 84d758aca358c1fe6540ce55ce9e07e30521d679 Mon Sep 17 00:00:00 2001 From: Dave Kelsey Date: Wed, 14 Jun 2017 07:41:44 +0100 Subject: [PATCH 1/3] first pass of removing ccid conversion Signed-off-by: Dave Kelsey --- .../lib/businessnetworkmetadata.js | 5 ++ .../test/businessnetworkmetadata.js | 22 ++++++- .../lib/hlfconnection.js | 25 ++----- .../test/hlfconnection.js | 45 +++++-------- .../test/hlfconnectionmanager.js | 66 +++++++++---------- .../test/proxyconnection.js | 6 +- .../test/proxyconnectionmanager.js | 2 +- .../test/connectorserver.js | 6 +- .../test/webconnection.js | 12 ++-- .../add-certificate.component.spec.ts | 6 +- .../add-connection-profile.component.spec.ts | 6 +- .../app/add-file/add-file.component.spec.ts | 6 +- .../src/app/services/admin.service.spec.ts | 8 +-- .../src/app/services/admin.service.ts | 10 +-- .../src/app/services/client.service.ts | 2 +- .../composer-rest-server/server/composer.json | 2 +- packages/composer-rest-server/test/cli.js | 14 ++-- .../composer-rest-server/test/lib/util.js | 2 +- .../test/server/servercmd.js | 4 +- .../systest/accesscontrols.js | 2 +- packages/composer-systests/systest/assets.js | 2 +- packages/composer-systests/systest/events.js | 2 +- .../composer-systests/systest/identities.js | 2 +- .../composer-systests/systest/participants.js | 2 +- packages/composer-systests/systest/post.js | 2 +- packages/composer-systests/systest/query.js | 2 +- .../systest/transactions.assets.js | 2 +- .../composer-systests/systest/transactions.js | 2 +- .../systest/transactions.participants.js | 2 +- 29 files changed, 135 insertions(+), 134 deletions(-) diff --git a/packages/composer-common/lib/businessnetworkmetadata.js b/packages/composer-common/lib/businessnetworkmetadata.js index 67147c2878..474ae28fd7 100644 --- a/packages/composer-common/lib/businessnetworkmetadata.js +++ b/packages/composer-common/lib/businessnetworkmetadata.js @@ -47,6 +47,11 @@ class BusinessNetworkMetadata { throw new Error('package.json is required and must be an object'); } + const regex = /^[a-z0-9_-]+$/; + if (!packageJson.name || !regex.test(packageJson.name)) { + throw new Error ('business network name can only contain lowercase alphanumerics, _ or -'); + } + this.packageJson = packageJson; if(readme && typeof(readme) !== 'string') { diff --git a/packages/composer-common/test/businessnetworkmetadata.js b/packages/composer-common/test/businessnetworkmetadata.js index d75a662bd0..98e33d4e18 100644 --- a/packages/composer-common/test/businessnetworkmetadata.js +++ b/packages/composer-common/test/businessnetworkmetadata.js @@ -29,13 +29,31 @@ describe('BusinessNetworkMetadata', () => { it('should throw if readme not specified', () => { (() => { - new BusinessNetworkMetadata({}, {}); + const packageJson = {name: 'foo'}; + new BusinessNetworkMetadata(packageJson, {}); }).should.throw(/README must be a string/); }); + it('should throw if business network connection name contains upper case', () => { + (() => { + const readme = 'TEST README'; + const packageJson = {name: 'fOo'}; + new BusinessNetworkMetadata(packageJson,readme); + }).should.throw(/business network name can only contain/); + }); + + it('should throw if business network connection name contains dots', () => { + (() => { + const readme = 'TEST README'; + const packageJson = {name: 'foo.bar'}; + new BusinessNetworkMetadata(packageJson,readme); + }).should.throw(/business network name can only contain/); + }); + + it('should store package.json and README', () => { const readme = 'TEST README'; - const packageJson = {name: 'Foo'}; + const packageJson = {name: 'foo_bar-v1'}; let metadata = new BusinessNetworkMetadata(packageJson,readme); metadata.getREADME().should.equal(readme); metadata.getPackageJson().should.equal(packageJson); diff --git a/packages/composer-connector-hlfv1/lib/hlfconnection.js b/packages/composer-connector-hlfv1/lib/hlfconnection.js index 6e8c367991..b23e777d31 100644 --- a/packages/composer-connector-hlfv1/lib/hlfconnection.js +++ b/packages/composer-connector-hlfv1/lib/hlfconnection.js @@ -64,19 +64,6 @@ class HLFConnection extends Connection { return new EventHub(clientContext); } - /** - * generate a valid Ccid - * - * @static - * @param {string} input the name used to define the CCid - * @returns {string} a valid ccid - * - * @memberOf HLFConnection - */ - static generateCcid(input) { - return input.replace(/\./g, '-').replace(/[|&;$%@"<>()+,]/g, '').toLowerCase(); - } - /** * Constructor. * @param {ConnectionManager} connectionManager The owning connection manager. @@ -230,7 +217,7 @@ class HLFConnection extends Connection { if (this.businessNetworkIdentifier) { // register a chaincode event listener on the first peer only. - let ccid = HLFConnection.generateCcid(this.businessNetworkIdentifier); + let ccid = this.businessNetworkIdentifier; LOG.debug(method, 'registerChaincodeEvent', ccid, 'composer'); let ccEvent = this.eventHubs[0].registerChaincodeEvent(ccid, 'composer', (event) => { let evt = event.payload.toString('utf8'); @@ -358,7 +345,7 @@ class HLFConnection extends Connection { const request = { chaincodePath: chaincodePath, chaincodeVersion: runtimePackageJSON.version, - chaincodeId: HLFConnection.generateCcid(businessNetwork.getName()), + chaincodeId: businessNetwork.getName(), txId: txId, targets: this.channel.getPeers() }; @@ -432,7 +419,7 @@ class HLFConnection extends Connection { const request = { chaincodePath: chaincodePath, chaincodeVersion: runtimePackageJSON.version, - chaincodeId: HLFConnection.generateCcid(businessNetwork.getName()), + chaincodeId: businessNetwork.getName(), txId: finalTxId, fcn: 'init', args: [businessNetworkArchive.toString('base64')] @@ -503,7 +490,7 @@ class HLFConnection extends Connection { .then((queryResults) => { LOG.debug(method, 'Queried instantiated chaincodes', queryResults); let alreadyInstantiated = queryResults.chaincodes.some((chaincode) => { - return chaincode.path === 'composer' && chaincode.name === HLFConnection.generateCcid(businessNetwork.getName()); + return chaincode.path === 'composer' && chaincode.name === businessNetwork.getName(); }); if (alreadyInstantiated) { LOG.debug(method, 'chaincode already instantiated'); @@ -714,7 +701,7 @@ class HLFConnection extends Connection { // Submit the query request. const request = { - chaincodeId: HLFConnection.generateCcid(this.businessNetworkIdentifier), + chaincodeId: this.businessNetworkIdentifier, chaincodeVersion: runtimePackageJSON.version, txId: txId, fcn: functionName, @@ -778,7 +765,7 @@ class HLFConnection extends Connection { // Submit the transaction to the endorsers. const request = { - chaincodeId: HLFConnection.generateCcid(this.businessNetworkIdentifier), + chaincodeId: this.businessNetworkIdentifier, chaincodeVersion: runtimePackageJSON.version, txId: txId, fcn: functionName, diff --git a/packages/composer-connector-hlfv1/test/hlfconnection.js b/packages/composer-connector-hlfv1/test/hlfconnection.js index d1454ac249..591cff904e 100644 --- a/packages/composer-connector-hlfv1/test/hlfconnection.js +++ b/packages/composer-connector-hlfv1/test/hlfconnection.js @@ -66,7 +66,7 @@ describe('HLFConnection', () => { mockClient.newTransactionID.returns(mockTransactionID); mockSecurityContext = sinon.createStubInstance(HLFSecurityContext); mockBusinessNetwork = sinon.createStubInstance(BusinessNetworkDefinition); - mockBusinessNetwork.getName.returns('org.acme.biznet'); + mockBusinessNetwork.getName.returns('org-acme-biznet'); mockBusinessNetwork.toArchive.resolves(Buffer.from('hello world')); connectOptions = { channel: 'testchainid', @@ -77,7 +77,7 @@ describe('HLFConnection', () => { mockEventHubDef = { 'eventURL': 'http://localhost:7053' }; - connection = new HLFConnection(mockConnectionManager, 'hlfabric1', 'org.acme.biznet', connectOptions, mockClient, mockChannel, [mockEventHubDef], mockCAClient); + connection = new HLFConnection(mockConnectionManager, 'hlfabric1', 'org-acme-biznet', connectOptions, mockClient, mockChannel, [mockEventHubDef], mockCAClient); }); afterEach(() => { @@ -85,14 +85,6 @@ describe('HLFConnection', () => { connectorPackageJSON.version = originalVersion; }); - describe('#generateCcid', () => { - it('should create a valid ccid', () => { - HLFConnection.generateCcid('my.domain.biznet').should.equal('my-domain-biznet'); - HLFConnection.generateCcid('My.Domain.BIZnet').should.equal('my-domain-biznet'); - }); - - }); - describe('#createUser', () => { it('should create a new user', () => { @@ -125,38 +117,38 @@ describe('HLFConnection', () => { it('should throw if connectOptions not specified', () => { (() => { - new HLFConnection(mockConnectionManager, 'hlfabric1', 'org.acme.biznet', null, mockClient, mockChannel, [mockEventHubDef], mockCAClient); + new HLFConnection(mockConnectionManager, 'hlfabric1', 'org-acme-biznet', null, mockClient, mockChannel, [mockEventHubDef], mockCAClient); }).should.throw(/connectOptions not specified/); }); it('should throw if client not specified', () => { (() => { - new HLFConnection(mockConnectionManager, 'hlfabric1', 'org.acme.biznet', { type: 'hlfv1' }, null, mockChannel, [mockEventHubDef], mockCAClient); + new HLFConnection(mockConnectionManager, 'hlfabric1', 'org-acme-biznet', { type: 'hlfv1' }, null, mockChannel, [mockEventHubDef], mockCAClient); }).should.throw(/client not specified/); }); it('should throw if channel not specified', () => { (() => { - new HLFConnection(mockConnectionManager, 'hlfabric1', 'org.acme.biznet', { type: 'hlfv1' }, mockClient, null, [mockEventHubDef], mockCAClient); + new HLFConnection(mockConnectionManager, 'hlfabric1', 'org-acme-biznet', { type: 'hlfv1' }, mockClient, null, [mockEventHubDef], mockCAClient); }).should.throw(/channel not specified/); }); it('should throw if eventHubDefs not specified', () => { (() => { - new HLFConnection(mockConnectionManager, 'hlfabric1', 'org.acme.biznet', { type: 'hlfv1' }, mockClient, mockChannel, null, mockCAClient); + new HLFConnection(mockConnectionManager, 'hlfabric1', 'org-acme-biznet', { type: 'hlfv1' }, mockClient, mockChannel, null, mockCAClient); }).should.throw(/eventHubDefs not specified or not an array/); }); it('should throw if eventHubDefs not an array', () => { (() => { - new HLFConnection(mockConnectionManager, 'hlfabric1', 'org.acme.biznet', { type: 'hlfv1' }, mockClient, mockChannel, mockEventHubDef, mockCAClient); + new HLFConnection(mockConnectionManager, 'hlfabric1', 'org-acme-biznet', { type: 'hlfv1' }, mockClient, mockChannel, mockEventHubDef, mockCAClient); }).should.throw(/eventHubDefs not specified or not an array/); }); it('should throw if caClient not specified', () => { (() => { - new HLFConnection(mockConnectionManager, 'hlfabric1', 'org.acme.biznet', { type: 'hlfv1' }, mockClient, mockChannel, [mockEventHubDef], null); + new HLFConnection(mockConnectionManager, 'hlfabric1', 'org-acme-biznet', { type: 'hlfv1' }, mockClient, mockChannel, [mockEventHubDef], null); }).should.throw(/caClient not specified/); }); }); @@ -193,7 +185,6 @@ describe('HLFConnection', () => { }); it('should subscribe to the eventHub and emit events', () => { - //sandbox.stub(Buffer, 'from').returns('"{"event":"event"}"'); connection._connectToEventHubs(); const events = { payload: { @@ -592,7 +583,7 @@ describe('HLFConnection', () => { mspID: 'suchmsp', timeout: 22 }; - connection = new HLFConnection(mockConnectionManager, 'hlfabric1', 'org.acme.biznet', connectOptions, mockClient, mockChannel, [mockEventHubDef], mockCAClient); + connection = new HLFConnection(mockConnectionManager, 'hlfabric1', 'org-acme-biznet', connectOptions, mockClient, mockChannel, [mockEventHubDef], mockCAClient); sandbox.stub(connection, '_validateResponses').returns(); sandbox.stub(connection, '_initializeChannel').resolves(); connection._connectToEventHubs(); @@ -891,7 +882,7 @@ describe('HLFConnection', () => { it('should invoke the chaincode', () => { sandbox.stub(connection, 'invokeChainCode').resolves(); - return connection.undeploy(mockSecurityContext, 'org.acme.biznet') + return connection.undeploy(mockSecurityContext, 'org-acme-biznet') .then(() => { sinon.assert.calledOnce(connection.invokeChainCode); sinon.assert.calledWith(connection.invokeChainCode, mockSecurityContext, 'undeployBusinessNetwork', []); @@ -900,7 +891,7 @@ describe('HLFConnection', () => { it('should handle errors invoking the chaincode', () => { sandbox.stub(connection, 'invokeChainCode').rejects('such error'); - return connection.undeploy(mockSecurityContext, 'org.acme.biznet') + return connection.undeploy(mockSecurityContext, 'org-acme-biznet') .should.be.rejectedWith(/such error/); }); @@ -1180,7 +1171,7 @@ describe('HLFConnection', () => { mspID: 'suchmsp', timeout: 38 }; - connection = new HLFConnection(mockConnectionManager, 'hlfabric1', 'org.acme.biznet', connectOptions, mockClient, mockChannel, [mockEventHubDef], mockCAClient); + connection = new HLFConnection(mockConnectionManager, 'hlfabric1', 'org-acme-biznet', connectOptions, mockClient, mockChannel, [mockEventHubDef], mockCAClient); sandbox.stub(connection, '_validateResponses').returns(); sandbox.stub(connection, '_initializeChannel').resolves(); connection._connectToEventHubs(); @@ -1405,33 +1396,33 @@ describe('HLFConnection', () => { it('should return an array of chaincode names for all instantiated chaincodes', () => { mockChannel.queryInstantiatedChaincodes.resolves({ chaincodes: [{ - name: 'org.acme.biznet1', + name: 'org-acme-biznet1', version: '1.0.0', path: 'composer' }, { - name: 'org.acme.biznet2', + name: 'org-acme-biznet2', version: '1.2.0', path: 'composer' }] }); return connection.list(mockSecurityContext) - .should.eventually.be.deep.equal(['org.acme.biznet1', 'org.acme.biznet2']); + .should.eventually.be.deep.equal(['org-acme-biznet1', 'org-acme-biznet2']); }); it('should filter out any non-composer instantiated chaincodes', () => { mockChannel.queryInstantiatedChaincodes.resolves({ chaincodes: [{ - name: 'org.acme.biznet1', + name: 'org-acme-biznet1', version: '1.0.0', path: 'composer' }, { - name: 'org.acme.biznet2', + name: 'org-acme-biznet2', version: '1.2.0', path: 'dogecc' }] }); return connection.list(mockSecurityContext) - .should.eventually.be.deep.equal(['org.acme.biznet1']); + .should.eventually.be.deep.equal(['org-acme-biznet1']); }); it('should handle any errors querying instantiated chaincodes', () => { diff --git a/packages/composer-connector-hlfv1/test/hlfconnectionmanager.js b/packages/composer-connector-hlfv1/test/hlfconnectionmanager.js index 01ddefc8d2..7f39f4d7f7 100644 --- a/packages/composer-connector-hlfv1/test/hlfconnectionmanager.js +++ b/packages/composer-connector-hlfv1/test/hlfconnectionmanager.js @@ -545,48 +545,48 @@ describe('HLFConnectionManager', () => { it('should throw if connectionProfile not specified', () => { (() => { - connectionManager.connect(null, 'org.acme.biznet', connectOptions); + connectionManager.connect(null, 'org-acme-biznet', connectOptions); }).should.throw(/connectionProfile not specified/); }); it('should throw if connectOptions not specified', () => { (() => { - connectionManager.connect('hlfabric1', 'org.acme.biznet', null); + connectionManager.connect('hlfabric1', 'org-acme-biznet', null); }).should.throw(/connectOptions not specified/); }); it('should throw if msp id is not specified', () => { delete connectOptions.mspID; (() => { - connectionManager.connect('hlfabric1', 'org.acme.biznet', connectOptions); + connectionManager.connect('hlfabric1', 'org-acme-biznet', connectOptions); }).should.throw(/No msp id defined/); }); it('should throw if orderers are not specified', () => { delete connectOptions.orderers; (() => { - connectionManager.connect('hlfabric1', 'org.acme.biznet', connectOptions); + connectionManager.connect('hlfabric1', 'org-acme-biznet', connectOptions); }).should.throw(/orderers array has not been specified/); }); it('should throw if orderers is an empty array', () => { connectOptions.orderers = []; (() => { - connectionManager.connect('hlfabric1', 'org.acme.biznet', connectOptions); + connectionManager.connect('hlfabric1', 'org-acme-biznet', connectOptions); }).should.throw(/No orderer URLs have been specified/); }); it('should throw if peers are not specified', () => { delete connectOptions.peers; (() => { - connectionManager.connect('hlfabric1', 'org.acme.biznet', connectOptions); + connectionManager.connect('hlfabric1', 'org-acme-biznet', connectOptions); }).should.throw(/peers array has not been specified/); }); it('should throw if peers is an empty array', () => { connectOptions.peers = []; (() => { - connectionManager.connect('hlfabric1', 'org.acme.biznet', connectOptions); + connectionManager.connect('hlfabric1', 'org-acme-biznet', connectOptions); }).should.throw(/No peer URLs have been specified/); }); @@ -595,35 +595,35 @@ describe('HLFConnectionManager', () => { requestURL: 'grpc://localhost:7051' }]; (() => { - connectionManager.connect('hlfabric1', 'org.acme.biznet', connectOptions); + connectionManager.connect('hlfabric1', 'org-acme-biznet', connectOptions); }).should.throw('The peer at requestURL grpc://localhost:7051 has no eventURL defined'); connectOptions.peers = [{ eventURL: 'grpc://localhost:7053' }]; (() => { - connectionManager.connect('hlfabric1', 'org.acme.biznet', connectOptions); + connectionManager.connect('hlfabric1', 'org-acme-biznet', connectOptions); }).should.throw('The peer at eventURL grpc://localhost:7053 has no requestURL defined'); connectOptions.peers = [{ rurl: 'grpc://localhost:7051', eURL: 'grpc://localhost:7051' }]; (() => { - connectionManager.connect('hlfabric1', 'org.acme.biznet', connectOptions); + connectionManager.connect('hlfabric1', 'org-acme-biznet', connectOptions); }).should.throw('peer incorrectly defined'); }); it('should throw if ca is not specified', () => { delete connectOptions.ca; (() => { - connectionManager.connect('hlfabric1', 'org.acme.biznet', connectOptions); + connectionManager.connect('hlfabric1', 'org-acme-biznet', connectOptions); }).should.throw(/The certificate authority URL has not been specified/); }); it('should throw if keyValStore and wallet are not specified', () => { delete connectOptions.keyValStore; (() => { - connectionManager.connect('hlfabric1', 'org.acme.biznet', connectOptions); + connectionManager.connect('hlfabric1', 'org-acme-biznet', connectOptions); }).should.throw(/No key value store directory or wallet has been specified/); }); @@ -632,15 +632,15 @@ describe('HLFConnectionManager', () => { it('should throw if channel is not specified', () => { delete connectOptions.channel; (() => { - connectionManager.connect('hlfabric1', 'org.acme.biznet', connectOptions); + connectionManager.connect('hlfabric1', 'org-acme-biznet', connectOptions); }).should.throw(/No channel has been specified/); }); it('should create a new connection with a business network identifier', () => { - return connectionManager.connect('hlfabric1', 'org.acme.biznet', connectOptions) + return connectionManager.connect('hlfabric1', 'org-acme-biznet', connectOptions) .then((connection) => { connection.getConnectionManager().should.equal(connectionManager); - connection.getIdentifier().should.equal('org.acme.biznet@hlfabric1'); + connection.getIdentifier().should.equal('org-acme-biznet@hlfabric1'); connection.should.be.an.instanceOf(HLFConnection); connection.getConnectionOptions().should.deep.equal(connectOptions); connection.client.should.deep.equal(mockClient); @@ -691,7 +691,7 @@ describe('HLFConnectionManager', () => { it('should set message sizes to value specified', () => { connectOptions.maxSendSize = 7; connectOptions.maxRecvSize = 3; - return connectionManager.connect('hlfabric1', 'org.acme.biznet', connectOptions) + return connectionManager.connect('hlfabric1', 'org-acme-biznet', connectOptions) .then((connection) => { sinon.assert.calledTwice(configSettingStub); sinon.assert.calledWith(configSettingStub, 'grpc-max-send-message-length', 7 * 1024 * 1024); @@ -702,7 +702,7 @@ describe('HLFConnectionManager', () => { it('should set message sizes to -1 if -1 specified', () => { connectOptions.maxSendSize = -1; connectOptions.maxRecvSize = -1; - return connectionManager.connect('hlfabric1', 'org.acme.biznet', connectOptions) + return connectionManager.connect('hlfabric1', 'org-acme-biznet', connectOptions) .then((connection) => { sinon.assert.calledTwice(configSettingStub); sinon.assert.calledWith(configSettingStub, 'grpc-max-send-message-length', -1); @@ -713,7 +713,7 @@ describe('HLFConnectionManager', () => { it('should ignore a value of 0 for message size limits to leave as default', () => { connectOptions.maxSendSize = 0; connectOptions.maxRecvSize = 0; - return connectionManager.connect('hlfabric1', 'org.acme.biznet', connectOptions) + return connectionManager.connect('hlfabric1', 'org-acme-biznet', connectOptions) .then((connection) => { configSettingStub.called.should.be.false; }); @@ -722,14 +722,14 @@ describe('HLFConnectionManager', () => { it('should ignore string values for message size limits', () => { connectOptions.maxSendSize = '1'; connectOptions.maxRecvSize = '2'; - return connectionManager.connect('hlfabric1', 'org.acme.biznet', connectOptions) + return connectionManager.connect('hlfabric1', 'org-acme-biznet', connectOptions) .then((connection) => { configSettingStub.called.should.be.false; }); }); it('should add a single orderer to the chain', () => { - return connectionManager.connect('hlfabric1', 'org.acme.biznet', connectOptions) + return connectionManager.connect('hlfabric1', 'org-acme-biznet', connectOptions) .then((connection) => { sinon.assert.calledOnce(HLFConnectionManager.createOrderer); sinon.assert.calledWith(HLFConnectionManager.createOrderer, 'grpc://localhost:7050'); @@ -743,7 +743,7 @@ describe('HLFConnectionManager', () => { 'grpc://localhost:8050', 'grpc://localhost:9050' ]; - return connectionManager.connect('hlfabric1', 'org.acme.biznet', connectOptions) + return connectionManager.connect('hlfabric1', 'org-acme-biznet', connectOptions) .then((connection) => { sinon.assert.calledThrice(HLFConnectionManager.createOrderer); sinon.assert.calledWith(HLFConnectionManager.createOrderer, 'grpc://localhost:7050'); @@ -754,7 +754,7 @@ describe('HLFConnectionManager', () => { }); it('should add a single peer to the chain', () => { - return connectionManager.connect('hlfabric1', 'org.acme.biznet', connectOptions) + return connectionManager.connect('hlfabric1', 'org-acme-biznet', connectOptions) .then((connection) => { sinon.assert.calledOnce(HLFConnectionManager.createPeer); sinon.assert.calledWith(HLFConnectionManager.createPeer, 'grpc://localhost:7051'); @@ -768,7 +768,7 @@ describe('HLFConnectionManager', () => { {requestURL: 'grpc://localhost:8051', eventURL: 'grpc://localhost:8054'}, {requestURL: 'grpc://localhost:9051', eventURL: 'grpc://localhost:9054'} ]; - return connectionManager.connect('hlfabric1', 'org.acme.biznet', connectOptions) + return connectionManager.connect('hlfabric1', 'org-acme-biznet', connectOptions) .then((connection) => { sinon.assert.calledThrice(HLFConnectionManager.createPeer); sinon.assert.calledWith(HLFConnectionManager.createPeer, 'grpc://localhost:7051'); @@ -779,7 +779,7 @@ describe('HLFConnectionManager', () => { }); it('should connect a single certificate authority', () => { - return connectionManager.connect('hlfabric1', 'org.acme.biznet', connectOptions) + return connectionManager.connect('hlfabric1', 'org-acme-biznet', connectOptions) .then((connection) => { sinon.assert.calledOnce(HLFConnectionManager.createCAClient); sinon.assert.calledWith(HLFConnectionManager.createCAClient, 'http://localhost:7054', null, null); @@ -799,10 +799,10 @@ describe('HLFConnectionManager', () => { 'trustedRoots' : ['trusted'], 'verify': false }; - return connectionManager.connect('hlfabric1', 'org.acme.biznet', connectOptions) + return connectionManager.connect('hlfabric1', 'org-acme-biznet', connectOptions) .then((connection) => { connection.getConnectionManager().should.equal(connectionManager); - connection.getIdentifier().should.equal('org.acme.biznet@hlfabric1'); + connection.getIdentifier().should.equal('org-acme-biznet@hlfabric1'); connection.should.be.an.instanceOf(HLFConnection); connection.getConnectionOptions().should.deep.equal(connectOptions); connection.client.should.deep.equal(mockClient); @@ -839,7 +839,7 @@ describe('HLFConnectionManager', () => { }); it('should configure a default key value store', () => { - return connectionManager.connect('hlfabric1', 'org.acme.biznet', connectOptions) + return connectionManager.connect('hlfabric1', 'org-acme-biznet', connectOptions) .then((connection) => { sinon.assert.calledOnce(Client.newDefaultKeyValueStore); sinon.assert.calledWith(Client.newDefaultKeyValueStore, { path: '/tmp/hlfabric1' }); @@ -849,7 +849,7 @@ describe('HLFConnectionManager', () => { it('should handle an error creating a store using keyValStore', () => { Client.newDefaultKeyValueStore.rejects('wow such fail'); - return connectionManager.connect('hlfabric1', 'org.acme.biznet', connectOptions) + return connectionManager.connect('hlfabric1', 'org-acme-biznet', connectOptions) .should.be.rejectedWith(/wow such fail/); }); @@ -858,13 +858,13 @@ describe('HLFConnectionManager', () => { connectOptions.wallet = {}; sandbox.stub(Client, 'newCryptoKeyStore').throws('wow such fail'); - return connectionManager.connect('hlfabric1', 'org.acme.biznet', connectOptions) + return connectionManager.connect('hlfabric1', 'org-acme-biznet', connectOptions) .should.be.rejectedWith(/wow such fail/); }); it('should configure a wallet proxy using the specified wallet if provided', () => { connectOptions = Object.assign(connectOptions, { wallet: mockWallet }); - return connectionManager.connect('hlfabric1', 'org.acme.biznet', connectOptions) + return connectionManager.connect('hlfabric1', 'org-acme-biznet', connectOptions) .then((connection) => { sinon.assert.calledWith(mockClient.setStateStore, sinon.match.instanceOf(HLFWalletProxy)); }); @@ -872,7 +872,7 @@ describe('HLFConnectionManager', () => { it('should configure a wallet proxy if a singleton wallet is provided', () => { Wallet.setWallet(mockWallet); - return connectionManager.connect('hlfabric1', 'org.acme.biznet', connectOptions) + return connectionManager.connect('hlfabric1', 'org-acme-biznet', connectOptions) .then((connection) => { sinon.assert.calledWith(mockClient.setStateStore, sinon.match.instanceOf(HLFWalletProxy)); }); @@ -880,7 +880,7 @@ describe('HLFConnectionManager', () => { it('should set a default timeout', () => { delete connectOptions.timeout; - return connectionManager.connect('hlfabric1', 'org.acme.biznet', connectOptions) + return connectionManager.connect('hlfabric1', 'org-acme-biznet', connectOptions) .then((connection) => { connection.getConnectionOptions().timeout.should.equal(180); }); @@ -888,7 +888,7 @@ describe('HLFConnectionManager', () => { it('should use a supplied timeout', () => { connectOptions.timeout = 30; - return connectionManager.connect('hlfabric1', 'org.acme.biznet', connectOptions) + return connectionManager.connect('hlfabric1', 'org-acme-biznet', connectOptions) .then((connection) => { connection.getConnectionOptions().timeout.should.equal(30); }); diff --git a/packages/composer-connector-proxy/test/proxyconnection.js b/packages/composer-connector-proxy/test/proxyconnection.js index e10c1725f7..96e63da474 100644 --- a/packages/composer-connector-proxy/test/proxyconnection.js +++ b/packages/composer-connector-proxy/test/proxyconnection.js @@ -29,7 +29,7 @@ require('sinon-as-promised'); describe('ProxyConnection', () => { const connectionProfile = 'defaultProfile'; - const businessNetworkIdentifier = 'org.acme.biznet'; + const businessNetworkIdentifier = 'org-acme-biznet'; const connectionID = '3d382385-47a5-4be9-99b0-6b10166b9497'; const enrollmentID = 'alice1'; const enrollmentSecret = 'suchs3cret'; @@ -274,12 +274,12 @@ describe('ProxyConnection', () => { describe('#list', () => { it('should send a list call to the connector server', () => { - mockSocket.emit.withArgs('/api/connectionList', connectionID, securityContextID, sinon.match.func).yields(null, ['org.acme.biznet1', 'org.acme.biznet2']); + mockSocket.emit.withArgs('/api/connectionList', connectionID, securityContextID, sinon.match.func).yields(null, ['org-acme-biznet1', 'org-acme-biznet2']); return connection.list(mockSecurityContext) .then((result) => { sinon.assert.calledOnce(mockSocket.emit); sinon.assert.calledWith(mockSocket.emit, '/api/connectionList', connectionID, securityContextID, sinon.match.func); - result.should.deep.equal(['org.acme.biznet1', 'org.acme.biznet2']); + result.should.deep.equal(['org-acme-biznet1', 'org-acme-biznet2']); }); }); diff --git a/packages/composer-connector-proxy/test/proxyconnectionmanager.js b/packages/composer-connector-proxy/test/proxyconnectionmanager.js index c7d2a7c2db..ec9b6f75c4 100644 --- a/packages/composer-connector-proxy/test/proxyconnectionmanager.js +++ b/packages/composer-connector-proxy/test/proxyconnectionmanager.js @@ -26,7 +26,7 @@ const sinon = require('sinon'); describe('ProxyConnectionManager', () => { const connectionProfile = 'defaultProfile'; - const businessNetworkIdentifier = 'org.acme.biznet'; + const businessNetworkIdentifier = 'org-acme-biznet'; const connectionOptions = { type: 'embedded' }; diff --git a/packages/composer-connector-server/test/connectorserver.js b/packages/composer-connector-server/test/connectorserver.js index 4ecd700809..aa8a5747d1 100644 --- a/packages/composer-connector-server/test/connectorserver.js +++ b/packages/composer-connector-server/test/connectorserver.js @@ -29,7 +29,7 @@ require('sinon-as-promised'); describe('ConnectorServer', () => { const connectionProfile = 'defaultProfile'; - const businessNetworkIdentifier = 'org.acme.biznet'; + const businessNetworkIdentifier = 'org-acme-biznet'; const connectionOptions = { type: 'embedded', prop1: 'value1', @@ -742,14 +742,14 @@ describe('ConnectorServer', () => { }); it('should list', () => { - mockConnection.list.withArgs(mockSecurityContext).resolves(['org.acme.biznet1', 'org.acme.biznet2']); + mockConnection.list.withArgs(mockSecurityContext).resolves(['org-acme-biznet1', 'org-acme-biznet2']); const cb = sinon.stub(); return connectorServer.connectionList(connectionID, securityContextID, cb) .then(() => { sinon.assert.calledOnce(mockConnection.list); sinon.assert.calledWith(mockConnection.list, mockSecurityContext); sinon.assert.calledOnce(cb); - sinon.assert.calledWith(cb, null, ['org.acme.biznet1', 'org.acme.biznet2']); + sinon.assert.calledWith(cb, null, ['org-acme-biznet1', 'org-acme-biznet2']); }); }); diff --git a/packages/composer-connector-web/test/webconnection.js b/packages/composer-connector-web/test/webconnection.js index 082294fb5e..626402b1a0 100644 --- a/packages/composer-connector-web/test/webconnection.js +++ b/packages/composer-connector-web/test/webconnection.js @@ -419,12 +419,12 @@ describe('WebConnection', () => { mockConnectionProfileStore.load.withArgs('devFabric1').resolves({ type: 'web', networks: { - 'org.acme.business': '133c00a3-8555-4aa5-9165-9de9a8f8a838', - 'org.acme.biznet2': '6eeb8858-eced-4a32-b1cd-2491f1e3718f' + 'org-acme-business': '133c00a3-8555-4aa5-9165-9de9a8f8a838', + 'org-acme-biznet2': '6eeb8858-eced-4a32-b1cd-2491f1e3718f' } }); return connection.list() - .should.eventually.be.deep.equal(['org.acme.biznet2', 'org.acme.business']); + .should.eventually.be.deep.equal(['org-acme-biznet2', 'org-acme-business']); }); it('should cope with missing business networks', () => { @@ -453,7 +453,7 @@ describe('WebConnection', () => { type: 'web', networks: { 'org.acme.business': '133c00a3-8555-4aa5-9165-9de9a8f8a838' } }); - return connection.getChaincodeID('org.acme.biznet2') + return connection.getChaincodeID('org-acme-biznet2') .should.eventually.be.undefined; }); @@ -461,7 +461,7 @@ describe('WebConnection', () => { mockConnectionProfileStore.load.withArgs('devFabric1').resolves({ type: 'web' }); - return connection.getChaincodeID('org.acme.biznet2') + return connection.getChaincodeID('org-acme-biznet2') .should.eventually.be.undefined; }); @@ -522,7 +522,7 @@ describe('WebConnection', () => { type: 'web', networks: { 'org.acme.business': '133c00a3-8555-4aa5-9165-9de9a8f8a838' } }); - return connection.deleteChaincodeID('org.acme.biznet2') + return connection.deleteChaincodeID('org-acme-biznet2') .then(() => { sinon.assert.calledOnce(mockConnectionProfileStore.save); sinon.assert.calledWith(mockConnectionProfileStore.save, 'devFabric1', { diff --git a/packages/composer-playground/src/app/add-certificate/add-certificate.component.spec.ts b/packages/composer-playground/src/app/add-certificate/add-certificate.component.spec.ts index 75b6860c28..c421b0d5f3 100644 --- a/packages/composer-playground/src/app/add-certificate/add-certificate.component.spec.ts +++ b/packages/composer-playground/src/app/add-certificate/add-certificate.component.spec.ts @@ -35,18 +35,18 @@ class MockAdminService { deploy(): Promise { return new Promise((resolve, reject) => { - resolve(new BusinessNetworkDefinition('org.acme.biznet@0.0.1', 'Acme Business Network')); + resolve(new BusinessNetworkDefinition('org-acme-biznet@0.0.1', 'Acme Business Network')); }); } update(): Promise { return new Promise((resolve, reject) => { - resolve(new BusinessNetworkDefinition('org.acme.biznet@0.0.1', 'Acme Business Network')); + resolve(new BusinessNetworkDefinition('org-acme-biznet@0.0.1', 'Acme Business Network')); }); } generateDefaultBusinessNetwork(): BusinessNetworkDefinition { - return new BusinessNetworkDefinition('org.acme.biznet@0.0.1', 'Acme Business Network'); + return new BusinessNetworkDefinition('org-acme-biznet@0.0.1', 'Acme Business Network'); } isInitialDeploy(): boolean { diff --git a/packages/composer-playground/src/app/add-connection-profile/add-connection-profile.component.spec.ts b/packages/composer-playground/src/app/add-connection-profile/add-connection-profile.component.spec.ts index 07ac8f6a4f..6d0e5c5653 100644 --- a/packages/composer-playground/src/app/add-connection-profile/add-connection-profile.component.spec.ts +++ b/packages/composer-playground/src/app/add-connection-profile/add-connection-profile.component.spec.ts @@ -31,18 +31,18 @@ class MockAdminService { deploy(): Promise { return new Promise((resolve, reject) => { - resolve(new BusinessNetworkDefinition('org.acme.biznet@0.0.1', 'Acme Business Network')); + resolve(new BusinessNetworkDefinition('org-acme-biznet@0.0.1', 'Acme Business Network')); }); } update(): Promise { return new Promise((resolve, reject) => { - resolve(new BusinessNetworkDefinition('org.acme.biznet@0.0.1', 'Acme Business Network')); + resolve(new BusinessNetworkDefinition('org-acme-biznet@0.0.1', 'Acme Business Network')); }); } generateDefaultBusinessNetwork(): BusinessNetworkDefinition { - return new BusinessNetworkDefinition('org.acme.biznet@0.0.1', 'Acme Business Network'); + return new BusinessNetworkDefinition('org-acme-biznet@0.0.1', 'Acme Business Network'); } isInitialDeploy(): boolean { diff --git a/packages/composer-playground/src/app/add-file/add-file.component.spec.ts b/packages/composer-playground/src/app/add-file/add-file.component.spec.ts index c34d42dbcf..e26fedb04b 100644 --- a/packages/composer-playground/src/app/add-file/add-file.component.spec.ts +++ b/packages/composer-playground/src/app/add-file/add-file.component.spec.ts @@ -38,18 +38,18 @@ class MockAdminService { deploy(): Promise { return new Promise((resolve, reject) => { - resolve(new BusinessNetworkDefinition('org.acme.biznet@0.0.1', 'Acme Business Network')); + resolve(new BusinessNetworkDefinition('org-acme-biznet@0.0.1', 'Acme Business Network')); }); } update(): Promise { return new Promise((resolve, reject) => { - resolve(new BusinessNetworkDefinition('org.acme.biznet@0.0.1', 'Acme Business Network')); + resolve(new BusinessNetworkDefinition('org-acme-biznet@0.0.1', 'Acme Business Network')); }); } generateDefaultBusinessNetwork(): BusinessNetworkDefinition { - return new BusinessNetworkDefinition('org.acme.biznet@0.0.1', 'Acme Business Network'); + return new BusinessNetworkDefinition('org-acme-biznet@0.0.1', 'Acme Business Network'); } isInitialDeploy(): boolean { diff --git a/packages/composer-playground/src/app/services/admin.service.spec.ts b/packages/composer-playground/src/app/services/admin.service.spec.ts index 802258f9ad..9af2e6811e 100644 --- a/packages/composer-playground/src/app/services/admin.service.spec.ts +++ b/packages/composer-playground/src/app/services/admin.service.spec.ts @@ -184,7 +184,7 @@ describe('AdminService', () => { service['userID'].should.equal('myId'); service['madeItToConnect'].should.equal(true); - adminConnectionMock.connect.should.have.been.calledWith('my profile', 'myId', 'myPassword', 'org.acme.biznet'); + adminConnectionMock.connect.should.have.been.calledWith('my profile', 'myId', 'myPassword', 'org-acme-biznet'); }))); }); @@ -215,12 +215,12 @@ describe('AdminService', () => { service['initialDeploy'].should.equal(true); adminConnectionMock.disconnect.should.have.been.called; - adminConnectionMock.connect.should.have.been.calledWith('myProfile', 'myUser', 'mySecret', 'org.acme.biznet'); + adminConnectionMock.connect.should.have.been.calledWith('myProfile', 'myUser', 'mySecret', 'org-acme-biznet'); }))); it('should connect without an id but not deploy as already deployed', fakeAsync(inject([AdminService], (service: AdminService) => { adminConnectionMock.connect.returns(Promise.resolve()); - adminConnectionMock.list.returns(Promise.resolve(['org.acme.biznet'])); + adminConnectionMock.list.returns(Promise.resolve(['org-acme-biznet'])); let mockGetAdminConnection = sinon.stub(service, 'getAdminConnection').returns(adminConnectionMock); @@ -241,7 +241,7 @@ describe('AdminService', () => { mockGenerateBusinessNetwork.should.not.have.been.called; adminConnectionMock.disconnect.should.have.been.called; - adminConnectionMock.connect.should.have.been.calledWith('myProfile', 'myUser', 'mySecret', 'org.acme.biznet'); + adminConnectionMock.connect.should.have.been.calledWith('myProfile', 'myUser', 'mySecret', 'org-acme-biznet'); }))); }); diff --git a/packages/composer-playground/src/app/services/admin.service.ts b/packages/composer-playground/src/app/services/admin.service.ts index adb376c3d8..d6b64abd47 100644 --- a/packages/composer-playground/src/app/services/admin.service.ts +++ b/packages/composer-playground/src/app/services/admin.service.ts @@ -94,7 +94,7 @@ export class AdminService { .then((userSecret) => { this.userSecret = userSecret; this.madeItToConnect = true; - return this.getAdminConnection().connect(this.connectionProfile, this.userID, this.userSecret, 'org.acme.biznet'); + return this.getAdminConnection().connect(this.connectionProfile, this.userID, this.userSecret, 'org-acme-biznet'); }); } @@ -107,12 +107,12 @@ export class AdminService { .then((businessNetworks) => { console.log('Got business networks', businessNetworks); this.deployed = businessNetworks.some((businessNetwork) => { - return businessNetwork === 'org.acme.biznet'; + return businessNetwork === 'org-acme-biznet'; }); if (!this.deployed) { this.alertService.busyStatus$.next({ title: 'Creating Business Network', - text: 'creating business network org.acme.biznet' + text: 'creating business network org-acme-biznet' }); let businessNetworkDefinition = this.generateDefaultBusinessNetwork(); return this.getAdminConnection().deploy(businessNetworkDefinition) @@ -126,7 +126,7 @@ export class AdminService { }) .then(() => { console.log('Connecting to connection profile (w/ business network ID)', this.connectionProfile); - return this.getAdminConnection().connect(this.connectionProfile, this.userID, this.userSecret, 'org.acme.biznet'); + return this.getAdminConnection().connect(this.connectionProfile, this.userID, this.userSecret, 'org-acme-biznet'); }); } @@ -145,7 +145,7 @@ export class AdminService { } generateDefaultBusinessNetwork(): BusinessNetworkDefinition { - let businessNetworkDefinition = new BusinessNetworkDefinition('org.acme.biznet@0.0.1', 'Acme Business Network'); + let businessNetworkDefinition = new BusinessNetworkDefinition('org-acme-biznet@0.0.1', 'Acme Business Network'); return businessNetworkDefinition; } diff --git a/packages/composer-playground/src/app/services/client.service.ts b/packages/composer-playground/src/app/services/client.service.ts index b62c2dfa2e..4f697af4d3 100644 --- a/packages/composer-playground/src/app/services/client.service.ts +++ b/packages/composer-playground/src/app/services/client.service.ts @@ -282,7 +282,7 @@ export class ClientService { return this.identityService.getUserSecret(); }) .then((userSecret) => { - return this.getBusinessNetworkConnection().connect(connectionProfile, 'org.acme.biznet', userID, userSecret); + return this.getBusinessNetworkConnection().connect(connectionProfile, 'org-acme-biznet', userID, userSecret); }); } diff --git a/packages/composer-rest-server/server/composer.json b/packages/composer-rest-server/server/composer.json index 185cd5e137..e16279d58d 100644 --- a/packages/composer-rest-server/server/composer.json +++ b/packages/composer-rest-server/server/composer.json @@ -1,6 +1,6 @@ { "connectionProfileName": "defaultProfile", - "businessNetworkIdentifier": "org.acme.biznet", + "businessNetworkIdentifier": "org-acme-biznet", "participantId": "admin", "participantPwd": "adminpw", "namespaces": "always", diff --git a/packages/composer-rest-server/test/cli.js b/packages/composer-rest-server/test/cli.js index 2373615ab9..14f59ae461 100644 --- a/packages/composer-rest-server/test/cli.js +++ b/packages/composer-rest-server/test/cli.js @@ -29,7 +29,7 @@ describe('composer-rest-server CLI unit tests', () => { sandbox = sinon.sandbox.create(); sandbox.stub(Util, 'getConnectionSettings').resolves({ profilename: 'defaultProfile', - businessNetworkId: 'org.acme.biznet', + businessNetworkId: 'org-acme-biznet', userid: 'admin', secret: 'adminpw', namespaces: 'always', @@ -65,7 +65,7 @@ describe('composer-rest-server CLI unit tests', () => { }).then(() => { sinon.assert.calledOnce(Util.getConnectionSettings); const settings = { - businessNetworkIdentifier: 'org.acme.biznet', + businessNetworkIdentifier: 'org-acme-biznet', connectionProfileName: 'defaultProfile', namespaces: 'always', participantId: 'admin', @@ -79,7 +79,7 @@ describe('composer-rest-server CLI unit tests', () => { it('should throw an error if command line arguments specified but some are missing', () => { let listen = sinon.stub(); - process.argv = [ process.argv0, 'cli.js', '-n', 'org.acme.biznet' ]; + process.argv = [ process.argv0, 'cli.js', '-n', 'org-acme-biznet' ]; delete require.cache[require.resolve('yargs')]; return proxyquire('../cli', { clear: () => { }, @@ -104,7 +104,7 @@ describe('composer-rest-server CLI unit tests', () => { process.argv = [ process.argv0, 'cli.js', '-p', 'defaultProfile', - '-n', 'org.acme.biznet', + '-n', 'org-acme-biznet', '-i', 'admin', '-s', 'adminpw' ]; @@ -122,7 +122,7 @@ describe('composer-rest-server CLI unit tests', () => { }).then(() => { sinon.assert.notCalled(Util.getConnectionSettings); const settings = { - businessNetworkIdentifier: 'org.acme.biznet', + businessNetworkIdentifier: 'org-acme-biznet', connectionProfileName: 'defaultProfile', namespaces: 'always', participantId: 'admin', @@ -144,7 +144,7 @@ describe('composer-rest-server CLI unit tests', () => { process.argv = [ process.argv0, 'cli.js', '-p', 'defaultProfile', - '-n', 'org.acme.biznet', + '-n', 'org-acme-biznet', '-i', 'admin', '-s', 'adminpw' ]; @@ -179,7 +179,7 @@ describe('composer-rest-server CLI unit tests', () => { process.argv = [ process.argv0, 'cli.js', '-p', 'defaultProfile', - '-n', 'org.acme.biznet', + '-n', 'org-acme-biznet', '-i', 'admin', '-s', 'adminpw' ]; diff --git a/packages/composer-rest-server/test/lib/util.js b/packages/composer-rest-server/test/lib/util.js index c3ca124220..2f85389f6d 100644 --- a/packages/composer-rest-server/test/lib/util.js +++ b/packages/composer-rest-server/test/lib/util.js @@ -70,7 +70,7 @@ describe('Util', () => { return question.name === 'businessNetworkId'; }); question.validate('').should.match(/Please enter/); - question.validate('org.acme.biznet').should.be.true; + question.validate('org-acme-biznet').should.be.true; }); }); diff --git a/packages/composer-rest-server/test/server/servercmd.js b/packages/composer-rest-server/test/server/servercmd.js index a97cad58c5..8c8250ee69 100644 --- a/packages/composer-rest-server/test/server/servercmd.js +++ b/packages/composer-rest-server/test/server/servercmd.js @@ -57,7 +57,7 @@ describe('servercmd', () => { process.argv = [ process.argv0, 'cli.js', '-p', 'defaultProfile', - '-n', 'org.acme.biznet', + '-n', 'org-acme-biznet', '-i', 'admin', '-s', 'adminpw' ]; @@ -89,7 +89,7 @@ describe('servercmd', () => { process.argv = [ process.argv0, 'cli.js', '-p', 'defaultProfile', - '-n', 'org.acme.biznet', + '-n', 'org-acme-biznet', '-i', 'admin', '-s', 'adminpw' ]; diff --git a/packages/composer-systests/systest/accesscontrols.js b/packages/composer-systests/systest/accesscontrols.js index dcc0284749..26a8347450 100644 --- a/packages/composer-systests/systest/accesscontrols.js +++ b/packages/composer-systests/systest/accesscontrols.js @@ -45,7 +45,7 @@ describe('Access control system tests', () => { const scriptFiles = [ { identifier: 'identities.js', contents: fs.readFileSync(path.resolve(__dirname, 'data/accesscontrols.js'), 'utf8') } ]; - businessNetworkDefinition = new BusinessNetworkDefinition('systest.accesscontrols@0.0.1', 'The network for the access controls system tests'); + businessNetworkDefinition = new BusinessNetworkDefinition('systest-accesscontrols@0.0.1', 'The network for the access controls system tests'); modelFiles.forEach((modelFile) => { businessNetworkDefinition.getModelManager().addModelFile(modelFile.contents, modelFile.fileName); }); diff --git a/packages/composer-systests/systest/assets.js b/packages/composer-systests/systest/assets.js index 347adae7d5..43c912ee88 100644 --- a/packages/composer-systests/systest/assets.js +++ b/packages/composer-systests/systest/assets.js @@ -37,7 +37,7 @@ describe('Asset system tests', function () { const modelFiles = [ { fileName: 'UNKNOWN', contents:fs.readFileSync(path.resolve(__dirname, 'data/assets.cto'), 'utf8') } ]; - businessNetworkDefinition = new BusinessNetworkDefinition('systest.assets@0.0.1', 'The network for the asset system tests'); + businessNetworkDefinition = new BusinessNetworkDefinition('systest-assets@0.0.1', 'The network for the asset system tests'); modelFiles.forEach((modelFile) => { businessNetworkDefinition.getModelManager().addModelFile(modelFile.contents, modelFile.fileName); }); diff --git a/packages/composer-systests/systest/events.js b/packages/composer-systests/systest/events.js index f3ac713b04..37e565f289 100644 --- a/packages/composer-systests/systest/events.js +++ b/packages/composer-systests/systest/events.js @@ -39,7 +39,7 @@ describe('Event system tests', function () { const scriptFiles = [ { identifier: 'events.js', contents: fs.readFileSync(path.resolve(__dirname, 'data/events.js'), 'utf8') } ]; - businessNetworkDefinition = new BusinessNetworkDefinition('systest.events@0.0.1', 'The network for the event system tests'); + businessNetworkDefinition = new BusinessNetworkDefinition('systest-events@0.0.1', 'The network for the event system tests'); modelFiles.forEach((modelFile) => { businessNetworkDefinition.getModelManager().addModelFile(modelFile.contents); }); diff --git a/packages/composer-systests/systest/identities.js b/packages/composer-systests/systest/identities.js index 55e0edb297..a55c2cb765 100644 --- a/packages/composer-systests/systest/identities.js +++ b/packages/composer-systests/systest/identities.js @@ -42,7 +42,7 @@ describe('Identity system tests', () => { const scriptFiles = [ { identifier: 'identities.js', contents: fs.readFileSync(path.resolve(__dirname, 'data/identities.js'), 'utf8') } ]; - businessNetworkDefinition = new BusinessNetworkDefinition('systest.identities@0.0.1', 'The network for the identities system tests'); + businessNetworkDefinition = new BusinessNetworkDefinition('systest-identities@0.0.1', 'The network for the identities system tests'); modelFiles.forEach((modelFile) => { businessNetworkDefinition.getModelManager().addModelFile(modelFile.contents, modelFile.fileName); }); diff --git a/packages/composer-systests/systest/participants.js b/packages/composer-systests/systest/participants.js index 209bcaa0b0..60600240fa 100644 --- a/packages/composer-systests/systest/participants.js +++ b/packages/composer-systests/systest/participants.js @@ -36,7 +36,7 @@ describe('Participant system tests', function () { const modelFiles = [ { fileName: undefined, contents: fs.readFileSync(path.resolve(__dirname, 'data/participants.cto'), 'utf8') } ]; - businessNetworkDefinition = new BusinessNetworkDefinition('systest.participants@0.0.1', 'The network for the participant system tests'); + businessNetworkDefinition = new BusinessNetworkDefinition('systest-participants@0.0.1', 'The network for the participant system tests'); modelFiles.forEach((modelFile) => { businessNetworkDefinition.getModelManager().addModelFile(modelFile.contents, modelFile.fileName); }); diff --git a/packages/composer-systests/systest/post.js b/packages/composer-systests/systest/post.js index a920f76082..1ae19b592d 100644 --- a/packages/composer-systests/systest/post.js +++ b/packages/composer-systests/systest/post.js @@ -38,7 +38,7 @@ describe('HTTP POST system tests', () => { const scriptFiles= [ { identifier: 'post.js', contents: fs.readFileSync(path.resolve(__dirname, 'data/post.js'), 'utf8') } ]; - businessNetworkDefinition = new BusinessNetworkDefinition('systest.post@0.0.1', 'The network for the HTTP POST system tests'); + businessNetworkDefinition = new BusinessNetworkDefinition('systest-post@0.0.1', 'The network for the HTTP POST system tests'); modelFiles.forEach((modelFile) => { businessNetworkDefinition.getModelManager().addModelFile(modelFile.contents, modelFile.fileName); }); diff --git a/packages/composer-systests/systest/query.js b/packages/composer-systests/systest/query.js index ba940cc17d..138d7cbe89 100644 --- a/packages/composer-systests/systest/query.js +++ b/packages/composer-systests/systest/query.js @@ -43,7 +43,7 @@ describe('Query system tests', function () { const scriptFiles = [ { identifier: 'query.js', contents: fs.readFileSync(path.resolve(__dirname, 'data/query.js'), 'utf8') } ]; - businessNetworkDefinition = new BusinessNetworkDefinition('systest.query@0.0.1', 'The network for the query system tests'); + businessNetworkDefinition = new BusinessNetworkDefinition('systest-query@0.0.1', 'The network for the query system tests'); modelFiles.forEach((modelFile) => { businessNetworkDefinition.getModelManager().addModelFile(modelFile.contents, modelFile.fileName); }); diff --git a/packages/composer-systests/systest/transactions.assets.js b/packages/composer-systests/systest/transactions.assets.js index b7bf2a45bd..8b2699c772 100644 --- a/packages/composer-systests/systest/transactions.assets.js +++ b/packages/composer-systests/systest/transactions.assets.js @@ -39,7 +39,7 @@ describe('Transaction (asset specific) system tests', () => { const scriptFiles= [ { identifier: 'transactions.assets.js', contents: fs.readFileSync(path.resolve(__dirname, 'data/transactions.assets.js'), 'utf8') } ]; - businessNetworkDefinition = new BusinessNetworkDefinition('systest.transactions.assets@0.0.1', 'The network for the transaction (asset specific) system tests'); + businessNetworkDefinition = new BusinessNetworkDefinition('systest-transactions-assets@0.0.1', 'The network for the transaction (asset specific) system tests'); modelFiles.forEach((modelFile) => { businessNetworkDefinition.getModelManager().addModelFile(modelFile.contents, modelFile.fileName); }); diff --git a/packages/composer-systests/systest/transactions.js b/packages/composer-systests/systest/transactions.js index e7f864d92a..871823db1e 100644 --- a/packages/composer-systests/systest/transactions.js +++ b/packages/composer-systests/systest/transactions.js @@ -39,7 +39,7 @@ describe('Transaction system tests', () => { { identifier: 'transactions.js', contents: fs.readFileSync(path.resolve(__dirname, 'data/transactions.js'), 'utf8') }, { identifier: 'transactions.utility.js', contents: fs.readFileSync(path.resolve(__dirname, 'data/transactions.utility.js'), 'utf8') } ]; - businessNetworkDefinition = new BusinessNetworkDefinition('systest.transactions@0.0.1', 'The network for the transaction system tests'); + businessNetworkDefinition = new BusinessNetworkDefinition('systest-transactions@0.0.1', 'The network for the transaction system tests'); modelFiles.forEach((modelFile) => { businessNetworkDefinition.getModelManager().addModelFile(modelFile.contents, modelFile.fileName); }); diff --git a/packages/composer-systests/systest/transactions.participants.js b/packages/composer-systests/systest/transactions.participants.js index 0de48e858e..7f5c2a75dc 100644 --- a/packages/composer-systests/systest/transactions.participants.js +++ b/packages/composer-systests/systest/transactions.participants.js @@ -39,7 +39,7 @@ describe('Transaction (participant specific) system tests', () => { const scriptFiles= [ { identifier: 'transactions.participants.js', contents: fs.readFileSync(path.resolve(__dirname, 'data/transactions.participants.js'), 'utf8') } ]; - businessNetworkDefinition = new BusinessNetworkDefinition('systest.transactions.participants@0.0.1', 'The network for the transaction (participant specific) system tests'); + businessNetworkDefinition = new BusinessNetworkDefinition('systest-transactions-participants@0.0.1', 'The network for the transaction (participant specific) system tests'); modelFiles.forEach((modelFile) => { businessNetworkDefinition.getModelManager().addModelFile(modelFile.contents, modelFile.fileName); }); From fba3fe00315f0020beb604150183753a1cb9c898 Mon Sep 17 00:00:00 2001 From: Dave Kelsey Date: Wed, 14 Jun 2017 14:54:56 +0100 Subject: [PATCH 2/3] re-add admin, adminpw, address business network name when running inside runtime. Signed-off-by: Dave Kelsey --- .../lib/businessnetworkmetadata.js | 25 +++++++++++++++++-- .../test/codegen/plantumlvisitor.js | 2 +- .../docker-compose-playground-unstable.yml | 3 ++- .../hlfv1/docker-compose-playground.yml | 3 ++- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/packages/composer-common/lib/businessnetworkmetadata.js b/packages/composer-common/lib/businessnetworkmetadata.js index 474ae28fd7..abae1b81c1 100644 --- a/packages/composer-common/lib/businessnetworkmetadata.js +++ b/packages/composer-common/lib/businessnetworkmetadata.js @@ -47,8 +47,7 @@ class BusinessNetworkMetadata { throw new Error('package.json is required and must be an object'); } - const regex = /^[a-z0-9_-]+$/; - if (!packageJson.name || !regex.test(packageJson.name)) { + if (!packageJson.name || !this._validName(packageJson.name)) { throw new Error ('business network name can only contain lowercase alphanumerics, _ or -'); } @@ -63,6 +62,28 @@ class BusinessNetworkMetadata { LOG.exit(method); } + /** + * check to see if it is a valid name. for some reason regex is not working when this executes + * inside the chaincode runtime, which is why regex hasn't been used. + * + * @param {string} name the business network name to check + * @returns {boolean} true if valid, false otherwise + * + * @memberOf BusinessNetworkMetadata + * @private + */ + _validName(name) { + const validChars = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z', + '0','1','2','3','4','5','6','7','8','9','-','_']; + for (let i = 0; i Date: Wed, 14 Jun 2017 15:27:32 +0100 Subject: [PATCH 3/3] system test changes to non dot business network names Signed-off-by: Dave Kelsey --- .../composer-systests/systest/accesscontrols.js | 8 ++++---- packages/composer-systests/systest/assets.js | 2 +- packages/composer-systests/systest/events.js | 2 +- packages/composer-systests/systest/identities.js | 16 ++++++++-------- .../composer-systests/systest/participants.js | 2 +- packages/composer-systests/systest/post.js | 2 +- packages/composer-systests/systest/query.js | 2 +- .../systest/transactions.assets.js | 2 +- .../composer-systests/systest/transactions.js | 2 +- .../systest/transactions.participants.js | 2 +- 10 files changed, 20 insertions(+), 20 deletions(-) diff --git a/packages/composer-systests/systest/accesscontrols.js b/packages/composer-systests/systest/accesscontrols.js index 26a8347450..922b90252d 100644 --- a/packages/composer-systests/systest/accesscontrols.js +++ b/packages/composer-systests/systest/accesscontrols.js @@ -58,7 +58,7 @@ describe('Access control system tests', () => { admin = TestUtil.getAdmin(); return admin.deploy(businessNetworkDefinition) .then(() => { - return TestUtil.getClient('systest.accesscontrols') + return TestUtil.getClient('systest-accesscontrols') .then((result) => { client = result; }); @@ -88,14 +88,14 @@ describe('Access control system tests', () => { return client.issueIdentity(alice, aliceIdentity); }) .then((identity) => { - return TestUtil.getClient('systest.accesscontrols', identity.userID, identity.userSecret); + return TestUtil.getClient('systest-accesscontrols', identity.userID, identity.userSecret); }) .then((result) => { aliceClient = result; return client.issueIdentity(bob, bobIdentity); }) .then((identity) => { - return TestUtil.getClient('systest.accesscontrols', identity.userID, identity.userSecret); + return TestUtil.getClient('systest-accesscontrols', identity.userID, identity.userSecret); }) .then((result) => { bobClient = result; @@ -125,7 +125,7 @@ describe('Access control system tests', () => { }); afterEach(() => { - return TestUtil.getClient('systest.accesscontrols') + return TestUtil.getClient('systest-accesscontrols') .then((result) => { client = result; }); diff --git a/packages/composer-systests/systest/assets.js b/packages/composer-systests/systest/assets.js index 43c912ee88..818f6eb198 100644 --- a/packages/composer-systests/systest/assets.js +++ b/packages/composer-systests/systest/assets.js @@ -44,7 +44,7 @@ describe('Asset system tests', function () { admin = TestUtil.getAdmin(); return admin.deploy(businessNetworkDefinition) .then(() => { - return TestUtil.getClient('systest.assets') + return TestUtil.getClient('systest-assets') .then((result) => { client = result; }); diff --git a/packages/composer-systests/systest/events.js b/packages/composer-systests/systest/events.js index 37e565f289..2dcac0e357 100644 --- a/packages/composer-systests/systest/events.js +++ b/packages/composer-systests/systest/events.js @@ -51,7 +51,7 @@ describe('Event system tests', function () { admin = TestUtil.getAdmin(); return admin.deploy(businessNetworkDefinition) .then(() => { - return TestUtil.getClient('systest.events') + return TestUtil.getClient('systest-events') .then((result) => { client = result; }); diff --git a/packages/composer-systests/systest/identities.js b/packages/composer-systests/systest/identities.js index a55c2cb765..5fa5dfaf93 100644 --- a/packages/composer-systests/systest/identities.js +++ b/packages/composer-systests/systest/identities.js @@ -53,7 +53,7 @@ describe('Identity system tests', () => { admin = TestUtil.getAdmin(); return admin.deploy(businessNetworkDefinition) .then(() => { - return TestUtil.getClient('systest.identities') + return TestUtil.getClient('systest-identities') .then((result) => { client = result; }); @@ -72,7 +72,7 @@ describe('Identity system tests', () => { }); afterEach(() => { - return TestUtil.getClient('systest.identities') + return TestUtil.getClient('systest-identities') .then((result) => { client = result; }); @@ -82,7 +82,7 @@ describe('Identity system tests', () => { let identity = uuid.v4(); return client.issueIdentity(participant, identity) .then((identity) => { - return TestUtil.getClient('systest.identities', identity.userID, identity.userSecret); + return TestUtil.getClient('systest-identities', identity.userID, identity.userSecret); }) .then((result) => { client = result; @@ -97,7 +97,7 @@ describe('Identity system tests', () => { let identity = uuid.v4(); return client.issueIdentity(participant, identity) .then((identity) => { - return TestUtil.getClient('systest.identities', identity.userID, identity.userSecret); + return TestUtil.getClient('systest-identities', identity.userID, identity.userSecret); }) .then((result) => { client = result; @@ -118,7 +118,7 @@ describe('Identity system tests', () => { return participantRegistry.remove(participant); }) .then(() => { - return TestUtil.getClient('systest.identities', identity.userID, identity.userSecret); + return TestUtil.getClient('systest-identities', identity.userID, identity.userSecret); }); }) .then((result) => { @@ -132,7 +132,7 @@ describe('Identity system tests', () => { let identity = uuid.v4(); return client.issueIdentity(participant, identity) .then((identity) => { - return TestUtil.getClient('systest.identities', identity.userID, identity.userSecret); + return TestUtil.getClient('systest-identities', identity.userID, identity.userSecret); }) .then((result) => { client = result; @@ -146,7 +146,7 @@ describe('Identity system tests', () => { let identity = uuid.v4(); return client.issueIdentity(participant, identity) .then((identity) => { - return TestUtil.getClient('systest.identities', identity.userID, identity.userSecret); + return TestUtil.getClient('systest-identities', identity.userID, identity.userSecret); }) .then((result) => { client = result; @@ -169,7 +169,7 @@ describe('Identity system tests', () => { return participantRegistry.remove(participant); }) .then(() => { - return TestUtil.getClient('systest.identities', identity.userID, identity.userSecret); + return TestUtil.getClient('systest-identities', identity.userID, identity.userSecret); }); }) .then((result) => { diff --git a/packages/composer-systests/systest/participants.js b/packages/composer-systests/systest/participants.js index 60600240fa..b112dd1513 100644 --- a/packages/composer-systests/systest/participants.js +++ b/packages/composer-systests/systest/participants.js @@ -43,7 +43,7 @@ describe('Participant system tests', function () { admin = TestUtil.getAdmin(); return admin.deploy(businessNetworkDefinition) .then(() => { - return TestUtil.getClient('systest.participants') + return TestUtil.getClient('systest-participants') .then((result) => { client = result; }); diff --git a/packages/composer-systests/systest/post.js b/packages/composer-systests/systest/post.js index 1ae19b592d..8f87ec7701 100644 --- a/packages/composer-systests/systest/post.js +++ b/packages/composer-systests/systest/post.js @@ -49,7 +49,7 @@ describe('HTTP POST system tests', () => { admin = TestUtil.getAdmin(); return admin.deploy(businessNetworkDefinition) .then(() => { - return TestUtil.getClient('systest.post') + return TestUtil.getClient('systest-post') .then((result) => { client = result; }); diff --git a/packages/composer-systests/systest/query.js b/packages/composer-systests/systest/query.js index 138d7cbe89..52d31b592c 100644 --- a/packages/composer-systests/systest/query.js +++ b/packages/composer-systests/systest/query.js @@ -55,7 +55,7 @@ describe('Query system tests', function () { admin = TestUtil.getAdmin(); return admin.deploy(businessNetworkDefinition) .then(() => { - return TestUtil.getClient('systest.query') + return TestUtil.getClient('systest-query') .then((result) => { client = result; }); diff --git a/packages/composer-systests/systest/transactions.assets.js b/packages/composer-systests/systest/transactions.assets.js index 8b2699c772..e3f5bf7a40 100644 --- a/packages/composer-systests/systest/transactions.assets.js +++ b/packages/composer-systests/systest/transactions.assets.js @@ -50,7 +50,7 @@ describe('Transaction (asset specific) system tests', () => { admin = TestUtil.getAdmin(); return admin.deploy(businessNetworkDefinition) .then(() => { - return TestUtil.getClient('systest.transactions.assets') + return TestUtil.getClient('systest-transactions-assets') .then((result) => { client = result; }); diff --git a/packages/composer-systests/systest/transactions.js b/packages/composer-systests/systest/transactions.js index 871823db1e..9c8634bffe 100644 --- a/packages/composer-systests/systest/transactions.js +++ b/packages/composer-systests/systest/transactions.js @@ -50,7 +50,7 @@ describe('Transaction system tests', () => { admin = TestUtil.getAdmin(); return admin.deploy(businessNetworkDefinition) .then(() => { - return TestUtil.getClient('systest.transactions') + return TestUtil.getClient('systest-transactions') .then((result) => { client = result; }); diff --git a/packages/composer-systests/systest/transactions.participants.js b/packages/composer-systests/systest/transactions.participants.js index 7f5c2a75dc..911b75495c 100644 --- a/packages/composer-systests/systest/transactions.participants.js +++ b/packages/composer-systests/systest/transactions.participants.js @@ -50,7 +50,7 @@ describe('Transaction (participant specific) system tests', () => { admin = TestUtil.getAdmin(); return admin.deploy(businessNetworkDefinition) .then(() => { - return TestUtil.getClient('systest.transactions.participants') + return TestUtil.getClient('systest-transactions-participants') .then((result) => { client = result; });