Skip to content

Commit e310be3

Browse files
committed
[FAB-10383] Add support v1.3 MSP
Add new v1.3 MSP version, for which SatisfiesPrincipal will be enhanced to handle the extended version of MSPPrincipal. Change-Id: Iaa9181f3ba8f6774ae766425ba7be6ff89415706 Signed-off-by: Mathias Bjoerkqvist <mbj@zurich.ibm.com>
1 parent ff950e2 commit e310be3

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

msp/factory.go

+5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ type MSPVersion int
1515
const (
1616
MSPv1_0 = iota
1717
MSPv1_1
18+
MSPv1_3
1819
)
1920

2021
// NewOpts represent
@@ -51,11 +52,15 @@ func New(opts NewOpts) (MSP, error) {
5152
return newBccspMsp(MSPv1_0)
5253
case MSPv1_1:
5354
return newBccspMsp(MSPv1_1)
55+
case MSPv1_3:
56+
return newBccspMsp(MSPv1_3)
5457
default:
5558
return nil, errors.Errorf("Invalid *BCCSPNewOpts. Version not recognized [%v]", opts.GetVersion())
5659
}
5760
case *IdemixNewOpts:
5861
switch opts.GetVersion() {
62+
case MSPv1_3:
63+
fallthrough
5964
case MSPv1_1:
6065
return newIdemixMsp()
6166
default:

msp/msp_test.go

+28-2
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ func TestAdminPolicyPrincipal(t *testing.T) {
787787
}
788788

789789
func TestAdminPolicyPrincipalFails(t *testing.T) {
790-
id, err := localMsp.GetDefaultSigningIdentity()
790+
id, err := localMspV13.GetDefaultSigningIdentity()
791791
assert.NoError(t, err)
792792

793793
principalBytes, err := proto.Marshal(&msp.MSPRole{Role: msp.MSPRole_ADMIN, MspIdentifier: "SampleOrg"})
@@ -798,7 +798,7 @@ func TestAdminPolicyPrincipalFails(t *testing.T) {
798798
Principal: principalBytes}
799799

800800
// remove the admin so validation will fail
801-
localMsp.(*bccspmsp).admins = make([]Identity, 0)
801+
localMspV13.(*bccspmsp).admins = make([]Identity, 0)
802802

803803
err = id.SatisfiesPrincipal(principal)
804804
assert.Error(t, err)
@@ -924,6 +924,8 @@ func TestIdentityPolicyPrincipalFails(t *testing.T) {
924924

925925
var conf *msp.MSPConfig
926926
var localMsp MSP
927+
var localMspV11 MSP
928+
var localMspV13 MSP
927929

928930
// Required because deleting the cert or msp options from localMsp causes parallel tests to fail
929931
var localMspBad MSP
@@ -955,6 +957,30 @@ func TestMain(m *testing.M) {
955957
os.Exit(-1)
956958
}
957959

960+
localMspV13, err = newBccspMsp(MSPv1_3)
961+
if err != nil {
962+
fmt.Printf("Constructor for V1.3 msp should have succeeded, got err %s instead", err)
963+
os.Exit(-1)
964+
}
965+
966+
localMspV11, err = newBccspMsp(MSPv1_1)
967+
if err != nil {
968+
fmt.Printf("Constructor for V1.1 msp should have succeeded, got err %s instead", err)
969+
os.Exit(-1)
970+
}
971+
972+
err = localMspV11.Setup(conf)
973+
if err != nil {
974+
fmt.Printf("Setup for V1.1 msp should have succeeded, got err %s instead", err)
975+
os.Exit(-1)
976+
}
977+
978+
err = localMspV13.Setup(conf)
979+
if err != nil {
980+
fmt.Printf("Setup for V1.3 msp should have succeeded, got err %s instead", err)
981+
os.Exit(-1)
982+
}
983+
958984
err = localMsp.Setup(conf)
959985
if err != nil {
960986
fmt.Printf("Setup for msp should have succeeded, got err %s instead", err)

msp/mspimpl.go

+3
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ func newBccspMsp(version MSPVersion) (MSP, error) {
108108
case MSPv1_1:
109109
theMsp.internalSetupFunc = theMsp.setupV11
110110
theMsp.internalValidateIdentityOusFunc = theMsp.validateIdentityOUsV11
111+
case MSPv1_3:
112+
theMsp.internalSetupFunc = theMsp.setupV11
113+
theMsp.internalValidateIdentityOusFunc = theMsp.validateIdentityOUsV11
111114
default:
112115
return nil, errors.Errorf("Invalid MSP version [%v]", version)
113116
}

0 commit comments

Comments
 (0)