mirror of https://github.com/grpc/grpc-go.git
cleanup: replace grpc.WithInsecure with insecure.NewCredentials (#5177)
This commit is contained in:
parent
91967153f5
commit
c44f627fd1
|
@ -33,6 +33,7 @@ import (
|
|||
"google.golang.org/grpc/admin"
|
||||
channelzpb "google.golang.org/grpc/channelz/grpc_channelz_v1"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/internal/xds"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
@ -78,7 +79,7 @@ func RunRegisterTests(t *testing.T, ec ExpectedStatusCodes) {
|
|||
server.Serve(lis)
|
||||
}()
|
||||
|
||||
conn, err := grpc.Dial(lis.Addr().String(), grpc.WithInsecure())
|
||||
conn, err := grpc.Dial(lis.Addr().String(), grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
t.Fatalf("cannot connect to server: %v", err)
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ import (
|
|||
"google.golang.org/grpc/authz"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/credentials"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/internal/grpctest"
|
||||
"google.golang.org/grpc/metadata"
|
||||
"google.golang.org/grpc/status"
|
||||
|
@ -324,7 +325,7 @@ func (s) TestSDKStaticPolicyEnd2End(t *testing.T) {
|
|||
go s.Serve(lis)
|
||||
|
||||
// Establish a connection to the server.
|
||||
clientConn, err := grpc.Dial(lis.Addr().String(), grpc.WithInsecure())
|
||||
clientConn, err := grpc.Dial(lis.Addr().String(), grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
t.Fatalf("grpc.Dial(%v) failed: %v", lis.Addr().String(), err)
|
||||
}
|
||||
|
@ -514,7 +515,7 @@ func (s) TestSDKFileWatcherEnd2End(t *testing.T) {
|
|||
go s.Serve(lis)
|
||||
|
||||
// Establish a connection to the server.
|
||||
clientConn, err := grpc.Dial(lis.Addr().String(), grpc.WithInsecure())
|
||||
clientConn, err := grpc.Dial(lis.Addr().String(), grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
t.Fatalf("grpc.Dial(%v) failed: %v", lis.Addr().String(), err)
|
||||
}
|
||||
|
@ -583,7 +584,7 @@ func (s) TestSDKFileWatcher_ValidPolicyRefresh(t *testing.T) {
|
|||
go s.Serve(lis)
|
||||
|
||||
// Establish a connection to the server.
|
||||
clientConn, err := grpc.Dial(lis.Addr().String(), grpc.WithInsecure())
|
||||
clientConn, err := grpc.Dial(lis.Addr().String(), grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
t.Fatalf("grpc.Dial(%v) failed: %v", lis.Addr().String(), err)
|
||||
}
|
||||
|
@ -631,7 +632,7 @@ func (s) TestSDKFileWatcher_InvalidPolicySkipReload(t *testing.T) {
|
|||
go s.Serve(lis)
|
||||
|
||||
// Establish a connection to the server.
|
||||
clientConn, err := grpc.Dial(lis.Addr().String(), grpc.WithInsecure())
|
||||
clientConn, err := grpc.Dial(lis.Addr().String(), grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
t.Fatalf("grpc.Dial(%v) failed: %v", lis.Addr().String(), err)
|
||||
}
|
||||
|
@ -682,7 +683,7 @@ func (s) TestSDKFileWatcher_RecoversFromReloadFailure(t *testing.T) {
|
|||
go s.Serve(lis)
|
||||
|
||||
// Establish a connection to the server.
|
||||
clientConn, err := grpc.Dial(lis.Addr().String(), grpc.WithInsecure())
|
||||
clientConn, err := grpc.Dial(lis.Addr().String(), grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
t.Fatalf("grpc.Dial(%v) failed: %v", lis.Addr().String(), err)
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ import (
|
|||
"google.golang.org/grpc/balancer"
|
||||
lbpb "google.golang.org/grpc/balancer/grpclb/grpc_lb_v1"
|
||||
"google.golang.org/grpc/connectivity"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/internal/backoff"
|
||||
"google.golang.org/grpc/internal/channelz"
|
||||
imetadata "google.golang.org/grpc/internal/metadata"
|
||||
|
@ -228,7 +229,7 @@ func (lb *lbBalancer) newRemoteBalancerCCWrapper() {
|
|||
} else if bundle := lb.grpclbClientConnCreds; bundle != nil {
|
||||
dopts = append(dopts, grpc.WithCredentialsBundle(bundle))
|
||||
} else {
|
||||
dopts = append(dopts, grpc.WithInsecure())
|
||||
dopts = append(dopts, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
}
|
||||
if lb.opt.Dialer != nil {
|
||||
dopts = append(dopts, grpc.WithContextDialer(lb.opt.Dialer))
|
||||
|
|
|
@ -27,6 +27,7 @@ import (
|
|||
"google.golang.org/grpc/balancer"
|
||||
"google.golang.org/grpc/balancer/rls/internal/adaptive"
|
||||
"google.golang.org/grpc/connectivity"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/internal"
|
||||
internalgrpclog "google.golang.org/grpc/internal/grpclog"
|
||||
"google.golang.org/grpc/internal/pretty"
|
||||
|
@ -115,7 +116,7 @@ func (cc *controlChannel) dialOpts(bOpts balancer.BuildOptions, serviceConfig st
|
|||
credsOpt = grpc.WithCredentialsBundle(bundle)
|
||||
default:
|
||||
cc.logger.Warningf("no credentials available, using Insecure")
|
||||
credsOpt = grpc.WithInsecure()
|
||||
credsOpt = grpc.WithTransportCredentials(insecure.NewCredentials())
|
||||
}
|
||||
dopts = append(dopts, credsOpt)
|
||||
|
||||
|
|
|
@ -63,6 +63,7 @@ import (
|
|||
"google.golang.org/grpc/benchmark/flags"
|
||||
"google.golang.org/grpc/benchmark/latency"
|
||||
"google.golang.org/grpc/benchmark/stats"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/grpclog"
|
||||
"google.golang.org/grpc/internal/channelz"
|
||||
"google.golang.org/grpc/keepalive"
|
||||
|
@ -305,7 +306,7 @@ func makeClient(bf stats.Features) (testgrpc.BenchmarkServiceClient, func()) {
|
|||
)
|
||||
}
|
||||
sopts = append(sopts, grpc.MaxConcurrentStreams(uint32(bf.MaxConcurrentCalls+1)))
|
||||
opts = append(opts, grpc.WithInsecure())
|
||||
opts = append(opts, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
|
||||
var lis net.Listener
|
||||
if bf.UseBufConn {
|
||||
|
|
|
@ -51,6 +51,7 @@ import (
|
|||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/benchmark"
|
||||
"google.golang.org/grpc/benchmark/stats"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/grpclog"
|
||||
"google.golang.org/grpc/internal/syscall"
|
||||
|
||||
|
@ -135,7 +136,7 @@ func main() {
|
|||
func buildConnections(ctx context.Context) []*grpc.ClientConn {
|
||||
ccs := make([]*grpc.ClientConn, *numConn)
|
||||
for i := range ccs {
|
||||
ccs[i] = benchmark.NewClientConnWithContext(ctx, "localhost:"+*port, grpc.WithInsecure(), grpc.WithBlock())
|
||||
ccs[i] = benchmark.NewClientConnWithContext(ctx, "localhost:"+*port, grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithBlock())
|
||||
}
|
||||
return ccs
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import (
|
|||
"google.golang.org/grpc/benchmark/stats"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/credentials"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/internal/syscall"
|
||||
"google.golang.org/grpc/status"
|
||||
"google.golang.org/grpc/testdata"
|
||||
|
@ -135,7 +136,7 @@ func createConns(config *testpb.ClientConfig) ([]*grpc.ClientConn, func(), error
|
|||
}
|
||||
opts = append(opts, grpc.WithTransportCredentials(creds))
|
||||
} else {
|
||||
opts = append(opts, grpc.WithInsecure())
|
||||
opts = append(opts, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
}
|
||||
|
||||
// Use byteBufCodec if it is required.
|
||||
|
|
|
@ -31,6 +31,7 @@ import (
|
|||
"github.com/golang/protobuf/proto"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/binarylog"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/grpclog"
|
||||
iblog "google.golang.org/grpc/internal/binarylog"
|
||||
"google.golang.org/grpc/internal/grpctest"
|
||||
|
@ -310,7 +311,7 @@ func (te *test) clientConn() *grpc.ClientConn {
|
|||
if te.cc != nil {
|
||||
return te.cc
|
||||
}
|
||||
opts := []grpc.DialOption{grpc.WithInsecure(), grpc.WithBlock()}
|
||||
opts := []grpc.DialOption{grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithBlock()}
|
||||
|
||||
var err error
|
||||
te.cc, err = grpc.Dial(te.srvAddr, opts...)
|
||||
|
|
|
@ -79,7 +79,7 @@ var (
|
|||
// errNoTransportSecurity indicates that there is no transport security
|
||||
// being set for ClientConn. Users should either set one or explicitly
|
||||
// call WithInsecure DialOption to disable security.
|
||||
errNoTransportSecurity = errors.New("grpc: no transport security set (use grpc.WithInsecure() explicitly or set credentials)")
|
||||
errNoTransportSecurity = errors.New("grpc: no transport security set (use grpc.WithTransportCredentials(insecure.NewCredentials()) explicitly or set credentials)")
|
||||
// errTransportCredsAndBundle indicates that creds bundle is used together
|
||||
// with other individual Transport Credentials.
|
||||
errTransportCredsAndBundle = errors.New("grpc: credentials.Bundle may not be used with individual TransportCredentials")
|
||||
|
|
|
@ -24,6 +24,7 @@ import (
|
|||
"sync"
|
||||
|
||||
grpc "google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -49,7 +50,7 @@ func Dial(hsAddress string) (*grpc.ClientConn, error) {
|
|||
// Create a new connection to the handshaker service. Note that
|
||||
// this connection stays open until the application is closed.
|
||||
var err error
|
||||
hsConn, err = hsDialer(hsAddress, grpc.WithInsecure())
|
||||
hsConn, err = hsDialer(hsAddress, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import (
|
|||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
pb "google.golang.org/grpc/examples/features/proto/echo"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
@ -55,7 +56,7 @@ func main() {
|
|||
flag.Parse()
|
||||
|
||||
// Set up a connection to the server.
|
||||
conn, err := grpc.Dial(*addr, grpc.WithInsecure())
|
||||
conn, err := grpc.Dial(*addr, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
log.Fatalf("did not connect: %v", err)
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import (
|
|||
"time"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/encoding/gzip" // Install the gzip compressor
|
||||
pb "google.golang.org/grpc/examples/features/proto/echo"
|
||||
)
|
||||
|
@ -37,7 +38,7 @@ func main() {
|
|||
flag.Parse()
|
||||
|
||||
// Set up a connection to the server.
|
||||
conn, err := grpc.Dial(*addr, grpc.WithInsecure())
|
||||
conn, err := grpc.Dial(*addr, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
log.Fatalf("did not connect: %v", err)
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import (
|
|||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
pb "google.golang.org/grpc/examples/features/proto/echo"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
@ -72,7 +73,7 @@ func streamingCall(c pb.EchoClient, requestID int, message string, want codes.Co
|
|||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
conn, err := grpc.Dial(*addr, grpc.WithInsecure())
|
||||
conn, err := grpc.Dial(*addr, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
log.Fatalf("did not connect: %v", err)
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import (
|
|||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
pb "google.golang.org/grpc/examples/features/proto/echo"
|
||||
|
@ -94,7 +95,7 @@ func (s *server) Close() {
|
|||
|
||||
func newEchoServer() *server {
|
||||
target := fmt.Sprintf("localhost:%v", *port)
|
||||
cc, err := grpc.Dial(target, grpc.WithInsecure())
|
||||
cc, err := grpc.Dial(target, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
log.Fatalf("did not connect: %v", err)
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import (
|
|||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/channelz/service"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/resolver"
|
||||
"google.golang.org/grpc/resolver/manual"
|
||||
|
||||
|
@ -59,7 +60,7 @@ func main() {
|
|||
/***** Initialize manual resolver and Dial *****/
|
||||
r := manual.NewBuilderWithScheme("whatever")
|
||||
// Set up a connection to the server.
|
||||
conn, err := grpc.Dial(r.Scheme()+":///test.server", grpc.WithInsecure(), grpc.WithResolvers(r), grpc.WithDefaultServiceConfig(`{"loadBalancingPolicy":"round_robin"}`))
|
||||
conn, err := grpc.Dial(r.Scheme()+":///test.server", grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithResolvers(r), grpc.WithDefaultServiceConfig(`{"loadBalancingPolicy":"round_robin"}`))
|
||||
if err != nil {
|
||||
log.Fatalf("did not connect: %v", err)
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import (
|
|||
|
||||
epb "google.golang.org/genproto/googleapis/rpc/errdetails"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
pb "google.golang.org/grpc/examples/helloworld/helloworld"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
@ -38,7 +39,7 @@ func main() {
|
|||
flag.Parse()
|
||||
|
||||
// Set up a connection to the server.
|
||||
conn, err := grpc.Dial(*addr, grpc.WithInsecure())
|
||||
conn, err := grpc.Dial(*addr, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
log.Fatalf("did not connect: %v", err)
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import (
|
|||
"time"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
pb "google.golang.org/grpc/examples/features/proto/echo"
|
||||
_ "google.golang.org/grpc/health"
|
||||
"google.golang.org/grpc/resolver"
|
||||
|
@ -65,7 +66,7 @@ func main() {
|
|||
address := fmt.Sprintf("%s:///unused", r.Scheme())
|
||||
|
||||
options := []grpc.DialOption{
|
||||
grpc.WithInsecure(),
|
||||
grpc.WithTransportCredentials(insecure.NewCredentials()),
|
||||
grpc.WithBlock(),
|
||||
grpc.WithResolvers(r),
|
||||
grpc.WithDefaultServiceConfig(serviceConfig),
|
||||
|
|
|
@ -27,6 +27,7 @@ import (
|
|||
"time"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
pb "google.golang.org/grpc/examples/features/proto/echo"
|
||||
"google.golang.org/grpc/keepalive"
|
||||
)
|
||||
|
@ -42,7 +43,7 @@ var kacp = keepalive.ClientParameters{
|
|||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
conn, err := grpc.Dial(*addr, grpc.WithInsecure(), grpc.WithKeepaliveParams(kacp))
|
||||
conn, err := grpc.Dial(*addr, grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithKeepaliveParams(kacp))
|
||||
if err != nil {
|
||||
log.Fatalf("did not connect: %v", err)
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import (
|
|||
"time"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
ecpb "google.golang.org/grpc/examples/features/proto/echo"
|
||||
"google.golang.org/grpc/resolver"
|
||||
)
|
||||
|
@ -58,7 +59,7 @@ func main() {
|
|||
// "pick_first" is the default, so there's no need to set the load balancing policy.
|
||||
pickfirstConn, err := grpc.Dial(
|
||||
fmt.Sprintf("%s:///%s", exampleScheme, exampleServiceName),
|
||||
grpc.WithInsecure(),
|
||||
grpc.WithTransportCredentials(insecure.NewCredentials()),
|
||||
)
|
||||
if err != nil {
|
||||
log.Fatalf("did not connect: %v", err)
|
||||
|
@ -74,7 +75,7 @@ func main() {
|
|||
roundrobinConn, err := grpc.Dial(
|
||||
fmt.Sprintf("%s:///%s", exampleScheme, exampleServiceName),
|
||||
grpc.WithDefaultServiceConfig(`{"loadBalancingConfig": [{"round_robin":{}}]}`), // This sets the initial balancing policy.
|
||||
grpc.WithInsecure(),
|
||||
grpc.WithTransportCredentials(insecure.NewCredentials()),
|
||||
)
|
||||
if err != nil {
|
||||
log.Fatalf("did not connect: %v", err)
|
||||
|
|
|
@ -28,6 +28,7 @@ import (
|
|||
"time"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
pb "google.golang.org/grpc/examples/features/proto/echo"
|
||||
"google.golang.org/grpc/metadata"
|
||||
)
|
||||
|
@ -286,7 +287,7 @@ const message = "this is examples/metadata"
|
|||
func main() {
|
||||
flag.Parse()
|
||||
// Set up a connection to the server.
|
||||
conn, err := grpc.Dial(*addr, grpc.WithInsecure())
|
||||
conn, err := grpc.Dial(*addr, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
log.Fatalf("did not connect: %v", err)
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import (
|
|||
"time"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
ecpb "google.golang.org/grpc/examples/features/proto/echo"
|
||||
hwpb "google.golang.org/grpc/examples/helloworld/helloworld"
|
||||
)
|
||||
|
@ -58,7 +59,7 @@ func callUnaryEcho(client ecpb.EchoClient, message string) {
|
|||
func main() {
|
||||
flag.Parse()
|
||||
// Set up a connection to the server.
|
||||
conn, err := grpc.Dial(*addr, grpc.WithInsecure())
|
||||
conn, err := grpc.Dial(*addr, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
log.Fatalf("did not connect: %v", err)
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import (
|
|||
"time"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
ecpb "google.golang.org/grpc/examples/features/proto/echo"
|
||||
"google.golang.org/grpc/resolver"
|
||||
)
|
||||
|
@ -57,7 +58,7 @@ func makeRPCs(cc *grpc.ClientConn, n int) {
|
|||
func main() {
|
||||
passthroughConn, err := grpc.Dial(
|
||||
fmt.Sprintf("passthrough:///%s", backendAddr), // Dial to "passthrough:///localhost:50051"
|
||||
grpc.WithInsecure(),
|
||||
grpc.WithTransportCredentials(insecure.NewCredentials()),
|
||||
)
|
||||
if err != nil {
|
||||
log.Fatalf("did not connect: %v", err)
|
||||
|
@ -71,7 +72,7 @@ func main() {
|
|||
|
||||
exampleConn, err := grpc.Dial(
|
||||
fmt.Sprintf("%s:///%s", exampleScheme, exampleServiceName), // Dial to "example:///resolver.example.grpc.io"
|
||||
grpc.WithInsecure(),
|
||||
grpc.WithTransportCredentials(insecure.NewCredentials()),
|
||||
)
|
||||
if err != nil {
|
||||
log.Fatalf("did not connect: %v", err)
|
||||
|
|
|
@ -62,5 +62,5 @@ To use the above service config, pass it with `grpc.WithDefaultServiceConfig` to
|
|||
`grpc.Dial`.
|
||||
|
||||
```go
|
||||
conn, err := grpc.Dial(ctx,grpc.WithInsecure(), grpc.WithDefaultServiceConfig(retryPolicy))
|
||||
conn, err := grpc.Dial(ctx,grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithDefaultServiceConfig(retryPolicy))
|
||||
```
|
||||
|
|
|
@ -26,6 +26,7 @@ import (
|
|||
"time"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
pb "google.golang.org/grpc/examples/features/proto/echo"
|
||||
)
|
||||
|
||||
|
@ -48,7 +49,7 @@ var (
|
|||
|
||||
// use grpc.WithDefaultServiceConfig() to set service config
|
||||
func retryDial() (*grpc.ClientConn, error) {
|
||||
return grpc.Dial(*addr, grpc.WithInsecure(), grpc.WithDefaultServiceConfig(retryPolicy))
|
||||
return grpc.Dial(*addr, grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithDefaultServiceConfig(retryPolicy))
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
|
|
@ -31,6 +31,7 @@ import (
|
|||
"time"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
ecpb "google.golang.org/grpc/examples/features/proto/echo"
|
||||
)
|
||||
|
||||
|
@ -62,7 +63,7 @@ func makeRPCs(cc *grpc.ClientConn, n int) {
|
|||
func main() {
|
||||
flag.Parse()
|
||||
sockAddr := fmt.Sprintf("unix-abstract:%v", *addr)
|
||||
cc, err := grpc.Dial(sockAddr, grpc.WithInsecure())
|
||||
cc, err := grpc.Dial(sockAddr, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
log.Fatalf("grpc.Dial(%q) failed: %v", sockAddr, err)
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ import (
|
|||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
pb "google.golang.org/grpc/examples/features/proto/echo"
|
||||
|
@ -58,7 +59,7 @@ func serve() {
|
|||
}
|
||||
|
||||
func main() {
|
||||
conn, err := grpc.Dial("localhost:50053", grpc.WithInsecure())
|
||||
conn, err := grpc.Dial("localhost:50053", grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
log.Fatalf("did not connect: %v", err)
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import (
|
|||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/connectivity"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/resolver"
|
||||
"google.golang.org/grpc/resolver/manual"
|
||||
"google.golang.org/grpc/serviceconfig"
|
||||
|
@ -116,7 +117,7 @@ func (ss *StubServer) StartServer(sopts ...grpc.ServerOption) error {
|
|||
// StartClient creates a client connected to this service that the test may use.
|
||||
// The newly created client will be available in the Client field of StubServer.
|
||||
func (ss *StubServer) StartClient(dopts ...grpc.DialOption) error {
|
||||
opts := append([]grpc.DialOption{grpc.WithInsecure()}, dopts...)
|
||||
opts := append([]grpc.DialOption{grpc.WithTransportCredentials(insecure.NewCredentials())}, dopts...)
|
||||
if ss.R != nil {
|
||||
ss.Target = ss.R.Scheme() + ":///" + ss.Address
|
||||
opts = append(opts, grpc.WithResolvers(ss.R))
|
||||
|
|
|
@ -33,6 +33,7 @@ import (
|
|||
"google.golang.org/grpc/credentials"
|
||||
"google.golang.org/grpc/credentials/alts"
|
||||
"google.golang.org/grpc/credentials/google"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/credentials/oauth"
|
||||
"google.golang.org/grpc/grpclog"
|
||||
"google.golang.org/grpc/interop"
|
||||
|
@ -176,7 +177,7 @@ func main() {
|
|||
case credsComputeEngineCreds:
|
||||
opts = append(opts, grpc.WithCredentialsBundle(google.NewComputeEngineCredentials()))
|
||||
case credsNone:
|
||||
opts = append(opts, grpc.WithInsecure())
|
||||
opts = append(opts, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
default:
|
||||
logger.Fatal("Invalid creds")
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ import (
|
|||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/grpclog"
|
||||
"google.golang.org/grpc/interop"
|
||||
"google.golang.org/grpc/status"
|
||||
|
@ -131,7 +132,7 @@ func main() {
|
|||
flag.Parse()
|
||||
serverAddr := net.JoinHostPort(*serverHost, strconv.Itoa(*serverPort))
|
||||
var opts []grpc.DialOption
|
||||
opts = append(opts, grpc.WithInsecure())
|
||||
opts = append(opts, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
conn, err := grpc.Dial(serverAddr, opts...)
|
||||
if err != nil {
|
||||
logger.Fatalf("Fail to dial: %v", err)
|
||||
|
|
|
@ -26,6 +26,7 @@ import (
|
|||
"time"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
ppb "google.golang.org/grpc/profiling/proto"
|
||||
)
|
||||
|
||||
|
@ -78,7 +79,7 @@ func remoteCommand() error {
|
|||
}
|
||||
|
||||
logger.Infof("dialing %s", *flagAddress)
|
||||
cc, err := grpc.Dial(*flagAddress, grpc.WithInsecure())
|
||||
cc, err := grpc.Dial(*flagAddress, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
logger.Errorf("cannot dial %s: %v", *flagAddress, err)
|
||||
return err
|
||||
|
|
|
@ -30,6 +30,7 @@ import (
|
|||
"github.com/golang/protobuf/proto"
|
||||
dpb "github.com/golang/protobuf/protoc-gen-go/descriptor"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/internal/grpctest"
|
||||
rpb "google.golang.org/grpc/reflection/grpc_reflection_v1alpha"
|
||||
pb "google.golang.org/grpc/reflection/grpc_testing"
|
||||
|
@ -205,7 +206,7 @@ func (x) TestReflectionEnd2end(t *testing.T) {
|
|||
go s.Serve(lis)
|
||||
|
||||
// Create client.
|
||||
conn, err := grpc.Dial(lis.Addr().String(), grpc.WithInsecure())
|
||||
conn, err := grpc.Dial(lis.Addr().String(), grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
t.Fatalf("cannot connect to server: %v", err)
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ import (
|
|||
|
||||
"github.com/golang/protobuf/proto"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/internal/grpctest"
|
||||
"google.golang.org/grpc/metadata"
|
||||
"google.golang.org/grpc/stats"
|
||||
|
@ -246,7 +247,7 @@ func (te *test) clientConn() *grpc.ClientConn {
|
|||
return te.cc
|
||||
}
|
||||
opts := []grpc.DialOption{
|
||||
grpc.WithInsecure(),
|
||||
grpc.WithTransportCredentials(insecure.NewCredentials()),
|
||||
grpc.WithBlock(),
|
||||
grpc.WithUserAgent("test/0.0.1"),
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ import (
|
|||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/credentials"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/grpclog"
|
||||
"google.golang.org/grpc/interop"
|
||||
"google.golang.org/grpc/status"
|
||||
|
@ -293,7 +294,7 @@ func newConn(address string, useTLS, testCA bool, tlsServerName string) (*grpc.C
|
|||
}
|
||||
opts = append(opts, grpc.WithTransportCredentials(creds))
|
||||
} else {
|
||||
opts = append(opts, grpc.WithInsecure())
|
||||
opts = append(opts, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
}
|
||||
return grpc.Dial(address, opts...)
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import (
|
|||
"io"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/grpclog"
|
||||
metricspb "google.golang.org/grpc/stress/grpc_testing"
|
||||
)
|
||||
|
@ -74,7 +75,7 @@ func main() {
|
|||
logger.Fatalf("Metrics server address is empty.")
|
||||
}
|
||||
|
||||
conn, err := grpc.Dial(*metricsServerAddress, grpc.WithInsecure())
|
||||
conn, err := grpc.Dial(*metricsServerAddress, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
logger.Fatalf("cannot connect to metrics server: %v", err)
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ import (
|
|||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/internal/stubserver"
|
||||
"google.golang.org/grpc/metadata"
|
||||
"google.golang.org/grpc/status"
|
||||
|
@ -193,7 +194,7 @@ func (s) TestColonPortAuthority(t *testing.T) {
|
|||
//
|
||||
// Append "localhost" before calling net.Dial, in case net.Dial on certain
|
||||
// platforms doesn't work well for address without the IP.
|
||||
cc, err := grpc.Dial(":"+port, grpc.WithInsecure(), grpc.WithContextDialer(func(ctx context.Context, addr string) (net.Conn, error) {
|
||||
cc, err := grpc.Dial(":"+port, grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithContextDialer(func(ctx context.Context, addr string) (net.Conn, error) {
|
||||
return (&net.Dialer{}).DialContext(ctx, "tcp", "localhost"+addr)
|
||||
}))
|
||||
if err != nil {
|
||||
|
|
|
@ -393,7 +393,7 @@ func (s) TestNonGRPCLBBalancerGetsNoGRPCLBAddress(t *testing.T) {
|
|||
b := newTestBalancerKeepAddresses()
|
||||
balancer.Register(b)
|
||||
|
||||
cc, err := grpc.Dial(r.Scheme()+":///test.server", grpc.WithInsecure(), grpc.WithResolvers(r),
|
||||
cc, err := grpc.Dial(r.Scheme()+":///test.server", grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithResolvers(r),
|
||||
grpc.WithBalancerName(b.Name()))
|
||||
if err != nil {
|
||||
t.Fatalf("failed to dial: %v", err)
|
||||
|
@ -655,7 +655,7 @@ func (s) TestServersSwap(t *testing.T) {
|
|||
// Initialize client
|
||||
r := manual.NewBuilderWithScheme("whatever")
|
||||
r.InitialState(resolver.State{Addresses: []resolver.Address{{Addr: addr1}}})
|
||||
cc, err := grpc.DialContext(ctx, r.Scheme()+":///", grpc.WithInsecure(), grpc.WithResolvers(r))
|
||||
cc, err := grpc.DialContext(ctx, r.Scheme()+":///", grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithResolvers(r))
|
||||
if err != nil {
|
||||
t.Fatalf("Error creating client: %v", err)
|
||||
}
|
||||
|
@ -709,7 +709,7 @@ func (s) TestEmptyAddrs(t *testing.T) {
|
|||
|
||||
pfr.InitialState(resolver.State{Addresses: []resolver.Address{{Addr: lis.Addr().String()}}})
|
||||
|
||||
pfcc, err := grpc.DialContext(ctx, pfr.Scheme()+":///", grpc.WithInsecure(), grpc.WithResolvers(pfr))
|
||||
pfcc, err := grpc.DialContext(ctx, pfr.Scheme()+":///", grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithResolvers(pfr))
|
||||
if err != nil {
|
||||
t.Fatalf("Error creating client: %v", err)
|
||||
}
|
||||
|
@ -729,7 +729,7 @@ func (s) TestEmptyAddrs(t *testing.T) {
|
|||
|
||||
rrr.InitialState(resolver.State{Addresses: []resolver.Address{{Addr: lis.Addr().String()}}})
|
||||
|
||||
rrcc, err := grpc.DialContext(ctx, rrr.Scheme()+":///", grpc.WithInsecure(), grpc.WithResolvers(rrr),
|
||||
rrcc, err := grpc.DialContext(ctx, rrr.Scheme()+":///", grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithResolvers(rrr),
|
||||
grpc.WithDefaultServiceConfig(fmt.Sprintf(`{ "loadBalancingConfig": [{"%v": {}}] }`, roundrobin.Name)))
|
||||
if err != nil {
|
||||
t.Fatalf("Error creating client: %v", err)
|
||||
|
@ -785,7 +785,7 @@ func (s) TestWaitForReady(t *testing.T) {
|
|||
// Initialize client
|
||||
r := manual.NewBuilderWithScheme("whatever")
|
||||
|
||||
cc, err := grpc.DialContext(ctx, r.Scheme()+":///", grpc.WithInsecure(), grpc.WithResolvers(r))
|
||||
cc, err := grpc.DialContext(ctx, r.Scheme()+":///", grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithResolvers(r))
|
||||
if err != nil {
|
||||
t.Fatalf("Error creating client: %v", err)
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@ import (
|
|||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/connectivity"
|
||||
"google.golang.org/grpc/credentials"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/encoding"
|
||||
_ "google.golang.org/grpc/encoding/gzip"
|
||||
"google.golang.org/grpc/health"
|
||||
|
@ -801,7 +802,7 @@ func (te *test) configDial(opts ...grpc.DialOption) ([]grpc.DialOption, string)
|
|||
case "empty":
|
||||
// Don't add any transport creds option.
|
||||
default:
|
||||
opts = append(opts, grpc.WithInsecure())
|
||||
opts = append(opts, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
}
|
||||
// TODO(bar) switch balancer case "pick_first".
|
||||
var scheme string
|
||||
|
@ -3740,7 +3741,7 @@ func (s) TestTransparentRetry(t *testing.T) {
|
|||
},
|
||||
}
|
||||
server.start(t, lis)
|
||||
cc, err := grpc.Dial(lis.Addr().String(), grpc.WithInsecure())
|
||||
cc, err := grpc.Dial(lis.Addr().String(), grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
t.Fatalf("failed to dial due to err: %v", err)
|
||||
}
|
||||
|
@ -5131,7 +5132,7 @@ func (s) TestFlowControlLogicalRace(t *testing.T) {
|
|||
|
||||
go s.Serve(lis)
|
||||
|
||||
cc, err := grpc.Dial(lis.Addr().String(), grpc.WithInsecure())
|
||||
cc, err := grpc.Dial(lis.Addr().String(), grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
t.Fatalf("grpc.Dial(%q) = %v", lis.Addr().String(), err)
|
||||
}
|
||||
|
@ -6561,7 +6562,7 @@ func (s) TestServeExitsWhenListenerClosed(t *testing.T) {
|
|||
close(done)
|
||||
}()
|
||||
|
||||
cc, err := grpc.Dial(lis.Addr().String(), grpc.WithInsecure())
|
||||
cc, err := grpc.Dial(lis.Addr().String(), grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to dial server: %v", err)
|
||||
}
|
||||
|
@ -6780,7 +6781,7 @@ func (s) TestDisabledIOBuffers(t *testing.T) {
|
|||
defer s.Stop()
|
||||
dctx, dcancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer dcancel()
|
||||
cc, err := grpc.DialContext(dctx, lis.Addr().String(), grpc.WithInsecure(), grpc.WithWriteBufferSize(0), grpc.WithReadBufferSize(0))
|
||||
cc, err := grpc.DialContext(dctx, lis.Addr().String(), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithWriteBufferSize(0), grpc.WithReadBufferSize(0))
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to dial server")
|
||||
}
|
||||
|
@ -6982,7 +6983,7 @@ func (s) TestNetPipeConn(t *testing.T) {
|
|||
go s.Serve(pl)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
cc, err := grpc.DialContext(ctx, "", grpc.WithInsecure(), grpc.WithDialer(pl.Dialer()))
|
||||
cc, err := grpc.DialContext(ctx, "", grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithDialer(pl.Dialer()))
|
||||
if err != nil {
|
||||
t.Fatalf("Error creating client: %v", err)
|
||||
}
|
||||
|
@ -7082,7 +7083,7 @@ func (s) TestGoAwayThenClose(t *testing.T) {
|
|||
{Addr: lis1.Addr().String()},
|
||||
{Addr: lis2.Addr().String()},
|
||||
}})
|
||||
cc, err := grpc.DialContext(ctx, r.Scheme()+":///", grpc.WithResolvers(r), grpc.WithInsecure())
|
||||
cc, err := grpc.DialContext(ctx, r.Scheme()+":///", grpc.WithResolvers(r), grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
t.Fatalf("Error creating client: %v", err)
|
||||
}
|
||||
|
@ -7483,7 +7484,7 @@ func doHTTPHeaderTest(t *testing.T, errCode codes.Code, headerFields ...[]string
|
|||
responses: []httpServerResponse{{trailers: headerFields}},
|
||||
}
|
||||
server.start(t, lis)
|
||||
cc, err := grpc.Dial(lis.Addr().String(), grpc.WithInsecure())
|
||||
cc, err := grpc.Dial(lis.Addr().String(), grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
t.Fatalf("failed to dial due to err: %v", err)
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import (
|
|||
"time"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/internal/stubserver"
|
||||
"google.golang.org/grpc/keepalive"
|
||||
testpb "google.golang.org/grpc/test/grpc_testing"
|
||||
|
@ -57,7 +58,7 @@ func (s) TestGracefulClientOnGoAway(t *testing.T) {
|
|||
}
|
||||
go s.Serve(lis)
|
||||
|
||||
cc, err := grpc.Dial(lis.Addr().String(), grpc.WithInsecure())
|
||||
cc, err := grpc.Dial(lis.Addr().String(), grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to dial server: %v", err)
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import (
|
|||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/internal/stubserver"
|
||||
"google.golang.org/grpc/status"
|
||||
testpb "google.golang.org/grpc/test/grpc_testing"
|
||||
|
@ -146,7 +147,7 @@ func (s) TestGracefulStop(t *testing.T) {
|
|||
// even though GracefulStop has closed the listener.
|
||||
ctx, dialCancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer dialCancel()
|
||||
cc, err := grpc.DialContext(ctx, "", grpc.WithInsecure(), grpc.WithContextDialer(d))
|
||||
cc, err := grpc.DialContext(ctx, "", grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithContextDialer(d))
|
||||
if err != nil {
|
||||
t.Fatalf("grpc.DialContext(_, %q, _) = %v", lis.Addr().String(), err)
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ import (
|
|||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/connectivity"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
_ "google.golang.org/grpc/health"
|
||||
healthgrpc "google.golang.org/grpc/health/grpc_health_v1"
|
||||
healthpb "google.golang.org/grpc/health/grpc_health_v1"
|
||||
|
@ -154,7 +155,7 @@ type clientConfig struct {
|
|||
func setupClient(c *clientConfig) (cc *grpc.ClientConn, r *manual.Resolver, deferFunc func(), err error) {
|
||||
r = manual.NewBuilderWithScheme("whatever")
|
||||
var opts []grpc.DialOption
|
||||
opts = append(opts, grpc.WithInsecure(), grpc.WithResolvers(r), grpc.WithBalancerName(c.balancerName))
|
||||
opts = append(opts, grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithResolvers(r), grpc.WithBalancerName(c.balancerName))
|
||||
if c.testHealthCheckFuncWrapper != nil {
|
||||
opts = append(opts, internal.WithHealthCheckFunc.(func(internal.HealthChecker) grpc.DialOption)(c.testHealthCheckFuncWrapper))
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ func (s) TestInsecureCreds(t *testing.T) {
|
|||
go s.Serve(lis)
|
||||
|
||||
addr := lis.Addr().String()
|
||||
opts := []grpc.DialOption{grpc.WithInsecure()}
|
||||
opts := []grpc.DialOption{grpc.WithTransportCredentials(insecure.NewCredentials())}
|
||||
if test.clientInsecureCreds {
|
||||
opts = []grpc.DialOption{grpc.WithTransportCredentials(insecure.NewCredentials())}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ import (
|
|||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/credentials"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/credentials/local"
|
||||
"google.golang.org/grpc/internal/stubserver"
|
||||
"google.golang.org/grpc/peer"
|
||||
|
@ -218,7 +219,7 @@ func (s) TestLocalCredsClientFail(t *testing.T) {
|
|||
|
||||
func (s) TestLocalCredsServerFail(t *testing.T) {
|
||||
// Use insecure at client-side which should lead to server-side failure.
|
||||
opts := []grpc.DialOption{grpc.WithInsecure()}
|
||||
opts := []grpc.DialOption{grpc.WithTransportCredentials(insecure.NewCredentials())}
|
||||
if err := testLocalCredsE2EFail(opts); status.Code(err) != codes.Unavailable {
|
||||
t.Fatalf("testLocalCredsE2EFail() = %v; want %v", err, codes.Unavailable)
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ import (
|
|||
"github.com/golang/protobuf/proto"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/internal/stubserver"
|
||||
"google.golang.org/grpc/metadata"
|
||||
"google.golang.org/grpc/stats"
|
||||
|
@ -531,7 +532,7 @@ func (s) TestRetryStats(t *testing.T) {
|
|||
}
|
||||
server.start(t, lis)
|
||||
handler := &retryStatsHandler{}
|
||||
cc, err := grpc.Dial(lis.Addr().String(), grpc.WithInsecure(), grpc.WithStatsHandler(handler),
|
||||
cc, err := grpc.Dial(lis.Addr().String(), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithStatsHandler(handler),
|
||||
grpc.WithDefaultServiceConfig((`{
|
||||
"methodConfig": [{
|
||||
"name": [{"service": "grpc.testing.TestService"}],
|
||||
|
|
|
@ -30,6 +30,7 @@ import (
|
|||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/google/uuid"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/internal/grpctest"
|
||||
"google.golang.org/grpc/internal/testutils"
|
||||
"google.golang.org/grpc/internal/xds"
|
||||
|
@ -278,7 +279,7 @@ func commonSetup(ctx context.Context, t *testing.T) (xdsclient.XDSClient, *e2e.M
|
|||
}()
|
||||
|
||||
// Create CSDS client.
|
||||
conn, err := grpc.Dial(lis.Addr().String(), grpc.WithInsecure())
|
||||
conn, err := grpc.Dial(lis.Addr().String(), grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
t.Fatalf("cannot connect to server: %v", err)
|
||||
}
|
||||
|
@ -525,7 +526,7 @@ func (s) TestCSDSNoXDSClient(t *testing.T) {
|
|||
defer server.Stop()
|
||||
|
||||
// Create CSDS client.
|
||||
conn, err := grpc.Dial(lis.Addr().String(), grpc.WithInsecure())
|
||||
conn, err := grpc.Dial(lis.Addr().String(), grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
t.Fatalf("cannot connect to server: %v", err)
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import (
|
|||
"google.golang.org/grpc"
|
||||
channelzgrpc "google.golang.org/grpc/channelz/grpc_channelz_v1"
|
||||
channelzpb "google.golang.org/grpc/channelz/grpc_channelz_v1"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
testgrpc "google.golang.org/grpc/interop/grpc_testing"
|
||||
testpb "google.golang.org/grpc/interop/grpc_testing"
|
||||
)
|
||||
|
@ -70,7 +71,7 @@ func newClient(target, binaryPath, bootstrap string, logger io.Writer, flags ...
|
|||
)
|
||||
cmd.Start()
|
||||
|
||||
cc, err := grpc.Dial(fmt.Sprintf("localhost:%d", clientStatsPort), grpc.WithInsecure(), grpc.WithDefaultCallOptions(grpc.WaitForReady(true)))
|
||||
cc, err := grpc.Dial(fmt.Sprintf("localhost:%d", clientStatsPort), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithDefaultCallOptions(grpc.WaitForReady(true)))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -565,7 +565,7 @@ func (s) TestServerSideXDS_RouteConfiguration(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
cc, err := grpc.DialContext(ctx, fmt.Sprintf("xds:///%s", serviceName), grpc.WithInsecure(), grpc.WithResolvers(resolver))
|
||||
cc, err := grpc.DialContext(ctx, fmt.Sprintf("xds:///%s", serviceName), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithResolvers(resolver))
|
||||
if err != nil {
|
||||
t.Fatalf("failed to dial local test server: %v", err)
|
||||
}
|
||||
|
@ -952,7 +952,7 @@ func (s) TestRBACHTTPFilter(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
cc, err := grpc.DialContext(ctx, fmt.Sprintf("xds:///%s", serviceName), grpc.WithInsecure(), grpc.WithResolvers(resolver))
|
||||
cc, err := grpc.DialContext(ctx, fmt.Sprintf("xds:///%s", serviceName), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithResolvers(resolver))
|
||||
if err != nil {
|
||||
t.Fatalf("failed to dial local test server: %v", err)
|
||||
}
|
||||
|
@ -1143,7 +1143,7 @@ func (s) TestRBACToggledOn_WithBadRouteConfiguration(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
cc, err := grpc.DialContext(ctx, fmt.Sprintf("xds:///%s", serviceName), grpc.WithInsecure(), grpc.WithResolvers(resolver))
|
||||
cc, err := grpc.DialContext(ctx, fmt.Sprintf("xds:///%s", serviceName), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithResolvers(resolver))
|
||||
if err != nil {
|
||||
t.Fatalf("failed to dial local test server: %v", err)
|
||||
}
|
||||
|
@ -1200,7 +1200,7 @@ func (s) TestRBACToggledOff_WithBadRouteConfiguration(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
cc, err := grpc.DialContext(ctx, fmt.Sprintf("xds:///%s", serviceName), grpc.WithInsecure(), grpc.WithResolvers(resolver))
|
||||
cc, err := grpc.DialContext(ctx, fmt.Sprintf("xds:///%s", serviceName), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithResolvers(resolver))
|
||||
if err != nil {
|
||||
t.Fatalf("failed to dial local test server: %v", err)
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ func (s) TestNew(t *testing.T) {
|
|||
name: "happy-case",
|
||||
config: &bootstrap.ServerConfig{
|
||||
ServerURI: testXDSServer,
|
||||
Creds: grpc.WithInsecure(),
|
||||
Creds: grpc.WithTransportCredentials(insecure.NewCredentials()),
|
||||
NodeProto: testutils.EmptyNodeProtoV2,
|
||||
},
|
||||
},
|
||||
|
@ -111,7 +111,7 @@ func (s) TestNew(t *testing.T) {
|
|||
func (s) TestNewWithGRPCDial(t *testing.T) {
|
||||
config := &bootstrap.ServerConfig{
|
||||
ServerURI: testXDSServer,
|
||||
Creds: grpc.WithInsecure(),
|
||||
Creds: grpc.WithTransportCredentials(insecure.NewCredentials()),
|
||||
NodeProto: testutils.EmptyNodeProtoV2,
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/internal/testutils"
|
||||
xdstestutils "google.golang.org/grpc/xds/internal/testutils"
|
||||
"google.golang.org/grpc/xds/internal/xdsclient/bootstrap"
|
||||
|
@ -37,7 +38,7 @@ func (s) TestClientNewSingleton(t *testing.T) {
|
|||
return &bootstrap.Config{
|
||||
XDSServer: &bootstrap.ServerConfig{
|
||||
ServerURI: testXDSServer,
|
||||
Creds: grpc.WithInsecure(),
|
||||
Creds: grpc.WithTransportCredentials(insecure.NewCredentials()),
|
||||
NodeProto: xdstestutils.EmptyNodeProtoV2,
|
||||
},
|
||||
}, nil
|
||||
|
|
Loading…
Reference in New Issue