
    i8                        d Z ddlZddlZddlZddlZddlZej                  j                  ej                  j                  e	            Z
ej                  j                  ej                  j                  e
            Zej                  j                  e
d      Zej                  j                  ed      Zej                  j                  ed      ZdZdZdZd	Zd
Zdj+                  e      ZdZej0                  j3                  d      ZeR ej6                  e      Zej9                         rej;                         sA edj+                  e              ed       n! ej6                   ej@                               ZejC                  d      Z" e#e"jC                  dd            Z$d Z%d Z&d0dZ'g dZ(g dZ)dgZ*dgZ+d Z, ejZ                  e+      d        Z. ejZ                  e+      d        Z/ ejZ                  e+      d        Z0 ejZ                  e+      d        Z1 ejZ                  e+      d        Z2 ejZ                  e+      d         Z3 ejZ                  e+      d!        Z4 ejZ                  e+      d"        Z5 ejZ                  e+      d#        Z6 ejZ                  e+      d$        Z7 ejZ                  e+      d%        Z8 ejZ                  e+      d&        Z9 ejZ                  e*      d'        Z: ejZ                  e+      d(        Z; ejZ                  e*      d)        Z< ejZ                  e*      d*        Z= ejZ                  e*      d+        Z> ejZ                  e*      d,        Z? ejZ                  e*      d-        Z@ ejZ                  e*      d.        ZA ejZ                  e*      d/        ZBy)1a  Noxfile for automating system tests.

This file handles setting up environments needed by the system tests. This
separates the tests from their environment configuration.

See the `nox docs`_ for details on how this file works:

.. _nox docs: http://nox.readthedocs.io/en/latest/
    Ndatazservice_account.jsonzauthorized_user.jsonGOOGLE_APPLICATION_CREDENTIALSGOOGLE_CLOUD_PROJECTEXPECT_PROJECT_ID)GOOGLE_EXTERNAL_ACCOUNT_ALLOW_EXECUTABLESzgoogle-cloud-sdk.tar.gzz,https://dl.google.com/dl/cloudsdk/release/{}CLOUDSDK_CONFIGCLOUD_SDK_ROOTz_{} did not exist! Please set the CLOUD_SDK_ROOT environment variable to a directory that exists   zgoogle-cloud-sdkbingcloudc           
         t        t              | j                  t        <   t        t        j                  d            t        j                  z   t        j                  d   z   | j                  d<   t        j                  t              j                         r| j                  t        ddd       yt        j                  t              }| j                  dt        dt        |      d	
       | j                  ddt        |      dt        t                     |j!                          | j                  t        t        j                  d            ddddddd	
       y)z,Downloads and installs the Google Cloud SDK.r   PATH
componentsupdatez-qNwgetz-OTsilenttarxzfz-Cz
install.shz--usage-reportingfalsez--path-updatez--command-completion)strr	   envCLOUD_SDK_CONFIG_ENVCLOUD_SDK_INSTALL_DIRjoinpathospathsepenvironpathlibPathGCLOUDexistsrunCLOUD_SDK_DIST_FILENAMECLOUD_SDK_DOWNLOAD_URLunlink)sessiontar_paths     Nplatform/gsutil/third_party/google-auth-library-python/system_tests/noxfile.pyinstall_cloud_sdkr*   K   s    ),N(;GKK$% 	!**512RZZ?"**VBTT KK
 ||F""$FL(D9&&'>?H KK.c(mDKQ KKuc(mT3~3FGOO KK!**<89  	    c                     t         j                  d      }|j                         r|j                          t	        j
                  t        j                  |       |       y)zPCopies credentials into the SDK root as the application default
    credentials.z$application_default_credentials.jsonN)r	   r   r"   r&   shutilcopyfiler   r    )credentials_pathdests     r)   copy_credentialsr1   s   s?     ""#IJD{{}
OOGLL!12D9r+   c                    t        |        | j                  t        dddt               |r| j                  t        dddd       n| j                  t        ddd       | j                  t        |       | j                  t        dd	d
d       y)zInstalls and configures the Cloud SDK with the given application default
    credentials.

    If project is True, then a project will be set in the active config.
    If it is false, this will ensure no project is set.
    authzactivate-service-accountz
--key-fileconfigsetprojectexample-projectunsetzapplication-defaultzprint-access-tokenTr   N)r*   r#   r!   SERVICE_ACCOUNT_FILEr1   )r'   application_default_credentialsr6   s      r)   configure_cloud_sdkr;   |   s     g KK2LBV FHeY8IJFHgy9 KK "AB KK-/CD  r+   )aiohttpzpytest-asyncioznest-asynciomock)pytestrequestsr=   pyjwtz3.7c                 r    dt        | j                  j                         d} | j                  d|g|  y )Nz--junitxml=system_z_sponge_log.xmlr>   )r   _runnerfriendly_namer#   )r'   
test_paths
sponge_logs      r)   defaultrF      s=     &c'//*G*G&H%IYJGKK*)r+   )pythonc                      | j                   t          | j                  t               t        | dg| j                    y )Nz)system_tests_sync/test_service_account.pyinstallTEST_DEPENDENCIES_SYNCLIBRARY_DIRrF   posargsr'   s    r)   service_account_syncrO      s9    GOO+,OOK 3 
r+   c                     t         | j                  t        <   d| j                  t        <    | j                  t
          | j	                  t               t        | ddg| j                    y )N1!system_tests_sync/test_default.pyz"system_tests_sync/test_id_token.py)	r9   r   EXPLICIT_CREDENTIALS_ENVEXPECT_PROJECT_ENVrJ   rK   rL   rF   rM   rN   s    r)    default_explicit_service_accountrU      sZ    ,@GKK()&)GKK"#GOO+,OOK +, 
	r+   c                     t         | j                  t        <    | j                  t          | j                  t
               t        | dg| j                    y NrR   )AUTHORIZED_USER_FILEr   rS   rJ   rK   rL   rF   rM   rN   s    r)    default_explicit_authorized_userrY      sH    ,@GKK()GOO+,OOK + 
r+   c                     t         | j                  t        <   d| j                  t        <   d| j                  t        <    | j
                  t          | j                  t               t        | dg| j                    y )Nr7   rQ   rR   )
rX   r   rS   EXPLICIT_PROJECT_ENVrT   rJ   rK   rL   rF   rM   rN   s    r)   1default_explicit_authorized_user_explicit_projectr\      sf    ,@GKK()(9GKK$%&)GKK"#GOO+,OOK + 
r+   c                     t        | t               d| j                  t        <    | j                  t
          | j	                  t               t        | dg| j                    y )NrQ   rR   )	r;   r9   r   rT   rJ   rK   rL   rF   rM   rN   s    r)   !default_cloud_sdk_service_accountr^      sS    !56&)GKK"#GOO+,OOK + 
r+   c                     t        | t                | j                  t          | j                  t               t        | dg| j                    y rW   )r;   rX   rJ   rK   rL   rF   rM   rN   s    r)   !default_cloud_sdk_authorized_userr`      sD    !56GOO+,OOK + 
r+   c                     t        | t        d       d| j                  t        <    | j                  t
          | j	                  t               t        | dg| j                    y )NTr6   rQ   rR   )	r;   rX   r   rT   rJ   rK   rL   rF   rM   rN   s    r)   4default_cloud_sdk_authorized_user_configured_projectrc      sU    !5tD&)GKK"#GOO+,OOK + 
r+   c                      | j                   t          | j                  j                  d= | j                  t               t        | dg| j                    y )Nr   z(system_tests_sync/test_compute_engine.py)rJ   rK   
virtualenvr   rL   rF   rM   rN   s    r)   compute_enginerf     sP    GOO+, 	?@OOK 2 
r+   c                     | j                  t               | j                  d        | j                   g t        d  t        | j                  t
        <   t        | dg| j                    y )Nsixzgoogle-cloud-pubsub==1.7.2zsystem_tests_sync/test_grpc.pyrJ   rL   rK   r9   r   rS   rF   rM   rN   s    r)   grpcrj     s]    OOK OOEGOOJ+J-IJ,@GKK()( 
r+   c                     | j                  t                | j                   t          t        | j                  t
        <   t        | dg| j                    y )Nz"system_tests_sync/test_requests.pyri   rN   s    r)   r?   r?   (  sH    OOK GOO+,,@GKK(), 
r+   c                     | j                  t                | j                   t          t        | j                  t
        <   t        | dg| j                    y )Nz!system_tests_sync/test_urllib3.pyri   rN   s    r)   urllib3rm   4  sH    OOK GOO+,,@GKK()+ 
r+   c                     | j                  t                | j                   g t        d  t        | j                  t
        <   t        | dg| j                    y )N	pyopensslz#system_tests_sync/test_mtls_http.pyri   rN   s    r)   	mtls_httprp   @  sP    OOK GOO9+9[9,@GKK()- 
r+   c                     d| j                   t        <    | j                  g t        t        d  t        | dg| j                    y )NrQ   zgoogle-api-python-clientz+system_tests_sync/test_external_accounts.py)r   ALLOW_PLUGGABLE_ENVrJ   TEST_DEPENDENCIES_ASYNCrL   rF   rM   rN   s    r)   external_accountsrt   L  sW    '*GKK#$GOO 	  	#
 5 
r+   c                 n     | j                   g t        t        d  t        | dg| j                    y )Nzgoogle-cloud-storagez%system_tests_sync/test_downscoping.pyrI   rN   s    r)   downscopingrv   [  sH    GOO 	 	
 / 
r+   c                      | j                   t        t        z     | j                  t               t	        | dg| j
                    y )Nz*system_tests_async/test_service_account.py)rJ   rK   rs   rL   rF   rM   rN   s    r)   service_account_asyncrx   k  s?    GOO,/FFHOOK 4 
r+   c                     t         | j                  t        <   d| j                  t        <    | j                  t
        t        z     | j	                  t               t        | ddg| j                    y )NrQ   "system_tests_async/test_default.pyz#system_tests_async/test_id_token.py)
r9   r   rS   rT   rJ   rK   rs   rL   rF   rM   rN   s    r)   &default_explicit_service_account_asyncr{   v  s`    ,@GKK()&)GKK"#GOO,/FFHOOK ,- 
	r+   c                     t         | j                  t        <    | j                  t        t
        z     | j                  t               t        | dg| j                    y Nrz   )	rX   r   rS   rJ   rK   rs   rL   rF   rM   rN   s    r)   &default_explicit_authorized_user_asyncr~     sN    ,@GKK()GOO,/FFHOOK , 
r+   c                 
   t         | j                  t        <   d| j                  t        <   d| j                  t        <    | j
                  t        t        z     | j                  t               t        | dg| j                    y )Nr7   rQ   rz   )rX   r   rS   r[   rT   rJ   rK   rs   rL   rF   rM   rN   s    r)   7default_explicit_authorized_user_explicit_project_asyncr     sl    ,@GKK()(9GKK$%&)GKK"#GOO,/FFHOOK , 
r+   c                     t        | t               d| j                  t        <    | j                  t
        t        z     | j	                  t               t        | dg| j                    y )NrQ   rz   )
r;   r9   r   rT   rJ   rK   rs   rL   rF   rM   rN   s    r)   'default_cloud_sdk_service_account_asyncr     sY    !56&)GKK"#GOO,/FFHOOK , 
r+   c                     t        | t                | j                  t        t        z     | j                  t
               t        | dg| j                    y r}   )r;   rX   rJ   rK   rs   rL   rF   rM   rN   s    r)   'default_cloud_sdk_authorized_user_asyncr     sJ    !56GOO,/FFHOOK , 
r+   c                     t        | t        d       d| j                  t        <    | j                  t
        t        z     | j	                  t               t        | dg| j                    y )NTrb   rQ   rz   )
r;   rX   r   rT   rJ   rK   rs   rL   rF   rM   rN   s    r)   :default_cloud_sdk_authorized_user_configured_project_asyncr     s[    !5tD&)GKK"#GOO,/FFHOOK , 
r+   )F)C__doc__r   r   r-   tempfilenoxpathabspathdirname__file__HERErL   joinDATA_DIRr9   rX   rS   r[   rT   rr   r$   formatr%   r   r   getr	   r    r"   is_dirprintexitmkdtempr   r   r   r!   r*   r1   r;   rs   rK   PYTHON_VERSIONS_ASYNCPYTHON_VERSIONS_SYNCrF   r'   rO   rU   rY   r\   r^   r`   rc   rf   rj   r?   rm   rp   rt   rv   rx   r{   r~   r   r   r   r    r+   r)   <module>r      s\   
    
	wwrwwx01ggoobggood3477<<f%ww||H.DE ww||H.DE ; - ( A  4 GNN  )   01!W\\.1N  ".*?*?*Aovv  xF  G  	HQ!W\\"2("2"2"45N '//0BC  
"++E8<	=
%P:#P P @  w  () * ()
 *
 () * ()
 *
 ()	 *	 () * ()	 *	 ()
 *
 ()	 *	 () * () * () * )* + ()
 *
 )* + )*
 +
 )* + )*
 +
 )*	 +	 )* + )*	 +	r+   