@@ -29,93 +29,93 @@ import (
29
29
mspproto "github.com/hyperledger/fabric/protos/msp"
30
30
)
31
31
32
- type mockChannelPolicyManagerGetter struct {
33
- managers map [string ]policies.Manager
32
+ type MockChannelPolicyManagerGetter struct {
33
+ Managers map [string ]policies.Manager
34
34
}
35
35
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
38
38
}
39
39
40
- type mockChannelPolicyManager struct {
41
- mockPolicy policies.Policy
40
+ type MockChannelPolicyManager struct {
41
+ MockPolicy policies.Policy
42
42
}
43
43
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
46
46
}
47
47
48
- func (m * mockChannelPolicyManager ) Manager (path []string ) (policies.Manager , bool ) {
48
+ func (m * MockChannelPolicyManager ) Manager (path []string ) (policies.Manager , bool ) {
49
49
panic ("Not implemented" )
50
50
}
51
51
52
- func (m * mockChannelPolicyManager ) BasePath () string {
52
+ func (m * MockChannelPolicyManager ) BasePath () string {
53
53
panic ("Not implemented" )
54
54
}
55
55
56
- func (m * mockChannelPolicyManager ) PolicyNames () []string {
56
+ func (m * MockChannelPolicyManager ) PolicyNames () []string {
57
57
panic ("Not implemented" )
58
58
}
59
59
60
- type mockPolicy struct {
61
- deserializer msp.IdentityDeserializer
60
+ type MockPolicy struct {
61
+ Deserializer msp.IdentityDeserializer
62
62
}
63
63
64
64
// 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 {
66
66
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 )
68
68
if err != nil {
69
69
return err
70
70
}
71
71
72
72
return identity .Verify (signatureSet [0 ].Data , signatureSet [0 ].Signature )
73
73
}
74
74
75
- type mockIdentityDeserializer struct {
76
- identity []byte
77
- msg []byte
75
+ type MockIdentityDeserializer struct {
76
+ Identity []byte
77
+ Msg []byte
78
78
}
79
79
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
85
85
}
86
86
87
- return nil , errors .New ("Invalid identity " )
87
+ return nil , errors .New ("Invalid Identity " )
88
88
}
89
89
90
- type mockIdentity struct {
90
+ type MockIdentity struct {
91
91
identity []byte
92
92
msg []byte
93
93
}
94
94
95
- func (id * mockIdentity ) SatisfiesPrincipal (p * mspproto.MSPPrincipal ) error {
95
+ func (id * MockIdentity ) SatisfiesPrincipal (p * mspproto.MSPPrincipal ) error {
96
96
if ! bytes .Equal (id .identity , p .Principal ) {
97
97
return fmt .Errorf ("Different identities [% x]!=[% x]" , id .identity , p .Principal )
98
98
}
99
99
return nil
100
100
}
101
101
102
- func (id * mockIdentity ) GetIdentifier () * msp.IdentityIdentifier {
102
+ func (id * MockIdentity ) GetIdentifier () * msp.IdentityIdentifier {
103
103
return & msp.IdentityIdentifier {Mspid : "mock" , Id : "mock" }
104
104
}
105
105
106
- func (id * mockIdentity ) GetMSPIdentifier () string {
106
+ func (id * MockIdentity ) GetMSPIdentifier () string {
107
107
return "mock"
108
108
}
109
109
110
- func (id * mockIdentity ) Validate () error {
110
+ func (id * MockIdentity ) Validate () error {
111
111
return nil
112
112
}
113
113
114
- func (id * mockIdentity ) GetOrganizationalUnits () []string {
114
+ func (id * MockIdentity ) GetOrganizationalUnits () []string {
115
115
return []string {"dunno" }
116
116
}
117
117
118
- func (id * mockIdentity ) Verify (msg []byte , sig []byte ) error {
118
+ func (id * MockIdentity ) Verify (msg []byte , sig []byte ) error {
119
119
fmt .Printf ("VERIFY [% x], [% x], [% x]\n " , string (id .msg ), string (msg ), string (sig ))
120
120
if bytes .Equal (id .msg , msg ) {
121
121
if bytes .Equal (msg , sig ) {
@@ -126,22 +126,22 @@ func (id *mockIdentity) Verify(msg []byte, sig []byte) error {
126
126
return errors .New ("Invalid Signature" )
127
127
}
128
128
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 {
130
130
return nil
131
131
}
132
132
133
- func (id * mockIdentity ) VerifyAttributes (proof []byte , spec * msp.AttributeProofSpec ) error {
133
+ func (id * MockIdentity ) VerifyAttributes (proof []byte , spec * msp.AttributeProofSpec ) error {
134
134
return nil
135
135
}
136
136
137
- func (id * mockIdentity ) Serialize () ([]byte , error ) {
137
+ func (id * MockIdentity ) Serialize () ([]byte , error ) {
138
138
return []byte ("cert" ), nil
139
139
}
140
140
141
- type mockMSPPrincipalGetter struct {
141
+ type MockMSPPrincipalGetter struct {
142
142
Principal []byte
143
143
}
144
144
145
- func (m * mockMSPPrincipalGetter ) Get (role string ) (* mspproto.MSPPrincipal , error ) {
145
+ func (m * MockMSPPrincipalGetter ) Get (role string ) (* mspproto.MSPPrincipal , error ) {
146
146
return & mspproto.MSPPrincipal {Principal : m .Principal }, nil
147
147
}
0 commit comments