Skip to content

Commit

Permalink
fix: fix deprecated use of grpc.WithInsecure
Browse files Browse the repository at this point in the history
  • Loading branch information
bojand committed May 27, 2022
1 parent 1909abd commit f84dcdc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
7 changes: 4 additions & 3 deletions protodesc/protodesc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/jhump/protoreflect/grpcreflect"
"github.com/stretchr/testify/assert"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/metadata"
reflectpb "google.golang.org/grpc/reflection/grpc_reflection_v1alpha"
)
Expand Down Expand Up @@ -138,7 +139,7 @@ func TestProtodesc_GetMethodDescFromReflect(t *testing.T) {

t.Run("test known call", func(t *testing.T) {
var opts []grpc.DialOption
opts = append(opts, grpc.WithInsecure())
opts = append(opts, grpc.WithTransportCredentials(insecure.NewCredentials()))
ctx := context.Background()
conn, err := grpc.DialContext(ctx, internal.TestLocalhost, opts...)
assert.NoError(t, err)
Expand All @@ -157,7 +158,7 @@ func TestProtodesc_GetMethodDescFromReflect(t *testing.T) {

t.Run("test known call with /", func(t *testing.T) {
var opts []grpc.DialOption
opts = append(opts, grpc.WithInsecure())
opts = append(opts, grpc.WithTransportCredentials(insecure.NewCredentials()))
ctx := context.Background()
conn, err := grpc.DialContext(ctx, internal.TestLocalhost, opts...)
assert.NoError(t, err)
Expand All @@ -176,7 +177,7 @@ func TestProtodesc_GetMethodDescFromReflect(t *testing.T) {

t.Run("test unknown known call", func(t *testing.T) {
var opts []grpc.DialOption
opts = append(opts, grpc.WithInsecure())
opts = append(opts, grpc.WithTransportCredentials(insecure.NewCredentials()))
ctx := context.Background()
conn, err := grpc.DialContext(ctx, internal.TestLocalhost, opts...)
assert.NoError(t, err)
Expand Down
3 changes: 2 additions & 1 deletion runner/requester.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"go.uber.org/multierr"
"google.golang.org/grpc"
"google.golang.org/grpc/connectivity"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/keepalive"
"google.golang.org/grpc/metadata"

Expand Down Expand Up @@ -292,7 +293,7 @@ func (b *Requester) newClientConn(withStatsHandler bool) (*grpc.ClientConn, erro
var opts []grpc.DialOption

if b.config.insecure {
opts = append(opts, grpc.WithInsecure())
opts = append(opts, grpc.WithTransportCredentials(insecure.NewCredentials()))
} else {
opts = append(opts, grpc.WithTransportCredentials(b.config.creds))
}
Expand Down
3 changes: 2 additions & 1 deletion runner/stats_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/bojand/ghz/internal/helloworld"
"github.com/stretchr/testify/assert"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
)

func TestStatsHandler(t *testing.T) {
Expand All @@ -33,7 +34,7 @@ func TestStatsHandler(t *testing.T) {

conn, err := grpc.Dial(
internal.TestLocalhost,
grpc.WithInsecure(),
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithStatsHandler(&statsHandler{results: rChan}))

if err != nil {
Expand Down

0 comments on commit f84dcdc

Please sign in to comment.