github.com/Hnampk/fabric@v2.1.1+incompatible/core/ledger/kvledger/benchmark/mocks/msp.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  	mspprotos "github.com/hyperledger/fabric-protos-go/msp"
    13  	"github.com/hyperledger/fabric/msp"
    14  )
    15  
    16  type noopmsp struct {
    17  }
    18  
    19  // NewNoopMsp returns a no-op implementation of the MSP interface
    20  func NewNoopMsp() msp.MSP {
    21  	return &noopmsp{}
    22  }
    23  
    24  func (msp *noopmsp) Setup(*mspprotos.MSPConfig) error {
    25  	return nil
    26  }
    27  
    28  func (msp *noopmsp) GetVersion() msp.MSPVersion {
    29  	return 1
    30  }
    31  
    32  func (msp *noopmsp) GetType() msp.ProviderType {
    33  	return 0
    34  }
    35  
    36  func (msp *noopmsp) GetIdentifier() (string, error) {
    37  	return "NOOP", nil
    38  }
    39  
    40  func (msp *noopmsp) GetSigningIdentity(identifier *msp.IdentityIdentifier) (msp.SigningIdentity, error) {
    41  	id, _ := newNoopSigningIdentity()
    42  	return id, nil
    43  }
    44  
    45  func (msp *noopmsp) GetDefaultSigningIdentity() (msp.SigningIdentity, error) {
    46  	id, _ := newNoopSigningIdentity()
    47  	return id, nil
    48  }
    49  
    50  // GetRootCerts returns the root certificates for this MSP
    51  func (msp *noopmsp) GetRootCerts() []msp.Identity {
    52  	return nil
    53  }
    54  
    55  // GetIntermediateCerts returns the intermediate root certificates for this MSP
    56  func (msp *noopmsp) GetIntermediateCerts() []msp.Identity {
    57  	return nil
    58  }
    59  
    60  // GetTLSRootCerts returns the root certificates for this MSP
    61  func (msp *noopmsp) GetTLSRootCerts() [][]byte {
    62  	return nil
    63  }
    64  
    65  // GetTLSIntermediateCerts returns the intermediate root certificates for this MSP
    66  func (msp *noopmsp) GetTLSIntermediateCerts() [][]byte {
    67  	return nil
    68  }
    69  
    70  func (msp *noopmsp) DeserializeIdentity(serializedID []byte) (msp.Identity, error) {
    71  	id, _ := newNoopIdentity()
    72  	return id, nil
    73  }
    74  
    75  func (msp *noopmsp) Validate(id msp.Identity) error {
    76  	return nil
    77  }
    78  
    79  func (msp *noopmsp) SatisfiesPrincipal(id msp.Identity, principal *mspprotos.MSPPrincipal) error {
    80  	return nil
    81  }
    82  
    83  // IsWellFormed checks if the given identity can be deserialized into its provider-specific form
    84  func (msp *noopmsp) IsWellFormed(_ *mspprotos.SerializedIdentity) error {
    85  	return nil
    86  }
    87  
    88  type noopidentity struct {
    89  }
    90  
    91  func newNoopIdentity() (msp.Identity, error) {
    92  	return &noopidentity{}, nil
    93  }
    94  
    95  func (id *noopidentity) Anonymous() bool {
    96  	panic("implement me")
    97  }
    98  
    99  func (id *noopidentity) SatisfiesPrincipal(*mspprotos.MSPPrincipal) error {
   100  	return nil
   101  }
   102  
   103  func (id *noopidentity) ExpiresAt() time.Time {
   104  	return time.Time{}
   105  }
   106  
   107  func (id *noopidentity) GetIdentifier() *msp.IdentityIdentifier {
   108  	return &msp.IdentityIdentifier{Mspid: "NOOP", Id: "Bob"}
   109  }
   110  
   111  func (id *noopidentity) GetMSPIdentifier() string {
   112  	return "MSPID"
   113  }
   114  
   115  func (id *noopidentity) Validate() error {
   116  	return nil
   117  }
   118  
   119  func (id *noopidentity) GetOrganizationalUnits() []*msp.OUIdentifier {
   120  	return nil
   121  }
   122  
   123  func (id *noopidentity) Verify(msg []byte, sig []byte) error {
   124  	return nil
   125  }
   126  
   127  func (id *noopidentity) Serialize() ([]byte, error) {
   128  	return []byte("cert"), nil
   129  }
   130  
   131  type noopsigningidentity struct {
   132  	noopidentity
   133  }
   134  
   135  func newNoopSigningIdentity() (msp.SigningIdentity, error) {
   136  	return &noopsigningidentity{}, nil
   137  }
   138  
   139  func (id *noopsigningidentity) Sign(msg []byte) ([]byte, error) {
   140  	return []byte("signature"), nil
   141  }
   142  
   143  func (id *noopsigningidentity) GetPublicVersion() msp.Identity {
   144  	return id
   145  }