Allow interop client to use call creds on any secure channel (#2185)

This commit is contained in:
apolcyn 2018-06-28 10:41:13 -07:00 committed by dfawley
parent 40a879c23a
commit 6a43dcc2ac
1 changed files with 11 additions and 9 deletions

View File

@ -96,6 +96,17 @@ func main() {
creds = credentials.NewClientTLSFromCert(nil, sn)
}
opts = append(opts, grpc.WithTransportCredentials(creds))
} else if *useALTS {
altsOpts := alts.DefaultClientOptions()
if *altsHSAddr != "" {
altsOpts.HandshakerServiceAddress = *altsHSAddr
}
altsTC := alts.NewClientCreds(altsOpts)
opts = append(opts, grpc.WithTransportCredentials(altsTC))
} else {
opts = append(opts, grpc.WithInsecure())
}
if *useTLS || *useALTS {
if *testCase == "compute_engine_creds" {
opts = append(opts, grpc.WithPerRPCCredentials(oauth.NewComputeEngine()))
} else if *testCase == "service_account_creds" {
@ -113,15 +124,6 @@ func main() {
} else if *testCase == "oauth2_auth_token" {
opts = append(opts, grpc.WithPerRPCCredentials(oauth.NewOauthAccess(interop.GetToken(*serviceAccountKeyFile, *oauthScope))))
}
} else if *useALTS {
altsOpts := alts.DefaultClientOptions()
if *altsHSAddr != "" {
altsOpts.HandshakerServiceAddress = *altsHSAddr
}
altsTC := alts.NewClientCreds(altsOpts)
opts = append(opts, grpc.WithTransportCredentials(altsTC))
} else {
opts = append(opts, grpc.WithInsecure())
}
opts = append(opts, grpc.WithBlock())
conn, err := grpc.Dial(serverAddr, opts...)