diff --git a/pkg/config/testdata/template/config.yaml b/pkg/config/testdata/template/config.yaml index 0372ceb149..4e4bffbdc2 100755 --- a/pkg/config/testdata/template/config.yaml +++ b/pkg/config/testdata/template/config.yaml @@ -210,7 +210,7 @@ orderers: # fail-fast: true # When no protocol provided in url, grpcs connection will be tried first, if failed it falls back to grpc when this option set to true -# allow-insecure: true +# allow-insecure: false # tlsCACerts: # Certificate location absolute path @@ -232,7 +232,7 @@ peers: # ssl-target-name-override: peer0.org1.example.com # grpc.http2.keepalive_time: 15 # When no protocol provided in url, grpcs connection will be tried first, if failed it falls back to grpc when this option set to true -# allow-insecure: true +# allow-insecure: false # tlsCACerts: # Certificate location absolute path diff --git a/pkg/fabric-client/orderer/deprecated_test.go b/pkg/fabric-client/orderer/deprecated_test.go index 8f75b80745..680d64a243 100644 --- a/pkg/fabric-client/orderer/deprecated_test.go +++ b/pkg/fabric-client/orderer/deprecated_test.go @@ -31,7 +31,7 @@ func TestDeprecatedSendDeliver(t *testing.T) { defer grpcServer.Stop() mockServer, addr := startMockServer(t, grpcServer) - orderer, _ := NewOrderer(addr, "", "", mocks.NewMockConfig(), kap) + orderer, _ := NewOrderer("grpc://"+addr, "", "", mocks.NewMockConfig(), kap) // Test deliver happy path blocks, errs := orderer.SendDeliver(&fab.SignedEnvelope{}) select { @@ -119,7 +119,7 @@ func TestDeprecatedSendBroadcast(t *testing.T) { defer grpcServer.Stop() _, addr := startMockServer(t, grpcServer) - orderer, _ := NewOrderer(addr, "", "", mocks.NewMockConfig(), kap) + orderer, _ := NewOrderer("grpc://"+addr, "", "", mocks.NewMockConfig(), kap) _, err := orderer.SendBroadcast(&fab.SignedEnvelope{}) if err != nil { @@ -148,7 +148,7 @@ func TestDeprecatedSendDeliverServerBadResponse(t *testing.T) { grpcServer := grpc.NewServer() defer grpcServer.Stop() addr := startCustomizedMockServer(t, testOrdererURL, grpcServer, &broadcastServer) - orderer, _ := NewOrderer(addr, "", "", mocks.NewMockConfig(), kap) + orderer, _ := NewOrderer("grpc://"+addr, "", "", mocks.NewMockConfig(), kap) blocks, errors := orderer.SendDeliver(&fab.SignedEnvelope{}) @@ -178,7 +178,7 @@ func TestDeprecatedSendDeliverServerSuccessResponse(t *testing.T) { defer grpcServer.Stop() addr := startCustomizedMockServer(t, testOrdererURL, grpcServer, &broadcastServer) - orderer, _ := NewOrderer(addr, "", "", mocks.NewMockConfig(), kap) + orderer, _ := NewOrderer("grpc://"+addr, "", "", mocks.NewMockConfig(), kap) blocks, errors := orderer.SendDeliver(&fab.SignedEnvelope{}) @@ -203,7 +203,7 @@ func TestDeprecatedSendDeliverFailure(t *testing.T) { grpcServer := grpc.NewServer() defer grpcServer.Stop() addr := startCustomizedMockServer(t, testOrdererURL, grpcServer, &broadcastServer) - orderer, _ := NewOrderer(addr, "", "", mocks.NewMockConfig(), kap) + orderer, _ := NewOrderer("grpc://"+addr, "", "", mocks.NewMockConfig(), kap) blocks, errors := orderer.SendDeliver(&fab.SignedEnvelope{}) @@ -228,7 +228,7 @@ func TestDeprecatedSendBroadcastServerBadResponse(t *testing.T) { grpcServer := grpc.NewServer() defer grpcServer.Stop() addr := startCustomizedMockServer(t, testOrdererURL, grpcServer, &broadcastServer) - orderer, _ := NewOrderer(addr, "", "", mocks.NewMockConfig(), kap) + orderer, _ := NewOrderer("grpc://"+addr, "", "", mocks.NewMockConfig(), kap) _, err := orderer.SendBroadcast(&fab.SignedEnvelope{}) @@ -250,7 +250,7 @@ func TestDeprecatedSendBroadcastError(t *testing.T) { grpcServer := grpc.NewServer() defer grpcServer.Stop() addr := startCustomizedMockServer(t, testOrdererURL, grpcServer, &broadcastServer) - orderer, _ := NewOrderer(addr, "", "", mocks.NewMockConfig(), kap) + orderer, _ := NewOrderer("grpc://"+addr, "", "", mocks.NewMockConfig(), kap) status, err := orderer.SendBroadcast(&fab.SignedEnvelope{}) diff --git a/pkg/fabric-client/orderer/orderer_test.go b/pkg/fabric-client/orderer/orderer_test.go index e5ef2423c3..aa0b77f804 100644 --- a/pkg/fabric-client/orderer/orderer_test.go +++ b/pkg/fabric-client/orderer/orderer_test.go @@ -223,7 +223,7 @@ func TestSendDeliverServerBadResponse(t *testing.T) { grpcServer := grpc.NewServer() defer grpcServer.Stop() addr := startCustomizedMockServer(t, testOrdererURL, grpcServer, &broadcastServer) - orderer, _ := New(mocks.NewMockConfig(), WithURL(addr), WithInsecure()) + orderer, _ := New(mocks.NewMockConfig(), WithURL("grpc://"+addr), WithInsecure()) blocks, errors := orderer.SendDeliver(&fab.SignedEnvelope{}) @@ -253,7 +253,7 @@ func TestSendDeliverServerSuccessResponse(t *testing.T) { defer grpcServer.Stop() addr := startCustomizedMockServer(t, testOrdererURL, grpcServer, &broadcastServer) - orderer, _ := New(mocks.NewMockConfig(), WithURL(addr), WithInsecure()) + orderer, _ := New(mocks.NewMockConfig(), WithURL("grpc://"+addr), WithInsecure()) blocks, errors := orderer.SendDeliver(&fab.SignedEnvelope{}) @@ -278,7 +278,7 @@ func TestSendDeliverFailure(t *testing.T) { grpcServer := grpc.NewServer() defer grpcServer.Stop() addr := startCustomizedMockServer(t, testOrdererURL, grpcServer, &broadcastServer) - orderer, _ := New(mocks.NewMockConfig(), WithURL(addr), WithInsecure()) + orderer, _ := New(mocks.NewMockConfig(), WithURL("grpc://"+addr), WithInsecure()) blocks, errors := orderer.SendDeliver(&fab.SignedEnvelope{}) @@ -303,7 +303,7 @@ func TestSendBroadcastServerBadResponse(t *testing.T) { grpcServer := grpc.NewServer() defer grpcServer.Stop() addr := startCustomizedMockServer(t, testOrdererURL, grpcServer, &broadcastServer) - orderer, _ := New(mocks.NewMockConfig(), WithURL(addr), WithInsecure()) + orderer, _ := New(mocks.NewMockConfig(), WithURL("grpc://"+addr), WithInsecure()) _, err := orderer.SendBroadcast(&fab.SignedEnvelope{}) @@ -325,7 +325,7 @@ func TestSendBroadcastError(t *testing.T) { grpcServer := grpc.NewServer() defer grpcServer.Stop() addr := startCustomizedMockServer(t, testOrdererURL, grpcServer, &broadcastServer) - orderer, _ := New(mocks.NewMockConfig(), WithURL(addr), WithInsecure()) + orderer, _ := New(mocks.NewMockConfig(), WithURL("grpc://"+addr), WithInsecure()) statusCode, err := orderer.SendBroadcast(&fab.SignedEnvelope{}) @@ -346,7 +346,7 @@ func TestBroadcastBadDial(t *testing.T) { config.EXPECT().TimeoutOrDefault(apiconfig.OrdererConnection).Return(time.Second * 1) config.EXPECT().TLSCACertPool(gomock.Any()).Return(nil, errors.New("error adding cert to pool")).AnyTimes() - orderer, _ := NewOrderer("127.0.0.1:0", "", "", config, kap) + orderer, _ := NewOrderer("grpc://127.0.0.1:0", "", "", config, kap) orderer.grpcDialOption = append(orderer.grpcDialOption, grpc.WithBlock()) orderer.secured = true orderer.allowInsecure = true @@ -444,7 +444,7 @@ func TestForDeadlineExceeded(t *testing.T) { func TestSendDeliverDefaultOpts(t *testing.T) { //keep alive option is not set and fail fast is false - invalid URL - orderer, _ := New(mocks.NewMockConfig(), WithURL(testOrdererURL+"Test"), WithInsecure()) + orderer, _ := New(mocks.NewMockConfig(), WithURL("grpc://"+testOrdererURL+"Test"), WithInsecure()) orderer.dialTimeout = 5 * time.Second fmt.Printf("GRPC opts%v \n", orderer.grpcDialOption) for i, v := range orderer.grpcDialOption { @@ -460,7 +460,7 @@ func TestSendDeliverDefaultOpts(t *testing.T) { defer grpcServer.Stop() _, addr := startMockServer(t, grpcServer) - orderer, _ = New(mocks.NewMockConfig(), WithURL(addr), WithInsecure()) + orderer, _ = New(mocks.NewMockConfig(), WithURL("grpc://"+addr), WithInsecure()) orderer.dialTimeout = 5 * time.Second // Test deliver happy path blocks, errs := orderer.SendDeliver(&fab.SignedEnvelope{}) @@ -479,7 +479,7 @@ func TestSendDeliverDefaultOpts(t *testing.T) { func TestForGRPCErrorsWithKeepAliveOpts(t *testing.T) { //keep alive options set and failfast is true - ordererConfig := getGRPCOpts(testOrdererURL+"Test", true, true) + ordererConfig := getGRPCOpts("grpc://"+testOrdererURL+"Test", true, true) orderer, _ := New(mocks.NewMockConfig(), WithURL(testOrdererURL+"Test"), FromOrdererConfig(ordererConfig)) orderer.dialTimeout = 5 * time.Second _, err := orderer.SendBroadcast(&fab.SignedEnvelope{}) diff --git a/pkg/fabric-client/peer/peerendorser_test.go b/pkg/fabric-client/peer/peerendorser_test.go index 8fd98b2756..fc911818ca 100644 --- a/pkg/fabric-client/peer/peerendorser_test.go +++ b/pkg/fabric-client/peer/peerendorser_test.go @@ -260,7 +260,7 @@ func TestNewPeerEndorserTLSBad(t *testing.T) { // TestProcessProposalBadDial validates that a down // endorser fails gracefully. func TestProcessProposalBadDial(t *testing.T) { - _, err := testProcessProposal(t, testAddress) + _, err := testProcessProposal(t, "grpc://"+testAddress) if err == nil { t.Fatalf("Process proposal should have failed") } @@ -273,7 +273,7 @@ func TestProcessProposalGoodDial(t *testing.T) { defer grpcServer.Stop() _, addr := startEndorserServer(t, grpcServer) - _, err := testProcessProposal(t, addr) + _, err := testProcessProposal(t, "grpc://"+addr) if err != nil { t.Fatalf("Process proposal failed (%v)", err) } @@ -334,7 +334,7 @@ func startEndorserServerWithError(t *testing.T, grpcServer *grpc.Server, testErr } func TestEndorserConnectionError(t *testing.T) { - _, err := testProcessProposal(t, testAddress) + _, err := testProcessProposal(t, "grpc://"+testAddress) assert.NotNil(t, err, "Expected connection error without server running") statusError, ok := status.FromError(err) @@ -350,7 +350,7 @@ func TestEndorserRPCError(t *testing.T) { defer grpcServer.Stop() _, addr := startEndorserServerWithError(t, grpcServer, fmt.Errorf(testErrorMessage)) - _, err := testProcessProposal(t, addr) + _, err := testProcessProposal(t, "grpc://"+addr) statusError, ok := status.FromError(err) assert.True(t, ok, "Expected status error on failed connection") assert.Equal(t, status.GRPCTransportStatus, statusError.Group) diff --git a/test/fixtures/config/config_pkcs11_test.yaml b/test/fixtures/config/config_pkcs11_test.yaml index 6a48eb9b1b..d51569e7e8 100755 --- a/test/fixtures/config/config_pkcs11_test.yaml +++ b/test/fixtures/config/config_pkcs11_test.yaml @@ -342,7 +342,7 @@ orderers: ssl-target-name-override: orderer.example.com grpc-max-send-message-length: 15 #will be taken into consideration if address has no protocol defined and secured connection fails - allow-insecure: true + allow-insecure: false tlsCACerts: # Certificate location absolute path @@ -365,7 +365,7 @@ peers: ssl-target-name-override: peer0.org1.example.com grpc.http2.keepalive_time: 15 #will be taken into consideration if address has no protocol defined and secured connection fails - allow-insecure: true + allow-insecure: false tlsCACerts: # Certificate location absolute path @@ -378,7 +378,7 @@ peers: grpcOptions: ssl-target-name-override: peer0.org2.example.com #will be taken into consideration if address has no protocol defined and secured connection fails - allow-insecure: true + allow-insecure: false tlsCACerts: path: ${GOPATH}/src/github.com/hyperledger/fabric-sdk-go/${CRYPTOCONFIG_FIXTURES_PATH}/peerOrganizations/org2.example.com/tlsca/tlsca.org2.example.com-cert.pem diff --git a/test/fixtures/config/config_test.yaml b/test/fixtures/config/config_test.yaml index ff114baeff..398267d1ef 100755 --- a/test/fixtures/config/config_test.yaml +++ b/test/fixtures/config/config_test.yaml @@ -250,7 +250,7 @@ orderers: keep-alive-permit: false fail-fast: true #will be taken into consideration if address has no protocol defined and secured connection fails - allow-insecure: true + allow-insecure: false tlsCACerts: # Certificate location absolute path @@ -280,7 +280,7 @@ peers: keep-alive-permit: false fail-fast: true #will be taken into consideration if address has no protocol defined and secured connection fails - allow-insecure: true + allow-insecure: false tlsCACerts: # Certificate location absolute path @@ -300,7 +300,7 @@ peers: keep-alive-permit: false fail-fast: true #will be taken into consideration if address has no protocol defined and secured connection fails - allow-insecure: true + allow-insecure: false tlsCACerts: path: ${GOPATH}/src/github.com/hyperledger/fabric-sdk-go/${CRYPTOCONFIG_FIXTURES_PATH}/peerOrganizations/org2.example.com/tlsca/tlsca.org2.example.com-cert.pem diff --git a/test/fixtures/config/config_test_embedded_pems.yaml b/test/fixtures/config/config_test_embedded_pems.yaml index abac89efea..9965d74096 100755 --- a/test/fixtures/config/config_test_embedded_pems.yaml +++ b/test/fixtures/config/config_test_embedded_pems.yaml @@ -404,7 +404,7 @@ orderers: ssl-target-name-override: orderer.example.com grpc-max-send-message-length: 15 #will be taken into consideration if address has no protocol defined and secured connection fails - allow-insecure: true + allow-insecure: false tlsCACerts: # pem supersedes path @@ -444,7 +444,7 @@ peers: ssl-target-name-override: peer0.org1.example.com grpc.http2.keepalive_time: 15 #will be taken into consideration if address has no protocol defined and secured connection fails - allow-insecure: true + allow-insecure: false tlsCACerts: pem: | @@ -474,7 +474,7 @@ peers: grpcOptions: ssl-target-name-override: peer0.org2.example.com #will be taken into consideration if address has no protocol defined and secured connection fails - allow-insecure: true + allow-insecure: false tlsCACerts: pem: path: diff --git a/test/fixtures/config/config_test_no_orderer.yaml b/test/fixtures/config/config_test_no_orderer.yaml index 495af18439..a66d35a536 100755 --- a/test/fixtures/config/config_test_no_orderer.yaml +++ b/test/fixtures/config/config_test_no_orderer.yaml @@ -196,7 +196,7 @@ peers: ssl-target-name-override: peer0.org1.example.com grpc.http2.keepalive_time: 15 #will be taken into consideration if address has no protocol defined and secured connection fails - allow-insecure: true + allow-insecure: false tlsCACerts: # Certificate location absolute path