@@ -17,7 +17,11 @@ import (
17
17
)
18
18
19
19
func setup (configPath string , ID string ) (MSP , error ) {
20
- msp , err := newIdemixMsp ()
20
+ return setupWithVersion (configPath , ID , MSPv1_3 )
21
+ }
22
+
23
+ func setupWithVersion (configPath string , ID string , version MSPVersion ) (MSP , error ) {
24
+ msp , err := newIdemixMsp (version )
21
25
if err != nil {
22
26
return nil , err
23
27
}
@@ -65,7 +69,7 @@ func TestSetupBad(t *testing.T) {
65
69
assert .Error (t , err )
66
70
assert .Contains (t , err .Error (), "Getting MSP config failed" )
67
71
68
- msp1 , err := newIdemixMsp ()
72
+ msp1 , err := newIdemixMsp (MSPv1_3 )
69
73
assert .NoError (t , err )
70
74
71
75
// Setup with nil config
@@ -306,6 +310,25 @@ func TestAnonymityPrincipalBad(t *testing.T) {
306
310
assert .Contains (t , err .Error (), "principal is nominal, but idemix MSP is anonymous" )
307
311
}
308
312
313
+ func TestAnonymityPrincipalV11 (t * testing.T ) {
314
+ msp1 , err := setupWithVersion ("testdata/idemix/MSP1OU1" , "MSP1OU1" , MSPv1_1 )
315
+ assert .NoError (t , err )
316
+
317
+ id1 , err := getDefaultSigner (msp1 )
318
+ assert .NoError (t , err )
319
+
320
+ principalBytes , err := proto .Marshal (& msp.MSPIdentityAnonymity {AnonymityType : msp .MSPIdentityAnonymity_NOMINAL })
321
+ assert .NoError (t , err )
322
+
323
+ principal := & msp.MSPPrincipal {
324
+ PrincipalClassification : msp .MSPPrincipal_ANONYMITY ,
325
+ Principal : principalBytes }
326
+
327
+ err = id1 .SatisfiesPrincipal (principal )
328
+ assert .Error (t , err )
329
+ assert .Contains (t , err .Error (), "Anonymity MSP Principals are unsupported in MSPv1_1" )
330
+ }
331
+
309
332
func TestIdemixIsWellFormed (t * testing.T ) {
310
333
idemixMSP , err := setup ("testdata/idemix/MSP1OU1" , "TestName" )
311
334
assert .NoError (t , err )
@@ -618,3 +641,43 @@ func TestPrincipalCombinedBad(t *testing.T) {
618
641
assert .Error (t , err , "non-admin member of OU1 in MSP1 should not satisfy principal admin and OU1 in MSP1" )
619
642
assert .Contains (t , err .Error (), "user is not an admin" )
620
643
}
644
+
645
+ func TestPrincipalCombinedV11 (t * testing.T ) {
646
+ msp1 , err := setupWithVersion ("testdata/idemix/MSP1OU1" , "MSP1OU1" , MSPv1_1 )
647
+ assert .NoError (t , err )
648
+
649
+ id1 , err := getDefaultSigner (msp1 )
650
+ assert .NoError (t , err )
651
+
652
+ ou := & msp.OrganizationUnit {
653
+ OrganizationalUnitIdentifier : id1 .GetOrganizationalUnits ()[0 ].OrganizationalUnitIdentifier ,
654
+ MspIdentifier : id1 .GetMSPIdentifier (),
655
+ CertifiersIdentifier : nil ,
656
+ }
657
+ principalBytes , err := proto .Marshal (ou )
658
+ assert .NoError (t , err )
659
+
660
+ principalOU := & msp.MSPPrincipal {
661
+ PrincipalClassification : msp .MSPPrincipal_ORGANIZATION_UNIT ,
662
+ Principal : principalBytes }
663
+
664
+ principalBytes , err = proto .Marshal (& msp.MSPRole {Role : msp .MSPRole_MEMBER , MspIdentifier : id1 .GetMSPIdentifier ()})
665
+ assert .NoError (t , err )
666
+
667
+ principalRole := & msp.MSPPrincipal {
668
+ PrincipalClassification : msp .MSPPrincipal_ROLE ,
669
+ Principal : principalBytes }
670
+
671
+ principals := []* msp.MSPPrincipal {principalOU , principalRole }
672
+
673
+ combinedPrincipal := & msp.CombinedPrincipal {Principals : principals }
674
+ combinedPrincipalBytes , err := proto .Marshal (combinedPrincipal )
675
+
676
+ assert .NoError (t , err )
677
+
678
+ principalsCombined := & msp.MSPPrincipal {PrincipalClassification : msp .MSPPrincipal_COMBINED , Principal : combinedPrincipalBytes }
679
+
680
+ err = id1 .SatisfiesPrincipal (principalsCombined )
681
+ assert .Error (t , err )
682
+ assert .Contains (t , err .Error (), "Combined MSP Principals are unsupported in MSPv1_1" )
683
+ }
0 commit comments