diff options
Diffstat (limited to 'src/csharp/Grpc.IntegrationTesting/InteropClient.cs')
-rw-r--r-- | src/csharp/Grpc.IntegrationTesting/InteropClient.cs | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/src/csharp/Grpc.IntegrationTesting/InteropClient.cs b/src/csharp/Grpc.IntegrationTesting/InteropClient.cs index d3b7fe87f3..c99084d1a9 100644 --- a/src/csharp/Grpc.IntegrationTesting/InteropClient.cs +++ b/src/csharp/Grpc.IntegrationTesting/InteropClient.cs @@ -116,6 +116,24 @@ namespace Grpc.IntegrationTesting private async Task Run() { + var credentials = await CreateCredentialsAsync(); + + List<ChannelOption> channelOptions = null; + if (!string.IsNullOrEmpty(options.ServerHostOverride)) + { + channelOptions = new List<ChannelOption> + { + new ChannelOption(ChannelOptions.SslTargetNameOverride, options.ServerHostOverride) + }; + } + var channel = new Channel(options.ServerHost, options.ServerPort, credentials, channelOptions); + TestService.TestServiceClient client = new TestService.TestServiceClient(channel); + await RunTestCaseAsync(client, options); + await channel.ShutdownAsync(); + } + + private async Task<Credentials> CreateCredentialsAsync() + { var credentials = options.UseTls ? TestCredentials.CreateTestClientCredentials(options.UseTestCa) : Credentials.Insecure; if (options.TestCase == "jwt_token_creds") @@ -131,19 +149,7 @@ namespace Grpc.IntegrationTesting Assert.IsFalse(googleCredential.IsCreateScopedRequired); credentials = CompositeCredentials.Create(googleCredential.ToGrpcCredentials(), credentials); } - - List<ChannelOption> channelOptions = null; - if (!string.IsNullOrEmpty(options.ServerHostOverride)) - { - channelOptions = new List<ChannelOption> - { - new ChannelOption(ChannelOptions.SslTargetNameOverride, options.ServerHostOverride) - }; - } - var channel = new Channel(options.ServerHost, options.ServerPort, credentials, channelOptions); - TestService.TestServiceClient client = new TestService.TestServiceClient(channel); - await RunTestCaseAsync(client, options); - await channel.ShutdownAsync(); + return credentials; } private async Task RunTestCaseAsync(TestService.TestServiceClient client, ClientOptions options) |