@@ -20,7 +20,7 @@ import (
20
20
"text/template"
21
21
"time"
22
22
23
- docker "github.com/fsouza/go-dockerclient"
23
+ "github.com/fsouza/go-dockerclient"
24
24
"github.com/hyperledger/fabric/integration/helpers"
25
25
"github.com/hyperledger/fabric/integration/nwo/commands"
26
26
"github.com/hyperledger/fabric/integration/nwo/fabricconfig"
@@ -308,16 +308,31 @@ func (n *Network) WritePeerConfig(p *Peer, config *fabricconfig.Core) {
308
308
Expect (err ).NotTo (HaveOccurred ())
309
309
}
310
310
311
- // peerUserCrpytoDir returns the path to the directory containing the
311
+ // peerUserCryptoDir returns the path to the directory containing the
312
312
// certificates and keys for the specified user of the peer.
313
- func (n * Network ) peerUserCrpytoDir (p * Peer , user , cryptoMaterialType string ) string {
313
+ func (n * Network ) peerUserCryptoDir (p * Peer , user , cryptoMaterialType string ) string {
314
314
org := n .Organization (p .Organization )
315
315
Expect (org ).NotTo (BeNil ())
316
316
317
+ return n .userCryptoDir (org , "peerOrganizations" , user , cryptoMaterialType )
318
+ }
319
+
320
+ // ordererUserCryptoDir returns the path to the directory containing the
321
+ // certificates and keys for the specified user of the orderer.
322
+ func (n * Network ) ordererUserCryptoDir (o * Orderer , user , cryptoMaterialType string ) string {
323
+ org := n .Organization (o .Organization )
324
+ Expect (org ).NotTo (BeNil ())
325
+
326
+ return n .userCryptoDir (org , "ordererOrganizations" , user , cryptoMaterialType )
327
+ }
328
+
329
+ // userCryptoDir returns the path to the folder with crypto materials for either peers or orderer organizations
330
+ // specific user
331
+ func (n * Network ) userCryptoDir (org * Organization , nodeOrganizationType , user , cryptoMaterialType string ) string {
317
332
return filepath .Join (
318
333
n .RootDir ,
319
334
"crypto" ,
320
- "peerOrganizations" ,
335
+ nodeOrganizationType ,
321
336
org .Domain ,
322
337
"users" ,
323
338
fmt .Sprintf ("%s@%s" , user , org .Domain ),
@@ -328,13 +343,19 @@ func (n *Network) peerUserCrpytoDir(p *Peer, user, cryptoMaterialType string) st
328
343
// PeerUserMSPDir returns the path to the MSP directory containing the
329
344
// certificates and keys for the specified user of the peer.
330
345
func (n * Network ) PeerUserMSPDir (p * Peer , user string ) string {
331
- return n .peerUserCrpytoDir (p , user , "msp" )
346
+ return n .peerUserCryptoDir (p , user , "msp" )
347
+ }
348
+
349
+ // OrdererUserMSPDir returns the path to the MSP directory containing the
350
+ // certificates and keys for the specified user of the peer.
351
+ func (n * Network ) OrdererUserMSPDir (o * Orderer , user string ) string {
352
+ return n .ordererUserCryptoDir (o , user , "msp" )
332
353
}
333
354
334
355
// PeerUserTLSDir returns the path to the TLS directory containing the
335
356
// certificates and keys for the specified user of the peer.
336
357
func (n * Network ) PeerUserTLSDir (p * Peer , user string ) string {
337
- return n .peerUserCrpytoDir (p , user , "tls" )
358
+ return n .peerUserCryptoDir (p , user , "tls" )
338
359
}
339
360
340
361
// PeerUserCert returns the path to the certificate for the specified user in
@@ -960,6 +981,18 @@ func (n *Network) PeerUserSession(p *Peer, user string, command Command) (*gexec
960
981
return n .StartSession (cmd , command .SessionName ())
961
982
}
962
983
984
+ // OrdererAdminSession execute a gexec.Session as an orderer node admin user. This is used primarily
985
+ // to generate orderer configuration updates
986
+ func (n * Network ) OrdererAdminSession (o * Orderer , p * Peer , command Command ) (* gexec.Session , error ) {
987
+ cmd := n .peerCommand (
988
+ command ,
989
+ "CORE_PEER_LOCALMSPID=OrdererMSP" ,
990
+ fmt .Sprintf ("FABRIC_CFG_PATH=%s" , n .PeerDir (p )),
991
+ fmt .Sprintf ("CORE_PEER_MSPCONFIGPATH=%s" , n .OrdererUserMSPDir (o , "Admin" )),
992
+ )
993
+ return n .StartSession (cmd , command .SessionName ())
994
+ }
995
+
963
996
// Peer returns the information about the named Peer in the named organization.
964
997
func (n * Network ) Peer (orgName , peerName string ) * Peer {
965
998
for _ , p := range n .PeersInOrg (orgName ) {
0 commit comments