|
|
@ -41,9 +41,9 @@ |
|
|
|
#include <grpc/support/time.h> |
|
|
|
#include <grpc/support/time.h> |
|
|
|
|
|
|
|
|
|
|
|
#include "src/core/lib/channel/channel_args.h" |
|
|
|
#include "src/core/lib/channel/channel_args.h" |
|
|
|
|
|
|
|
#include "src/core/lib/gpr/env.h" |
|
|
|
#include "src/core/lib/gpr/string.h" |
|
|
|
#include "src/core/lib/gpr/string.h" |
|
|
|
#include "src/core/lib/gpr/tmpfile.h" |
|
|
|
#include "src/core/lib/gpr/tmpfile.h" |
|
|
|
#include "src/core/lib/gprpp/env.h" |
|
|
|
|
|
|
|
#include "src/core/lib/gprpp/host_port.h" |
|
|
|
#include "src/core/lib/gprpp/host_port.h" |
|
|
|
#include "src/core/lib/gprpp/time.h" |
|
|
|
#include "src/core/lib/gprpp/time.h" |
|
|
|
#include "src/core/lib/gprpp/unique_type_name.h" |
|
|
|
#include "src/core/lib/gprpp/unique_type_name.h" |
|
|
@ -1512,7 +1512,7 @@ void set_google_default_creds_env_var_with_file_contents( |
|
|
|
GPR_ASSERT(creds_file != nullptr); |
|
|
|
GPR_ASSERT(creds_file != nullptr); |
|
|
|
GPR_ASSERT(fwrite(contents, 1, contents_len, creds_file) == contents_len); |
|
|
|
GPR_ASSERT(fwrite(contents, 1, contents_len, creds_file) == contents_len); |
|
|
|
fclose(creds_file); |
|
|
|
fclose(creds_file); |
|
|
|
SetEnv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR, creds_file_name); |
|
|
|
gpr_setenv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR, creds_file_name); |
|
|
|
gpr_free(creds_file_name); |
|
|
|
gpr_free(creds_file_name); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1551,7 +1551,7 @@ TEST(CredentialsTest, TestGoogleDefaultCredsAuthKey) { |
|
|
|
0); |
|
|
|
0); |
|
|
|
GPR_ASSERT(g_test_gce_tenancy_checker_called == false); |
|
|
|
GPR_ASSERT(g_test_gce_tenancy_checker_called == false); |
|
|
|
creds->Unref(); |
|
|
|
creds->Unref(); |
|
|
|
SetEnv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR, ""); /* Reset. */ |
|
|
|
gpr_setenv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR, ""); /* Reset. */ |
|
|
|
grpc_override_well_known_credentials_path_getter(nullptr); |
|
|
|
grpc_override_well_known_credentials_path_getter(nullptr); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1575,7 +1575,7 @@ TEST(CredentialsTest, TestGoogleDefaultCredsRefreshToken) { |
|
|
|
GPR_ASSERT(strcmp(refresh->refresh_token().client_id, |
|
|
|
GPR_ASSERT(strcmp(refresh->refresh_token().client_id, |
|
|
|
"32555999999.apps.googleusercontent.com") == 0); |
|
|
|
"32555999999.apps.googleusercontent.com") == 0); |
|
|
|
creds->Unref(); |
|
|
|
creds->Unref(); |
|
|
|
SetEnv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR, ""); /* Reset. */ |
|
|
|
gpr_setenv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR, ""); /* Reset. */ |
|
|
|
grpc_override_well_known_credentials_path_getter(nullptr); |
|
|
|
grpc_override_well_known_credentials_path_getter(nullptr); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1598,7 +1598,7 @@ TEST(CredentialsTest, TestGoogleDefaultCredsExternalAccountCredentials) { |
|
|
|
reinterpret_cast<const ExternalAccountCredentials*>(creds->call_creds()); |
|
|
|
reinterpret_cast<const ExternalAccountCredentials*>(creds->call_creds()); |
|
|
|
GPR_ASSERT(external != nullptr); |
|
|
|
GPR_ASSERT(external != nullptr); |
|
|
|
creds->Unref(); |
|
|
|
creds->Unref(); |
|
|
|
SetEnv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR, ""); /* Reset. */ |
|
|
|
gpr_setenv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR, ""); /* Reset. */ |
|
|
|
grpc_override_well_known_credentials_path_getter(nullptr); |
|
|
|
grpc_override_well_known_credentials_path_getter(nullptr); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1622,7 +1622,7 @@ TEST(CredentialsTest, |
|
|
|
reinterpret_cast<const ExternalAccountCredentials*>(creds->call_creds()); |
|
|
|
reinterpret_cast<const ExternalAccountCredentials*>(creds->call_creds()); |
|
|
|
GPR_ASSERT(external != nullptr); |
|
|
|
GPR_ASSERT(external != nullptr); |
|
|
|
creds->Unref(); |
|
|
|
creds->Unref(); |
|
|
|
SetEnv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR, ""); /* Reset. */ |
|
|
|
gpr_setenv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR, ""); /* Reset. */ |
|
|
|
grpc_override_well_known_credentials_path_getter(nullptr); |
|
|
|
grpc_override_well_known_credentials_path_getter(nullptr); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1646,7 +1646,7 @@ TEST(CredentialsTest, |
|
|
|
reinterpret_cast<const ExternalAccountCredentials*>(creds->call_creds()); |
|
|
|
reinterpret_cast<const ExternalAccountCredentials*>(creds->call_creds()); |
|
|
|
GPR_ASSERT(external != nullptr); |
|
|
|
GPR_ASSERT(external != nullptr); |
|
|
|
creds->Unref(); |
|
|
|
creds->Unref(); |
|
|
|
SetEnv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR, ""); /* Reset. */ |
|
|
|
gpr_setenv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR, ""); /* Reset. */ |
|
|
|
grpc_override_well_known_credentials_path_getter(nullptr); |
|
|
|
grpc_override_well_known_credentials_path_getter(nullptr); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1673,7 +1673,7 @@ TEST(CredentialsTest, TestGoogleDefaultCredsGce) { |
|
|
|
GRPC_ERROR_NONE, |
|
|
|
GRPC_ERROR_NONE, |
|
|
|
"authorization: Bearer ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_"); |
|
|
|
"authorization: Bearer ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_"); |
|
|
|
grpc_flush_cached_google_default_credentials(); |
|
|
|
grpc_flush_cached_google_default_credentials(); |
|
|
|
SetEnv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR, ""); /* Reset. */ |
|
|
|
gpr_setenv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR, ""); /* Reset. */ |
|
|
|
grpc_override_well_known_credentials_path_getter( |
|
|
|
grpc_override_well_known_credentials_path_getter( |
|
|
|
null_well_known_creds_path_getter); |
|
|
|
null_well_known_creds_path_getter); |
|
|
|
set_gce_tenancy_checker_for_testing(test_gce_tenancy_checker); |
|
|
|
set_gce_tenancy_checker_for_testing(test_gce_tenancy_checker); |
|
|
@ -1709,7 +1709,7 @@ TEST(CredentialsTest, TestGoogleDefaultCredsNonGce) { |
|
|
|
GRPC_ERROR_NONE, |
|
|
|
GRPC_ERROR_NONE, |
|
|
|
"authorization: Bearer ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_"); |
|
|
|
"authorization: Bearer ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_"); |
|
|
|
grpc_flush_cached_google_default_credentials(); |
|
|
|
grpc_flush_cached_google_default_credentials(); |
|
|
|
SetEnv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR, ""); /* Reset. */ |
|
|
|
gpr_setenv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR, ""); /* Reset. */ |
|
|
|
grpc_override_well_known_credentials_path_getter( |
|
|
|
grpc_override_well_known_credentials_path_getter( |
|
|
|
null_well_known_creds_path_getter); |
|
|
|
null_well_known_creds_path_getter); |
|
|
|
set_gce_tenancy_checker_for_testing(test_gce_tenancy_checker); |
|
|
|
set_gce_tenancy_checker_for_testing(test_gce_tenancy_checker); |
|
|
@ -1752,7 +1752,7 @@ int default_creds_gce_detection_httpcli_get_failure_override( |
|
|
|
|
|
|
|
|
|
|
|
TEST(CredentialsTest, TestNoGoogleDefaultCreds) { |
|
|
|
TEST(CredentialsTest, TestNoGoogleDefaultCreds) { |
|
|
|
grpc_flush_cached_google_default_credentials(); |
|
|
|
grpc_flush_cached_google_default_credentials(); |
|
|
|
SetEnv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR, ""); /* Reset. */ |
|
|
|
gpr_setenv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR, ""); /* Reset. */ |
|
|
|
grpc_override_well_known_credentials_path_getter( |
|
|
|
grpc_override_well_known_credentials_path_getter( |
|
|
|
null_well_known_creds_path_getter); |
|
|
|
null_well_known_creds_path_getter); |
|
|
|
set_gce_tenancy_checker_for_testing(test_gce_tenancy_checker); |
|
|
|
set_gce_tenancy_checker_for_testing(test_gce_tenancy_checker); |
|
|
@ -1987,27 +1987,32 @@ TEST(CredentialsTest, TestMetadataPluginFailure) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
TEST(CredentialsTest, TestGetWellKnownGoogleCredentialsFilePath) { |
|
|
|
TEST(CredentialsTest, TestGetWellKnownGoogleCredentialsFilePath) { |
|
|
|
auto home = GetEnv("HOME"); |
|
|
|
char* home = gpr_getenv("HOME"); |
|
|
|
bool restore_home_env = false; |
|
|
|
bool restore_home_env = false; |
|
|
|
#if defined(GRPC_BAZEL_BUILD) && \ |
|
|
|
#if defined(GRPC_BAZEL_BUILD) && \ |
|
|
|
(defined(GPR_POSIX_ENV) || defined(GPR_LINUX_ENV)) |
|
|
|
(defined(GPR_POSIX_ENV) || defined(GPR_LINUX_ENV)) |
|
|
|
// when running under bazel locally, the HOME variable is not set
|
|
|
|
// when running under bazel locally, the HOME variable is not set
|
|
|
|
// so we set it to some fake value
|
|
|
|
// so we set it to some fake value
|
|
|
|
restore_home_env = true; |
|
|
|
restore_home_env = true; |
|
|
|
SetEnv("HOME", "/fake/home/for/bazel"); |
|
|
|
gpr_setenv("HOME", "/fake/home/for/bazel"); |
|
|
|
#endif /* defined(GRPC_BAZEL_BUILD) && (defined(GPR_POSIX_ENV) || \ |
|
|
|
#endif /* defined(GRPC_BAZEL_BUILD) && (defined(GPR_POSIX_ENV) || \ |
|
|
|
defined(GPR_LINUX_ENV)) */ |
|
|
|
defined(GPR_LINUX_ENV)) */ |
|
|
|
std::string path = grpc_get_well_known_google_credentials_file_path(); |
|
|
|
std::string path = grpc_get_well_known_google_credentials_file_path(); |
|
|
|
GPR_ASSERT(!path.empty()); |
|
|
|
GPR_ASSERT(!path.empty()); |
|
|
|
#if defined(GPR_POSIX_ENV) || defined(GPR_LINUX_ENV) |
|
|
|
#if defined(GPR_POSIX_ENV) || defined(GPR_LINUX_ENV) |
|
|
|
restore_home_env = true; |
|
|
|
restore_home_env = true; |
|
|
|
UnsetEnv("HOME"); |
|
|
|
gpr_unsetenv("HOME"); |
|
|
|
path = grpc_get_well_known_google_credentials_file_path(); |
|
|
|
path = grpc_get_well_known_google_credentials_file_path(); |
|
|
|
GPR_ASSERT(path.empty()); |
|
|
|
GPR_ASSERT(path.empty()); |
|
|
|
#endif /* GPR_POSIX_ENV || GPR_LINUX_ENV */ |
|
|
|
#endif /* GPR_POSIX_ENV || GPR_LINUX_ENV */ |
|
|
|
if (restore_home_env) { |
|
|
|
if (restore_home_env) { |
|
|
|
SetOrUnsetEnv("HOME", home); |
|
|
|
if (home) { |
|
|
|
|
|
|
|
gpr_setenv("HOME", home); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
gpr_unsetenv("HOME"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
gpr_free(home); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
TEST(CredentialsTest, TestChannelCredsDuplicateWithoutCallCreds) { |
|
|
|
TEST(CredentialsTest, TestChannelCredsDuplicateWithoutCallCreds) { |
|
|
@ -2985,7 +2990,7 @@ TEST(CredentialsTest, TestAwsImdsv2ExternalAccountCredsSuccess) { |
|
|
|
|
|
|
|
|
|
|
|
TEST(CredentialsTest, TestAwsExternalAccountCredsSuccessPathRegionEnvKeysUrl) { |
|
|
|
TEST(CredentialsTest, TestAwsExternalAccountCredsSuccessPathRegionEnvKeysUrl) { |
|
|
|
ExecCtx exec_ctx; |
|
|
|
ExecCtx exec_ctx; |
|
|
|
SetEnv("AWS_REGION", "test_regionz"); |
|
|
|
gpr_setenv("AWS_REGION", "test_regionz"); |
|
|
|
auto credential_source = |
|
|
|
auto credential_source = |
|
|
|
Json::Parse(valid_aws_external_account_creds_options_credential_source); |
|
|
|
Json::Parse(valid_aws_external_account_creds_options_credential_source); |
|
|
|
GPR_ASSERT(credential_source.ok()); |
|
|
|
GPR_ASSERT(credential_source.ok()); |
|
|
@ -3016,13 +3021,13 @@ TEST(CredentialsTest, TestAwsExternalAccountCredsSuccessPathRegionEnvKeysUrl) { |
|
|
|
kTestPath); |
|
|
|
kTestPath); |
|
|
|
ExecCtx::Get()->Flush(); |
|
|
|
ExecCtx::Get()->Flush(); |
|
|
|
HttpRequest::SetOverride(nullptr, nullptr, nullptr); |
|
|
|
HttpRequest::SetOverride(nullptr, nullptr, nullptr); |
|
|
|
UnsetEnv("AWS_REGION"); |
|
|
|
gpr_unsetenv("AWS_REGION"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
TEST(CredentialsTest, |
|
|
|
TEST(CredentialsTest, |
|
|
|
TestAwsExternalAccountCredsSuccessPathDefaultRegionEnvKeysUrl) { |
|
|
|
TestAwsExternalAccountCredsSuccessPathDefaultRegionEnvKeysUrl) { |
|
|
|
ExecCtx exec_ctx; |
|
|
|
ExecCtx exec_ctx; |
|
|
|
SetEnv("AWS_DEFAULT_REGION", "test_regionz"); |
|
|
|
gpr_setenv("AWS_DEFAULT_REGION", "test_regionz"); |
|
|
|
auto credential_source = |
|
|
|
auto credential_source = |
|
|
|
Json::Parse(valid_aws_external_account_creds_options_credential_source); |
|
|
|
Json::Parse(valid_aws_external_account_creds_options_credential_source); |
|
|
|
GPR_ASSERT(credential_source.ok()); |
|
|
|
GPR_ASSERT(credential_source.ok()); |
|
|
@ -3053,15 +3058,15 @@ TEST(CredentialsTest, |
|
|
|
kTestPath); |
|
|
|
kTestPath); |
|
|
|
ExecCtx::Get()->Flush(); |
|
|
|
ExecCtx::Get()->Flush(); |
|
|
|
HttpRequest::SetOverride(nullptr, nullptr, nullptr); |
|
|
|
HttpRequest::SetOverride(nullptr, nullptr, nullptr); |
|
|
|
UnsetEnv("AWS_DEFAULT_REGION"); |
|
|
|
gpr_unsetenv("AWS_DEFAULT_REGION"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
TEST(CredentialsTest, |
|
|
|
TEST(CredentialsTest, |
|
|
|
TestAwsExternalAccountCredsSuccessPathDuplicateRegionEnvKeysUrl) { |
|
|
|
TestAwsExternalAccountCredsSuccessPathDuplicateRegionEnvKeysUrl) { |
|
|
|
ExecCtx exec_ctx; |
|
|
|
ExecCtx exec_ctx; |
|
|
|
// Make sure that AWS_REGION gets used over AWS_DEFAULT_REGION
|
|
|
|
// Make sure that AWS_REGION gets used over AWS_DEFAULT_REGION
|
|
|
|
SetEnv("AWS_REGION", "test_regionz"); |
|
|
|
gpr_setenv("AWS_REGION", "test_regionz"); |
|
|
|
SetEnv("AWS_DEFAULT_REGION", "ERROR_REGION"); |
|
|
|
gpr_setenv("AWS_DEFAULT_REGION", "ERROR_REGION"); |
|
|
|
auto credential_source = |
|
|
|
auto credential_source = |
|
|
|
Json::Parse(valid_aws_external_account_creds_options_credential_source); |
|
|
|
Json::Parse(valid_aws_external_account_creds_options_credential_source); |
|
|
|
GPR_ASSERT(credential_source.ok()); |
|
|
|
GPR_ASSERT(credential_source.ok()); |
|
|
@ -3092,15 +3097,15 @@ TEST(CredentialsTest, |
|
|
|
kTestPath); |
|
|
|
kTestPath); |
|
|
|
ExecCtx::Get()->Flush(); |
|
|
|
ExecCtx::Get()->Flush(); |
|
|
|
HttpRequest::SetOverride(nullptr, nullptr, nullptr); |
|
|
|
HttpRequest::SetOverride(nullptr, nullptr, nullptr); |
|
|
|
UnsetEnv("AWS_REGION"); |
|
|
|
gpr_unsetenv("AWS_REGION"); |
|
|
|
UnsetEnv("AWS_DEFAULT_REGION"); |
|
|
|
gpr_unsetenv("AWS_DEFAULT_REGION"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
TEST(CredentialsTest, TestAwsExternalAccountCredsSuccessPathRegionUrlKeysEnv) { |
|
|
|
TEST(CredentialsTest, TestAwsExternalAccountCredsSuccessPathRegionUrlKeysEnv) { |
|
|
|
ExecCtx exec_ctx; |
|
|
|
ExecCtx exec_ctx; |
|
|
|
SetEnv("AWS_ACCESS_KEY_ID", "test_access_key_id"); |
|
|
|
gpr_setenv("AWS_ACCESS_KEY_ID", "test_access_key_id"); |
|
|
|
SetEnv("AWS_SECRET_ACCESS_KEY", "test_secret_access_key"); |
|
|
|
gpr_setenv("AWS_SECRET_ACCESS_KEY", "test_secret_access_key"); |
|
|
|
SetEnv("AWS_SESSION_TOKEN", "test_token"); |
|
|
|
gpr_setenv("AWS_SESSION_TOKEN", "test_token"); |
|
|
|
auto credential_source = |
|
|
|
auto credential_source = |
|
|
|
Json::Parse(valid_aws_external_account_creds_options_credential_source); |
|
|
|
Json::Parse(valid_aws_external_account_creds_options_credential_source); |
|
|
|
GPR_ASSERT(credential_source.ok()); |
|
|
|
GPR_ASSERT(credential_source.ok()); |
|
|
@ -3131,17 +3136,17 @@ TEST(CredentialsTest, TestAwsExternalAccountCredsSuccessPathRegionUrlKeysEnv) { |
|
|
|
kTestPath); |
|
|
|
kTestPath); |
|
|
|
ExecCtx::Get()->Flush(); |
|
|
|
ExecCtx::Get()->Flush(); |
|
|
|
HttpRequest::SetOverride(nullptr, nullptr, nullptr); |
|
|
|
HttpRequest::SetOverride(nullptr, nullptr, nullptr); |
|
|
|
UnsetEnv("AWS_ACCESS_KEY_ID"); |
|
|
|
gpr_unsetenv("AWS_ACCESS_KEY_ID"); |
|
|
|
UnsetEnv("AWS_SECRET_ACCESS_KEY"); |
|
|
|
gpr_unsetenv("AWS_SECRET_ACCESS_KEY"); |
|
|
|
UnsetEnv("AWS_SESSION_TOKEN"); |
|
|
|
gpr_unsetenv("AWS_SESSION_TOKEN"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
TEST(CredentialsTest, TestAwsExternalAccountCredsSuccessPathRegionEnvKeysEnv) { |
|
|
|
TEST(CredentialsTest, TestAwsExternalAccountCredsSuccessPathRegionEnvKeysEnv) { |
|
|
|
ExecCtx exec_ctx; |
|
|
|
ExecCtx exec_ctx; |
|
|
|
SetEnv("AWS_REGION", "test_regionz"); |
|
|
|
gpr_setenv("AWS_REGION", "test_regionz"); |
|
|
|
SetEnv("AWS_ACCESS_KEY_ID", "test_access_key_id"); |
|
|
|
gpr_setenv("AWS_ACCESS_KEY_ID", "test_access_key_id"); |
|
|
|
SetEnv("AWS_SECRET_ACCESS_KEY", "test_secret_access_key"); |
|
|
|
gpr_setenv("AWS_SECRET_ACCESS_KEY", "test_secret_access_key"); |
|
|
|
SetEnv("AWS_SESSION_TOKEN", "test_token"); |
|
|
|
gpr_setenv("AWS_SESSION_TOKEN", "test_token"); |
|
|
|
auto credential_source = |
|
|
|
auto credential_source = |
|
|
|
Json::Parse(valid_aws_external_account_creds_options_credential_source); |
|
|
|
Json::Parse(valid_aws_external_account_creds_options_credential_source); |
|
|
|
GPR_ASSERT(credential_source.ok()); |
|
|
|
GPR_ASSERT(credential_source.ok()); |
|
|
@ -3172,10 +3177,10 @@ TEST(CredentialsTest, TestAwsExternalAccountCredsSuccessPathRegionEnvKeysEnv) { |
|
|
|
kTestPath); |
|
|
|
kTestPath); |
|
|
|
ExecCtx::Get()->Flush(); |
|
|
|
ExecCtx::Get()->Flush(); |
|
|
|
HttpRequest::SetOverride(nullptr, nullptr, nullptr); |
|
|
|
HttpRequest::SetOverride(nullptr, nullptr, nullptr); |
|
|
|
UnsetEnv("AWS_REGION"); |
|
|
|
gpr_unsetenv("AWS_REGION"); |
|
|
|
UnsetEnv("AWS_ACCESS_KEY_ID"); |
|
|
|
gpr_unsetenv("AWS_ACCESS_KEY_ID"); |
|
|
|
UnsetEnv("AWS_SECRET_ACCESS_KEY"); |
|
|
|
gpr_unsetenv("AWS_SECRET_ACCESS_KEY"); |
|
|
|
UnsetEnv("AWS_SESSION_TOKEN"); |
|
|
|
gpr_unsetenv("AWS_SESSION_TOKEN"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
TEST(CredentialsTest, |
|
|
|
TEST(CredentialsTest, |
|
|
@ -3183,10 +3188,10 @@ TEST(CredentialsTest, |
|
|
|
std::map<std::string, std::string> emd = { |
|
|
|
std::map<std::string, std::string> emd = { |
|
|
|
{"authorization", "Bearer token_exchange_access_token"}}; |
|
|
|
{"authorization", "Bearer token_exchange_access_token"}}; |
|
|
|
ExecCtx exec_ctx; |
|
|
|
ExecCtx exec_ctx; |
|
|
|
SetEnv("AWS_DEFAULT_REGION", "test_regionz"); |
|
|
|
gpr_setenv("AWS_DEFAULT_REGION", "test_regionz"); |
|
|
|
SetEnv("AWS_ACCESS_KEY_ID", "test_access_key_id"); |
|
|
|
gpr_setenv("AWS_ACCESS_KEY_ID", "test_access_key_id"); |
|
|
|
SetEnv("AWS_SECRET_ACCESS_KEY", "test_secret_access_key"); |
|
|
|
gpr_setenv("AWS_SECRET_ACCESS_KEY", "test_secret_access_key"); |
|
|
|
SetEnv("AWS_SESSION_TOKEN", "test_token"); |
|
|
|
gpr_setenv("AWS_SESSION_TOKEN", "test_token"); |
|
|
|
auto credential_source = |
|
|
|
auto credential_source = |
|
|
|
Json::Parse(valid_aws_external_account_creds_options_credential_source); |
|
|
|
Json::Parse(valid_aws_external_account_creds_options_credential_source); |
|
|
|
GPR_ASSERT(credential_source.ok()); |
|
|
|
GPR_ASSERT(credential_source.ok()); |
|
|
@ -3217,21 +3222,21 @@ TEST(CredentialsTest, |
|
|
|
kTestPath); |
|
|
|
kTestPath); |
|
|
|
ExecCtx::Get()->Flush(); |
|
|
|
ExecCtx::Get()->Flush(); |
|
|
|
HttpRequest::SetOverride(nullptr, nullptr, nullptr); |
|
|
|
HttpRequest::SetOverride(nullptr, nullptr, nullptr); |
|
|
|
UnsetEnv("AWS_DEFAULT_REGION"); |
|
|
|
gpr_unsetenv("AWS_DEFAULT_REGION"); |
|
|
|
UnsetEnv("AWS_ACCESS_KEY_ID"); |
|
|
|
gpr_unsetenv("AWS_ACCESS_KEY_ID"); |
|
|
|
UnsetEnv("AWS_SECRET_ACCESS_KEY"); |
|
|
|
gpr_unsetenv("AWS_SECRET_ACCESS_KEY"); |
|
|
|
UnsetEnv("AWS_SESSION_TOKEN"); |
|
|
|
gpr_unsetenv("AWS_SESSION_TOKEN"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
TEST(CredentialsTest, |
|
|
|
TEST(CredentialsTest, |
|
|
|
TestAwsExternalAccountCredsSuccessPathDuplicateRegionEnvKeysEnv) { |
|
|
|
TestAwsExternalAccountCredsSuccessPathDuplicateRegionEnvKeysEnv) { |
|
|
|
ExecCtx exec_ctx; |
|
|
|
ExecCtx exec_ctx; |
|
|
|
// Make sure that AWS_REGION gets used over AWS_DEFAULT_REGION
|
|
|
|
// Make sure that AWS_REGION gets used over AWS_DEFAULT_REGION
|
|
|
|
SetEnv("AWS_REGION", "test_regionz"); |
|
|
|
gpr_setenv("AWS_REGION", "test_regionz"); |
|
|
|
SetEnv("AWS_DEFAULT_REGION", "ERROR_REGION"); |
|
|
|
gpr_setenv("AWS_DEFAULT_REGION", "ERROR_REGION"); |
|
|
|
SetEnv("AWS_ACCESS_KEY_ID", "test_access_key_id"); |
|
|
|
gpr_setenv("AWS_ACCESS_KEY_ID", "test_access_key_id"); |
|
|
|
SetEnv("AWS_SECRET_ACCESS_KEY", "test_secret_access_key"); |
|
|
|
gpr_setenv("AWS_SECRET_ACCESS_KEY", "test_secret_access_key"); |
|
|
|
SetEnv("AWS_SESSION_TOKEN", "test_token"); |
|
|
|
gpr_setenv("AWS_SESSION_TOKEN", "test_token"); |
|
|
|
auto credential_source = |
|
|
|
auto credential_source = |
|
|
|
Json::Parse(valid_aws_external_account_creds_options_credential_source); |
|
|
|
Json::Parse(valid_aws_external_account_creds_options_credential_source); |
|
|
|
GPR_ASSERT(credential_source.ok()); |
|
|
|
GPR_ASSERT(credential_source.ok()); |
|
|
@ -3262,11 +3267,11 @@ TEST(CredentialsTest, |
|
|
|
kTestPath); |
|
|
|
kTestPath); |
|
|
|
ExecCtx::Get()->Flush(); |
|
|
|
ExecCtx::Get()->Flush(); |
|
|
|
HttpRequest::SetOverride(nullptr, nullptr, nullptr); |
|
|
|
HttpRequest::SetOverride(nullptr, nullptr, nullptr); |
|
|
|
UnsetEnv("AWS_REGION"); |
|
|
|
gpr_unsetenv("AWS_REGION"); |
|
|
|
UnsetEnv("AWS_DEFAULT_REGION"); |
|
|
|
gpr_unsetenv("AWS_DEFAULT_REGION"); |
|
|
|
UnsetEnv("AWS_ACCESS_KEY_ID"); |
|
|
|
gpr_unsetenv("AWS_ACCESS_KEY_ID"); |
|
|
|
UnsetEnv("AWS_SECRET_ACCESS_KEY"); |
|
|
|
gpr_unsetenv("AWS_SECRET_ACCESS_KEY"); |
|
|
|
UnsetEnv("AWS_SESSION_TOKEN"); |
|
|
|
gpr_unsetenv("AWS_SESSION_TOKEN"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
TEST(CredentialsTest, |
|
|
|
TEST(CredentialsTest, |
|
|
|