Skip to content

Commit

Permalink
FAB-8749 NodeSDK - allow admin identity
Browse files Browse the repository at this point in the history
Allow the admin identity to get the config from the orderer.
Clean up the create channel test case. Add a test case
to demonstrate using only admin identities to perform
tasks.

Change-Id: Iad5e1fc492630f78faa8693544d1a78080f7a366
Signed-off-by: Bret Harrison <[email protected]>
  • Loading branch information
harrisob committed Mar 22, 2018
1 parent ab2c8e8 commit 0bc73ac
Show file tree
Hide file tree
Showing 8 changed files with 741 additions and 292 deletions.
7 changes: 4 additions & 3 deletions build/tasks/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,12 @@ gulp.task('test', ['clean-up', 'lint', 'pre-test', 'compile', 'docker-ready', 'c
'test/integration/e2e/invoke-transaction.js',
'test/integration/e2e/query.js',
'test/integration/invoke.js',
'test/integration/perf/orderer.js',
'test/integration/perf/peer.js',
'test/integration/network-config.js',
// channel: mychannel, chaincode: e2enodecc:v0
'test/integration/nodechaincode/e2e.js'
'test/integration/nodechaincode/e2e.js',
'test/integration/only-admin.js',
'test/integration/perf/orderer.js',
'test/integration/perf/peer.js'
]))
.pipe(addsrc.append(
'test/unit/logger.js' // put this to the last so the debugging levels are not mixed up
Expand Down
4 changes: 2 additions & 2 deletions fabric-client/lib/Channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -653,8 +653,8 @@ var Channel = class {
var self = this;
var orderer = this._clientContext.getTargetOrderer(null, this._orderers, this._name);

var signer = this._clientContext._getSigningIdentity();
var txId = new TransactionID(signer);
var signer = this._clientContext._getSigningIdentity(true);
var txId = new TransactionID(signer, true);

// seek the latest block
var seekSpecifiedStart = new _abProto.SeekNewest();
Expand Down
8 changes: 4 additions & 4 deletions fabric-client/lib/ChannelEventHub.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,8 @@ var ChannelEventHub = class {
*/
connect(full_block){
logger.debug('connect - start');
if (!this._clientContext._userContext) {
throw new Error('The clientContext has not been properly initialized, missing userContext');
if (!this._clientContext._userContext && !this._clientContext._adminSigningIdentity) {
throw new Error('The clientContext has not been properly initialized, missing userContext or admin identity');
}

if(typeof full_block === 'boolean') {
Expand Down Expand Up @@ -499,8 +499,8 @@ var ChannelEventHub = class {
// the blocks come in
// FAIL_IF_NOT_READY will mean if the block is not there throw an error
seekInfo.setBehavior(_abProto.SeekInfo.SeekBehavior.BLOCK_UNTIL_READY);
let tx_id = this._clientContext.newTransactionID();
let signer = this._clientContext._getSigningIdentity();
let tx_id = this._clientContext.newTransactionID(true);
let signer = this._clientContext._getSigningIdentity(true);

// build the header for use with the seekInfo payload
let seekInfoHeader = clientUtils.buildChannelHeader(
Expand Down
Binary file added test/fixtures/channel/adminconfig.tx
Binary file not shown.
89 changes: 89 additions & 0 deletions test/fixtures/network-ad.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: "global-trade-network"
description: "The network to be in if you want to stay in the global trade business"
version: "1.0"

channels:
adminconfig:
orderers:
- orderer.example.com
peers:
peer0.org1.example.com:
endorsingPeer: true
chaincodeQuery: true
ledgerQuery: true
eventSource: true
peer0.org2.example.com:
endorsingPeer: true
chaincodeQuery: false
ledgerQuery: true
eventSource: true

organizations:
Org1:
mspid: Org1MSP

peers:
- peer0.org1.example.com
certificateAuthorities:
- ca-org1
adminPrivateKey:
path: test/fixtures/channel/crypto-config/peerOrganizations/org1.example.com/users/[email protected]/keystore/9022d671ceedbb24af3ea69b5a8136cc64203df6b9920e26f48123fcfcb1d2e9_sk
signedCert:
path: test/fixtures/channel/crypto-config/peerOrganizations/org1.example.com/users/[email protected]/signcerts/[email protected]
Org2:
mspid: Org2MSP
peers:
- peer0.org2.example.com
certificateAuthorities:
- ca-org2
adminPrivateKey:
path: test/fixtures/channel/crypto-config/peerOrganizations/org2.example.com/users/[email protected]/keystore/5a983ddcbefe52a7f9b8ee5b85a590c3e3a43c4ccd70c7795bec504e7f74848d_sk
signedCert:
path: test/fixtures/channel/crypto-config/peerOrganizations/org2.example.com/users/[email protected]/signcerts/[email protected]
orderers:
orderer.example.com:
url: grpcs://localhost:7050
grpcOptions:
ssl-target-name-override: orderer.example.com
grpc-max-send-message-length: 15

tlsCACerts:
path: test/fixtures/channel/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tlscacerts/example.com-cert.pem
peers:
peer0.org1.example.com:
url: grpcs://localhost:7051
grpcOptions:
ssl-target-name-override: peer0.org1.example.com
grpc.http2.keepalive_time: 15
tlsCACerts:
path: test/fixtures/channel/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tlscacerts/org1.example.com-cert.pem

peer0.org2.example.com:
url: grpcs://localhost:8051
grpcOptions:
ssl-target-name-override: peer0.org2.example.com
tlsCACerts:
path: test/fixtures/channel/crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tlscacerts/org2.example.com-cert.pem

certificateAuthorities:
ca-org1:
url: https://localhost:7054
httpOptions:
verify: false
tlsCACerts:
path: test/fixtures/channel/crypto-config/peerOrganizations/org1.example.com/ca/org1.example.com-cert.pem
registrar:
- enrollId: admin
enrollSecret: adminpw
caName: ca-org1

ca-org2:
url: https://localhost:8054
httpOptions:
verify: false
tlsCACerts:
path: test/fixtures/channel/crypto-config/peerOrganizations/org2.example.com/ca/org2.example.com-cert.pem
registrar:
- enrollId: admin
enrollSecret: adminpw
caName: ca-org2
Loading

0 comments on commit 0bc73ac

Please sign in to comment.