github.com/defanghe/fabric@v2.1.1+incompatible/msp/mocks/mocks.go (about)

     1  /*
     2  Copyright IBM Corp. All Rights Reserved.
     3  
     4  SPDX-License-Identifier: Apache-2.0
     5  */
     6  
     7  package mocks
     8  
     9  import (
    10  	"time"
    11  
    12  	pmsp "github.com/hyperledger/fabric-protos-go/msp"
    13  	"github.com/hyperledger/fabric/msp"
    14  	"github.com/stretchr/testify/mock"
    15  )
    16  
    17  type MockMSP struct {
    18  	mock.Mock
    19  }
    20  
    21  func (m *MockMSP) IsWellFormed(_ *pmsp.SerializedIdentity) error {
    22  	return nil
    23  }
    24  
    25  func (m *MockMSP) DeserializeIdentity(serializedIdentity []byte) (msp.Identity, error) {
    26  	args := m.Called(serializedIdentity)
    27  	return args.Get(0).(msp.Identity), args.Error(1)
    28  }
    29  
    30  func (m *MockMSP) Setup(config *pmsp.MSPConfig) error {
    31  	args := m.Called(config)
    32  	return args.Error(0)
    33  }
    34  
    35  func (m *MockMSP) GetVersion() msp.MSPVersion {
    36  	args := m.Called()
    37  	return args.Get(0).(msp.MSPVersion)
    38  }
    39  
    40  func (m *MockMSP) GetType() msp.ProviderType {
    41  	args := m.Called()
    42  	return args.Get(0).(msp.ProviderType)
    43  }
    44  
    45  func (m *MockMSP) GetIdentifier() (string, error) {
    46  	args := m.Called()
    47  	return args.String(0), args.Error(1)
    48  }
    49  
    50  func (m *MockMSP) GetSigningIdentity(identifier *msp.IdentityIdentifier) (msp.SigningIdentity, error) {
    51  	args := m.Called(identifier)
    52  	return args.Get(0).(msp.SigningIdentity), args.Error(1)
    53  }
    54  
    55  func (m *MockMSP) GetDefaultSigningIdentity() (msp.SigningIdentity, error) {
    56  	args := m.Called()
    57  	return args.Get(0).(msp.SigningIdentity), args.Error(1)
    58  }
    59  
    60  func (m *MockMSP) GetTLSRootCerts() [][]byte {
    61  	args := m.Called()
    62  	return args.Get(0).([][]byte)
    63  }
    64  
    65  func (m *MockMSP) GetTLSIntermediateCerts() [][]byte {
    66  	args := m.Called()
    67  	return args.Get(0).([][]byte)
    68  }
    69  
    70  func (m *MockMSP) Validate(id msp.Identity) error {
    71  	args := m.Called(id)
    72  	return args.Error(0)
    73  }
    74  
    75  func (m *MockMSP) SatisfiesPrincipal(id msp.Identity, principal *pmsp.MSPPrincipal) error {
    76  	args := m.Called(id, principal)
    77  	return args.Error(0)
    78  }
    79  
    80  type MockIdentity struct {
    81  	mock.Mock
    82  
    83  	ID string
    84  }
    85  
    86  func (m *MockIdentity) Anonymous() bool {
    87  	panic("implement me")
    88  }
    89  
    90  func (m *MockIdentity) ExpiresAt() time.Time {
    91  	panic("implement me")
    92  }
    93  
    94  func (m *MockIdentity) GetIdentifier() *msp.IdentityIdentifier {
    95  	args := m.Called()
    96  	return args.Get(0).(*msp.IdentityIdentifier)
    97  }
    98  
    99  func (*MockIdentity) GetMSPIdentifier() string {
   100  	panic("implement me")
   101  }
   102  
   103  func (m *MockIdentity) Validate() error {
   104  	return m.Called().Error(0)
   105  }
   106  
   107  func (*MockIdentity) GetOrganizationalUnits() []*msp.OUIdentifier {
   108  	panic("implement me")
   109  }
   110  
   111  func (*MockIdentity) Verify(msg []byte, sig []byte) error {
   112  	return nil
   113  }
   114  
   115  func (*MockIdentity) Serialize() ([]byte, error) {
   116  	panic("implement me")
   117  }
   118  
   119  func (m *MockIdentity) SatisfiesPrincipal(principal *pmsp.MSPPrincipal) error {
   120  	return m.Called(principal).Error(0)
   121  }
   122  
   123  type MockSigningIdentity struct {
   124  	mock.Mock
   125  	*MockIdentity
   126  }
   127  
   128  func (*MockSigningIdentity) Sign(msg []byte) ([]byte, error) {
   129  	panic("implement me")
   130  }
   131  
   132  func (*MockSigningIdentity) GetPublicVersion() msp.Identity {
   133  	panic("implement me")
   134  }