@@ -29,93 +29,93 @@ import (
2929 mspproto "github.com/hyperledger/fabric/protos/msp"
3030)
3131
32- type mockChannelPolicyManagerGetter struct {
33- managers map [string ]policies.Manager
32+ type MockChannelPolicyManagerGetter struct {
33+ Managers map [string ]policies.Manager
3434}
3535
36- func (c * mockChannelPolicyManagerGetter ) Manager (channelID string ) (policies.Manager , bool ) {
37- return c .managers [channelID ], true
36+ func (c * MockChannelPolicyManagerGetter ) Manager (channelID string ) (policies.Manager , bool ) {
37+ return c .Managers [channelID ], true
3838}
3939
40- type mockChannelPolicyManager struct {
41- mockPolicy policies.Policy
40+ type MockChannelPolicyManager struct {
41+ MockPolicy policies.Policy
4242}
4343
44- func (m * mockChannelPolicyManager ) GetPolicy (id string ) (policies.Policy , bool ) {
45- return m .mockPolicy , true
44+ func (m * MockChannelPolicyManager ) GetPolicy (id string ) (policies.Policy , bool ) {
45+ return m .MockPolicy , true
4646}
4747
48- func (m * mockChannelPolicyManager ) Manager (path []string ) (policies.Manager , bool ) {
48+ func (m * MockChannelPolicyManager ) Manager (path []string ) (policies.Manager , bool ) {
4949 panic ("Not implemented" )
5050}
5151
52- func (m * mockChannelPolicyManager ) BasePath () string {
52+ func (m * MockChannelPolicyManager ) BasePath () string {
5353 panic ("Not implemented" )
5454}
5555
56- func (m * mockChannelPolicyManager ) PolicyNames () []string {
56+ func (m * MockChannelPolicyManager ) PolicyNames () []string {
5757 panic ("Not implemented" )
5858}
5959
60- type mockPolicy struct {
61- deserializer msp.IdentityDeserializer
60+ type MockPolicy struct {
61+ Deserializer msp.IdentityDeserializer
6262}
6363
6464// Evaluate takes a set of SignedData and evaluates whether this set of signatures satisfies the policy
65- func (m * mockPolicy ) Evaluate (signatureSet []* common.SignedData ) error {
65+ func (m * MockPolicy ) Evaluate (signatureSet []* common.SignedData ) error {
6666 fmt .Printf ("Evaluate [%s], [% x], [% x]\n " , string (signatureSet [0 ].Identity ), string (signatureSet [0 ].Data ), string (signatureSet [0 ].Signature ))
67- identity , err := m .deserializer .DeserializeIdentity (signatureSet [0 ].Identity )
67+ identity , err := m .Deserializer .DeserializeIdentity (signatureSet [0 ].Identity )
6868 if err != nil {
6969 return err
7070 }
7171
7272 return identity .Verify (signatureSet [0 ].Data , signatureSet [0 ].Signature )
7373}
7474
75- type mockIdentityDeserializer struct {
76- identity []byte
77- msg []byte
75+ type MockIdentityDeserializer struct {
76+ Identity []byte
77+ Msg []byte
7878}
7979
80- func (d * mockIdentityDeserializer ) DeserializeIdentity (serializedIdentity []byte ) (msp.Identity , error ) {
81- fmt .Printf ("id : [%s], [%s]\n " , string (serializedIdentity ), string (d .identity ))
82- if bytes .Equal (d .identity , serializedIdentity ) {
83- fmt .Printf ("GOT : [%s], [%s]\n " , string (serializedIdentity ), string (d .identity ))
84- return & mockIdentity {identity : d .identity , msg : d .msg }, nil
80+ func (d * MockIdentityDeserializer ) DeserializeIdentity (serializedIdentity []byte ) (msp.Identity , error ) {
81+ fmt .Printf ("id : [%s], [%s]\n " , string (serializedIdentity ), string (d .Identity ))
82+ if bytes .Equal (d .Identity , serializedIdentity ) {
83+ fmt .Printf ("GOT : [%s], [%s]\n " , string (serializedIdentity ), string (d .Identity ))
84+ return & MockIdentity {identity : d .Identity , msg : d .Msg }, nil
8585 }
8686
87- return nil , errors .New ("Invalid identity " )
87+ return nil , errors .New ("Invalid Identity " )
8888}
8989
90- type mockIdentity struct {
90+ type MockIdentity struct {
9191 identity []byte
9292 msg []byte
9393}
9494
95- func (id * mockIdentity ) SatisfiesPrincipal (p * mspproto.MSPPrincipal ) error {
95+ func (id * MockIdentity ) SatisfiesPrincipal (p * mspproto.MSPPrincipal ) error {
9696 if ! bytes .Equal (id .identity , p .Principal ) {
9797 return fmt .Errorf ("Different identities [% x]!=[% x]" , id .identity , p .Principal )
9898 }
9999 return nil
100100}
101101
102- func (id * mockIdentity ) GetIdentifier () * msp.IdentityIdentifier {
102+ func (id * MockIdentity ) GetIdentifier () * msp.IdentityIdentifier {
103103 return & msp.IdentityIdentifier {Mspid : "mock" , Id : "mock" }
104104}
105105
106- func (id * mockIdentity ) GetMSPIdentifier () string {
106+ func (id * MockIdentity ) GetMSPIdentifier () string {
107107 return "mock"
108108}
109109
110- func (id * mockIdentity ) Validate () error {
110+ func (id * MockIdentity ) Validate () error {
111111 return nil
112112}
113113
114- func (id * mockIdentity ) GetOrganizationalUnits () []string {
114+ func (id * MockIdentity ) GetOrganizationalUnits () []string {
115115 return []string {"dunno" }
116116}
117117
118- func (id * mockIdentity ) Verify (msg []byte , sig []byte ) error {
118+ func (id * MockIdentity ) Verify (msg []byte , sig []byte ) error {
119119 fmt .Printf ("VERIFY [% x], [% x], [% x]\n " , string (id .msg ), string (msg ), string (sig ))
120120 if bytes .Equal (id .msg , msg ) {
121121 if bytes .Equal (msg , sig ) {
@@ -126,22 +126,22 @@ func (id *mockIdentity) Verify(msg []byte, sig []byte) error {
126126 return errors .New ("Invalid Signature" )
127127}
128128
129- func (id * mockIdentity ) VerifyOpts (msg []byte , sig []byte , opts msp.SignatureOpts ) error {
129+ func (id * MockIdentity ) VerifyOpts (msg []byte , sig []byte , opts msp.SignatureOpts ) error {
130130 return nil
131131}
132132
133- func (id * mockIdentity ) VerifyAttributes (proof []byte , spec * msp.AttributeProofSpec ) error {
133+ func (id * MockIdentity ) VerifyAttributes (proof []byte , spec * msp.AttributeProofSpec ) error {
134134 return nil
135135}
136136
137- func (id * mockIdentity ) Serialize () ([]byte , error ) {
137+ func (id * MockIdentity ) Serialize () ([]byte , error ) {
138138 return []byte ("cert" ), nil
139139}
140140
141- type mockMSPPrincipalGetter struct {
141+ type MockMSPPrincipalGetter struct {
142142 Principal []byte
143143}
144144
145- func (m * mockMSPPrincipalGetter ) Get (role string ) (* mspproto.MSPPrincipal , error ) {
145+ func (m * MockMSPPrincipalGetter ) Get (role string ) (* mspproto.MSPPrincipal , error ) {
146146 return & mspproto.MSPPrincipal {Principal : m .Principal }, nil
147147}
0 commit comments