Skip to content

Commit

Permalink
migrate from grpc.WithInsecure to grpc.WithTransportCredentials(insec…
Browse files Browse the repository at this point in the history
…ure.NewCredentials()) to satisfy linter
  • Loading branch information
rosstimothy committed Jan 10, 2022
1 parent c2e4f03 commit f800bf8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
19 changes: 10 additions & 9 deletions api/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/gravitational/teleport/api/client/proto"
"github.com/gravitational/teleport/api/defaults"
"github.com/gravitational/teleport/api/types"
"google.golang.org/grpc/credentials/insecure"

"github.com/gravitational/trace"
"github.com/gravitational/trace/trail"
Expand Down Expand Up @@ -290,7 +291,7 @@ func TestNew(t *testing.T) {
&mockInsecureTLSCredentials{}, // TODO(Joerger) replace insecure credentials
},
DialOpts: []grpc.DialOption{
grpc.WithInsecure(), // TODO(Joerger) remove insecure dial option
grpc.WithTransportCredentials(insecure.NewCredentials()), // TODO(Joerger) remove insecure dial option
},
},
assertErr: require.NoError,
Expand All @@ -304,7 +305,7 @@ func TestNew(t *testing.T) {
&tlsConfigCreds{nil},
},
DialOpts: []grpc.DialOption{
grpc.WithInsecure(), // TODO(Joerger) remove insecure dial option
grpc.WithTransportCredentials(insecure.NewCredentials()), // TODO(Joerger) remove insecure dial option
},
},
assertErr: require.NoError,
Expand All @@ -317,7 +318,7 @@ func TestNew(t *testing.T) {
&mockInsecureTLSCredentials{}, // TODO(Joerger) replace insecure credentials
},
DialOpts: []grpc.DialOption{
grpc.WithInsecure(), // TODO(Joerger) remove insecure dial option
grpc.WithTransportCredentials(insecure.NewCredentials()), // TODO(Joerger) remove insecure dial option
},
},
assertErr: func(t require.TestingT, err error, _ ...interface{}) {
Expand All @@ -331,7 +332,7 @@ func TestNew(t *testing.T) {
&mockInsecureTLSCredentials{}, // TODO(Joerger) replace insecure credentials
},
DialOpts: []grpc.DialOption{
grpc.WithInsecure(), // TODO(Joerger) remove insecure dial option
grpc.WithTransportCredentials(insecure.NewCredentials()), // TODO(Joerger) remove insecure dial option
},
},
assertErr: func(t require.TestingT, err error, _ ...interface{}) {
Expand Down Expand Up @@ -372,7 +373,7 @@ func TestNewDialBackground(t *testing.T) {
&mockInsecureTLSCredentials{}, // TODO(Joerger) replace insecure credentials
},
DialOpts: []grpc.DialOption{
grpc.WithInsecure(), // TODO(Joerger) remove insecure dial option
grpc.WithTransportCredentials(insecure.NewCredentials()), // TODO(Joerger) remove insecure dial option
},
})
require.NoError(t, err)
Expand Down Expand Up @@ -410,7 +411,7 @@ func TestWaitForConnectionReady(t *testing.T) {
&mockInsecureTLSCredentials{}, // TODO(Joerger) replace insecure credentials
},
DialOpts: []grpc.DialOption{
grpc.WithInsecure(), // TODO(Joerger) remove insecure dial option
grpc.WithTransportCredentials(insecure.NewCredentials()), // TODO(Joerger) remove insecure dial option
},
})
require.NoError(t, err)
Expand Down Expand Up @@ -443,7 +444,7 @@ func TestLimitExceeded(t *testing.T) {
&mockInsecureTLSCredentials{}, // TODO(Joerger) replace insecure credentials
},
DialOpts: []grpc.DialOption{
grpc.WithInsecure(), // TODO(Joerger) remove insecure dial option
grpc.WithTransportCredentials(insecure.NewCredentials()), // TODO(Joerger) remove insecure dial option
},
})
require.NoError(t, err)
Expand Down Expand Up @@ -495,7 +496,7 @@ func TestListResources(t *testing.T) {
&mockInsecureTLSCredentials{}, // TODO(Joerger) replace insecure credentials
},
DialOpts: []grpc.DialOption{
grpc.WithInsecure(), // TODO(Joerger) remove insecure dial option
grpc.WithTransportCredentials(insecure.NewCredentials()), // TODO(Joerger) remove insecure dial option
},
})
require.NoError(t, err)
Expand Down Expand Up @@ -536,7 +537,7 @@ func TestGetResources(t *testing.T) {
&mockInsecureTLSCredentials{}, // TODO(Joerger) replace insecure credentials
},
DialOpts: []grpc.DialOption{
grpc.WithInsecure(), // TODO(Joerger) remove insecure dial option
grpc.WithTransportCredentials(insecure.NewCredentials()), // TODO(Joerger) remove insecure dial option
},
})
require.NoError(t, err)
Expand Down
3 changes: 2 additions & 1 deletion lib/backend/firestore/firestorebk.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
adminpb "google.golang.org/genproto/googleapis/firestore/admin/v1"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/status"

"github.com/gravitational/teleport/api/types"
Expand Down Expand Up @@ -218,7 +219,7 @@ func CreateFirestoreClients(ctx context.Context, projectID string, endPoint stri
var args []option.ClientOption

if len(endPoint) != 0 {
args = append(args, option.WithoutAuthentication(), option.WithEndpoint(endPoint), option.WithGRPCDialOption(grpc.WithInsecure()))
args = append(args, option.WithoutAuthentication(), option.WithEndpoint(endPoint), option.WithGRPCDialOption(grpc.WithTransportCredentials(insecure.NewCredentials())))
} else if len(credentialsFile) != 0 {
args = append(args, option.WithCredentialsFile(credentialsFile))
}
Expand Down
3 changes: 2 additions & 1 deletion lib/events/gcssessions/gcshandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/gravitational/teleport/lib/session"
"github.com/gravitational/teleport/lib/utils"
"github.com/gravitational/trace"
"google.golang.org/grpc/credentials/insecure"

"cloud.google.com/go/storage"
"github.com/prometheus/client_golang/prometheus"
Expand Down Expand Up @@ -170,7 +171,7 @@ func composerRun(ctx context.Context, composer *storage.Composer) (*storage.Obje
func DefaultNewHandler(ctx context.Context, cfg Config) (*Handler, error) {
var args []option.ClientOption
if len(cfg.Endpoint) != 0 {
args = append(args, option.WithoutAuthentication(), option.WithEndpoint(cfg.Endpoint), option.WithGRPCDialOption(grpc.WithInsecure()))
args = append(args, option.WithoutAuthentication(), option.WithEndpoint(cfg.Endpoint), option.WithGRPCDialOption(grpc.WithTransportCredentials(insecure.NewCredentials())))
} else if len(cfg.CredentialsPath) != 0 {
args = append(args, option.WithCredentialsFile(cfg.CredentialsPath))
}
Expand Down
7 changes: 4 additions & 3 deletions lib/srv/db/common/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"github.com/aws/aws-sdk-go/service/redshift/redshiftiface"
"github.com/aws/aws-sdk-go/service/sts"
"github.com/aws/aws-sdk-go/service/sts/stsiface"
"google.golang.org/grpc/credentials/insecure"

"github.com/gravitational/trace"
"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -280,14 +281,14 @@ func (c *TestCloudClients) GetAWSSTSClient(region string) (stsiface.STSAPI, erro
// GetGCPIAMClient returns GCP IAM client.
func (c *TestCloudClients) GetGCPIAMClient(ctx context.Context) (*gcpcredentials.IamCredentialsClient, error) {
return gcpcredentials.NewIamCredentialsClient(ctx,
option.WithGRPCDialOption(grpc.WithInsecure()), // Insecure must be set for unauth client.
option.WithGRPCDialOption(grpc.WithTransportCredentials(insecure.NewCredentials())), // Insecure must be set for unauth client.
option.WithoutAuthentication())
}

// GetGCPSQLAdminClient returns GCP Cloud SQL Admin client.
func (c *TestCloudClients) GetGCPSQLAdminClient(ctx context.Context) (*sqladmin.Service, error) {
return sqladmin.NewService(ctx,
option.WithGRPCDialOption(grpc.WithInsecure()), // Insecure must be set for unauth client.
option.WithGRPCDialOption(grpc.WithTransportCredentials(insecure.NewCredentials())), // Insecure must be set for unauth client.
option.WithoutAuthentication())
}

Expand All @@ -296,7 +297,7 @@ func (c *TestCloudClients) GetAzureCredential() (azcore.TokenCredential, error)
return &azidentity.ChainedTokenCredential{}, nil
}

// Closer closes all initialized clients.
// Close closes all initialized clients.
func (c *TestCloudClients) Close() error {
return nil
}

0 comments on commit f800bf8

Please sign in to comment.