github.com/xiaqingdoc/fabric@v2.1.1+incompatible/core/handlers/auth/plugin/filter_test.go (about)

     1  /*
     2  Copyright IBM Corp. All Rights Reserved.
     3  
     4  SPDX-License-Identifier: Apache-2.0
     5  */
     6  
     7  package main
     8  
     9  import (
    10  	"context"
    11  	"testing"
    12  
    13  	"github.com/hyperledger/fabric-protos-go/peer"
    14  	"github.com/stretchr/testify/assert"
    15  )
    16  
    17  type mockEndorserServer struct {
    18  	invoked bool
    19  }
    20  
    21  func (es *mockEndorserServer) ProcessProposal(context.Context,
    22  	*peer.SignedProposal) (*peer.ProposalResponse, error) {
    23  	es.invoked = true
    24  	return nil, nil
    25  }
    26  
    27  func TestFilter(t *testing.T) {
    28  	auth := NewFilter()
    29  	nextEndorser := &mockEndorserServer{}
    30  	auth.Init(nextEndorser)
    31  	auth.ProcessProposal(nil, nil)
    32  	assert.True(t, nextEndorser.invoked)
    33  }