github.com/myafeier/fabric@v1.0.1-0.20170722181825-3a4b1f2bce86/core/comm/creds_test.go (about)

     1  /*
     2  Copyright IBM Corp. All Rights Reserved.
     3  
     4  SPDX-License-Identifier: Apache-2.0
     5  */
     6  
     7  package comm_test
     8  
     9  import (
    10  	"crypto/tls"
    11  	"testing"
    12  
    13  	"google.golang.org/grpc/credentials"
    14  
    15  	"github.com/hyperledger/fabric/core/comm"
    16  	"github.com/stretchr/testify/assert"
    17  )
    18  
    19  func TestCreds(t *testing.T) {
    20  	var creds credentials.TransportCredentials
    21  	creds = comm.NewServerTransportCredentials(&tls.Config{})
    22  	_, _, err := creds.ClientHandshake(nil, "", nil)
    23  	assert.EqualError(t, err, comm.ClientHandshakeNotImplError.Error())
    24  	err = creds.OverrideServerName("")
    25  	assert.EqualError(t, err, comm.OverrrideHostnameNotSupportedError.Error())
    26  	clone := creds.Clone()
    27  	assert.Equal(t, creds, clone)
    28  	assert.Equal(t, "1.2", creds.Info().SecurityVersion)
    29  	assert.Equal(t, "tls", creds.Info().SecurityProtocol)
    30  }