github.com/yacovm/fabric@v2.0.0-alpha.0.20191128145320-c5d4087dc723+incompatible/common/channelconfig/application_test.go (about) 1 /* 2 Copyright IBM Corp. 2017 All Rights Reserved. 3 4 SPDX-License-Identifier: Apache-2.0 5 */ 6 7 package channelconfig 8 9 import ( 10 "testing" 11 12 "github.com/golang/protobuf/proto" 13 cb "github.com/hyperledger/fabric-protos-go/common" 14 "github.com/hyperledger/fabric/common/capabilities" 15 "github.com/hyperledger/fabric/protoutil" 16 . "github.com/onsi/gomega" 17 ) 18 19 func TestApplicationInterface(t *testing.T) { 20 _ = Application((*ApplicationConfig)(nil)) 21 } 22 23 func TestACL(t *testing.T) { 24 g := NewGomegaWithT(t) 25 cgt := &cb.ConfigGroup{ 26 Values: map[string]*cb.ConfigValue{ 27 ACLsKey: { 28 Value: protoutil.MarshalOrPanic( 29 ACLValues(map[string]string{}).Value(), 30 ), 31 }, 32 CapabilitiesKey: { 33 Value: protoutil.MarshalOrPanic( 34 CapabilitiesValue(map[string]bool{ 35 capabilities.ApplicationV1_2: true, 36 }).Value(), 37 ), 38 }, 39 }, 40 } 41 42 t.Run("Success", func(t *testing.T) { 43 cg := proto.Clone(cgt).(*cb.ConfigGroup) 44 _, err := NewApplicationConfig(proto.Clone(cg).(*cb.ConfigGroup), nil) 45 g.Expect(err).NotTo(HaveOccurred()) 46 }) 47 48 t.Run("MissingCapability", func(t *testing.T) { 49 cg := proto.Clone(cgt).(*cb.ConfigGroup) 50 delete(cg.Values, CapabilitiesKey) 51 _, err := NewApplicationConfig(cg, nil) 52 g.Expect(err).To(MatchError("ACLs may not be specified without the required capability")) 53 }) 54 }