@ -126,45 +126,6 @@ const char test_refresh_token_str[] =
" \" refresh_token \" : \" 1/Blahblasj424jladJDSGNf-u4Sua3HDA2ngjd42 \" , "
" \" type \" : \" authorized_user \" } " ;
// Test external account credentials.
const char test_external_account_credentials_str [ ] =
" { \" type \" : \" external_account \" , \" audience \" : \" audience \" , \" subject_ "
" token_type \" : \" subject_token_type \" , \" service_account_impersonation_ "
" url \" : \" https://iamcredentials.googleapis.com:5555/ "
" service_account_impersonation_url \" , \" token_url \" : \" https:// "
" sts.googleapis.com:5555/ "
" token \" , \" token_info_url \" : \" https://sts.googleapis.com:5555/ "
" token_info \" , \" credential_source \" :{ \" file \" : "
" \" credentials_file_path \" }, "
" \" quota_project_id \" : \" quota_ "
" project_id \" , \" client_id \" : \" client_id \" , \" client_secret \" : \" client_ "
" secret \" } " ;
const char test_external_account_credentials_multi_pattern_sts_str [ ] =
" { \" type \" : \" external_account \" , \" audience \" : \" audience \" , \" subject_ "
" token_type \" : \" subject_token_type \" , \" service_account_impersonation_ "
" url \" : \" https://sts.test.googleapis.com:5555/ "
" service_account_impersonation_url \" , \" token_url \" : \" https:// "
" test.sts.googleapis.com:5555/token \" , \" token_info_url \" : \" https:// "
" test-sts.googleapis.com:5555/ "
" token_info \" , \" credential_source \" :{ \" file \" : \" credentials_file_path \" }, "
" \" quota_project_id \" : \" quota_ "
" project_id \" , \" client_id \" : \" client_id \" , \" client_secret \" : \" client_ "
" secret \" } " ;
const char test_external_account_credentials_multi_pattern_iam_str [ ] =
" { \" type \" : \" external_account \" , \" audience \" : \" audience \" , \" subject_ "
" token_type \" : \" subject_token_type \" , \" service_account_impersonation_ "
" url \" : \" https://iamcredentials.test.googleapis.com:5555/ "
" service_account_impersonation_url \" , \" token_url \" : \" https:// "
" test.iamcredentials.googleapis.com:5555/ "
" token \" , \" token_info_url \" : \" https:// "
" test-iamcredentials.googleapis.com:5555/ "
" token_info \" , \" credential_source \" :{ \" file \" : \" credentials_file_path \" }, "
" \" quota_project_id \" : \" quota_ "
" project_id \" , \" client_id \" : \" client_id \" , \" client_secret \" : \" client_ "
" secret \" } " ;
const char test_external_account_credentials_psc_sts_str [ ] =
" { \" type \" : \" external_account \" , \" audience \" : \" audience \" , \" subject_ "
" token_type \" : \" subject_token_type \" , \" service_account_impersonation_ "
@ -1611,77 +1572,6 @@ TEST(CredentialsTest, TestGoogleDefaultCredsRefreshToken) {
grpc_override_well_known_credentials_path_getter ( nullptr ) ;
}
TEST ( CredentialsTest , TestGoogleDefaultCredsExternalAccountCredentials ) {
ExecCtx exec_ctx ;
grpc_composite_channel_credentials * creds ;
grpc_flush_cached_google_default_credentials ( ) ;
set_google_default_creds_env_var_with_file_contents (
" google_default_creds_external_account_credentials " ,
test_external_account_credentials_str ) ;
grpc_override_well_known_credentials_path_getter (
null_well_known_creds_path_getter ) ;
creds = reinterpret_cast < grpc_composite_channel_credentials * > (
grpc_google_default_credentials_create ( nullptr ) ) ;
auto * default_creds =
reinterpret_cast < const grpc_google_default_channel_credentials * > (
creds - > inner_creds ( ) ) ;
GPR_ASSERT ( default_creds - > ssl_creds ( ) ! = nullptr ) ;
auto * external =
reinterpret_cast < const ExternalAccountCredentials * > ( creds - > call_creds ( ) ) ;
GPR_ASSERT ( external ! = nullptr ) ;
creds - > Unref ( ) ;
SetEnv ( GRPC_GOOGLE_CREDENTIALS_ENV_VAR , " " ) ; // Reset.
grpc_override_well_known_credentials_path_getter ( nullptr ) ;
}
TEST ( CredentialsTest ,
TestGoogleDefaultCredsExternalAccountCredentialsMultiPatternSts ) {
ExecCtx exec_ctx ;
grpc_composite_channel_credentials * creds ;
grpc_flush_cached_google_default_credentials ( ) ;
set_google_default_creds_env_var_with_file_contents (
" google_default_creds_external_account_credentials_multi_pattern_sts " ,
test_external_account_credentials_multi_pattern_sts_str ) ;
grpc_override_well_known_credentials_path_getter (
null_well_known_creds_path_getter ) ;
creds = reinterpret_cast < grpc_composite_channel_credentials * > (
grpc_google_default_credentials_create ( nullptr ) ) ;
auto * default_creds =
reinterpret_cast < const grpc_google_default_channel_credentials * > (
creds - > inner_creds ( ) ) ;
GPR_ASSERT ( default_creds - > ssl_creds ( ) ! = nullptr ) ;
auto * external =
reinterpret_cast < const ExternalAccountCredentials * > ( creds - > call_creds ( ) ) ;
GPR_ASSERT ( external ! = nullptr ) ;
creds - > Unref ( ) ;
SetEnv ( GRPC_GOOGLE_CREDENTIALS_ENV_VAR , " " ) ; // Reset.
grpc_override_well_known_credentials_path_getter ( nullptr ) ;
}
TEST ( CredentialsTest ,
TestGoogleDefaultCredsExternalAccountCredentialsMultiPatternIam ) {
ExecCtx exec_ctx ;
grpc_composite_channel_credentials * creds ;
grpc_flush_cached_google_default_credentials ( ) ;
set_google_default_creds_env_var_with_file_contents (
" google_default_creds_external_account_credentials_multi_pattern_iam " ,
test_external_account_credentials_multi_pattern_iam_str ) ;
grpc_override_well_known_credentials_path_getter (
null_well_known_creds_path_getter ) ;
creds = reinterpret_cast < grpc_composite_channel_credentials * > (
grpc_google_default_credentials_create ( nullptr ) ) ;
auto * default_creds =
reinterpret_cast < const grpc_google_default_channel_credentials * > (
creds - > inner_creds ( ) ) ;
GPR_ASSERT ( default_creds - > ssl_creds ( ) ! = nullptr ) ;
auto * external =
reinterpret_cast < const ExternalAccountCredentials * > ( creds - > call_creds ( ) ) ;
GPR_ASSERT ( external ! = nullptr ) ;
creds - > Unref ( ) ;
SetEnv ( GRPC_GOOGLE_CREDENTIALS_ENV_VAR , " " ) ; // Reset.
grpc_override_well_known_credentials_path_getter ( nullptr ) ;
}
TEST ( CredentialsTest , TestGoogleDefaultCredsExternalAccountCredentialsPscSts ) {
ExecCtx exec_ctx ;
grpc_composite_channel_credentials * creds ;