
    S                        d dl Z d dlmZ d dlZd dlZd dlZd dlZd dlm	Z	 d dlm
Z
 d dlmZ d dlmZ d dlmZ d dlmZ dZd	Zd
ZdZdZdZg dZg dZ G d dej0                        Z G d de      Zd Zy)    N)_helpers)
exceptions)external_account)	transport)DEFAULT_UNIVERSE_DOMAIN)
TokenStatez9gl-python/3.7 auth/1.1 auth-request-type/at cred-type/impzgl-python/3.7 auth/1.1usernamepasswordzdXNlcm5hbWU6cGFzc3dvcmQ=z1service-1234@service-name.iam.gserviceaccount.com)zR//iam.googleapis.com/locations/global/workforcePools/pool-id/providers/provider-idzN//iam.googleapis.com/locations/eu/workforcePools/pool-id/providers/provider-idz\//iam.googleapis.com/locations/eu/workforcePools/workloadIdentityPools/providers/provider-id)	%identitynamespace:1f12345:my_providerzi//iam.googleapis.com/projects/123456/locations/global/workloadIdentityPools/pool-id/providers/provider-idze//iam.googleapis.com/projects/123456/locations/eu/workloadIdentityPools/pool-id/providers/provider-idzp//iam.googleapis.com/projects/123456/locations/global/workloadIdentityPools/workforcePools/providers/provider-idzM//iamgoogleapis.com/locations/eu/workforcePools/pool-id/providers/provider-idzM//iam.googleapiscom/locations/eu/workforcePools/pool-id/providers/provider-idzK//iam.googleapis.com/locations/workforcePools/pool-id/providers/provider-idzM//iam.googleapis.com/locations/eu/workforcePool/pool-id/providers/provider-idzK//iam.googleapis.com/locations//workforcePool/pool-id/providers/provider-idc                   $     e Zd Z fdZd Z xZS )CredentialsImplc                 :    t        t        | 
  di | d| _        y )Nr    )superr   __init___counter)selfkwargs	__class__s     Uplatform/gsutil/third_party/google-auth-library-python/tests/test_external_account.pyr   zCredentialsImpl.__init__L   s    ot-77    c                 f    | j                   }| xj                   dz  c_         dj                  |      S )N   zsubject_token_{})r   format)r   requestcounters      r   retrieve_subject_tokenz&CredentialsImpl.retrieve_subject_tokenP   s*    --!((11r   )__name__
__module____qualname__r   r   __classcell__)r   s   @r   r   r   K   s    2r   r   c            
          e Zd ZdZdZdZdZdZdj                  eee      Z	dj                  ee      Z
dZd	Zd
ZddiZddddddZddddZdZddj                  e      z   ZddgZddddd iZd!Zd"Zeed#d$d%d&d'd(d)Zed*d*d*d*d*d*d*i ef	d+       Ze	 	 	 	 	 	 	 d{d,       Zeej<                  d*d*d*d*d*fd-       Ze	 d|d.       Z e	 d|d/       Z!ed0        Z"d1 Z#d2 Z$d3 Z%d4 Z&d5 Z'd6 Z(d7 Z)d8 Z*d9 Z+d: Z,d; Z-d< Z.d= Z/d> Z0d? Z1d@ Z2dA Z3dB Z4dC Z5dD Z6dE Z7e8jr                  ju                  dFe;      dG        Z<e8jr                  ju                  dFe=      dH        Z>e8jr                  ju                  dFe=      dI        Z?e8jr                  ju                  dFe;      dJ        Z@e8jr                  ju                  dFe=      dK        ZAe8jr                  ju                  dFe=      dL        ZBe8jr                  ju                  dMdNdOg       eCj                  dPeEQ       eCj                  dReFj                  j                  Q      dS                      ZH eCj                  dPeEQ       eCj                  dReFj                  j                  Q       eCj                  dTdUQ       eCj                  dVdWQ      dX                             ZI eCj                  dPeEQ       eCj                  dReFj                  j                  Q      dY               ZJ eCj                  dPeEQ       eCj                  dReFj                  j                  Q      dZ               ZK eCj                  dPeEQ       eCj                  dReFj                  j                  Q      d[               ZL eCj                  d\eMQ       eCj                  dPeEQ      d]               ZN eCj                  d\eMQ       eCj                  dPeEQ       eCj                  dTdUQ       eCj                  dVdWQ      d^                             ZO eCj                  d\eMQ       eCj                  dPeEQ      d_               ZP eCj                  dPeEQ      d`        ZQ eCj                  dPeEQ      da        ZRdb ZSdc ZTdd ZU eCj                  dPeEQ      de        ZV eCj                  d\eMQ       eCj                  dPeEQ      df               ZW eCj                  d\eMQ       eCj                  dPeEQ      dg               ZXdh ZYdi ZZdj Z[dk Z\dl Z]dm Z^dn Z_do Z` eCj                  dR      dp        Za eCj                  dR      dq        Zbe8jr                  ju                  dFg dr      ds        Zcdt Zddu Zedv Zf eCj                  d\eMQ       eCj                  dPeEQ      dw               Zg eCj                  dPeEQ      dx        Zh eCj                  d\eMQ       eCj                  dPeEQ      dy               Zidz Zjy*)}TestCredentialsz#https://sts.googleapis.com/v1/tokenz(https://sts.googleapis.com/v1/introspect123456POOL_IDPROVIDER_IDzW//iam.googleapis.com/projects/{}/locations/global/workloadIdentityPools/{}/providers/{}zD//iam.googleapis.com/locations/global/workforcePools/{}/providers/{}"WORKFORCE_POOL_USER_PROJECT_NUMBERz$urn:ietf:params:oauth:token-type:jwtz)urn:ietf:params:oauth:token-type:id_tokenfilez/var/run/secrets/goog.id/tokenACCESS_TOKEN-urn:ietf:params:oauth:token-type:access_tokenBearer  scope1 scope2)access_tokenissued_token_type
token_type
expires_inscopeinvalid_requestzInvalid subject tokenz#https://tools.ietf.org/html/rfc6749)errorerror_description	error_uriQUOTA_PROJECT_IDz<https://us-east1-iamcredentials.googleapis.com/v1/projects/-z'/serviceAccounts/{}:generateAccessTokenscope1scope2r4   i  z$Request contains an invalid argumentINVALID_ARGUMENT)codemessagestatusz
my-proj-idz8https://cloudresourcemanager.googleapis.com/v1/projects/ACTIVEzproject-namez2018-11-06T04:42:54.109Zfolder12345678901)typeid)projectNumber	projectIdlifecycleStatename
createTimeparentNc
                     t        | j                  | j                  | j                  |||| j                  ||||||	      S )N)audiencesubject_token_type	token_urltoken_info_url!service_account_impersonation_url%service_account_impersonation_optionscredential_source	client_idclient_secretquota_project_idscopesdefault_scopesuniverse_domain)r   AUDIENCESUBJECT_TOKEN_TYPE	TOKEN_URLCREDENTIAL_SOURCE)
clsrQ   rR   rS   rM   rT   rU   rN   rO   rV   s
             r   make_credentialsz TestCredentials.make_credentials   sL     \\"55mm).O2W!33'-)+
 	
r   c                 ~    t        | j                  | j                  | j                  || j                  ||||||      S )N)rJ   rK   rL   rN   rP   rQ   rR   rS   rT   rU   workforce_pool_user_project)r   WORKFORCE_AUDIENCEWORKFORCE_SUBJECT_TOKEN_TYPErY   rZ   )r[   rQ   rR   rS   rT   rU   rN   r^   s           r   make_workforce_pool_credentialsz/TestCredentials.make_workforce_pool_credentials   sH     ++"??mm.O!33'-)(C
 	
r   c                    t        j                  t        j                  d      }||_        t        j                  |      j                  d      |_        |g}|rft        j                  t        j                  d      }	||	_        t        j                  |      j                  d      |	_        |j                  |	       |rft        j                  t        j                  d      }
||
_        t        j                  |      j                  d      |
_        |j                  |
       t        j                  t        j                        }||_        |S )NT)instanceutf-8)mockcreate_autospecr   Responser=   jsondumpsencodedataappendRequestside_effect)r[   r=   rk   impersonation_statusimpersonation_datacloud_resource_manager_statuscloud_resource_manager_datatoken_response	responsesimpersonation_responsecloud_resource_manager_responser   s               r   make_mock_requestz!TestCredentials.make_mock_request   s$    --i.@.@4P &"jj.55g>#$	  %)%9%9""T&" -A")*.**5G*H*O*OPW*X"'34 ).2.B.B""T/+ 6S+237::+4fWo ,0 <=&&y'8'89'r   c                 |   |d   | j                   k(  sJ |d   dk(  sJ |d   |k(  sJ |
|d   |k(  sJ d|vsJ |d   J t        j                  j                  |d         }|D ]-  \  }}|j	                  d      ||j	                  d         k(  r-J  t        |      t        |j                               k(  sJ y NurlmethodPOSTheaderscertbodyrd   )rY   urllibparse	parse_qsldecodelenkeys)r[   request_kwargsr}   request_datar~   body_tupleskvs           r   assert_token_request_kwargsz+TestCredentials.assert_token_request_kwargs   s     e$555h'6111i(G333!&)T111///f%111ll,,^F-CD!FQ88G$QXXg5F(GGGG ";3|'8'8':#;;;;r   c                     |d   | j                   k(  sJ |d   dk(  sJ |d   |k(  sJ |
|d   |k(  sJ d|vsJ |d   J t        j                  |d   j                  d            }||k(  sJ y ry   )!SERVICE_ACCOUNT_IMPERSONATION_URLrh   loadsr   )r[   r   r}   r   r~   	body_jsons         r   #assert_impersonation_request_kwargsz3TestCredentials.assert_impersonation_request_kwargs   s     e$(M(MMMMh'6111i(G333!&)T111///f%111JJ~f5<<WEF	L(((r   c                 f    |d   | j                   |z   k(  sJ |d   dk(  sJ |d   |k(  sJ d|vsJ y )Nrz   r{   GETr}   r   )CLOUD_RESOURCE_MANAGER_URL)r[   r   project_numberr}   s       r   &assert_resource_manager_request_kwargsz6TestCredentials.assert_resource_manager_request_kwargs  sV     e$(F(F(WWWWh'5000i(G333^+++r   c                     | j                         }|j                         rJ d|_        |j                         dddk(  sJ | j                  |_        |j                         ddt
        dk(  sJ y )N/path/to/filezexternal account credentials)rP   credential_type)rP   r   	principal)r\   get_cred_info_cred_file_pathr   "_service_account_impersonation_urlSERVICE_ACCOUNT_EMAILr   credentialss     r   test_get_cred_infoz"TestCredentials.test_get_cred_info  s    ++-,,...&5#((*!0=/
 
 	
 
 22 	6 ((*!0=./
 
 	
 
r   c                 t    | j                         }d|_        |j                         }|j                  dk(  sJ y )Nr   )r\   r   
_make_copy)r   r   	cred_copys      r   test__make_copy_get_cred_infoz-TestCredentials.test__make_copy_get_cred_info)  s:    ++-&5#**,	((O;;;r   c                 T   | j                  | j                        }|j                  sJ |j                  sJ |j                  rJ |j
                  rJ |j                  rJ |j                  rJ |j                  rJ |j                  sJ |j                  rJ |j                  rJ y NrN   )r\   r   
_token_urlr   tokenvalidexpiryexpiredrT   requires_scopesrS   rM   r   s     r   test_default_statez"TestCredentials.test_default_state/  s    ++.2.T.T , 

 %%%%====$$$$$$$$%%%%&&&&%%%%****////-----r   c                 
   t        j                  t              5 }t        | j                  | j
                  | j                  | j                  | j                         d d d        j                  d      sJ y # 1 sw Y   xY w)NrJ   rK   rL   rP   r^   zPworkforce_pool_user_project should not be set for non-workforce pool credentials)
pytestraises
ValueErrorr   rW   rX   rY   rZ   WORKFORCE_POOL_USER_PROJECTmatch)r   excinfos     r   2test_nonworkforce_with_workforce_pool_user_projectzBTestCredentials.test_nonworkforce_with_workforce_pool_user_projectD  sl    ]]:&'#'#:#:.."&"8"8,0,L,L ' }}
 	
 
 '&s   AA99Bc                     | j                         }|j                  rJ |j                  sJ |j                  dg      }|j	                  dg      sJ |j                  rJ y )Nemailr\   rT   r   with_scopes
has_scopesr   r   scoped_credentialss      r   test_with_scopesz TestCredentials.test_with_scopesS  si    ++-%%%%****(44gY?!,,gY777%55555r   c                 0   | j                  | j                        }|j                  rJ |j                  sJ |j	                  dg      }|j                  dg      sJ |j                  rJ |j                  j                  d      | j                  k(  sJ y )Nr^   r   r^   )ra   r   rT   r   r   r   infogetr   s      r   test_with_scopes_workforce_poolz/TestCredentials.test_with_scopes_workforce_pool^  s    ::(,(H(H ; 
 %%%%****(44gY?!,,gY777%5555##''(EF//0	
0r   c                 :   | j                         }|j                  rJ |j                  sJ |j                  dgdg      }|j	                  dg      sJ |j	                  dg      rJ |j                  rJ |j                  dgk(  sJ |j
                  dgk(  sJ y )Nr   profilerU   )r\   rT   r   r   r   rU   r   s      r   .test_with_scopes_using_user_and_default_scopesz>TestCredentials.test_with_scopes_using_user_and_default_scopeso  s    ++-%%%%****(44Iyk 5 
 ",,gY777%00)===%5555!((WI555!00YK???r   c                     | j                         }|j                  rJ |j                  sJ |j                  d dg      }|j	                  dg      sJ |j                  rJ y )Nr   r   r   r   s      r   *test_with_scopes_using_default_scopes_onlyz:TestCredentials.test_with_scopes_using_default_scopes_only  sn    ++-%%%%****(44T9+4V!,,i[999%55555r   c                 6   | j                  t        t        | j                  | j                  | j
                  dg| j                  ddi      }t        j                  j                  t        j                  dd       5 }|j                  dgdg       d d d        j                  | j                  | j                  | j                   | j
                  | j"                  | j                  ddit        t        | j                  dgdgt$        	       y # 1 sw Y   ~xY w)
Ndefault1token_lifetime_seconds
  )rQ   rR   rS   rT   rM   rU   rN   rO   r   return_valuer   default2rJ   rK   rL   rM   rP   rN   rO   rQ   rR   rS   rT   rU   rV   )r\   	CLIENT_IDCLIENT_SECRETr7   SCOPESTOKEN_INFO_URLr   re   patchobjectr   Credentialsr   assert_called_once_withrW   rX   rY   rZ   r   )r   r   	mock_inits      r   (test_with_scopes_full_options_propagatedz8TestCredentials.test_with_scopes_full_options_propagated  s   ++'!22;;..&<.2.T.T3KT2R , 	
 ZZ((*4  
##WI
|<
 	))]]#66nn.."44.2.T.T3KT2R'!229&<3 	* 	

 
s   =DDc                     | j                         }d}|j                  | j                  k(  sJ |j                  |      }|j                  |k(  sJ y )N&https://eu-sts.googleapis.com/v1/token)r\   r   rY   with_token_urir   r   new_token_uricreds_with_new_token_uris       r   test_with_token_uriz#TestCredentials.test_with_token_uri  sR    ++-@%%777#.#=#=m#L '22mCCCr   c                    | j                  | j                        }d}|j                  | j                  k(  sJ |j	                  |      }|j                  |k(  sJ |j
                  j                  d      | j                  k(  sJ y )Nr   r   r^   )ra   r   r   rY   r   r   r   r   s       r   "test_with_token_uri_workforce_poolz2TestCredentials.test_with_token_uri_workforce_pool  s    ::(,(H(H ; 
 A%%777#.#=#=m#L '22mCCC$))--.KL//0	
0r   c                     | j                         }|j                  rJ |j                  rJ |j                  d      }|j                  dk(  sJ y )Nproject-foo)r\   rT   rS   with_quota_projectr   r   quota_project_credss      r   test_with_quota_projectz'TestCredentials.test_with_quota_project  sS    ++-%%%%////)<<]K"33}DDDr   c                    | j                  | j                        }|j                  rJ |j                  rJ |j	                  d      }|j                  dk(  sJ |j
                  j                  d      | j                  k(  sJ y )Nr   r   r^   )ra   r   rT   rS   r   r   r   r   s      r   &test_with_quota_project_workforce_poolz6TestCredentials.test_with_quota_project_workforce_pool  s    ::(,(H(H ; 
 %%%%////)<<]K"33}DDD$$(()FG//0	
0r   c                 f   | j                  t        t        | j                  | j                  | j
                  dg| j                  ddi      }t        j                  j                  t        j                  dd       5 }|j                  d      }|j                  | j                  | j                  | j                   | j                  | j"                  | j                  ddit        t        | j                  | j
                  dgt$               |j&                  dk(  sJ 	 d d d        y # 1 sw Y   y xY w)	Nr   r   r   )rQ   rR   rM   rS   rT   rU   rN   rO   r   r   r   r   )r\   r   r   r   r7   r   r   re   r   r   r   r   r   r   rW   rX   rY   rZ   r   rS   )r   r   r   new_creds       r   /test_with_quota_project_full_options_propagatedz?TestCredentials.test_with_quota_project_full_options_propagated  s   ++'..!22;;&<.2.T.T3KT2R , 	
 ZZ((*4  
"55mDH --#'#:#:..#22"&"8"8262X2X7OQU6V#+!%!6!6{{ *| 7 . $ ,,===3
 
 
s   =B D''D0c                     | j                  d      }|j                  d| j                  | j                  | j                  | j
                  j                         ddk(  sJ y )Ndummy_universe.comrV   r   )rA   rJ   rK   rL   rP   rV   )r\   r   rW   rX   rY   rZ   copyr   s     r   	test_infozTestCredentials.test_info	  sb    ++<P+Q&"&"9"9!%!7!7!<!<!>3$
 
 	
 
r   c                     | j                  d      }|j                  dk(  sJ | j                         }|j                  t        k(  sJ y )Nr   r   )r\   rV   r   r   s     r   test_universe_domainz$TestCredentials.test_universe_domain  sN    ++<P+Q**.BBBB++-**.EEEEr   c                 h    | j                         }|j                  d      }|j                  dk(  sJ y )Nr   )r\   with_universe_domainrV   )r   r   new_credentialss      r   test_with_universe_domainz)TestCredentials.test_with_universe_domain  s6    ++-%::;OP..2FFFFr   c           	          | j                  | j                        }|j                  d| j                  | j                  | j
                  | j                  j                         | j                  t        dk(  sJ y )Nr   r   )rA   rJ   rK   rL   rP   r^   rV   )	ra   r   r   r_   r`   rY   rZ   r   r   r   s     r   test_info_workforce_poolz(TestCredentials.test_info_workforce_pool!  sy    ::(,(H(H ; 
 &//"&"C"C!%!7!7!<!<!>+/+K+K6$
 
 	
 
r   c                    | j                  t        t        | j                  | j                  | j
                  ddi      }|j                  d| j                  | j                  | j                  | j                  | j
                  ddi| j                  j                         | j                  t        t        t        dk(  sJ y )Nr   r   )rQ   rR   rS   rM   rN   rO   r   )rA   rJ   rK   rL   rM   rN   service_account_impersonationrP   rS   rQ   rR   rV   )r\   r   r   r7   r   r   r   rW   rX   rY   rZ   r   r   r   s     r   test_info_with_full_optionsz+TestCredentials.test_info_with_full_options0  s    ++'!22...2.T.T3KT2R , 
 &"&"9"9"11151W1W.F-M!%!7!7!<!<!> $ 5 5"*6$
 
 	
 
r   c                 @    | j                         }|j                  J y N)r\   service_account_emailr   s     r   0test_service_account_email_without_impersonationz@TestCredentials.test_service_account_email_without_impersonationI  s"    ++-00888r   c                 f    | j                  | j                        }|j                  t        k(  sJ y r   )r\   r   r  r   r   s     r   -test_service_account_email_with_impersonationz=TestCredentials.test_service_account_email_with_impersonationN  s7    ++.2.T.T , 
 004IIIIr   rJ   c                 ~    t        || j                  | j                  | j                        }|j                  du sJ y NrJ   rK   rL   rP   Fr   rX   rY   rZ   is_userr   rJ   r   s      r   test_is_user_with_non_usersz+TestCredentials.test_is_user_with_non_usersU  s>    %#66nn"44	
 ""e+++r   c                 ~    t        || j                  | j                  | j                        }|j                  du sJ y Nr	  Tr
  r  s      r   test_is_user_with_usersz'TestCredentials.test_is_user_with_users`  s>    %#66nn"44	
 ""d***r   c                     t        || j                  | j                  | j                  | j                        }|j
                  du sJ y )NrJ   rK   rL   rP   rN   F)r   rX   rY   rZ   r   r  r  s      r   )test_is_user_with_users_and_impersonationz9TestCredentials.test_is_user_with_users_and_impersonationk  sI     &#66nn"44.2.T.T
 ""e+++r   c                 ~    t        || j                  | j                  | j                        }|j                  du sJ y r  r   rX   rY   rZ   is_workforce_poolr  s      r   %test_is_workforce_pool_with_non_usersz5TestCredentials.test_is_workforce_pool_with_non_users{  s>    %#66nn"44	
 ,,555r   c                 ~    t        || j                  | j                  | j                        }|j                  du sJ y r  r  r  s      r   !test_is_workforce_pool_with_usersz1TestCredentials.test_is_workforce_pool_with_users  s>    %#66nn"44	
 ,,444r   c                     t        || j                  | j                  | j                  | j                        }|j
                  du sJ y )Nr  T)r   rX   rY   rZ   r   r  r  s      r   3test_is_workforce_pool_with_users_and_impersonationzCTestCredentials.test_is_workforce_pool_with_users_and_impersonation  sI     &#66nn"44.2.T.T
 ,,444r   mock_expires_inr   2800z/google.auth.metrics.python_and_auth_lib_versionr   zgoogle.auth._helpers.utcnowc                 >   | j                   j                         }||d<   t        j                  j                  t        j                  t        |            z   }ddd}d| j                  dd| j                  d	}| j                  t        j                  |
      }| j                         }	|	j                  |       | j                  |j                  d   ||       |	j                  sJ |	j                   |k(  sJ |	j"                  rJ |	j$                  |d   k(  sJ y )Nr1   seconds!application/x-www-form-urlencodedTgl-python/3.7 auth/1.1 google-byoid-sdk sa-impersonation/false config-lifetime/falseContent-Typex-goog-api-client/urn:ietf:params:oauth:grant-type:token-exchanger*   subject_token_0
grant_typerJ   requested_token_typesubject_tokenrK   r=   rk   r   r.   )SUCCESS_RESPONSEr   datetimemin	timedeltaintrW   rX   rw   http_clientOKr\   refreshr   	call_argsr   r   r   r   )
r   unused_utcnowmock_auth_lib_valuer  responseexpected_expiryr}   r   r   r   s
             r   (test_refresh_without_client_auth_successz8TestCredentials.test_refresh_without_client_auth_success  s    ((--/!0"++//(2D2D(3
 
 @!w

 L$S."&"9"9
 ((X(N++-G$(():):1)=wU    !!_444&&&&  H^$<<<<r   z7google.auth.external_account.Credentials._mtls_requiredTzEgoogle.auth.external_account.Credentials._get_mtls_cert_and_key_pathszpath/to/cert.pemzpath/to/key.pemc                 8   | j                   j                         }d|d<   t        j                  j                  t        j                  |d         z   }ddd}d| j
                  dd	| j                  d
}| j                  t        j                  |      }	| j                         }
|
j                  |	       d}| j                  |	j                  d   |||       |
j                  sJ |
j                  |k(  sJ |
j                   rJ |
j"                  |d   k(  sJ y )Nr   r1   r  r!  r"  r#  r&  r*   r'  r(  r,  r;  r   r.   )r-  r   r.  r/  r0  rW   rX   rw   r2  r3  r\   r4  r   r5  r   r   r   r   )r    mock_get_mtls_cert_and_key_pathsmock_mtls_requiredr6  r7  r8  r9  r}   r   r   r   expected_cert_paths               r   test_refresh_with_mtlsz&TestCredentials.test_refresh_with_mtls  s-   & ((--/!%"++//(2D2D\*3
 
 @!w

 L$S."&"9"9
 ((X(N++-G$D((a '<9K	
     !!_444&&&&  H^$<<<<r   c                    | j                   j                         }d|d<   t        j                  j                  t        j                  |d         z   }ddd}d| j
                  dd	| j                  t        j                  j                  t        j                  d
| j                  i            d}| j                  t        j                  |      }| j!                  | j                        }|j#                  |       | j%                  |j&                  d   ||       |j(                  sJ |j*                  |k(  sJ |j,                  rJ |j.                  |d   k(  sJ y )Nr   r1   r  r!  r"  r#  r&  r*   r'  userProject)r)  rJ   r*  r+  rK   optionsr,  r   r   r.   )r-  r   r.  r/  r0  r_   r`   r   r   quoterh   ri   r   rw   r2  r3  ra   r4  r   r5  r   r   r   r   )	r   r6  test_auth_lib_valuer8  r9  r}   r   r   r   s	            r   2test_refresh_workforce_without_client_auth_successzBTestCredentials.test_refresh_workforce_without_client_auth_success  s\    ((--/!%"++//(2D2D\*3
 
 @!w

 L//$S."&"C"C||))

M4+K+KLM	
 ((X(N::(,(H(H ; 
 	G$(():):1)=wU    !!_444&&&&  H^$<<<<r   c                    | j                   j                         }d|d<   t        j                  j                  t        j                  |d         z   }ddj                  t              dd}d| j                  d	d
| j                  d}| j                  t        j                  |      }| j                  t        t        | j                        }|j!                  |       | j#                  |j$                  d   ||       |j&                  sJ |j(                  |k(  sJ |j*                  rJ |j,                  |d   k(  sJ y Nr   r1   r  r!  Basic {}r"  r$  Authorizationr%  r&  r*   r'  r(  r,  )rQ   rR   r^   r   r.   )r-  r   r.  r/  r0  r   BASIC_AUTH_ENCODINGr_   r`   rw   r2  r3  ra   r   r   r   r4  r   r5  r   r   r   r   )	r   r6  r7  r8  r9  r}   r   r   r   s	            r   /test_refresh_workforce_with_client_auth_successz?TestCredentials.test_refresh_workforce_with_client_auth_success   sH    ((--/!%"++//(2D2D\*3
 
 @'../BC!w
 L//$S."&"C"C
 ((X(N::'(,(H(H ; 
 	G$(():):1)=wU    !!_444&&&&  H^$<<<<r   c                 r   | j                   j                         }d|d<   t        j                  j                  t        j                  |d         z   }ddj                  t              dd}d| j                  d	d
| j                  d}| j                  t        j                  |      }| j                  t        t        d       }|j                  |       | j!                  |j"                  d   ||       |j$                  sJ |j&                  |k(  sJ |j(                  rJ |j*                  |d   k(  sJ y rH  )r-  r   r.  r/  r0  r   rL  r_   r`   rw   r2  r3  ra   r   r   r4  r   r5  r   r   r   r   )	r   r6  mock_lib_version_valuer8  r9  r}   r   r   r   s	            r   Htest_refresh_workforce_with_client_auth_and_no_workforce_project_successzXTestCredentials.test_refresh_workforce_with_client_auth_and_no_workforce_project_successJ  sB    ((--/!%"++//(2D2D\*3
 
 @'../BC!w
 L//$S."&"C"C
 ((X(N::'(, ; 
 	G$(():):1)=wU    !!_444&&&&  H^$<<<<r   z:google.auth.metrics.token_request_access_token_impersonatec                    t        j                         j                  d      t        j                  d      z   j                  d      dz   }t        j                  j                  |d      }| j                  j                         }dd	d
}d| j                  dd| j                  dd}d|d}ddj                  |d         t        dd}	d | j                  dd}
| j                  t        j                   |t        j                   |      }| j#                  | j$                  | j                        }|j'                  |       t)        |j*                        dk(  sJ | j-                  |j*                  d   d   ||       | j/                  |j*                  d   d   |	|
       |j0                  sJ |j2                  |k(  sJ |j4                  rJ |j6                  |d   k(  sJ y )Nr   microsecondr   r  TZ%Y-%m-%dT%H:%M:%SZr!  Sgl-python/3.7 auth/1.1 google-byoid-sdk sa-impersonation/true config-lifetime/falser#  r&  r*   r'  #https://www.googleapis.com/auth/iamr)  rJ   r*  r+  rK   r2   SA_ACCESS_TOKENaccessToken
expireTimeapplication/json	Bearer {}r.   0x0r$  authorizationr%  x-allowed-locations3600s	delegatesr2   lifetimer=   rk   ro   rp   rN   rT      r   r\  r   utcnowreplacer.  r0  	isoformatstrptimer-  r   rW   rX   r   5IMPERSONATE_ACCESS_TOKEN_REQUEST_METRICS_HEADER_VALUEr   rw   r2  r3  r\   r   r4  r   call_args_listr   r   r   r   r   r   r   mock_metrics_header_valuer7  expire_timer9  rs   token_headerstoken_request_dataru   impersonation_headersimpersonation_request_datar   r   s                r   6test_refresh_impersonation_without_client_auth_successzFTestCredentials.test_refresh_impersonation_without_client_auth_successt  s	    OO%%!%4x7I7IRV7WW
)C.3 #++44[BVW..335?!v

 L$S."&"9"9:
 -%"

 /(//~0NO!V#(	!
 [[&
" ((>>!,5	 ) 
 ++.2.T.T;; , 

 	G$ 7))*a///((""1%a(-9K	
 	00""1%a(!&	

     !!_444&&&&  $:=$IIIIr   c                    t        j                         j                  d      t        j                  d      z   j                  d      dz   }t        j                  j                  |d      }| j                  j                         }dd	d
}d| j                  dd| j                  dd}	d|d}
ddj                  |d         t        dd}d | j                  dd}| j                  t        j                   |t        j                   |
      }| j#                  | j$                  | j                        }|j'                  |       t)        |j*                        dk(  sJ d}| j-                  |j*                  d   d   ||	|       | j/                  |j*                  d   d   |||       |j0                  sJ |j2                  |k(  sJ |j4                  rJ |j6                  |
d   k(  sJ y )Nr   rR  r   r  rT  rU  rV  r!  rW  r#  r&  r*   r'  rX  rY  rZ  r[  r^  r_  r.   r`  ra  rd  re  rh  ri  rj  r;  r   r\  rk  )r   r=  r>  rs  r7  rt  r9  rs   ru  rv  ru   rw  rx  r   r   expected_cert_pathss                   r   ,test_refresh_impersonation_with_mtls_successz<TestCredentials.test_refresh_impersonation_with_mtls_success  s   0 OO%%!%4x7I7IRV7WW
)C.3 #++44[BVW..335?!v

 L$S."&"9"9:
 -%"

 /(//~0NO!V#(	!
 [[&
" ((>>!,5	 ) 
 ++.2.T.T;; , 

 	G$ 7))*a///E((""1%a(		
 	00""1%a(!&		
     !!_444&&&&  $:=$IIIIr   c                 ^   t        j                         j                  d      t        j                  d      z   j                  d      dz   }t        j                  j                  |d      }| j                  j                         }dd	d
}d| j                  dd| j                  dt        j                  j                  t        j                  d| j                   i            d}d|d}ddj#                  |d         t$        dd}	d | j&                  dd}
| j)                  t*        j,                  |t*        j,                  |      }| j/                  | j0                  | j&                  | j                         }|j3                  |       t5        |j6                        dk(  sJ | j9                  |j6                  d   d   ||       | j;                  |j6                  d   d   |	|
       |j<                  sJ |j>                  |k(  sJ |j@                  rJ |jB                  |d   k(  sJ y )Nr   rR  r   r  rT  rU  rV  r!  rW  r#  r&  r*   r'  rX  rB  r)  rJ   r*  r+  rK   r2   rC  rZ  r[  r^  r_  r.   r`  ra  rd  re  rh  )rN   rT   r^   rj  r   r\  )"r   rl  rm  r.  r0  rn  ro  r-  r   r_   r`   r   r   rD  rh   ri   r   r   rp  r   rw   r2  r3  ra   r   r4  r   rq  r   r   r   r   r   r   rr  s                r   @test_refresh_workforce_impersonation_without_client_auth_successzPTestCredentials.test_refresh_workforce_impersonation_without_client_auth_success"  s=    OO%%!%4x7I7IRV7WW
)C.3 #++44[BVW..335?!v

 L//$S."&"C"C:||))

M4+K+KLM

 -%"

 /(//~0NO!V#(	!
 [[&
" ((>>!,5	 ) 
 ::.2.T.T;;(,(H(H ; 
 	G$ 7))*a///((""1%a(-9K	
 	00""1%a(!&	

     !!_444&&&&  $:=$IIIIr   c                    ddd}d| j                   ddd| j                  d}| j                  t        j                  | j
                  	      }| j                  d
dgdg      }|j                  |       | j                  |j                  d   ||       |j                  sJ |j                  rJ |j                  | j
                  d   k(  sJ |j                  d
dg      sJ |j                  dg      rJ y )Nr!  r"  r#  r&  r*   r-   r'  r)  rJ   r*  r2   r+  rK   r,  r8   r9   ignoredrT   rU   r   r.   rW   rX   rw   r2  r3  r-  r\   r4  r   r5  r   r   r   r   r   r7  r}   r   r   r   s         r   Stest_refresh_without_client_auth_success_explicit_user_scopes_ignore_default_scopeszcTestCredentials.test_refresh_without_client_auth_success_explicit_user_scopes_ignore_default_scopesu  s    @!w

 L$S$."&"9"9
 ((>>(=(= ) 
 ++h'%; , 
 	G$(():):1)=wU    &&&&  D$9$9.$IIII%%x&:;;;))9+6666r   c                    ddd}d| j                   ddd| j                  d}| j                  t        j                  | j
                  	      }| j                  d d
dg      }|j                  |       | j                  |j                  d   ||       |j                  sJ |j                  rJ |j                  | j
                  d   k(  sJ |j                  d
dg      sJ y )Nr!  r"  r#  r&  r*   r-   r'  r  r,  r8   r9   r  r   r.   r  r  s         r   Etest_refresh_without_client_auth_success_explicit_default_scopes_onlyzUTestCredentials.test_refresh_without_client_auth_success_explicit_default_scopes_only  s    @!w

 L$S$."&"9"9
 ((>>(=(= ) 
 ++$h/ , 
 	G$(():):1)=wU    &&&&  D$9$9.$IIII%%x&:;;;r   c                 j   | j                  t        j                  | j                        }| j	                         }t        j                  t        j                        5 }|j                  |       d d d        j                  d      sJ |j                  rJ |j                  J y # 1 sw Y   9xY w)Nr,  zWError code invalid_request: Invalid subject token - https://tools.ietf.org/html/rfc6749)rw   r2  BAD_REQUESTERROR_RESPONSEr\   r   r   r   
OAuthErrorr4  r   r   r   r   r   r   r   s       r   &test_refresh_without_client_auth_errorz6TestCredentials.test_refresh_without_client_auth_error  s    ((**1D1D ) 
 ++-]]:001W( 2 }}f
 	
 
 &&&&  ((( 21s   B))B2c                    | j                  t        j                  | j                  t        j                  | j
                        }| j                  | j                  | j                        }t        j                  t        j                        5 }|j                  |       d d d        j                  d      sJ |j                  rJ |j                   J y # 1 sw Y   9xY w)Nrh  ri  z*Unable to acquire impersonated credentials)rw   r2  r3  r-  r  IMPERSONATION_ERROR_RESPONSEr\   r   r   r   r   r   RefreshErrorr4  r   r   r   r  s       r   4test_refresh_impersonation_without_client_auth_errorzDTestCredentials.test_refresh_impersonation_without_client_auth_error  s    ((>>&&!,!8!8#@@	 ) 
 ++.2.T.T;; , 

 ]]:223w( 4 }}JKKK&&&&  ((( 43s   CC#c                 .   | j                  d| j                        }t        j                  t        j
                        5 }|j                  d        d d d        j                  d      sJ |j                  rJ |j                  J y # 1 sw Y   9xY w)Nz0https://iamcredentials.googleapis.com/v1/invalidri  zLUnable to determine target principal from service account impersonation URL.)
r\   r   r   r   r   r  r4  r   r   r   )r   r   r   s      r   9test_refresh_impersonation_invalid_impersonated_url_errorzITestCredentials.test_refresh_impersonation_invalid_impersonated_url_error  s    ++.`;; , 

 ]]:223w% 4 }}[
 	
 
 &&&&  ((( 43s   BBc                    ddj                  t              dd}d| j                  dd| j                  d}| j	                  t
        j                  | j                  	      }| j                  t        t        
      }|j                  |       | j                  |j                  d   ||       |j                  sJ |j                  rJ |j                   | j                  d   k(  sJ y )Nr!  rI  r"  rJ  r&  r*   r'  r(  r,  )rQ   rR   r   r.   )r   rL  rW   rX   rw   r2  r3  r-  r\   r   r   r4  r   r5  r   r   r   r  s         r   %test_refresh_with_client_auth_successz5TestCredentials.test_refresh_with_client_auth_success  s     @'../BC!w
 L$S."&"9"9
 ((>>(=(= ) 
 ++} , 
 	G$(():):1)=wU    &&&&  D$9$9.$IIIIr   c                    t        j                         j                  d      t        j                  d      z   j                  d      dz   }t        j                  j                  |d      }| j                  j                         }dd	j                  t              d
d}d| j                  dd| j                  dd}d|d}ddj                  |d         t        dd}	d | j                  dd}
| j                  t         j"                  |t         j"                  |      }| j%                  t&        t(        | j*                  | j                  dg      }|j-                  |       t/        |j0                        dk(  sJ | j3                  |j0                  d   d   ||       | j5                  |j0                  d   d   |	|
       |j6                  sJ |j8                  |k(  sJ |j:                  rJ |j<                  |d   k(  sJ y ) Nr   rR  r   r  rT  rU  rV  r!  rI  rW  rJ  r&  r*   r'  rX  rY  rZ  r[  r^  r_  r.   r`  ra  rd  re  rh  r  rQ   rR   rN   rT   rU   rj  r   r\  r   rl  rm  r.  r0  rn  ro  r-  r   r   rL  rW   rX   rp  r   rw   r2  r3  r\   r   r   r   r4  r   rq  r   r   r   r   r   r   rr  s                r   Itest_refresh_impersonation_with_client_auth_success_ignore_default_scopeszYTestCredentials.test_refresh_impersonation_with_client_auth_success_ignore_default_scopes  s#    OO%%!%4x7I7IRV7WW
)C.3 #++44[BVW..335?'../BC!v
 L$S."&"9"9:
 -%"

 /(//~0NO!V#(	!
 [[&
" ((>>!,5	 ) 
 ++'.2.T.T;;%; , 
 	G$ 7))*a///((""1%a(-9K	
 	00""1%a(!&	

     !!_444&&&&  $:=$IIIIr   c                    t        j                         j                  d      t        j                  d      z   j                  d      dz   }t        j                  j                  |d      }| j                  j                         }dd	j                  t              d
d}d| j                  dd| j                  dd}d|d}ddj                  |d         t        dd}	d | j                  dd}
| j                  t         j"                  |t         j"                  |      }| j%                  t&        t(        | j*                  d | j                        }|j-                  |       t/        |j0                        dk(  sJ | j3                  |j0                  d   d   ||       | j5                  |j0                  d   d   |	|
       |j6                  sJ |j8                  |k(  sJ |j:                  rJ |j<                  |d   k(  sJ y )Nr   rR  r   r  rT  rU  rV  r!  rI  rW  rJ  r&  r*   r'  rX  rY  rZ  r[  r^  r_  r.   r`  ra  rd  re  rh  r  rj  r   r\  r  rr  s                r   Ftest_refresh_impersonation_with_client_auth_success_use_default_scopeszVTestCredentials.test_refresh_impersonation_with_client_auth_success_use_default_scopesb  s!    OO%%!%4x7I7IRV7WW
)C.3 #++44[BVW..335?'../BC!v
 L$S."&"9"9:
 -%"

 /(//~0NO!V#(	!
 [[&
" ((>>!,5	 ) 
 ++'.2.T.T;; , 
 	G$ 7))*a///((""1%a(-9K	
 	00""1%a(!&	

     !!_444&&&&  $:=$IIIIr   c                    i }| j                  t        j                  | j                        }| j	                         }|j                  |       |j                  |       |dj                  | j                  d         ddk(  sJ y )Nr,  r_  r.   r`  rb  rc  )rw   r2  r3  r-  r\   r4  applyr   r   r}   r   r   s       r   #test_apply_without_quota_project_idz3TestCredentials.test_apply_without_quota_project_id  s    ((>>(=(= ) 
 ++-G$'"(//0E0En0UV#(
 
 	
 
r   c                 &   i }| j                  t        j                  | j                        }| j	                  | j
                        }|j                  |       |j                  |       |dj                  | j                  d         ddk(  sJ y )Nr,  r   r_  r.   r`  r  )	rw   r2  r3  r-  ra   r   r4  r  r   r  s       r   -test_apply_workforce_without_quota_project_idz=TestCredentials.test_apply_workforce_without_quota_project_id  s    ((>>(=(= ) 
 ::(,(H(H ; 
 	G$'"(//0E0En0UV#(
 
 	
 
r   c                    t        j                         j                  d      t        j                  d      z   j                  d      dz   }d|d}| j                  t        j                  | j                  j                         t        j                  |	      }| j                  | j                  | j                  
      }i }|j                  |       |j                  |       |dj!                  |d         ddk(  sJ y )Nr   rR  r,   r  rT  rU  rZ  r[  rh  ri  r_  r\  r`  r  )r   rl  rm  r.  r0  rn  rw   r2  r3  r-  r   r\   r   r   r4  r  r   r   rt  ru   r   r   r}   s         r   1test_apply_impersonation_without_quota_project_idzATestCredentials.test_apply_impersonation_without_quota_project_id  s    OO%%!%4x7I7IRV7WW
)C.3
 -%"
 ((>>&&++-!,5	 ) 
 ++.2.T.T;; , 
 G$'"(//0F}0UV#(
 
 	
 
r   c                 B   ddi}| j                  t        j                  | j                        }| j	                  | j
                        }|j                  |       |j                  |       |ddj                  | j                  d         | j
                  ddk(  sJ y )	Notherheader-valuer,  )rS   r_  r.   r`  r  rb  x-goog-user-projectrc  )	rw   r2  r3  r-  r\   r7   r4  r  r   r  s       r    test_apply_with_quota_project_idz0TestCredentials.test_apply_with_quota_project_id  s    N+((>>(=(= ) 
 ++T=R=R+SG$'"#(//0E0En0UV#'#8#8#(	
 
 	
 
r   c                 :   t        j                         j                  d      t        j                  d      z   j                  d      dz   }d|d}| j                  t        j                  | j                  j                         t        j                  |	      }| j                  | j                  | j                  | j                  
      }ddi}|j                  |       |j!                  |       |ddj#                  |d         | j                  ddk(  sJ y )Nr   rR  r,   r  rT  rU  rZ  r[  rh  rN   rT   rS   r  r  r_  r\  r`  r  )r   rl  rm  r.  r0  rn  rw   r2  r3  r-  r   r\   r   r   r7   r4  r  r   r  s         r   .test_apply_impersonation_with_quota_project_idz>TestCredentials.test_apply_impersonation_with_quota_project_id  s   OO%%!%4x7I7IRV7WW
)C.3
 -%"
 ((>>&&++-!,5	 ) 
 ++.2.T.T;;!22 , 

 N+G$'"#(//0F}0UV#'#8#8#(	
 
 	
 
r   c                 n   ddi}| j                  t        j                  | j                        }| j	                         }|j                  |dd|       |ddj                  | j                  d         dd	k(  sJ |j                  |dd|       |ddj                  | j                  d         dd	k(  sJ y )
Nr  r  r,  r|   https://example.com/apir_  r.   r`  r  rb  rc  )rw   r2  r3  r-  r\   before_requestr   r  s       r   test_before_requestz#TestCredentials.test_before_request*  s    N+((>>(=(= ) 
 ++- 	""7F4MwW#(//0E0En0UV#(
 
 	
 
 	""7F4MwW#(//0E0En0UV#(
 
 	
 
r   c                    ddi}| j                  t        j                  | j                        }| j	                  | j
                        }|j                  |dd|       |ddj                  | j                  d         d	d
k(  sJ |j                  |dd|       |ddj                  | j                  d         d	d
k(  sJ y )Nr  r  r,  r   r|   r  r_  r.   r`  r  )rw   r2  r3  r-  ra   r   r  r   r  s       r   test_before_request_workforcez-TestCredentials.test_before_request_workforceC  s    N+((>>(=(= ) 
 ::(,(H(H ; 

 	""7F4MwW#(//0E0En0UV#(
 
 	
 
 	""7F4MwW#(//0E0En0UV#(
 
 	
 
r   c                 >   t        j                         j                  d      t        j                  d      z   j                  d      dz   }d|d}| j                  t        j                  | j                  j                         t        j                  |	      }d
di}| j                  | j                        }|j                  |dd|       |ddj                  |d         ddk(  sJ |j                  |dd|       |ddj                  |d         ddk(  sJ y )Nr   rR  r,   r  rT  rU  rZ  r[  rh  r  r  r   r|   r  r_  r\  r`  r  )r   rl  rm  r.  r0  rn  rw   r2  r3  r-  r   r\   r   r  r   )r   rt  ru   r   r}   r   s         r   !test_before_request_impersonationz1TestCredentials.test_before_request_impersonation^  sA   OO%%!%4x7I7IRV7WW
)C.3
 -%"
 ((>>&&++-!,5	 ) 
 N+++.2.T.T , 

 	""7F4MwW#(//0F}0UV#(
 
 	
 
 	""7F4MwW#(//0F}0UV#(
 
 	
 
r   c                    i }| j                  t        j                  | j                        }| j	                         }d|_        t        j                  j                  |_        t        j                  j                  t        j                  z   t        j                  d      z   |_        |j                  sJ |j                  rJ |j                  t         j"                  k(  sJ |j%                  |dd|       |ddd	k(  sJ t        j                  j                  t        j                  d      z   |_        |j                  rJ |j                  sJ |j                  t         j&                  k(  sJ |j%                  |dd|       |j                  t         j"                  k(  sJ |d
j)                  | j                  d         dd	k(  sJ y )Nr,  r   r   r  r|   r  Bearer tokenr`  r  r_  r.   )rw   r2  r3  r-  r\   r   r.  r/  r   r   REFRESH_THRESHOLDr0  r   r   r   token_stater   FRESHr  STALEr   )r   rl  r}   r   r   s        r   test_before_request_expiredz+TestCredentials.test_before_request_expired  s   ((>>(=(= ) 
 ++-#&//33 !!(()  +, 	     &&&&&&**:*::::""7F4MwW +#(
 
 	
 
 '//33h6H6HQR6SS$$$$""""&&**:*::::""7F4MwW&&**:*:::: (//0E0En0UV#(
 
 	
 
r   c                    i }t         j                   j                  t        j                  d      z   j                  d      dz   }d|d}| j	                  t
        j                  | j                  j                         t
        j                  |      }| j                  | j                        }d	|_        t         j                   j                  |_        t         j                   j                  t        j                  z   t        j                  d
      z   |_        |j                   sJ |j"                  rJ |j$                  t&        j(                  k(  sJ |j+                  |dd|       |j$                  t&        j(                  k(  sJ |dddk(  sJ t         j                   j                  t        j                  d
      z   |_        |j                   rJ |j"                  sJ |j$                  t&        j,                  k(  sJ |j+                  |dd|       |j$                  t&        j(                  k(  sJ |j+                  |dd|       |dj/                  |d         ddk(  sJ y )Ni  r  rT  rU  rZ  r[  rh  r   r   r   r|   r  r  r`  r  r_  r\  )r.  r/  r0  rn  rw   r2  r3  r-  r   r\   r   r   r   r   r  r   r   r   r  r   r  r  r  r   )r   rl  r}   rt  ru   r   r   s          r   )test_before_request_impersonation_expiredz9TestCredentials.test_before_request_impersonation_expired  sU   !!H$6$6t$DD
)C.3
 -%"
 ((>>&&++-!,5	 ) 
 ++.2.T.T , 
 $&//33 !!(()  +, 	     &&&&&&**:*::::""7F4MwW&&**:*:::: +#(
 
 	
 
 '//33h6H6HQR6SS$$$$""""&&**:*::::""7F4MwW&&**:*::::""7F4MwW (//0F}0UV#(
 
 	
 
r   )r   z//iam.googleapis.com/projectsz//iam.googleapis.com/projects/z#//iam.googleapis.com/project/123456z%//iam.googleapis.com/projects//123456z+//iam.googleapis.com/prefix_projects/123456z+//iam.googleapis.com/projects_suffix/123456c                     t        || j                  | j                  | j                        }|j                  J |j                  d       J y Nr	  )r   rX   rY   rZ   r   get_project_idr  s      r   "test_project_number_indeterminablez2TestCredentials.test_project_number_indeterminable  sU     &#66nn"44	
 ))111))$/777r   c                     t        | j                  | j                  | j                  | j                        }|j
                  | j                  k(  sJ y r  )r   rW   rX   rY   rZ   r   PROJECT_NUMBERr   s     r    test_project_number_determinablez0TestCredentials.test_project_number_determinable  sH    %]]#66nn"44	
 ))T-@-@@@@r   c                     t        | j                  | j                  | j                  | j                  | j
                        }|j                  J y )Nr   )r   r_   r`   rY   rZ   r   r   r   s     r   test_project_number_workforcez-TestCredentials.test_project_number_workforce  sK    %,,#@@nn"44(,(H(H
 ))111r   c                     t        | j                  | j                  | j                  | j                        }|j                  d       J y r  )r   rW   rX   rY   rZ   r  r   s     r   test_project_id_without_scopesz.TestCredentials.test_project_id_without_scopes!  sE    %]]#66nn"44	
 ))$/777r   c           	         | j                   j                         }ddd}d| j                  dd| j                  dd}t	        j
                         j                  d	
      t        j                  d      z   j                  d      dz   }t        j                  j                  |d      }d|d}d| j                  dj                  |d         t        dd}	d | j                  dd}
| j                  t         j"                  | j                   j                         t         j"                  |t         j"                  | j$                        }| j'                  | j(                  | j                  | j                        }|j+                  |      }|| j,                  k(  sJ t/        |j0                        dk(  sJ | j3                  |j0                  d	   d   ||       | j5                  |j0                  d   d   |	|
       |j6                  sJ |j8                  |k(  sJ |j:                  rJ |j<                  |d   k(  sJ | j?                  |j0                  d   d   | j@                  | j                  dj                  |d         dd       |j+                  |      }|| j,                  k(  sJ t/        |j0                        dk(  sJ y ) Nr!  rW  r#  r&  r*   r'  rX  rY  r   rR  r,   r  rT  rU  rV  rZ  r[  r^  r_  r.   r`  )r$  r  rb  r%  rc  rd  re  )r=   rk   ro   rp   rq   rr   r     r   r\  rj  r  rb  rc  )!r-  r   rW   rX   r   rl  rm  r.  r0  rn  ro  r7   r   rp  r   rw   r2  r3  'CLOUD_RESOURCE_MANAGER_SUCCESS_RESPONSEr\   r   r  
PROJECT_IDr   rq  r   r   r   r   r   r   r   r  )r   rs  r7  rs   ru  rv  rt  r9  ru   rw  rx  r   r   
project_ids                 r   2test_get_project_id_cloud_resource_manager_successzBTestCredentials.test_get_project_id_cloud_resource_manager_success,  s    ..335?!v

 L$S."&"9"9:
 OO%%!%4x7I7IRV7WW
)C.3 #++44[BVW,%"

 /#'#8#8(//~0NO!V#(!
 [[&
" ((>>&&++-!,5*5..(,(T(T ) 
 ++.2.T.T;;!22 , 
 !//8
T__,,,7))*a///((""1%a(-9K	
 	00""1%a(!&	
     !!_444&&&&  $:=$IIII33""1%a('+'<'<!,!3!3*=9" (-
	
 !//8
T__,,,7))*a///r   c                 $   ddd}d| j                   dd| j                  dt        j                  j	                  t        j                  d| j                  i            d	}| j                  t        j                  | j                  j                         t        j                  | j                  
      }| j                  | j                  | j                   | j                        }|j#                  |      }|| j$                  k(  sJ t'        |j(                        dk(  sJ | j+                  |j(                  d   d   ||       |j,                  sJ |j.                  rJ |j0                  | j                  d   k(  sJ | j3                  |j(                  d   d   | j                  | j                   dj5                  | j                  d         dd       |j#                  |      }|| j$                  k(  sJ t'        |j(                        dk(  sJ y )Nr!  r"  r#  r&  r*   r'  r-   rB  r~  )r=   rk   rq   rr   )rT   rS   r^   rj  r   r   r.   r_  r`  r  )r_   r`   r   r   rD  rh   ri   r   rw   r2  r3  r-  r   r  ra   r   r7   r  r  r   rq  r   r   r   r   r   r   )r   r7  ru  rv  r   r   r  s          r   Atest_workforce_pool_get_project_id_cloud_resource_manager_successzQTestCredentials.test_workforce_pool_get_project_id_cloud_resource_manager_success  s    @!w

 L//$S."&"C"C$||))

M4+K+KLM

 ((>>&&++-*5..(,(T(T	 ) 
 ::;;!22(,(H(H ; 
 !//8
T__,,,7))*a///((""1%a(-9K	

     &&&&  D$9$9.$IIII33""1%a(,,'+'<'<!,!3!3)).9" (-
	
 !//8
T__,,,7))*a///r   c                    t        j                         j                  d      t        j                  d      z   j                  d      dz   }t        j                  j                  |d      }| j                  j                         }dd	d
}d| j                  dd| j                  dd}d|d}ddj                  |d         t        dd}	d | j                  dd}
| j                  t        j                   |t        j                   |      }| j#                  | j$                  ddi| j                        }|j'                  |       t)        |j*                        dk(  sJ | j-                  |j*                  d   d   ||       | j/                  |j*                  d   d   |	|
       |j0                  sJ |j2                  |k(  sJ |j4                  rJ |j6                  |d   k(  sJ y )Nr   rR  r   r  rT  rU  rV  r!  zRgl-python/3.7 auth/1.1 google-byoid-sdk sa-impersonation/true config-lifetime/truer#  r&  r*   r'  rX  rY  rZ  r[  r^  r_  r.   r`  ra  2800sre  rh  r   )rN   rO   rT   rj  r   r\  rk  rr  s                r   (test_refresh_impersonation_with_lifetimez8TestCredentials.test_refresh_impersonation_with_lifetime  s    OO%%!%4x7I7IRV7WW
)C.3 #++44[BVW..335?!u

 L$S."&"9"9:
 -%"

 /(//~0NO!V#(	!
 [[&
" ((>>!,5	 ) 
 ++.2.T.T3KT2R;; , 
 	G$ 7))*a///((""1%a(-9K	
 	00""1%a(!&	

     !!_444&&&&  $:=$IIIIr   c                 *   | j                  t        j                  | j                  j	                         t        j
                        }| j                  | j                        }|j                  |      }|J t        |j                        dk(  sJ y )N)r=   rk   rq   )rT   rj  )rw   r2  r3  r-  r   UNAUTHORIZEDr\   r   r  r   rq  )r   r   r   r  s       r   0test_get_project_id_cloud_resource_manager_errorz@TestCredentials.test_get_project_id_cloud_resource_manager_error,  s     ((>>&&++-*5*B*B ) 

 ++4;;+? //8
!!!7))*a///r   )NNNNNNNr  )kr   r   r    rY   r   r  r%   r&   r   rW   r_   r   rX   r`   rZ   r-  r  r7   r   r   r   r  r  r   r  classmethodr   r\   ra   r2  r3  rw   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r   markparametrizeTEST_NON_USER_AUDIENCESr  TEST_USER_AUDIENCESr  r  r  r  r  re   r   !LANG_LIBRARY_METRICS_HEADER_VALUEr.  r/  r:  r@  rF  rM  rP  rp  ry  r|  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r   r   r#   r#   V   si   5I?NNGK	 f^Wk2	  	OfWk"  #G?#N !AB&L  #4:N
 *F
3
:
:;P
Q	R & !F=(
$  JB  ("0#=9/+  *..0/
 
8  *.$(
 
0  ~~!&*$(& &P 9=< <  9=) ) , ,
&<.*
	6
"@ 	6!
FD
"E
 %>N

FG


29
J [[Z)@A, B, [[Z)<=+ >+ [[Z)<=, >, [[Z)@A6 B6 [[Z)<=5 >5 [[Z)<=5 >5 [[.v?TZZ96 TZZ-H<M<M<Q<QR= S	 @=> TZZ96 TZZ-H<M<M<Q<QRTZZAPT TZZO<$=	 S	$=L TZZ96 TZZ-H<M<M<Q<QR"= S	
"=H TZZ96 TZZ-H<M<M<Q<QR#= S	
#=J TZZ96 TZZ-H<M<M<Q<QR#= S	
#=J TZZDJ TZZ96EJ		EJN TZZDJ TZZ96 TZZAPT TZZO<NJ			NJ` TZZDJ TZZ96IJ		IJV TZZ967	7B TZZ96<	<@))&) TZZ96J	J6 TZZDJ TZZ96JJ		JJX TZZDJ TZZ96JJ		JJX

"
@
"!
F
2
6&
P TZZ-.*
 /*
X TZZ-.=
 /=
~ [[
	
	8	8A	2	8 TZZDJ TZZ96^0		^0@ TZZ96B0	B0H TZZDJ TZZ96FJ		FJP0r   r#   c                  t    t        j                  dd      } | j                  dk(  sJ | j                  dk(  sJ y )NTestTokenTypeTestAudience)r   SupplierContextrK   rJ   )contexts    r   test_supplier_contextr  =  s<    ..OG%%888~---r   )r.  http.clientclientr2  rh   r   re   r   google.authr   r   r   r   google.auth.credentialsr   r   rp  r  r   r   rL  r   r  r  r   r   r   r#   r  r   r   r   <module>r     s     !       " ( ! ; . @ 6 %= !	0 K   82&22 2d0f d0N?.r   