@@ -124,7 +124,7 @@ func TestInstall(t *testing.T) {
124
124
testInstall (t , "" , "0" , path , false , EmptyChaincodeNameErr ("" ).Error (), "Alice" , scc , stub )
125
125
testInstall (t , "example02" , "1{}0" , path , false , InvalidVersionErr ("1{}0" ).Error (), "Alice" , scc , stub )
126
126
testInstall (t , "example02" , "0" , path , true , InvalidStatedbArtifactsErr ("" ).Error (), "Alice" , scc , stub )
127
- testInstall (t , "example02" , "0" , path , false , "Authorization for INSTALL has been denied " , "Bob" , scc , stub )
127
+ testInstall (t , "example02" , "0" , path , false , "access denied for [install] " , "Bob" , scc , stub )
128
128
testInstall (t , "example02-2" , "1.0-alpha+001" , path , false , "" , "Alice" , scc , stub )
129
129
testInstall (t , "example02-2" , "1.0+sha.c0ffee" , path , false , "" , "Alice" , scc , stub )
130
130
@@ -640,21 +640,23 @@ func TestFunctionsWithAliases(t *testing.T) {
640
640
sProp .Signature = sProp .ProposalBytes
641
641
642
642
testInvoke := func (function , resource string ) {
643
- res = stub .MockInvokeWithSignedProposal ("1" , [][]byte {[]byte (function ), []byte ("testchannel1" )}, nil )
644
- assert .NotEqual (t , int32 (shim .OK ), res .Status )
645
- assert .Equal (t , "invalid number of arguments to lscc: 2" , res .Message )
643
+ t .Run (function , func (t * testing.T ) {
644
+ res = stub .MockInvokeWithSignedProposal ("1" , [][]byte {[]byte (function ), []byte ("testchannel1" )}, nil )
645
+ assert .NotEqual (t , int32 (shim .OK ), res .Status )
646
+ assert .Equal (t , "invalid number of arguments to lscc: 2" , res .Message )
646
647
647
- mockAclProvider .Reset ()
648
- mockAclProvider .On ("CheckACL" , resource , "testchannel1" , sProp ).Return (errors .New ("bonanza" ))
649
- res = stub .MockInvokeWithSignedProposal ("1" , [][]byte {[]byte (function ), []byte ("testchannel1" ), []byte ("chaincode" )}, sProp )
650
- assert .NotEqual (t , int32 (shim .OK ), res .Status , res .Message )
651
- assert .Contains (t , res . Message , "Authorization request failed testchannel1: bonanza" )
648
+ mockAclProvider .Reset ()
649
+ mockAclProvider .On ("CheckACL" , resource , "testchannel1" , sProp ).Return (errors .New ("bonanza" ))
650
+ res = stub .MockInvokeWithSignedProposal ("1" , [][]byte {[]byte (function ), []byte ("testchannel1" ), []byte ("chaincode" )}, sProp )
651
+ assert .NotEqual (t , int32 (shim .OK ), res .Status , res .Message )
652
+ assert .Equal (t , fmt . Sprintf ( "access denied for [%s][ testchannel1] : bonanza", function ), res . Message )
652
653
653
- mockAclProvider .Reset ()
654
- mockAclProvider .On ("CheckACL" , resource , "testchannel1" , sProp ).Return (nil )
655
- res = stub .MockInvokeWithSignedProposal ("1" , [][]byte {[]byte (function ), []byte ("testchannel1" ), []byte ("nonexistentchaincode" )}, sProp )
656
- assert .NotEqual (t , int32 (shim .OK ), res .Status , res .Message )
657
- assert .Equal (t , res .Message , "could not find chaincode with name 'nonexistentchaincode'" )
654
+ mockAclProvider .Reset ()
655
+ mockAclProvider .On ("CheckACL" , resource , "testchannel1" , sProp ).Return (nil )
656
+ res = stub .MockInvokeWithSignedProposal ("1" , [][]byte {[]byte (function ), []byte ("testchannel1" ), []byte ("nonexistentchaincode" )}, sProp )
657
+ assert .NotEqual (t , int32 (shim .OK ), res .Status , res .Message )
658
+ assert .Equal (t , res .Message , "could not find chaincode with name 'nonexistentchaincode'" )
659
+ })
658
660
}
659
661
660
662
testInvoke ("getid" , "lscc/ChaincodeExists" )
@@ -686,7 +688,7 @@ func TestGetChaincodes(t *testing.T) {
686
688
mockAclProvider .On ("CheckACL" , resources .Lscc_GetInstantiatedChaincodes , "test" , sProp ).Return (errors .New ("coyote" ))
687
689
res = stub .MockInvokeWithSignedProposal ("1" , [][]byte {[]byte (function )}, sProp )
688
690
assert .NotEqual (t , int32 (shim .OK ), res .Status )
689
- assert .Regexp (t , "Authorization for GETCHAINCODES on channel (.*)coyote" , res .Message )
691
+ assert .Regexp (t , `access denied for \[` + function + `\]\[test\] (.*)coyote` , res .Message )
690
692
691
693
mockAclProvider .Reset ()
692
694
mockAclProvider .On ("CheckACL" , resources .Lscc_GetInstantiatedChaincodes , "test" , sProp ).Return (nil )
@@ -726,7 +728,7 @@ func TestGetInstalledChaincodes(t *testing.T) {
726
728
727
729
res = stub .MockInvokeWithSignedProposal ("1" , [][]byte {[]byte (function )}, sProp )
728
730
assert .NotEqual (t , int32 (shim .OK ), res .Status )
729
- assert .Contains (t , res .Message , "Authorization for GETINSTALLEDCHAINCODES " )
731
+ assert .Contains (t , res .Message , "access denied for [" + function + "] " )
730
732
731
733
sProp , _ = utils .MockSignedEndorserProposalOrPanic ("" , & pb.ChaincodeSpec {}, []byte ("Alice" ), []byte ("msg1" ))
732
734
identityDeserializer .Msg = sProp .ProposalBytes
0 commit comments