|
|
|
@ -145,26 +145,16 @@ namespace Grpc.IntegrationTesting |
|
|
|
|
|
|
|
|
|
if (options.TestCase == "jwt_token_creds") |
|
|
|
|
{ |
|
|
|
|
#if !NETCOREAPP1_0 |
|
|
|
|
var googleCredential = await GoogleCredential.GetApplicationDefaultAsync(); |
|
|
|
|
Assert.IsTrue(googleCredential.IsCreateScopedRequired); |
|
|
|
|
credentials = ChannelCredentials.Create(credentials, googleCredential.ToCallCredentials()); |
|
|
|
|
#else |
|
|
|
|
// TODO(jtattermusch): implement this |
|
|
|
|
throw new NotImplementedException("Not supported on CoreCLR yet"); |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (options.TestCase == "compute_engine_creds") |
|
|
|
|
{ |
|
|
|
|
#if !NETCOREAPP1_0 |
|
|
|
|
var googleCredential = await GoogleCredential.GetApplicationDefaultAsync(); |
|
|
|
|
Assert.IsFalse(googleCredential.IsCreateScopedRequired); |
|
|
|
|
credentials = ChannelCredentials.Create(credentials, googleCredential.ToCallCredentials()); |
|
|
|
|
#else |
|
|
|
|
// TODO(jtattermusch): implement this |
|
|
|
|
throw new NotImplementedException("Not supported on CoreCLR yet"); |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
return credentials; |
|
|
|
|
} |
|
|
|
@ -395,7 +385,6 @@ namespace Grpc.IntegrationTesting |
|
|
|
|
|
|
|
|
|
public static async Task RunOAuth2AuthTokenAsync(TestService.TestServiceClient client, string oauthScope) |
|
|
|
|
{ |
|
|
|
|
#if !NETCOREAPP1_0 |
|
|
|
|
Console.WriteLine("running oauth2_auth_token"); |
|
|
|
|
ITokenAccess credential = (await GoogleCredential.GetApplicationDefaultAsync()).CreateScoped(new[] { oauthScope }); |
|
|
|
|
string oauth2Token = await credential.GetAccessTokenForRequestAsync(); |
|
|
|
@ -413,15 +402,10 @@ namespace Grpc.IntegrationTesting |
|
|
|
|
Assert.True(oauthScope.Contains(response.OauthScope)); |
|
|
|
|
Assert.AreEqual(GetEmailFromServiceAccountFile(), response.Username); |
|
|
|
|
Console.WriteLine("Passed!"); |
|
|
|
|
#else |
|
|
|
|
// TODO(jtattermusch): implement this |
|
|
|
|
throw new NotImplementedException("Not supported on CoreCLR yet"); |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static async Task RunPerRpcCredsAsync(TestService.TestServiceClient client, string oauthScope) |
|
|
|
|
{ |
|
|
|
|
#if !NETCOREAPP1_0 |
|
|
|
|
Console.WriteLine("running per_rpc_creds"); |
|
|
|
|
ITokenAccess googleCredential = await GoogleCredential.GetApplicationDefaultAsync(); |
|
|
|
|
|
|
|
|
@ -435,10 +419,6 @@ namespace Grpc.IntegrationTesting |
|
|
|
|
|
|
|
|
|
Assert.AreEqual(GetEmailFromServiceAccountFile(), response.Username); |
|
|
|
|
Console.WriteLine("Passed!"); |
|
|
|
|
#else |
|
|
|
|
// TODO(jtattermusch): implement this |
|
|
|
|
throw new NotImplementedException("Not supported on CoreCLR yet"); |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static async Task RunCancelAfterBeginAsync(TestService.TestServiceClient client) |
|
|
|
@ -731,17 +711,12 @@ namespace Grpc.IntegrationTesting |
|
|
|
|
// extracts the client_email field from service account file used for auth test cases |
|
|
|
|
private static string GetEmailFromServiceAccountFile() |
|
|
|
|
{ |
|
|
|
|
#if !NETCOREAPP1_0 |
|
|
|
|
string keyFile = Environment.GetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS"); |
|
|
|
|
Assert.IsNotNull(keyFile); |
|
|
|
|
var jobject = JObject.Parse(File.ReadAllText(keyFile)); |
|
|
|
|
string email = jobject.GetValue("client_email").Value<string>(); |
|
|
|
|
Assert.IsTrue(email.Length > 0); // spec requires nonempty client email. |
|
|
|
|
return email; |
|
|
|
|
#else |
|
|
|
|
// TODO(jtattermusch): implement this |
|
|
|
|
throw new NotImplementedException("Not supported on CoreCLR yet"); |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static Metadata CreateTestMetadata() |
|
|
|
|