|
|
|
@ -2620,11 +2620,9 @@ TEST(CredentialsTest, |
|
|
|
|
|
|
|
|
|
TEST(CredentialsTest, TestUrlExternalAccountCredsSuccessFormatText) { |
|
|
|
|
ExecCtx exec_ctx; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
Json credential_source = Json::Parse( |
|
|
|
|
valid_url_external_account_creds_options_credential_source_format_text, |
|
|
|
|
&error); |
|
|
|
|
GPR_ASSERT(GRPC_ERROR_IS_NONE(error)); |
|
|
|
|
auto credential_source = Json::Parse( |
|
|
|
|
valid_url_external_account_creds_options_credential_source_format_text); |
|
|
|
|
GPR_ASSERT(credential_source.ok()); |
|
|
|
|
ExternalAccountCredentials::Options options = { |
|
|
|
|
"external_account", // type;
|
|
|
|
|
"audience", // audience;
|
|
|
|
@ -2632,12 +2630,13 @@ TEST(CredentialsTest, TestUrlExternalAccountCredsSuccessFormatText) { |
|
|
|
|
"", // service_account_impersonation_url;
|
|
|
|
|
"https://foo.com:5555/token", // token_url;
|
|
|
|
|
"https://foo.com:5555/token_info", // token_info_url;
|
|
|
|
|
credential_source, // credential_source;
|
|
|
|
|
*credential_source, // credential_source;
|
|
|
|
|
"quota_project_id", // quota_project_id;
|
|
|
|
|
"client_id", // client_id;
|
|
|
|
|
"client_secret", // client_secret;
|
|
|
|
|
"", // workforce_pool_user_project;
|
|
|
|
|
}; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto creds = UrlExternalAccountCredentials::Create(options, {}, &error); |
|
|
|
|
GPR_ASSERT(creds != nullptr); |
|
|
|
|
GPR_ASSERT(GRPC_ERROR_IS_NONE(error)); |
|
|
|
@ -2658,11 +2657,9 @@ TEST(CredentialsTest, |
|
|
|
|
std::map<std::string, std::string> emd = { |
|
|
|
|
{"authorization", "Bearer token_exchange_access_token"}}; |
|
|
|
|
ExecCtx exec_ctx; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
Json credential_source = Json::Parse( |
|
|
|
|
valid_url_external_account_creds_options_credential_source_with_qurey_params_format_text, |
|
|
|
|
&error); |
|
|
|
|
GPR_ASSERT(GRPC_ERROR_IS_NONE(error)); |
|
|
|
|
auto credential_source = Json::Parse( |
|
|
|
|
valid_url_external_account_creds_options_credential_source_with_qurey_params_format_text); |
|
|
|
|
GPR_ASSERT(credential_source.ok()); |
|
|
|
|
ExternalAccountCredentials::Options options = { |
|
|
|
|
"external_account", // type;
|
|
|
|
|
"audience", // audience;
|
|
|
|
@ -2670,12 +2667,13 @@ TEST(CredentialsTest, |
|
|
|
|
"", // service_account_impersonation_url;
|
|
|
|
|
"https://foo.com:5555/token", // token_url;
|
|
|
|
|
"https://foo.com:5555/token_info", // token_info_url;
|
|
|
|
|
credential_source, // credential_source;
|
|
|
|
|
*credential_source, // credential_source;
|
|
|
|
|
"quota_project_id", // quota_project_id;
|
|
|
|
|
"client_id", // client_id;
|
|
|
|
|
"client_secret", // client_secret;
|
|
|
|
|
"", // workforce_pool_user_project;
|
|
|
|
|
}; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto creds = UrlExternalAccountCredentials::Create(options, {}, &error); |
|
|
|
|
GPR_ASSERT(creds != nullptr); |
|
|
|
|
GPR_ASSERT(GRPC_ERROR_IS_NONE(error)); |
|
|
|
@ -2693,11 +2691,9 @@ TEST(CredentialsTest, |
|
|
|
|
|
|
|
|
|
TEST(CredentialsTest, TestUrlExternalAccountCredsSuccessFormatJson) { |
|
|
|
|
ExecCtx exec_ctx; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
Json credential_source = Json::Parse( |
|
|
|
|
valid_url_external_account_creds_options_credential_source_format_json, |
|
|
|
|
&error); |
|
|
|
|
GPR_ASSERT(GRPC_ERROR_IS_NONE(error)); |
|
|
|
|
auto credential_source = Json::Parse( |
|
|
|
|
valid_url_external_account_creds_options_credential_source_format_json); |
|
|
|
|
GPR_ASSERT(credential_source.ok()); |
|
|
|
|
ExternalAccountCredentials::Options options = { |
|
|
|
|
"external_account", // type;
|
|
|
|
|
"audience", // audience;
|
|
|
|
@ -2705,12 +2701,13 @@ TEST(CredentialsTest, TestUrlExternalAccountCredsSuccessFormatJson) { |
|
|
|
|
"", // service_account_impersonation_url;
|
|
|
|
|
"https://foo.com:5555/token", // token_url;
|
|
|
|
|
"https://foo.com:5555/token_info", // token_info_url;
|
|
|
|
|
credential_source, // credential_source;
|
|
|
|
|
*credential_source, // credential_source;
|
|
|
|
|
"quota_project_id", // quota_project_id;
|
|
|
|
|
"client_id", // client_id;
|
|
|
|
|
"client_secret", // client_secret;
|
|
|
|
|
"", // workforce_pool_user_project;
|
|
|
|
|
}; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto creds = UrlExternalAccountCredentials::Create(options, {}, &error); |
|
|
|
|
GPR_ASSERT(creds != nullptr); |
|
|
|
|
GPR_ASSERT(GRPC_ERROR_IS_NONE(error)); |
|
|
|
@ -2728,10 +2725,9 @@ TEST(CredentialsTest, TestUrlExternalAccountCredsSuccessFormatJson) { |
|
|
|
|
|
|
|
|
|
TEST(CredentialsTest, |
|
|
|
|
TestUrlExternalAccountCredsFailureInvalidCredentialSourceUrl) { |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
Json credential_source = Json::Parse( |
|
|
|
|
invalid_url_external_account_creds_options_credential_source, &error); |
|
|
|
|
GPR_ASSERT(GRPC_ERROR_IS_NONE(error)); |
|
|
|
|
auto credential_source = |
|
|
|
|
Json::Parse(invalid_url_external_account_creds_options_credential_source); |
|
|
|
|
GPR_ASSERT(credential_source.ok()); |
|
|
|
|
ExternalAccountCredentials::Options options = { |
|
|
|
|
"external_account", // type;
|
|
|
|
|
"audience", // audience;
|
|
|
|
@ -2739,12 +2735,13 @@ TEST(CredentialsTest, |
|
|
|
|
"", // service_account_impersonation_url;
|
|
|
|
|
"https://foo.com:5555/token", // token_url;
|
|
|
|
|
"https://foo.com:5555/token_info", // token_info_url;
|
|
|
|
|
credential_source, // credential_source;
|
|
|
|
|
*credential_source, // credential_source;
|
|
|
|
|
"quota_project_id", // quota_project_id;
|
|
|
|
|
"client_id", // client_id;
|
|
|
|
|
"client_secret", // client_secret;
|
|
|
|
|
"", // workforce_pool_user_project;
|
|
|
|
|
}; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto creds = UrlExternalAccountCredentials::Create(options, {}, &error); |
|
|
|
|
GPR_ASSERT(creds == nullptr); |
|
|
|
|
std::string actual_error; |
|
|
|
@ -2756,14 +2753,11 @@ TEST(CredentialsTest, |
|
|
|
|
|
|
|
|
|
TEST(CredentialsTest, TestFileExternalAccountCredsSuccessFormatText) { |
|
|
|
|
ExecCtx exec_ctx; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
char* subject_token_path = write_tmp_jwt_file("test_subject_token"); |
|
|
|
|
Json credential_source = Json::Parse( |
|
|
|
|
absl::StrFormat( |
|
|
|
|
"{\"file\":\"%s\"}", |
|
|
|
|
absl::StrReplaceAll(subject_token_path, {{"\\", "\\\\"}})), |
|
|
|
|
&error); |
|
|
|
|
GPR_ASSERT(GRPC_ERROR_IS_NONE(error)); |
|
|
|
|
auto credential_source = Json::Parse(absl::StrFormat( |
|
|
|
|
"{\"file\":\"%s\"}", |
|
|
|
|
absl::StrReplaceAll(subject_token_path, {{"\\", "\\\\"}}))); |
|
|
|
|
GPR_ASSERT(credential_source.ok()); |
|
|
|
|
ExternalAccountCredentials::Options options = { |
|
|
|
|
"external_account", // type;
|
|
|
|
|
"audience", // audience;
|
|
|
|
@ -2771,12 +2765,13 @@ TEST(CredentialsTest, TestFileExternalAccountCredsSuccessFormatText) { |
|
|
|
|
"", // service_account_impersonation_url;
|
|
|
|
|
"https://foo.com:5555/token", // token_url;
|
|
|
|
|
"https://foo.com:5555/token_info", // token_info_url;
|
|
|
|
|
credential_source, // credential_source;
|
|
|
|
|
*credential_source, // credential_source;
|
|
|
|
|
"quota_project_id", // quota_project_id;
|
|
|
|
|
"client_id", // client_id;
|
|
|
|
|
"client_secret", // client_secret;
|
|
|
|
|
"", // workforce_pool_user_project;
|
|
|
|
|
}; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto creds = FileExternalAccountCredentials::Create(options, {}, &error); |
|
|
|
|
GPR_ASSERT(creds != nullptr); |
|
|
|
|
GPR_ASSERT(GRPC_ERROR_IS_NONE(error)); |
|
|
|
@ -2796,22 +2791,19 @@ TEST(CredentialsTest, TestFileExternalAccountCredsSuccessFormatText) { |
|
|
|
|
|
|
|
|
|
TEST(CredentialsTest, TestFileExternalAccountCredsSuccessFormatJson) { |
|
|
|
|
ExecCtx exec_ctx; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
char* subject_token_path = |
|
|
|
|
write_tmp_jwt_file("{\"access_token\":\"test_subject_token\"}"); |
|
|
|
|
Json credential_source = Json::Parse( |
|
|
|
|
absl::StrFormat( |
|
|
|
|
"{\n" |
|
|
|
|
"\"file\":\"%s\",\n" |
|
|
|
|
"\"format\":\n" |
|
|
|
|
"{\n" |
|
|
|
|
"\"type\":\"json\",\n" |
|
|
|
|
"\"subject_token_field_name\":\"access_token\"\n" |
|
|
|
|
"}\n" |
|
|
|
|
"}", |
|
|
|
|
absl::StrReplaceAll(subject_token_path, {{"\\", "\\\\"}})), |
|
|
|
|
&error); |
|
|
|
|
GPR_ASSERT(GRPC_ERROR_IS_NONE(error)); |
|
|
|
|
auto credential_source = Json::Parse(absl::StrFormat( |
|
|
|
|
"{\n" |
|
|
|
|
"\"file\":\"%s\",\n" |
|
|
|
|
"\"format\":\n" |
|
|
|
|
"{\n" |
|
|
|
|
"\"type\":\"json\",\n" |
|
|
|
|
"\"subject_token_field_name\":\"access_token\"\n" |
|
|
|
|
"}\n" |
|
|
|
|
"}", |
|
|
|
|
absl::StrReplaceAll(subject_token_path, {{"\\", "\\\\"}}))); |
|
|
|
|
GPR_ASSERT(credential_source.ok()); |
|
|
|
|
ExternalAccountCredentials::Options options = { |
|
|
|
|
"external_account", // type;
|
|
|
|
|
"audience", // audience;
|
|
|
|
@ -2819,12 +2811,13 @@ TEST(CredentialsTest, TestFileExternalAccountCredsSuccessFormatJson) { |
|
|
|
|
"", // service_account_impersonation_url;
|
|
|
|
|
"https://foo.com:5555/token", // token_url;
|
|
|
|
|
"https://foo.com:5555/token_info", // token_info_url;
|
|
|
|
|
credential_source, // credential_source;
|
|
|
|
|
*credential_source, // credential_source;
|
|
|
|
|
"quota_project_id", // quota_project_id;
|
|
|
|
|
"client_id", // client_id;
|
|
|
|
|
"client_secret", // client_secret;
|
|
|
|
|
"", // workforce_pool_user_project;
|
|
|
|
|
}; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto creds = FileExternalAccountCredentials::Create(options, {}, &error); |
|
|
|
|
GPR_ASSERT(creds != nullptr); |
|
|
|
|
GPR_ASSERT(GRPC_ERROR_IS_NONE(error)); |
|
|
|
@ -2844,10 +2837,8 @@ TEST(CredentialsTest, TestFileExternalAccountCredsSuccessFormatJson) { |
|
|
|
|
|
|
|
|
|
TEST(CredentialsTest, TestFileExternalAccountCredsFailureFileNotFound) { |
|
|
|
|
ExecCtx exec_ctx; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
Json credential_source = |
|
|
|
|
Json::Parse("{\"file\":\"non_exisiting_file\"}", &error); |
|
|
|
|
GPR_ASSERT(GRPC_ERROR_IS_NONE(error)); |
|
|
|
|
auto credential_source = Json::Parse("{\"file\":\"non_exisiting_file\"}"); |
|
|
|
|
GPR_ASSERT(credential_source.ok()); |
|
|
|
|
ExternalAccountCredentials::Options options = { |
|
|
|
|
"external_account", // type;
|
|
|
|
|
"audience", // audience;
|
|
|
|
@ -2855,12 +2846,13 @@ TEST(CredentialsTest, TestFileExternalAccountCredsFailureFileNotFound) { |
|
|
|
|
"", // service_account_impersonation_url;
|
|
|
|
|
"https://foo.com:5555/token", // token_url;
|
|
|
|
|
"https://foo.com:5555/token_info", // token_info_url;
|
|
|
|
|
credential_source, // credential_source;
|
|
|
|
|
*credential_source, // credential_source;
|
|
|
|
|
"quota_project_id", // quota_project_id;
|
|
|
|
|
"client_id", // client_id;
|
|
|
|
|
"client_secret", // client_secret;
|
|
|
|
|
"", // workforce_pool_user_project;
|
|
|
|
|
}; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto creds = FileExternalAccountCredentials::Create(options, {}, &error); |
|
|
|
|
GPR_ASSERT(creds != nullptr); |
|
|
|
|
GPR_ASSERT(GRPC_ERROR_IS_NONE(error)); |
|
|
|
@ -2881,21 +2873,18 @@ TEST(CredentialsTest, TestFileExternalAccountCredsFailureFileNotFound) { |
|
|
|
|
|
|
|
|
|
TEST(CredentialsTest, TestFileExternalAccountCredsFailureInvalidJsonContent) { |
|
|
|
|
ExecCtx exec_ctx; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
char* subject_token_path = write_tmp_jwt_file("not_a_valid_json_file"); |
|
|
|
|
Json credential_source = Json::Parse( |
|
|
|
|
absl::StrFormat( |
|
|
|
|
"{\n" |
|
|
|
|
"\"file\":\"%s\",\n" |
|
|
|
|
"\"format\":\n" |
|
|
|
|
"{\n" |
|
|
|
|
"\"type\":\"json\",\n" |
|
|
|
|
"\"subject_token_field_name\":\"access_token\"\n" |
|
|
|
|
"}\n" |
|
|
|
|
"}", |
|
|
|
|
absl::StrReplaceAll(subject_token_path, {{"\\", "\\\\"}})), |
|
|
|
|
&error); |
|
|
|
|
GPR_ASSERT(GRPC_ERROR_IS_NONE(error)); |
|
|
|
|
auto credential_source = Json::Parse(absl::StrFormat( |
|
|
|
|
"{\n" |
|
|
|
|
"\"file\":\"%s\",\n" |
|
|
|
|
"\"format\":\n" |
|
|
|
|
"{\n" |
|
|
|
|
"\"type\":\"json\",\n" |
|
|
|
|
"\"subject_token_field_name\":\"access_token\"\n" |
|
|
|
|
"}\n" |
|
|
|
|
"}", |
|
|
|
|
absl::StrReplaceAll(subject_token_path, {{"\\", "\\\\"}}))); |
|
|
|
|
GPR_ASSERT(credential_source.ok()); |
|
|
|
|
ExternalAccountCredentials::Options options = { |
|
|
|
|
"external_account", // type;
|
|
|
|
|
"audience", // audience;
|
|
|
|
@ -2903,12 +2892,13 @@ TEST(CredentialsTest, TestFileExternalAccountCredsFailureInvalidJsonContent) { |
|
|
|
|
"", // service_account_impersonation_url;
|
|
|
|
|
"https://foo.com:5555/token", // token_url;
|
|
|
|
|
"https://foo.com:5555/token_info", // token_info_url;
|
|
|
|
|
credential_source, // credential_source;
|
|
|
|
|
*credential_source, // credential_source;
|
|
|
|
|
"quota_project_id", // quota_project_id;
|
|
|
|
|
"client_id", // client_id;
|
|
|
|
|
"client_secret", // client_secret;
|
|
|
|
|
"", // workforce_pool_user_project;
|
|
|
|
|
}; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto creds = FileExternalAccountCredentials::Create(options, {}, &error); |
|
|
|
|
GPR_ASSERT(creds != nullptr); |
|
|
|
|
GPR_ASSERT(GRPC_ERROR_IS_NONE(error)); |
|
|
|
@ -2931,10 +2921,9 @@ TEST(CredentialsTest, TestFileExternalAccountCredsFailureInvalidJsonContent) { |
|
|
|
|
|
|
|
|
|
TEST(CredentialsTest, TestAwsExternalAccountCredsSuccess) { |
|
|
|
|
ExecCtx exec_ctx; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
Json credential_source = Json::Parse( |
|
|
|
|
valid_aws_external_account_creds_options_credential_source, &error); |
|
|
|
|
GPR_ASSERT(GRPC_ERROR_IS_NONE(error)); |
|
|
|
|
auto credential_source = |
|
|
|
|
Json::Parse(valid_aws_external_account_creds_options_credential_source); |
|
|
|
|
GPR_ASSERT(credential_source.ok()); |
|
|
|
|
ExternalAccountCredentials::Options options = { |
|
|
|
|
"external_account", // type;
|
|
|
|
|
"audience", // audience;
|
|
|
|
@ -2942,12 +2931,13 @@ TEST(CredentialsTest, TestAwsExternalAccountCredsSuccess) { |
|
|
|
|
"", // service_account_impersonation_url;
|
|
|
|
|
"https://foo.com:5555/token", // token_url;
|
|
|
|
|
"https://foo.com:5555/token_info", // token_info_url;
|
|
|
|
|
credential_source, // credential_source;
|
|
|
|
|
*credential_source, // credential_source;
|
|
|
|
|
"quota_project_id", // quota_project_id;
|
|
|
|
|
"client_id", // client_id;
|
|
|
|
|
"client_secret", // client_secret;
|
|
|
|
|
"", // workforce_pool_user_project;
|
|
|
|
|
}; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto creds = AwsExternalAccountCredentials::Create(options, {}, &error); |
|
|
|
|
GPR_ASSERT(creds != nullptr); |
|
|
|
|
GPR_ASSERT(GRPC_ERROR_IS_NONE(error)); |
|
|
|
@ -2965,11 +2955,9 @@ TEST(CredentialsTest, TestAwsExternalAccountCredsSuccess) { |
|
|
|
|
|
|
|
|
|
TEST(CredentialsTest, TestAwsImdsv2ExternalAccountCredsSuccess) { |
|
|
|
|
ExecCtx exec_ctx; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
Json credential_source = Json::Parse( |
|
|
|
|
valid_aws_imdsv2_external_account_creds_options_credential_source, |
|
|
|
|
&error); |
|
|
|
|
GPR_ASSERT(GRPC_ERROR_IS_NONE(error)); |
|
|
|
|
auto credential_source = Json::Parse( |
|
|
|
|
valid_aws_imdsv2_external_account_creds_options_credential_source); |
|
|
|
|
GPR_ASSERT(credential_source.ok()); |
|
|
|
|
ExternalAccountCredentials::Options options = { |
|
|
|
|
"external_account", // type;
|
|
|
|
|
"audience", // audience;
|
|
|
|
@ -2977,12 +2965,13 @@ TEST(CredentialsTest, TestAwsImdsv2ExternalAccountCredsSuccess) { |
|
|
|
|
"", // service_account_impersonation_url;
|
|
|
|
|
"https://foo.com:5555/token", // token_url;
|
|
|
|
|
"https://foo.com:5555/token_info", // token_info_url;
|
|
|
|
|
credential_source, // credential_source;
|
|
|
|
|
*credential_source, // credential_source;
|
|
|
|
|
"quota_project_id", // quota_project_id;
|
|
|
|
|
"client_id", // client_id;
|
|
|
|
|
"client_secret", // client_secret;
|
|
|
|
|
"", // workforce_pool_user_project;
|
|
|
|
|
}; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto creds = AwsExternalAccountCredentials::Create(options, {}, &error); |
|
|
|
|
GPR_ASSERT(creds != nullptr); |
|
|
|
|
GPR_ASSERT(GRPC_ERROR_IS_NONE(error)); |
|
|
|
@ -3002,10 +2991,9 @@ TEST(CredentialsTest, TestAwsImdsv2ExternalAccountCredsSuccess) { |
|
|
|
|
TEST(CredentialsTest, TestAwsExternalAccountCredsSuccessPathRegionEnvKeysUrl) { |
|
|
|
|
ExecCtx exec_ctx; |
|
|
|
|
gpr_setenv("AWS_REGION", "test_regionz"); |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
Json credential_source = Json::Parse( |
|
|
|
|
valid_aws_external_account_creds_options_credential_source, &error); |
|
|
|
|
GPR_ASSERT(GRPC_ERROR_IS_NONE(error)); |
|
|
|
|
auto credential_source = |
|
|
|
|
Json::Parse(valid_aws_external_account_creds_options_credential_source); |
|
|
|
|
GPR_ASSERT(credential_source.ok()); |
|
|
|
|
ExternalAccountCredentials::Options options = { |
|
|
|
|
"external_account", // type;
|
|
|
|
|
"audience", // audience;
|
|
|
|
@ -3013,12 +3001,13 @@ TEST(CredentialsTest, TestAwsExternalAccountCredsSuccessPathRegionEnvKeysUrl) { |
|
|
|
|
"", // service_account_impersonation_url;
|
|
|
|
|
"https://foo.com:5555/token", // token_url;
|
|
|
|
|
"https://foo.com:5555/token_info", // token_info_url;
|
|
|
|
|
credential_source, // credential_source;
|
|
|
|
|
*credential_source, // credential_source;
|
|
|
|
|
"quota_project_id", // quota_project_id;
|
|
|
|
|
"client_id", // client_id;
|
|
|
|
|
"client_secret", // client_secret;
|
|
|
|
|
"", // workforce_pool_user_project;
|
|
|
|
|
}; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto creds = AwsExternalAccountCredentials::Create(options, {}, &error); |
|
|
|
|
GPR_ASSERT(creds != nullptr); |
|
|
|
|
GPR_ASSERT(GRPC_ERROR_IS_NONE(error)); |
|
|
|
@ -3039,10 +3028,9 @@ TEST(CredentialsTest, |
|
|
|
|
TestAwsExternalAccountCredsSuccessPathDefaultRegionEnvKeysUrl) { |
|
|
|
|
ExecCtx exec_ctx; |
|
|
|
|
gpr_setenv("AWS_DEFAULT_REGION", "test_regionz"); |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
Json credential_source = Json::Parse( |
|
|
|
|
valid_aws_external_account_creds_options_credential_source, &error); |
|
|
|
|
GPR_ASSERT(GRPC_ERROR_IS_NONE(error)); |
|
|
|
|
auto credential_source = |
|
|
|
|
Json::Parse(valid_aws_external_account_creds_options_credential_source); |
|
|
|
|
GPR_ASSERT(credential_source.ok()); |
|
|
|
|
ExternalAccountCredentials::Options options = { |
|
|
|
|
"external_account", // type;
|
|
|
|
|
"audience", // audience;
|
|
|
|
@ -3050,12 +3038,13 @@ TEST(CredentialsTest, |
|
|
|
|
"", // service_account_impersonation_url;
|
|
|
|
|
"https://foo.com:5555/token", // token_url;
|
|
|
|
|
"https://foo.com:5555/token_info", // token_info_url;
|
|
|
|
|
credential_source, // credential_source;
|
|
|
|
|
*credential_source, // credential_source;
|
|
|
|
|
"quota_project_id", // quota_project_id;
|
|
|
|
|
"client_id", // client_id;
|
|
|
|
|
"client_secret", // client_secret;
|
|
|
|
|
"", // workforce_pool_user_project;
|
|
|
|
|
}; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto creds = AwsExternalAccountCredentials::Create(options, {}, &error); |
|
|
|
|
GPR_ASSERT(creds != nullptr); |
|
|
|
|
GPR_ASSERT(GRPC_ERROR_IS_NONE(error)); |
|
|
|
@ -3078,10 +3067,9 @@ TEST(CredentialsTest, |
|
|
|
|
// Make sure that AWS_REGION gets used over AWS_DEFAULT_REGION
|
|
|
|
|
gpr_setenv("AWS_REGION", "test_regionz"); |
|
|
|
|
gpr_setenv("AWS_DEFAULT_REGION", "ERROR_REGION"); |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
Json credential_source = Json::Parse( |
|
|
|
|
valid_aws_external_account_creds_options_credential_source, &error); |
|
|
|
|
GPR_ASSERT(GRPC_ERROR_IS_NONE(error)); |
|
|
|
|
auto credential_source = |
|
|
|
|
Json::Parse(valid_aws_external_account_creds_options_credential_source); |
|
|
|
|
GPR_ASSERT(credential_source.ok()); |
|
|
|
|
ExternalAccountCredentials::Options options = { |
|
|
|
|
"external_account", // type;
|
|
|
|
|
"audience", // audience;
|
|
|
|
@ -3089,12 +3077,13 @@ TEST(CredentialsTest, |
|
|
|
|
"", // service_account_impersonation_url;
|
|
|
|
|
"https://foo.com:5555/token", // token_url;
|
|
|
|
|
"https://foo.com:5555/token_info", // token_info_url;
|
|
|
|
|
credential_source, // credential_source;
|
|
|
|
|
*credential_source, // credential_source;
|
|
|
|
|
"quota_project_id", // quota_project_id;
|
|
|
|
|
"client_id", // client_id;
|
|
|
|
|
"client_secret", // client_secret;
|
|
|
|
|
"", // workforce_pool_user_project;
|
|
|
|
|
}; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto creds = AwsExternalAccountCredentials::Create(options, {}, &error); |
|
|
|
|
GPR_ASSERT(creds != nullptr); |
|
|
|
|
GPR_ASSERT(GRPC_ERROR_IS_NONE(error)); |
|
|
|
@ -3117,10 +3106,9 @@ TEST(CredentialsTest, TestAwsExternalAccountCredsSuccessPathRegionUrlKeysEnv) { |
|
|
|
|
gpr_setenv("AWS_ACCESS_KEY_ID", "test_access_key_id"); |
|
|
|
|
gpr_setenv("AWS_SECRET_ACCESS_KEY", "test_secret_access_key"); |
|
|
|
|
gpr_setenv("AWS_SESSION_TOKEN", "test_token"); |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
Json credential_source = Json::Parse( |
|
|
|
|
valid_aws_external_account_creds_options_credential_source, &error); |
|
|
|
|
GPR_ASSERT(GRPC_ERROR_IS_NONE(error)); |
|
|
|
|
auto credential_source = |
|
|
|
|
Json::Parse(valid_aws_external_account_creds_options_credential_source); |
|
|
|
|
GPR_ASSERT(credential_source.ok()); |
|
|
|
|
ExternalAccountCredentials::Options options = { |
|
|
|
|
"external_account", // type;
|
|
|
|
|
"audience", // audience;
|
|
|
|
@ -3128,12 +3116,13 @@ TEST(CredentialsTest, TestAwsExternalAccountCredsSuccessPathRegionUrlKeysEnv) { |
|
|
|
|
"", // service_account_impersonation_url;
|
|
|
|
|
"https://foo.com:5555/token", // token_url;
|
|
|
|
|
"https://foo.com:5555/token_info", // token_info_url;
|
|
|
|
|
credential_source, // credential_source;
|
|
|
|
|
*credential_source, // credential_source;
|
|
|
|
|
"quota_project_id", // quota_project_id;
|
|
|
|
|
"client_id", // client_id;
|
|
|
|
|
"client_secret", // client_secret;
|
|
|
|
|
"", // workforce_pool_user_project;
|
|
|
|
|
}; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto creds = AwsExternalAccountCredentials::Create(options, {}, &error); |
|
|
|
|
GPR_ASSERT(creds != nullptr); |
|
|
|
|
GPR_ASSERT(GRPC_ERROR_IS_NONE(error)); |
|
|
|
@ -3158,10 +3147,9 @@ TEST(CredentialsTest, TestAwsExternalAccountCredsSuccessPathRegionEnvKeysEnv) { |
|
|
|
|
gpr_setenv("AWS_ACCESS_KEY_ID", "test_access_key_id"); |
|
|
|
|
gpr_setenv("AWS_SECRET_ACCESS_KEY", "test_secret_access_key"); |
|
|
|
|
gpr_setenv("AWS_SESSION_TOKEN", "test_token"); |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
Json credential_source = Json::Parse( |
|
|
|
|
valid_aws_external_account_creds_options_credential_source, &error); |
|
|
|
|
GPR_ASSERT(GRPC_ERROR_IS_NONE(error)); |
|
|
|
|
auto credential_source = |
|
|
|
|
Json::Parse(valid_aws_external_account_creds_options_credential_source); |
|
|
|
|
GPR_ASSERT(credential_source.ok()); |
|
|
|
|
ExternalAccountCredentials::Options options = { |
|
|
|
|
"external_account", // type;
|
|
|
|
|
"audience", // audience;
|
|
|
|
@ -3169,12 +3157,13 @@ TEST(CredentialsTest, TestAwsExternalAccountCredsSuccessPathRegionEnvKeysEnv) { |
|
|
|
|
"", // service_account_impersonation_url;
|
|
|
|
|
"https://foo.com:5555/token", // token_url;
|
|
|
|
|
"https://foo.com:5555/token_info", // token_info_url;
|
|
|
|
|
credential_source, // credential_source;
|
|
|
|
|
*credential_source, // credential_source;
|
|
|
|
|
"quota_project_id", // quota_project_id;
|
|
|
|
|
"client_id", // client_id;
|
|
|
|
|
"client_secret", // client_secret;
|
|
|
|
|
"", // workforce_pool_user_project;
|
|
|
|
|
}; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto creds = AwsExternalAccountCredentials::Create(options, {}, &error); |
|
|
|
|
GPR_ASSERT(creds != nullptr); |
|
|
|
|
GPR_ASSERT(GRPC_ERROR_IS_NONE(error)); |
|
|
|
@ -3203,10 +3192,9 @@ TEST(CredentialsTest, |
|
|
|
|
gpr_setenv("AWS_ACCESS_KEY_ID", "test_access_key_id"); |
|
|
|
|
gpr_setenv("AWS_SECRET_ACCESS_KEY", "test_secret_access_key"); |
|
|
|
|
gpr_setenv("AWS_SESSION_TOKEN", "test_token"); |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
Json credential_source = Json::Parse( |
|
|
|
|
valid_aws_external_account_creds_options_credential_source, &error); |
|
|
|
|
GPR_ASSERT(GRPC_ERROR_IS_NONE(error)); |
|
|
|
|
auto credential_source = |
|
|
|
|
Json::Parse(valid_aws_external_account_creds_options_credential_source); |
|
|
|
|
GPR_ASSERT(credential_source.ok()); |
|
|
|
|
ExternalAccountCredentials::Options options = { |
|
|
|
|
"external_account", // type;
|
|
|
|
|
"audience", // audience;
|
|
|
|
@ -3214,12 +3202,13 @@ TEST(CredentialsTest, |
|
|
|
|
"", // service_account_impersonation_url;
|
|
|
|
|
"https://foo.com:5555/token", // token_url;
|
|
|
|
|
"https://foo.com:5555/token_info", // token_info_url;
|
|
|
|
|
credential_source, // credential_source;
|
|
|
|
|
*credential_source, // credential_source;
|
|
|
|
|
"quota_project_id", // quota_project_id;
|
|
|
|
|
"client_id", // client_id;
|
|
|
|
|
"client_secret", // client_secret;
|
|
|
|
|
"", // workforce_pool_user_project;
|
|
|
|
|
}; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto creds = AwsExternalAccountCredentials::Create(options, {}, &error); |
|
|
|
|
GPR_ASSERT(creds != nullptr); |
|
|
|
|
GPR_ASSERT(GRPC_ERROR_IS_NONE(error)); |
|
|
|
@ -3248,10 +3237,9 @@ TEST(CredentialsTest, |
|
|
|
|
gpr_setenv("AWS_ACCESS_KEY_ID", "test_access_key_id"); |
|
|
|
|
gpr_setenv("AWS_SECRET_ACCESS_KEY", "test_secret_access_key"); |
|
|
|
|
gpr_setenv("AWS_SESSION_TOKEN", "test_token"); |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
Json credential_source = Json::Parse( |
|
|
|
|
valid_aws_external_account_creds_options_credential_source, &error); |
|
|
|
|
GPR_ASSERT(GRPC_ERROR_IS_NONE(error)); |
|
|
|
|
auto credential_source = |
|
|
|
|
Json::Parse(valid_aws_external_account_creds_options_credential_source); |
|
|
|
|
GPR_ASSERT(credential_source.ok()); |
|
|
|
|
ExternalAccountCredentials::Options options = { |
|
|
|
|
"external_account", // type;
|
|
|
|
|
"audience", // audience;
|
|
|
|
@ -3259,12 +3247,13 @@ TEST(CredentialsTest, |
|
|
|
|
"", // service_account_impersonation_url;
|
|
|
|
|
"https://foo.com:5555/token", // token_url;
|
|
|
|
|
"https://foo.com:5555/token_info", // token_info_url;
|
|
|
|
|
credential_source, // credential_source;
|
|
|
|
|
*credential_source, // credential_source;
|
|
|
|
|
"quota_project_id", // quota_project_id;
|
|
|
|
|
"client_id", // client_id;
|
|
|
|
|
"client_secret", // client_secret;
|
|
|
|
|
"", // workforce_pool_user_project;
|
|
|
|
|
}; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto creds = AwsExternalAccountCredentials::Create(options, {}, &error); |
|
|
|
|
GPR_ASSERT(creds != nullptr); |
|
|
|
|
GPR_ASSERT(GRPC_ERROR_IS_NONE(error)); |
|
|
|
@ -3287,11 +3276,9 @@ TEST(CredentialsTest, |
|
|
|
|
|
|
|
|
|
TEST(CredentialsTest, |
|
|
|
|
TestAwsExternalAccountCredsFailureUnmatchedEnvironmentId) { |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
Json credential_source = Json::Parse( |
|
|
|
|
invalid_aws_external_account_creds_options_credential_source_unmatched_environment_id, |
|
|
|
|
&error); |
|
|
|
|
GPR_ASSERT(GRPC_ERROR_IS_NONE(error)); |
|
|
|
|
auto credential_source = Json::Parse( |
|
|
|
|
invalid_aws_external_account_creds_options_credential_source_unmatched_environment_id); |
|
|
|
|
GPR_ASSERT(credential_source.ok()); |
|
|
|
|
ExternalAccountCredentials::Options options = { |
|
|
|
|
"external_account", // type;
|
|
|
|
|
"audience", // audience;
|
|
|
|
@ -3299,12 +3286,13 @@ TEST(CredentialsTest, |
|
|
|
|
"", // service_account_impersonation_url;
|
|
|
|
|
"https://foo.com:5555/token", // token_url;
|
|
|
|
|
"https://foo.com:5555/token_info", // token_info_url;
|
|
|
|
|
credential_source, // credential_source;
|
|
|
|
|
*credential_source, // credential_source;
|
|
|
|
|
"quota_project_id", // quota_project_id;
|
|
|
|
|
"client_id", // client_id;
|
|
|
|
|
"client_secret", // client_secret;
|
|
|
|
|
"", // workforce_pool_user_project;
|
|
|
|
|
}; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto creds = AwsExternalAccountCredentials::Create(options, {}, &error); |
|
|
|
|
GPR_ASSERT(creds == nullptr); |
|
|
|
|
std::string expected_error = "environment_id does not match."; |
|
|
|
@ -3317,11 +3305,9 @@ TEST(CredentialsTest, |
|
|
|
|
|
|
|
|
|
TEST(CredentialsTest, TestAwsExternalAccountCredsFailureInvalidRegionUrl) { |
|
|
|
|
ExecCtx exec_ctx; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
Json credential_source = Json::Parse( |
|
|
|
|
invalid_aws_external_account_creds_options_credential_source_invalid_region_url, |
|
|
|
|
&error); |
|
|
|
|
GPR_ASSERT(GRPC_ERROR_IS_NONE(error)); |
|
|
|
|
auto credential_source = Json::Parse( |
|
|
|
|
invalid_aws_external_account_creds_options_credential_source_invalid_region_url); |
|
|
|
|
GPR_ASSERT(credential_source.ok()); |
|
|
|
|
ExternalAccountCredentials::Options options = { |
|
|
|
|
"external_account", // type;
|
|
|
|
|
"audience", // audience;
|
|
|
|
@ -3329,12 +3315,13 @@ TEST(CredentialsTest, TestAwsExternalAccountCredsFailureInvalidRegionUrl) { |
|
|
|
|
"", // service_account_impersonation_url;
|
|
|
|
|
"https://foo.com:5555/token", // token_url;
|
|
|
|
|
"https://foo.com:5555/token_info", // token_info_url;
|
|
|
|
|
credential_source, // credential_source;
|
|
|
|
|
*credential_source, // credential_source;
|
|
|
|
|
"quota_project_id", // quota_project_id;
|
|
|
|
|
"client_id", // client_id;
|
|
|
|
|
"client_secret", // client_secret;
|
|
|
|
|
"", // workforce_pool_user_project;
|
|
|
|
|
}; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto creds = AwsExternalAccountCredentials::Create(options, {}, &error); |
|
|
|
|
GPR_ASSERT(creds != nullptr); |
|
|
|
|
GPR_ASSERT(GRPC_ERROR_IS_NONE(error)); |
|
|
|
@ -3357,11 +3344,9 @@ TEST(CredentialsTest, TestAwsExternalAccountCredsFailureInvalidRegionUrl) { |
|
|
|
|
|
|
|
|
|
TEST(CredentialsTest, TestAwsExternalAccountCredsFailureInvalidUrl) { |
|
|
|
|
ExecCtx exec_ctx; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
Json credential_source = Json::Parse( |
|
|
|
|
invalid_aws_external_account_creds_options_credential_source_invalid_url, |
|
|
|
|
&error); |
|
|
|
|
GPR_ASSERT(GRPC_ERROR_IS_NONE(error)); |
|
|
|
|
auto credential_source = Json::Parse( |
|
|
|
|
invalid_aws_external_account_creds_options_credential_source_invalid_url); |
|
|
|
|
GPR_ASSERT(credential_source.ok()); |
|
|
|
|
ExternalAccountCredentials::Options options = { |
|
|
|
|
"external_account", // type;
|
|
|
|
|
"audience", // audience;
|
|
|
|
@ -3369,12 +3354,13 @@ TEST(CredentialsTest, TestAwsExternalAccountCredsFailureInvalidUrl) { |
|
|
|
|
"", // service_account_impersonation_url;
|
|
|
|
|
"https://foo.com:5555/token", // token_url;
|
|
|
|
|
"https://foo.com:5555/token_info", // token_info_url;
|
|
|
|
|
credential_source, // credential_source;
|
|
|
|
|
*credential_source, // credential_source;
|
|
|
|
|
"quota_project_id", // quota_project_id;
|
|
|
|
|
"client_id", // client_id;
|
|
|
|
|
"client_secret", // client_secret;
|
|
|
|
|
"", // workforce_pool_user_project;
|
|
|
|
|
}; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto creds = AwsExternalAccountCredentials::Create(options, {}, &error); |
|
|
|
|
GPR_ASSERT(creds != nullptr); |
|
|
|
|
GPR_ASSERT(GRPC_ERROR_IS_NONE(error)); |
|
|
|
@ -3396,11 +3382,9 @@ TEST(CredentialsTest, TestAwsExternalAccountCredsFailureInvalidUrl) { |
|
|
|
|
|
|
|
|
|
TEST(CredentialsTest, TestAwsExternalAccountCredsFailureMissingRoleName) { |
|
|
|
|
ExecCtx exec_ctx; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
Json credential_source = Json::Parse( |
|
|
|
|
invalid_aws_external_account_creds_options_credential_source_missing_role_name, |
|
|
|
|
&error); |
|
|
|
|
GPR_ASSERT(GRPC_ERROR_IS_NONE(error)); |
|
|
|
|
auto credential_source = Json::Parse( |
|
|
|
|
invalid_aws_external_account_creds_options_credential_source_missing_role_name); |
|
|
|
|
GPR_ASSERT(credential_source.ok()); |
|
|
|
|
ExternalAccountCredentials::Options options = { |
|
|
|
|
"external_account", // type;
|
|
|
|
|
"audience", // audience;
|
|
|
|
@ -3408,12 +3392,13 @@ TEST(CredentialsTest, TestAwsExternalAccountCredsFailureMissingRoleName) { |
|
|
|
|
"", // service_account_impersonation_url;
|
|
|
|
|
"https://foo.com:5555/token", // token_url;
|
|
|
|
|
"https://foo.com:5555/token_info", // token_info_url;
|
|
|
|
|
credential_source, // credential_source;
|
|
|
|
|
*credential_source, // credential_source;
|
|
|
|
|
"quota_project_id", // quota_project_id;
|
|
|
|
|
"client_id", // client_id;
|
|
|
|
|
"client_secret", // client_secret;
|
|
|
|
|
"", // workforce_pool_user_project;
|
|
|
|
|
}; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto creds = AwsExternalAccountCredentials::Create(options, {}, &error); |
|
|
|
|
GPR_ASSERT(creds != nullptr); |
|
|
|
|
GPR_ASSERT(GRPC_ERROR_IS_NONE(error)); |
|
|
|
@ -3437,11 +3422,9 @@ TEST(CredentialsTest, TestAwsExternalAccountCredsFailureMissingRoleName) { |
|
|
|
|
TEST(CredentialsTest, |
|
|
|
|
TestAwsExternalAccountCredsFailureInvalidRegionalCredVerificationUrl) { |
|
|
|
|
ExecCtx exec_ctx; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
Json credential_source = Json::Parse( |
|
|
|
|
invalid_aws_external_account_creds_options_credential_source_invalid_regional_cred_verification_url, |
|
|
|
|
&error); |
|
|
|
|
GPR_ASSERT(GRPC_ERROR_IS_NONE(error)); |
|
|
|
|
auto credential_source = Json::Parse( |
|
|
|
|
invalid_aws_external_account_creds_options_credential_source_invalid_regional_cred_verification_url); |
|
|
|
|
GPR_ASSERT(credential_source.ok()); |
|
|
|
|
ExternalAccountCredentials::Options options = { |
|
|
|
|
"external_account", // type;
|
|
|
|
|
"audience", // audience;
|
|
|
|
@ -3449,12 +3432,13 @@ TEST(CredentialsTest, |
|
|
|
|
"", // service_account_impersonation_url;
|
|
|
|
|
"https://foo.com:5555/token", // token_url;
|
|
|
|
|
"https://foo.com:5555/token_info", // token_info_url;
|
|
|
|
|
credential_source, // credential_source;
|
|
|
|
|
*credential_source, // credential_source;
|
|
|
|
|
"quota_project_id", // quota_project_id;
|
|
|
|
|
"client_id", // client_id;
|
|
|
|
|
"client_secret", // client_secret;
|
|
|
|
|
"", // workforce_pool_user_project;
|
|
|
|
|
}; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto creds = AwsExternalAccountCredentials::Create(options, {}, &error); |
|
|
|
|
GPR_ASSERT(creds != nullptr); |
|
|
|
|
GPR_ASSERT(GRPC_ERROR_IS_NONE(error)); |
|
|
|
|