
                            S SK r S SKrS SKrS SKrS SKrS SKr S SKrS SKrS SK	rS SKJr  \R                  R                  \R                  R!                  \5      S5      r\R                  R                  \S5      rS rS	 rS
 rS r\R0                  S 5       r\R4                  " S5      S 5       r " S S\5      rS rS r\R0                  S 5       r S r!S r"g! \
 a    \R                  " SSS9   Nf = f)    Nz@Skipping oauth2client tests since oauth2client is not installed.T)allow_module_level)_oauth2clientdatazservice_account.jsonc                     [         R                  R                  SSSS[        R                  R                  SSSS9n [
        R                  " U 5      nUR                  U R                  :X  d   eUR                  U R                  :X  d   eUR                  U R                  :X  d   eUR                  U R                  :X  d   eUR                  U R                   :X  d   eUR"                  U R"                  :X  d   eg )	Naccess_token	client_idclient_secretrefresh_token	token_uri
user_agentone two)scopes)oauth2clientclientOAuth2Credentialsdatetimeminr   _convert_oauth2_credentialstokenr   _refresh_tokenr
   
_client_idr   _client_secretr	   
_token_urir   r   old_credentialsnew_credentialss     Rplatform/gsutil/third_party/google-auth-library-python/tests/test__oauth2client.py test__convert_oauth2_credentialsr   (   s    "));; < 	O $??PO  O$@$@@@@))_-J-JJJJ%%)B)BBBB))_-J-JJJJ%%)B)BBBB!!_%;%;;;;    c                  J   [         R                  R                  n U R                  [        5      n[
        R                  " U5      nUR                  UR                  :X  d   eUR                  R                  UR                  :X  d   eUR                  UR                  :X  d   eg N)r   service_accountServiceAccountCredentialsfrom_json_keyfile_nameSERVICE_ACCOUNT_JSON_FILEr   $_convert_service_account_credentialsservice_account_email_signerkey_id_private_key_idr   r   	old_classr   r   s      r   )test__convert_service_account_credentialsr-   >   s    ,,FFI667PQO#HHO
 	--1V1VVV""))_-L-LLLL%%)B)BBBBr   c                  J   [         R                  R                  n U R                  [        5      n[
        R                  " U5      nUR                  UR                  :X  d   eUR                  R                  UR                  :X  d   eUR                  UR                  :X  d   eg r!   )r   r"   _JWTAccessCredentialsr$   r%   r   r&   r'   r(   r)   r*   r   r   r+   s      r   2test__convert_service_account_credentials_with_jwtr0   M   s    ,,BBI667PQO#HHO
 	--1V1VVV""))_-L-LLLL%%)B)BBBBr   c                      [         R                  R                  R                  SS9n [        R
                  " U 5      nUR                  U R                  :X  d   eg )N
some_email)email)r   contribgceAppAssertionCredentialsr   &_convert_gce_app_assertion_credentialsr'   r   s     r   +test__convert_gce_app_assertion_credentialsr8   \   sZ    "**..FF G O $JJO
 	--1V1VVVr   c                 D    U " S5        U " S5        U " S5        U " S5        g )Nz!google.appengine.api.app_identityzgoogle.appengine.ext.ndbz google.appengine.ext.webapp.utilwebapp2 )mock_non_existent_modules    r   mock_oauth2client_gae_importsr=   j   s%    @A78?@Y'r   z#google.auth.app_engine.app_identityc                 8   [         R                  S:  a  [        R                  " S5        SS KnSnUR
                  R                  R                  SUS9n[        R                  " U5      nUR                  SS/:X  d   eUR                  UR                  :X  d   eg )	N      CSkipping test for Python 3.13+ due to oauth2client incompatibility.r   service_account_idr   )scoperC   onetwo)sysversion_infopytestskipoauth2client.contrib.appenginer4   	appenginer6   r   ,_convert_appengine_app_assertion_credentialsr   _service_account_idrC   )app_identityr=   r   rC   r   r   s         r   1test__convert_appengine_app_assertion_credentialsrP   r   s     7"Q	
 *-"**44LL,> M O $PPO !!eU^333../2T2TTTTr   c                       \ rS rSrSrg)FakeCredentials   r;   N)__name__
__module____qualname____firstlineno____static_attributes__r;   r   r   rR   rR      s    r   rR   c                  B   [         R                  " S/S9n [         R                  R                  [        S[
        U 05      n[        5       nU   [        R                  " U5      nS S S 5        U R                  U5        WU R                  :X  d   eg ! , (       d  f       N2= f)N__call__)spec_CLASS_CONVERSION_MAP)	mockMockpatchobjectr   rR   convertassert_called_once_withreturn_value)convert_functionconversion_map_patchcredentialsresults       r   test_convert_successrh      s    yyzl3::,,.BR0S "#K	&&{3 
 ,,[9%22222	 
	s   B
Bc                      [         R                  " [        5       n [        R                  " S5        S S S 5        W R                  S5      (       d   eg ! , (       d  f       N'= f)Nz(a string is not a real credentials classzUnable to convert)rI   raises
ValueErrorr   ra   match)excinfos    r   test_convert_not_foundrn      sE    	z	"gHI 
# ==,---- 
#	"s   A
A!c                  8    [         R                  " [        5        g)z.Reloads the _oauth2client module after a test.N)	importlibreloadr   r;   r   r   reset__oauth2client_modulerr      s     ]#r   c                     [         R                  S:  a  [        R                  " S5        [        R
                  " [        5        [        R                  (       d   eg )Nr?   rB   )rG   rH   rI   rJ   rp   rq   r   _HAS_APPENGINE)r=   rr   s     r   test_import_has_app_engineru      s@     7"Q	
 ]#''''r   c                    U R                  [        R                  SS 5        [        R                  " [
        5       n[        R                  " [        5        S S S 5        WR                  S5      (       d   eg ! , (       d  f       N'= f)Nr   )
setitemrG   modulesrI   rj   ImportErrorrp   rq   r   rl   )monkeypatchrr   rm   s      r    test_import_without_oauth2clientr{      sY    ^T:	{	#w' 
$ ==(((( 
$	#s   A88
B)#r   rp   osrG   r]   rI   oauth2client.clientr   oauth2client.contrib.gceoauth2client.service_accountry   rJ   google.authr   pathjoindirname__file__DATA_DIRr%   r   r-   r0   r8   fixturer=   r_   rP   r`   rR   rh   rn   rr   ru   r{   r;   r   r   <module>r      s     	 
  #' & 77<<16:GGLL3IJ <,CC ( ( 12U 3U6	f 	3. $ $
()C  
KKJs   C C76C7