
    ?g]                    B   d dl 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Zd dlZd dlZd dl	m
Z
 d dlmZ d dlZd dlmZmZ d dlmZ ddlmZ dd	lmZmZmZ dd
lmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z' dZ(dZ)dZ*dZ+dZ,d Z-d Z.d Z/d Z0d Z1dZ2dZ3dZ4dZ5 e-e5      Z6dZ7 e-e7      Z8dZ9dZ:dZ;dZ<ej                  j{                  e      j}                  d       ej~                  e*       z
  Z@ej                  j{                  e      j}                  d       ej~                  e+       z   ZA e/e@      ZBd!ZCd"ZD e-eD      ZEd#ZF e-eF      ZGd$ZH e-eH      ZId%ZJd&ZKd'ZLd(j                   e.eK       e.eL      g      ZNd(j                  eN e.eI      g      ZOdeOz  ZKd)ZP e.eK      d(z    e.eP      z   ZQd(j                  eQ e.eH      g      ZRd(j                   e.eK       e.eL      j}                  d*d+       e.eH      g      ZSd(j                   e.eK      d, e.eH      g      ZT e-eD      ZUeOZVd-ZWd.eWz   ZX G d/ d0ej                        ZZ G d1 d2eZ      Z[ G d3 d4eZ      Z\ G d5 d6      Z] G d7 d8eZ      Z^ G d9 d:eZ      Z_ G d; d<eZ      Z`ead=k(  r ej                          yy)>    N)pprint)
namedtuple)mock)PY3next)Configuration   )ConfigException)UTCformat_rfc3339parse_rfc3339)ENV_KUBECONFIG_PATH_SEPARATORCommandTokenSource
ConfigNode
FileOrDataKubeConfigLoaderKubeConfigMerger_cleanup_temp_files_create_temp_file_with_content_get_kube_config_loader%_get_kube_config_loader_for_yaml_filelist_kube_config_contextsload_kube_configload_kube_config_from_dictnew_client_from_confignew_client_from_config_dictz	Bearer %sz%Y-%m-%dT%H:%M:%SZ   <   zz_non_existing_file_472398324c                 d    t        j                  | j                               j                         S N)base64standard_b64encodeencodedecodestrings    W/var/www/openai/venv/lib/python3.12/site-packages/kubernetes/config/kube_config_test.py_base64r)   6   s"    $$V]]_5<<>>    c                     t        j                  | j                               j                         j	                  d      S )N=)r"   urlsafe_b64encoder$   r%   rstripr&   s    r(   _urlsafe_unpadded_b64encoder/   :   s-    ##FMMO4;;=DDSIIr*   c                 ,    | j                  t              S r!   )strftimeEXPIRY_DATETIME_FORMAT)dts    r(   _format_expiry_datetimer4   >   s    ;;-..r*   c                     fd| j                   j                  j                  d      D        }t        |      j                  d      j                  d      j                  d      j                  d      S )Nc              3   J   K   | ]  }|j                  d       k(  r|  yw)nameN)get).0itemactive_contexts     r(   	<genexpr>z_get_expiry.<locals>.<genexpr>C   s*      ?)J88F+~= )Js    #usersuserauth-providerconfigexpiry)_configvaluer8   r   )loaderr;   expired_gcp_confs    ` r(   _get_expiryrF   B   s\    ?)=)=)A)A')J ? !%%f-11/B	Xss8}%r*   c                     t        |       r!   )	Exception)sts    r(   _raise_exceptionrJ   I   s    
B-r*   filedataztest-filenamez	test-datazanother-test-dataz	test-hostmepasszBasic bWU6cGFzcw==tztzinfo)minuteszhttps://test-hostz	cert-auth
client-keyzclient-certzkubernetes.ioztest-oidc-tokenz{"name": "test"}.z!{"name": "test","exp": 536457600}a+aaaaaztest-azure-tokenBearer c                   &    e Zd Zd Zd ZddZd Zy)BaseTestCasec                     g | _         y r!   )_temp_filesselfs    r(   setUpzBaseTestCase.setUp   s
    r*   c                 P    | j                   D ]  }t        j                  |        y r!   )r]   osremove)r_   fs     r(   tearDownzBaseTestCase.tearDown   s    !!AIIaL "r*   c                     t        j                         \  }}| j                  j                  |       t	        j
                  |t        j                  |             t	        j                  |       |S r!   )	tempfilemkstempr]   appendrb   writestrr$   close)r_   contenthandlerr7   s       r(   _create_temp_filezBaseTestCase._create_temp_file   sP     ((*%
#**W-.
r*   c                     | j                  t              5 } ||i | d d d        | j                  |t        j                               y # 1 sw Y   /xY wr!   )assertRaisesr
   assertInrk   	exception)r_   funcmessage_partargskwargscontexts         r(   expect_exceptionzBaseTestCase.expect_exception   sF    /7$!&! 0lC(9(9$:; 0/s   	AAN) )__name__
__module____qualname__r`   re   ro   ry    r*   r(   r[   r[      s    <r*   r[   c                   v    e Zd Zed        Zd Zd Zd Zd Zd Z	d Z
d Zd	 Zd
 Zd Zd Zd Zd Zd Zd Zy)TestFileOrDatac                 d    t        |       5 }|j                         cd d d        S # 1 sw Y   y xY wr!   )openread)filenamerd   s     r(   get_file_contentzTestFileOrData.get_file_content   s    (^q668 ^^s   &/c                     t        t              }t        |i}t        |t              }| j	                  t        | j                  |j                                      y )Nobjfile_key_name)r   	TEST_DATATEST_FILE_KEYr   assertEqualr   as_filer_   temp_filenamer   ts       r(   test_file_given_filez#TestFileOrData.test_file_given_file   sC    6yAm,3m<D$9$9!))+$FGr*   c                 z    t         }t        |i}t        |t              }| j                  |j                  d       y )Nr   does not exist)NON_EXISTING_FILEr   r   ry   r   r   s       r(   !test_file_given_non_existing_filez0TestFileOrData.test_file_given_non_existing_file   s2    )m,3m<aii)9:r*   c                     t         t        i}t        |t        t               }| j	                  t
        | j                  |j                                      y Nr   r   data_key_name)TEST_DATA_KEYTEST_DATA_BASE64r   r   r   r   r   r   r_   r   r   s      r(   test_file_given_dataz#TestFileOrData.test_file_given_data   s?    ./3m%24D$9$9!))+$FGr*   c                     t         t        i}t        |t        t         d      }| j	                  t        | j                  |j                                      y NF)r   r   r   base64_file_content)r   r   r   r   r   r   r   r   s      r(   test_file_given_data_no_base64z-TestFileOrData.test_file_given_data_no_base64   sA    i(3m%2OD$9$9!))+$FGr*   c                     t         t        i}t        |t        t               }| j	                  t        |j                                y r   )r   r   r   r   r   as_datar   s      r(   test_data_given_dataz#TestFileOrData.test_data_given_data   s5    ./3m%24)199;7r*   c                     t         | j                  t              i}t        |t               }| j	                  t
        |j                                y )Nrm   r   )r   ro   r   r   r   r   r   r   s      r(   test_data_given_filez#TestFileOrData.test_data_given_file   s@    411)1DF3m<)199;7r*   c                     t         | j                  t              i}t        |t         d      }| j	                  t        |j                                y )Nr   F)r   r   r   )r   ro   r   r   r   r   r   s      r(   test_data_given_file_no_base64z-TestFileOrData.test_data_given_file_no_base64   sD    411)1DF3m+02AIIK0r*   c                     t         t        t        | j                  t              i}t        |t        t               }| j                  t        |j                                y Nr   r   )r   r   r   ro   TEST_ANOTHER_DATAr   r   r   r   s      r(   test_data_given_file_and_dataz,TestFileOrData.test_data_given_file_and_data   sQ    +411) 2 +, 3m%24)199;7r*   c                     t         t        t        | j                  t              i}t        |t        t               }| j                  t        | j                  |j                                      y r   )
r   r   r   ro   r   r   r   r   r   r   r   s      r(   test_file_given_file_and_dataz,TestFileOrData.test_file_given_file_and_data   s[    +411) 2 +, 3m%24D$9$9!))+$FGr*   c                 F   | j                  t              }t        j                  j	                  |      }t        j                  j                  |      }t        |i}t        |t        |      }| j                  t        | j                  |j                                      y )Nr   )r   r   file_base_path)ro   r   rb   pathdirnamebasenamer   r   r   r   r   )r_   rg   tempfile_dirtempfile_basenamer   r   s         r(   test_file_with_custom_dirnamez,TestFileOrData.test_file_with_custom_dirname   sy    ))))<wwx0GG,,X6/03m&24D$9$9!))+$FGr*   c                 |    | j                  t        | j                  t        t                           t	                y r!   )r   r   r   r   r   r^   s    r(   "test_create_temp_file_with_contentz1TestFileOrData.test_create_temp_file_with_content   s2    ..;IFH	I 	r*   c                     t         t        j                         i}t        |t        t               }| j                  t        | j                  |j                                      y r   )	r   r   r$   r   r   r   r   r   r   r   s      r(   test_file_given_data_bytesz)TestFileOrData.test_file_given_data_bytes   sH    .55783m%24D$9$9!))+$FGr*   c                     t         t        j                         i}t        |t        t         d      }| j                  t        | j                  |j                                      y r   )r   r   r$   r   r   r   r   r   r   s      r(   $test_file_given_data_bytes_no_base64z3TestFileOrData.test_file_given_data_bytes_no_base64   sJ    i..013m%2OD$9$9!))+$FGr*   c                 p    t        d t        t              }| j                  |j	                         d        y r   )r   r   r   r   r   r_   r   s     r(   test_file_given_no_objectz(TestFileOrData.test_file_given_no_object  )    4}%24d+r*   c                 p    t        d t        t              }| j                  |j	                         d        y r   )r   r   r   r   r   r   s     r(   test_file_given_no_object_dataz-TestFileOrData.test_file_given_no_object_data	  r   r*   N)r{   r|   r}   staticmethodr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r~   r*   r(   r   r      sf     H;HH8818HHHH,
,r*   r   c            	            e Zd Zdg dddiddddd	dhdd
g ddgddddd	dhdd
g ddgdZ fdZd Zd Zd Zd Zd Z	d Z
d Z xZS )TestConfigNodetestrV   bc	inner_keyinner_value	test_name
test_value)r7   rC   
test_name2key1
test_name3)r	   r      )r   key2key3
with_nameswith_names_dupc                 `    t         t        |           t        d| j                        | _        y )Ntest_obj)superr   r`   r   r   node)r_   	__class__s    r(   r`   zTestConfigNode.setUp  s"    nd)+z4==9	r*   c                    | j                  d| j                  d          | j                  dt        | j                               | j                  d| j                  d   j                         | j                  g d| j                  d   j                         | j                  d| j                  d   d          | j                  d	t        | j                  d                | j                  d
| j                  d   j                         | j                  ddi| j                  d   j                         | j                  d| j                  d   d          | j                  dt        | j                  d                y )Nr   r      ztest_obj/key2r   r   r   r	   r   ztest_obj/key3r   r   r   )r   r   lenr7   rC   r^   s    r(    test_normal_map_array_operationsz/TestConfigNode.test_normal_map_array_operations"  s/   6!23C		N+$))F*;*@*@A$))F*;*A*ABdii/23C		& 123$))F*;*@*@A+}56*00	2		&(9+(FGC		& 123r*   c                    | j                   d   }| j                  d|j                  d      d          | j                  t	        |j                  d      t
                     | j                  t	        |j                  d      t
                     | j                  d|j                  d      j                         | j                  d|j                  d      j                         y )	Nr   r   r   rC   r   r   z$test_obj/with_names[name=test_name2]z$test_obj/with_names[name=test_name3])r   r   get_with_name
assertTrue
isinstancer   r7   )r_   r   s     r(   test_get_with_namez!TestConfigNode.test_get_with_name1  s    yy&{+G4	6 	t)),7D	Ft)),7D	F?++L9>>	@?++L9>>	@r*   c                 Z      j                   fdd        j                   fdd       y )Nc                  "     j                   d   S )Nnot-exists-keyr   r^   s   r(   <lambda>z9TestConfigNode.test_key_does_not_exists.<locals>.<lambda>@  s    dii0@&Ar*   z'Expected key not-exists-key in test_objc                  (     j                   d   d   S )Nr   r   r   r^   s   r(   r   z9TestConfigNode.test_key_does_not_exists.<locals>.<lambda>B  s    dii&78H&Ir*   z,Expected key not-exists-key in test_obj/key3ry   r^   s   `r(   test_key_does_not_existsz'TestConfigNode.test_key_does_not_exists?  s-    AG	IIL	Nr*   c                 0      j                   fdd       y )Nc                  @     j                   d   j                  d      S )Nr   no-namer   r   r^   s   r(   r   zETestConfigNode.test_get_with_name_on_invalid_object.<locals>.<lambda>G      DIIf%33I>r*   z<Expected all values in test_obj/key2 list to have 'name' keyr   r^   s   `r(   $test_get_with_name_on_invalid_objectz3TestConfigNode.test_get_with_name_on_invalid_objectE  s    >L	Nr*   c                 0      j                   fdd       y )Nc                  @     j                   d   j                  d      S )Nr   r   r   r^   s   r(   r   zFTestConfigNode.test_get_with_name_on_non_list_object.<locals>.<lambda>L  r   r*   z#Expected test_obj/key3 to be a listr   r^   s   `r(   %test_get_with_name_on_non_list_objectz4TestConfigNode.test_get_with_name_on_non_list_objectJ  s    >1	3r*   c                 0      j                   fdd       y )Nc                  @     j                   d   j                  d      S )Nr   r   r   r^   s   r(   r   zKTestConfigNode.test_get_with_name_on_name_does_not_exists.<locals>.<lambda>Q  s    DIIl+99)Dr*   z=Expected object with name no-name in test_obj/with_names listr   r^   s   `r(   *test_get_with_name_on_name_does_not_existsz9TestConfigNode.test_get_with_name_on_name_does_not_existsO  s    DK	Mr*   c                 0      j                   fdd       y )Nc                  @     j                   d   j                  d      S )Nr   r   r   r^   s   r(   r   zETestConfigNode.test_get_with_name_on_duplicate_name.<locals>.<lambda>V  s    DII./==kJr*   zLExpected only one object with name test_name in test_obj/with_names_dup listr   r^   s   `r(   $test_get_with_name_on_duplicate_namez3TestConfigNode.test_get_with_name_on_duplicate_nameT  s    J+	,r*   )r{   r|   r}   r   r`   r   r   r   r   r   r   r   __classcell__)r   s   @r(   r   r     s    $m4(3lK(4*0&)9 ;(4yIK
 )<@(%v.0)I>	#H:4@NN
3
M
,r*   r   c                   .    e Zd Zg dZdgZddZd Zd Zy)
FakeConfig)ssl_ca_certkey_file	cert_filerefresh_api_key_hookNc                 x    i | _         d | _        |r|| j                   d<   | j                  j                  |       y )Nauthorization)api_keyr  __dict__update)r_   tokenrw   s      r(   __init__zFakeConfig.__init__`  s4    $(!,1DLL)V$r*   c                    t        | j                        t        |j                        k7  ry | j                  j                         D ]  \  }}|| j                  v r||j                  vr y || j                  v r|r{|j                  |   rl	 t        |      5 }t        |j                  |         5 }|j                         |j                         k7  r	 d d d        d d d         y 	 d d d        d d d        |j                  |   |k7  s y |j                  |   |k7  s y  y# 1 sw Y   >xY w# 1 sw Y   BxY w# t        $ r |j                  |   |k7  rY  y Y w xY w)NT)r   r  itemsIGNORE_KEYS	FILE_KEYSr   r   OSError)r_   otherkvf1f2s         r(   __eq__zFakeConfig.__eq__i  s*   t}}U^^!44MM'')DAqD$$$&DNN"*#!!WD1B,Cr!wwyBGGI5 & -DWW5 -DW ~~a(A->>!$)+ *,  -D,CWW # # !>>!,1" 2#sN   D;D/0#D#D/D;&D/.D;#D,(D//D8	4D;;EEc                 b   d}| j                   j                         D ]\  \  }}|}|| j                  v r;	 t        |      5 }dt        j                  |j                               z  }d d d        |d|d|dz  }^ d|z  S # 1 sw Y   xY w# t        $ r}dt	        |      z  }Y d }~;d }~ww xY w)N
zFILE: %sz	ERROR: %s	z: zConfig(%s
))r  r  r  r   rk   r%   r   r  )r_   repr  r  valrd   es          r(   __repr__zFakeConfig.__repr__  s    MM'')DAqCDNN"/aA(3::affh+?? ! 1c**C * ## ! /%A.C/s.   B'B&BB
	B	B.B))B.r!   )r{   r|   r}   r  r  r	  r  r  r~   r*   r(   r   r   [  s    8I)*K%6$r*   r   c                    F   e Zd Zddddiddddddddddddddddd	dd	ddd
dd
dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd dd!ddd"dd#ddd$d$dddgdd%eid&deed'd&ded(d'd&deed)d*d&ded+d,d&di d&d$eed)ed-d&gdee	e
d.d/ddd0eid1ee	e
d2d/ddeed3d1ee	e
d2d/d	deed3d1ee	e
d2d/d
d4d
d5eid1id/dd4ed6d7d8d9d:dd;id/dd4ed6d7d<d=d8d9d>dd;id/dd4ed6d7d<d?d8d9d>dd;id/dd4ed6d7d<d@d8d9d>dd;id/dd4ed6d7d<dAd8d9d>dd;id/dd4d
dBdCeedDdEdFd1id/dd4d
dBdCeedDdEdGd1id/dd4d
dBdCedDdEdHd1id/dd4d
dBdCedDdEdHd1id/dd4d
dBdCedDdEdHd1id/de	e
dId/deeedJd/ddKdLdMdNd/deeedOd/ddPdQdRg dSdTid/ddPdQdUg dTid/dd4ddVdWid1id/d!d4ddVdXid1id/d#d4ddYdZd[d1id/gd\Zd] Zd^ Zd_ Zd` Zda Zdb Zdc Zdd Z ej@                  de       ej@                  df      dg               Z! ej@                  de       ej@                  df      dh               Z" ej@                  de       ej@                  df      di               Z#dj Z$dk Z%dl Z&dm Z'dn Z(do Z)dp Z*dq Z+dr Z,ds Z-dt Z.du Z/dv Z0dw Z1dx Z2dy Z3dz Z4d{ Z5d| Z6d} Z7d~ Z8d Z9d Z:d Z;d Z<d Z=d Z>d Z? ej@                  d      d        Z@ ej@                  d      d        ZA ej@                  d      d        ZB ej@                  dd+      d        ZCd ZDd ZEd ZFd ZGd ZHd ZId ZJd ZKy)TestKubeConfigLoaderno_userclusterdefaultr7   rx   simple_tokenr  r>   gcpexpired_gcpexpired_gcp_refreshoidcazure	azure_num	azure_strazure_num_errorazure_str_errorexpired_oidcexpired_oidc_with_idp_ca_fileexpired_oidc_nocert oidc_contains_reserved_characteroidc_invalid_padding_length	user_passsslno_ssl_verificationssl-no_filessl-local-filenon_existing_userexec_cred_userexec_cred_user_certificatecontexttestcmdpathclustertestcmdpathusertestcmdpathcontexttestcmdpathemptyusertestcmdpathemptycontexttestcmdpathscopeusertestcmdpathscopetls-server-nameserverr7   r  )rB  zcertificate-authority	cert_testF)rB  certificate-authority-datainsecure-skip-tls-verifyT)rB  rF  )rB  rE  rF  rA  r  usernamepasswordr7   r>   access-tokenr7   r@   )r?   r  rH  rI  )rK  rA   r?   id-tokenz$00000002-0000-0000-c000-000000000000AzurePublicCloudrefreshTokenz$9d2ac018-e843-4e14-9e2b-4e0ddac75433)rK  apiserver-idenvironmentrefresh-token	tenant-id)r@   r7   0	156207275)rK  rP  rQ  z
expires-inz
expires-onrR  rS  z2018-10-18 00:52:29.044727z2018-10-18 00:52z-1tectonic-kubectlFAKE_SECREThttps://example.org/identity lucWJjEhlxZW01cXI3YmVlcYnpxNGhzk	client-idclient-secretrM  zidp-certificate-authority-dataidp-issuer-urlrR  )r[  r\  rM  zidp-certificate-authorityr]  rR  )r[  r\  rM  r]  rR  )rH  rI  )r  client-certificaterT   
token_fileclient_cert
client_key)	tokenFiler^  rT   r  zclient-certificate-datazclient-key-dataexecz$client.authentication.k8s.io/v1beta1zaws-iam-authenticator)r  z-izdummy-cluster)
apiVersioncommandrv   z custom-certificate-authenticatorcmd-pathcmdtorunrz   cmdscope)rg  scopescurrent-contextcontextsclustersr=   c                     t        t              }t               }t        | j                  d      j	                  |       | j                  ||       y )Nhostr  config_dictr;   r   	TEST_HOSTr   TEST_KUBE_CONFIGload_and_setr   r_   expectedactuals      r(   test_no_user_contextz)TestKubeConfigLoader.test_no_user_context  sA    9---$	&&2l6&:6*r*   c                     t        t        t        t        z        }t               }t	        | j
                  d      j                  |       | j                  ||       y )Nrr  r  r"  rs  )r   rv  BEARER_TOKEN_FORMATr   r   rw  rx  r   ry  s      r(   test_simple_tokenz&TestKubeConfigLoader.test_simple_token  sM    9$7:J$JL--)	++7<+?6*r*   c                     t        | j                  d      }| j                  |j                                | j	                  t
        t        z  |j                         y )Nr"  rs  )r   rw  r   _load_user_tokenr   r  r   r  r_   rD   s     r(   test_load_user_tokenz)TestKubeConfigLoader.test_load_user_token  sJ    !--)+ 	//12,/??Nr*   c                 h   t               }| j                  |j                         t        | j                  dd       j                  |       | j                  |j                         | j                  t        |j                         | j                  t        t        z  |j                  d          y )Nr$  c                      t        d      S NzSHOULD NOT BE CALLEDrJ   r~   r*   r(   r   z:TestKubeConfigLoader.test_gcp_no_refresh.<locals>.<lambda>      +;&,(r*   rt  r;   get_google_credentialsr  )r   assertIsNoner  r   rw  rx  assertIsNotNoner   rv  rr  r  r   r  )r_   fake_configs     r(   test_gcp_no_refreshz(TestKubeConfigLoader.test_gcp_no_refresh  s     l+::;-- $(	) *6k)B[==>K$4$45,/??$,,_=	?r*   c                     t        | j                  dd       }| j                  |j                                | j	                  t
        t        z  |j                         y )Nr$  c                      t        d      S r  r  r~   r*   r(   r   zETestKubeConfigLoader.test_load_gcp_token_no_refresh.<locals>.<lambda>  r  r*   r  )r   rw  r   _load_auth_provider_tokenr   r  r   r  r  s     r(   test_load_gcp_token_no_refreshz3TestKubeConfigLoader.test_load_gcp_token_no_refresh  sR    !-- $()
 	88:;,/??	'r*   c                    d t         _        t        j                  j                  t              j                  d       _        t        | j                  dfd      }t        |d      }| j                  |j                                t        |d      }| j                  ||kD         | j                  t        t         z  |j                         y )Nc                       y r!   r~   r~   r*   r(   credzCTestKubeConfigLoader.test_load_gcp_token_with_refresh.<locals>.cred  s    4r*   rO   rQ   r%  c                       S r!   r~   )r  s   r(   r   zGTestKubeConfigLoader.test_load_gcp_token_with_refresh.<locals>.<lambda>  s    4r*   r  )TEST_ANOTHER_DATA_BASE64r  datetimenowr   replacerA   r   rw  rF   r   r  r   r  )r_   rD   original_expiry
new_expiryr  s       @r(    test_load_gcp_token_with_refreshz5TestKubeConfigLoader.test_load_gcp_token_with_refresh  s    -
''++s+3;;4;H!--(#/1 &fm<88:; 7

_45,/GG	'r*   c                     G d d      } G d d      }t               }t        j                         }||g|_        t	        | j
                  d|      }|j                  |       t        |d      }|j                  |       t        |d      }| j                  ||kD         | j                  t        t        z  |j                         y )Nc                       e Zd ZeZeZy)DTestKubeConfigLoader.test_gcp_refresh_api_key_hook.<locals>.cred_oldN)r{   r|   r}   r   r  DATETIME_EXPIRY_PASTrA   r~   r*   r(   cred_oldr    s    $E)Fr*   r  c                       e Zd ZeZeZy)DTestKubeConfigLoader.test_gcp_refresh_api_key_hook.<locals>.cred_newN)r{   r|   r}   r  r  DATETIME_EXPIRY_FUTURErA   r~   r*   r(   cred_newr    s    ,E+Fr*   r  r&  r  )r   r   Mockside_effectr   rw  rx  rF   r  r   r   r  r  r  )r_   r  r  r  _get_google_credentialsrD   r  r  s           r(   test_gcp_refresh_api_key_hookz2TestKubeConfigLoader.test_gcp_refresh_api_key_hook  s    	* 	*	, 	, !l"&))+/7.B+!--0#:< 	K(%f.CD((5 )>?

_45,/GG	'r*   c                     t        | j                  d      }| j                  |j                                | j	                  t
        |j                         y )Nr'  rs  )r   rw  r   r  r   TEST_OIDC_TOKENr  r  s     r(   test_oidc_no_refreshz)TestKubeConfigLoader.test_oidc_no_refresh/  sC    !--!
 	88:;&,,7r*   z9kubernetes.config.kube_config.OAuth2Session.refresh_tokenz/kubernetes.config.kube_config.ApiClient.requestc                    t        j                         }t        j                  d      t        |      _        t        j                  t        j                  ddi            t        |      _        ||_        ddd|_        t        | j                  d	      }| j                  |j                                | j                  d
|j                         y )N   return_valuetoken_endpoint"https://example.org/identity/tokenabc123newtoken123id_tokenrefresh_tokenr-  rs  Bearer abc123r   	MagicMockPropertyMocktypestatusjsondumpsrL   r  r   rw  r   r  r   r  r_   mock_ApiClientmock_OAuth2Sessionmock_responserD   s        r(   test_oidc_with_refreshz+TestKubeConfigLoader.test_oidc_with_refresh7  s     (%)%6%6&
]" $(#4#4 "F% $
]  '4#7?<I+K' "--)
 	88:;&,,7r*   c                    t        j                         }t        j                  d      t        |      _        t        j                  t        j                  ddi            t        |      _        ||_        ddd|_        t        | j                  d	      }| j                  |j                                | j                  d
|j                         y )Nr  r  r  r  r  r  r  r.  rs  r  r  r  s        r(   "test_oidc_with_idp_ca_file_refreshz7TestKubeConfigLoader.test_oidc_with_idp_ca_file_refreshP  s     (%)%6%6&
]" $(#4#4 "F% $
]  '4#7?<I+K' "--:

 	88:;&,,7r*   c                    t        j                         }t        j                  d      t        |      _        t        j                  t        j                  ddi            t        |      _        ||_        ddd|_        t        | j                  d	      }| j                  |j                                | j                  d
|j                         y )Nr  r  r  r  r  r  r  r/  rs  r  r  r  s        r(   test_oidc_with_refresh_nocertz2TestKubeConfigLoader.test_oidc_with_refresh_nocertj  s     (%)%6%6&
]" $(#4#4 "F% $
]  '4#7?<I+K' "--0
 	88:;&,,7r*   c                 t    t        | j                  d      }| j                  |j                  d      d        y )Nr0  rs  r   rw  r   _load_oid_tokenr  s     r(   *test_oidc_fails_if_contains_reserved_charsz?TestKubeConfigLoader.test_oidc_fails_if_contains_reserved_chars  s:    !--=
 	""#EF	
r*   c                 t    t        | j                  d      }| j                  |j                  d      d        y )Nr1  rs  r  r  s     r(   )test_oidc_fails_if_invalid_padding_lengthz>TestKubeConfigLoader.test_oidc_fails_if_invalid_padding_length  s:    !--8
 	""#@A	
r*   c                     t        | j                  d      }| j                  |j                                | j	                  t
        |j                         y )Nr(  rs  )r   rw  r   r  r   TEST_AZURE_TOKEN_FULLr  r  s     r(   test_azure_no_refreshz*TestKubeConfigLoader.test_azure_no_refresh  sD    !--"
 	88:;.=r*   c                     t        | j                  d      }|j                  d   }| j                  |j	                  |             y )Nr)  rs  r?   r   rw  _userr   _azure_is_expiredr_   rD   providers      r(   test_azure_with_expired_numz0TestKubeConfigLoader.test_azure_with_expired_num  ?    !--&
 <<000:;r*   c                     t        | j                  d      }|j                  d   }| j                  |j	                  |             y )Nr*  rs  r?   r  r  s      r(   test_azure_with_expired_strz0TestKubeConfigLoader.test_azure_with_expired_str  r  r*   c                     t        | j                  d      }|j                  d   }| j                  t        |j
                  |       y )Nr,  rs  r?   r   rw  r  rq   
ValueErrorr  r  s      r(   !test_azure_with_expired_str_errorz6TestKubeConfigLoader.test_azure_with_expired_str_error  @    !--,
 <<0*f&>&>Ir*   c                     t        | j                  d      }|j                  d   }| j                  t        |j
                  |       y )Nr+  rs  r?   r  r  s      r(   !test_azure_with_expired_int_errorz6TestKubeConfigLoader.test_azure_with_expired_int_error  r  r*   c                     t        t        t              }t               }t        | j                  d      j                  |       | j                  ||       y )Nr~  r2  rs  )r   rv  TEST_BASIC_TOKENr   rw  rx  r   ry  s      r(   test_user_passz#TestKubeConfigLoader.test_user_pass  sD    94DE--&	((4V(<6*r*   c                     t        | j                  d      }| j                  |j                                | j	                  t
        |j                         y )Nr2  rs  )r   rw  r   _load_user_pass_tokenr   r  r  r  s     r(   test_load_user_pass_tokenz.TestKubeConfigLoader.test_load_user_pass_token  sD    !--&( 	4467)6<<8r*   c                 |    t        | j                  d      }| j                  |j                  dt	                      y )Nr5  rs  r   )r   rw  ry   rx  r   r  s     r(   test_ssl_no_cert_filesz+TestKubeConfigLoader.test_ssl_no_cert_files  s9    !--(* 	L	r*   c           	      :   t        t        t        t        z  | j	                  t
              | j	                  t              | j	                  t              d      }t               }t        | j                  d      j                  |       | j                  ||       y )NTrr  r  r  r   r   
verify_sslr3  rs  )r   TEST_SSL_HOSTr  r   ro   TEST_CLIENT_CERTTEST_CLIENT_KEYTEST_CERTIFICATE_AUTHr   rw  rx  r   ry  s      r(   test_sslzTestKubeConfigLoader.test_ssl  s~    %(88,,-=>++O<../DE
 -- 	"".,v"66*r*   c                    t        t        t        t        z  | j	                  t
              | j	                  t              dd       }t               }t        | j                  d      j                  |       | j                  ||       y )NF)rr  r  r  r   r  r   r4  rs  )r   r  r  r   ro   r  r  r   rw  rx  r   ry  s      r(   test_ssl_no_verificationz-TestKubeConfigLoader.test_ssl_no_verification  sr    %(88,,-=>++O<
 --0	22>,v2F6*r*   c           	      D   t        t        t        t        z  | j	                  t
              | j	                  t              | j	                  t              dt              }t               }t        | j                  d      j                  |       | j                  ||       y )NT)rr  r  r  r   r   r  tls_server_namerA  rs  )r   r  r  r   ro   r  r  r  TEST_TLS_SERVER_NAMEr   rw  rx  r   ry  s      r(   test_tls_server_namez)TestKubeConfigLoader.test_tls_server_name  s    %(88,,-=>++O<../DE0
 --,	..:l6.B6*r*   c                     t        | j                  d      }|j                         }t        d| j                        d   }|D ]2  }|j	                  |d         }| j                  |j                  |       4 y )Nr  rs  rz   rn  r7   )r   rw  list_contextsr   r   r   rC   )r_   rD   actual_contextsexpected_contextsr{  rz  s         r(   test_list_contextsz'TestKubeConfigLoader.test_list_contexts  sr    !--$& !..0&r4+@+@A*M%F(66vf~FHX^^V4 &r*   c                     t        | j                        }t        d| j                        d   }| j                  |j	                  d      j
                  |j                         y )Nrt  rz   rn  r  )r   rw  r   r   r   rC   current_contextr_   rD   r  s      r(   test_current_contextz)TestKubeConfigLoader.test_current_context  sU    !d.C.CD&r4+@+@A*M*88CII//	1r*   c                     t        | j                        }|j                  d       t        d| j                        d   }| j	                  |j                  d      j                  |j                         y )Nr  r3  rz   rn  )r   rw  set_active_contextr   r   r   rC   r  r  s      r(   test_set_active_contextz,TestKubeConfigLoader.test_set_active_context  sc    !d.C.CD!!%(&r4+@+@A*M*88?EE//	1r*   c           	         t        t        t        t        z  | j	                  t
              | j	                  t              | j	                  t                    }	 t        j                         }t               }t        t        j                  j                  |d      d      5 }|j                  t        j                                d d d        t        t        j                  j                  |d      d      5 }|j                  t
        j                                d d d        t        t        j                  j                  |d      d      5 }|j                  t        j                                d d d        t        t        j                  j                  |d      d      5 }|j                  t        j                                d d d        t!        | j"                  d|      j%                  |       | j'                  ||       t)        j*                  |       y # 1 sw Y   [xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   ~xY w# t)        j*                         w xY w)	N)rr  r  r  r   r   rD  wbr`  ra  r_  r6  rt  r;   config_base_path)r   r  r  r   ro   r  r  r  rg   mkdtempr   rb   r   joinrj   r$   r   rw  rx  r   shutilrmtree)r_   rz  temp_dirr{  fds        r(    test_ssl_with_relative_ssl_filesz5TestKubeConfigLoader.test_ssl_with_relative_ssl_files  s   %(88,,-=>++O<../DE
	$'')H\Fbggll8[94@B.5578 Abggll8];TBb)0023 Cbggll8\:DAR//12 Bbggll8\:DAR)0023 B 11/!)+ ,8<+?Xv.MM(# A@BBAAAA MM(#sn   AI "$H2I 8$H,2I $H922I $$IAI H)$I ,H61I 9I>I I
I I(c                     t        t        t        t        z        }| j	                  t        j                  | j                              }t               }t        |d|       | j                  ||       y )Nr~  r"  config_filerx   client_configuration)
r   rv  r  r   ro   yaml	safe_dumprw  r   r   r_   rz  r  r{  s       r(   $test_load_kube_config_from_file_pathz9TestKubeConfigLoader.test_load_kube_config_from_file_path8  s`    9$7:J$JL,,NN40013[..4	66*r*   c                    t        t        t        t        z        }t	        j
                         }	 t        d       |j                  t        t        j                  | j                        d             t               }t        |d|       | j                  ||       y # t        $ r1 |j                  t        j                  | j                               Y dw xY w)Nr~  rz   r  )errorsr"  r  )r   rv  r  r   ioStringIOunicoderj   r  r  rw  	NameErrorr   r   )r_   rz  config_file_like_objectr{  s       r(   +test_load_kube_config_from_file_like_objectz@TestKubeConfigLoader.test_load_kube_config_from_file_like_objectB  s    9$7:J$JL"$++-
	,BK#))NN--/$&' /"!'	) 	6*  	,#))))+,	,s   AB! !7CCc                     t        t        t        t        z        }t               }t	        | j
                  d|       | j                  ||       y )Nr~  r"  )rt  rx   r  )r   rv  r  r   r   rw  r   ry  s      r(   test_load_kube_config_from_dictz4TestKubeConfigLoader.test_load_kube_config_from_dictY  sH    9$7:J$JL"t/D/D+98>	@ 	6*r*   c           	      z   t        t        t        t        z  | j	                  t
              | j	                  t              | j	                  t              d      }t               }t        j                  j                  t        j                  j                  t        j                  j                  t        j                  j                  t                          d      }t        | j                  d||       | j!                  t        j"                  |      sdnd       | j%                  ||       t'                y )NTr  tmp_file_path_testr3  )rt  rx   r  temp_file_pathF)r   r  r  r   ro   r  r  r  rb   r   r  r   abspath__file__r   rw  assertFalselistdirr   r   )r_   rz  r{  tmp_paths       r(   3test_load_kube_config_from_dict_with_temp_file_pathzHTestKubeConfigLoader.test_load_kube_config_from_dict_with_temp_file_pathb  s    %(88,,-=>++O<../DE
 77<<GGOOGGOOH-/0 !	"
 	#t/D/D+08>2:	< 	RZZ%9uE6*r*   c                 b    t        j                         }| j                  t        t        |       y r!   )r  r  rq   r
   r   )r_   r!  s     r(   1test_load_kube_config_from_empty_file_like_objectzFTestKubeConfigLoader.test_load_kube_config_from_empty_file_like_objecty  s%    "$++-#	%r*   c                     | j                  t        j                  d             }| j                  t        t
        |       y r!   )ro   r  r  rq   r
   r   )r_   r  s     r(   %test_load_kube_config_from_empty_filez:TestKubeConfigLoader.test_load_kube_config_from_empty_file  s5    ,,NN4 "	r*   c                 L   | j                  t        j                  | j                              }t	        |      \  }}| j                  | j                  d   d   |       t        r | j                  | j                  d   |       y | j                  | j                  d   |       y )Nr  rn  r   )	ro   r  r  rw  r   assertDictEqualr   assertCountEqualassertItemsEqual)r_   r  rn  r;   s       r(   test_list_kube_config_contextsz3TestKubeConfigLoader.test_list_kube_config_contexts  s    ,,NN40013#<#$% .T22:>qA+	-!!$"7"7
"C"*, !!$"7"7
"C"*,r*   c                 6   | j                  t        j                  | j                              }t	        |d      }| j                  t        |j                  j                         | j                  t        t        z  |j                  j                  d          y Nr"  )r  rx   r  )ro   r  r  rw  r   r   rv  configurationrr  r  r   r  )r_   r  clients      r(   test_new_client_from_configz0TestKubeConfigLoader.test_new_client_from_config  s{    ,,NN40013'#^=F$8$8$=$=>,/??--55oF	Hr*   c                     t        | j                  d      }| j                  t        |j                  j
                         | j                  t        t        z  |j                  j                  d          y )Nr"  )rt  rx   r  )	r   rw  r   rv  r:  rr  r  r   r  )r_   r;  s     r(    test_new_client_from_config_dictz5TestKubeConfigLoader.test_new_client_from_config_dict  s`    ,--~GF$8$8$=$=>,/??--55oF	Hr*   c                     t        t              }t               }| j                  j                         }|d= t	        |d      j                  |       | j                  ||       y )Nrq  r=   r$  rs  )r   rv  rw  copyr   rx  r   )r_   rz  r{  test_kube_configs       r(   test_no_users_sectionz*TestKubeConfigLoader.test_no_users_section  sX    9-00557W%( 	"".,v"66*r*   c                     t        t              }t               }t        | j                  d      j	                  |       | j                  ||       y )Nrq  r7  rs  ru  ry  s      r(   test_non_existing_userz+TestKubeConfigLoader.test_non_existing_user  sA    9---.	00<V0D6*r*   z.kubernetes.config.kube_config.ExecProvider.runc                     d}d|i|_         t        t        dt        |z  i      }t               }t	        | j
                  d      j                  |       | j                  ||       y )Ndummyr  r  )rr  r  r8  rs  )r  r   rv  r  r   rw  rx  r   )r_   r   r  rz  r{  s        r(   test_user_exec_authz(TestKubeConfigLoader.test_user_exec_auth  sk    U
 9-/BU/J7L M--+	--9\&-A6*r*   c                    d}d}|t        t              d|t        t              dg|_        t	               }| j                  |j                         t        | j                  d      j                  |       | j                  |j                  d   t        |z         | j                  |j                         |j                  |       | j                  |j                  d   t        |z         y )Nexpiredcurrent)r  expirationTimestampr8  rs  r  )r   r  r  r  r   r  r  r   rw  rx  r   r  r  r  )r_   r   expired_tokencurrent_tokenr  s        r(   test_user_exec_auth_with_expiryz4TestKubeConfigLoader.test_user_exec_auth_with_expiry  s    !! ''56J'K
 ''56L'M	
 !l+::;--+	--9\+-F 	,,_=,}<	> 	[==>((5,,_=,}<	>r*   c                 F   t         t        d|_        t        t        | j                  t               | j                  t              | j                  t              d      }t               }t        | j                  d      j                  |       | j                  ||       y )N)clientCertificateDataclientKeyDataT)rr  r  r   r   r  r9  rs  )r  r  r  r   r  ro   r  r   rw  rx  r   )r_   r   rz  r{  s       r(    test_user_exec_auth_certificatesz5TestKubeConfigLoader.test_user_exec_auth_certificates  s     &6,
 ,,-=>++O<../DE --7	99Ef9M6*r*   )autospecc                     i fd}||_         d}t        | j                  d|      j                  t	                      | j                  |d          y )Nc                 $    | j                   d<   y )Ncwd)rV  )exec_providercaptures    r(   capture_cwdz<TestKubeConfigLoader.test_user_exec_cwd.<locals>.capture_cwd  s    *..GENr*   z/some/random/pathr8  r
  rV  )r  r   rw  rx  r   r   )r_   r   rY  rz  rX  s       @r(   test_user_exec_cwdz'TestKubeConfigLoader.test_user_exec_cwd  sS    	/&&--+%	' (4|JL'A75>2r*   c                 l   t        dddg      }d} ||t        t        j                  j                                     }t	        j
                  |      t        _        t        dt        |z  i      }t               }t        | j                  d	      j                  |       | j                  ||       y )
NAr  rA   rF  r  r  r  r:  rs  )r   r   r  r  r   r  r   r  r   r  r   rw  rx  r   r_   r\  r  r  rz  r{  s         r(   test_user_cmd_pathz'TestKubeConfigLoader.test_user_cmd_path  s    sWh/0h.?.?.C.C.E FG#'99,#G -/BU/J'L M--/	11=f1E6*r*   c                 ,    t        dddg      }d} ||t        t        j                  j                                     }t	        j
                  |      t        _        t        dt        |z  i      }t                j                   fdd	       y )
Nr\  r  rA   rF  r  r  r]  c                  P    t        j                  d      j                         S )Nr=  rs  r   rw  rx  r{  r_   s   r(   r   z?TestKubeConfigLoader.test_user_cmd_path_empty.<locals>.<lambda>  '    &6--4'66Bl66J'Kr*   zNmissing access token cmd (cmd-path is an empty string in your kubeconfig file)r   r   r  r  r   r  r   r  r   r  ry   r^  s   `    @r(   test_user_cmd_path_emptyz-TestKubeConfigLoader.test_user_cmd_path_empty  s    sWh/0h.?.?.C.C.E FG#'99,#G -/BU/J'L M KD	Er*   c                 ,    t        dddg      }d} ||t        t        j                  j                                     }t	        j
                  |      t        _        t        dt        |z  i      }t                j                   fdd	       y )
Nr\  r  rA   rF  r  r  r]  c                  P    t        j                  d      j                         S )Nr?  rs  rb  rc  s   r(   r   zDTestKubeConfigLoader.test_user_cmd_path_with_scope.<locals>.<lambda>*  rd  r*   zGscopes can only be used when kubectl is using a gcp service account keyre  r^  s   `    @r(   test_user_cmd_path_with_scopez2TestKubeConfigLoader.test_user_cmd_path_with_scope"  s    sWh/0h.?.?.C.C.E FG#'99,#G -/BU/J'L M K(	)r*   c                     t        t        t        t        z        }| j	                  t        j                  | j                              }t        |      }| j                  |j                         y )Nr~  )r   rv  r  r   ro   r  r  rw  r   r  _config_persisterr  s       r(   5test__get_kube_config_loader_for_yaml_file_no_persistzJTestKubeConfigLoader.test__get_kube_config_loader_for_yaml_file_no_persist0  sX    9$7:J$JL,,NN400136{C&223r*   c                 F   t        t        t        t        z        }| j	                  t        j                  | j                              }t        |d      }| j                  t        |j                               | j                  |j                  j                  d       y )Nr~  T)persist_configsave_changes)r   rv  r  r   ro   r  r  rw  r   r   callablerk  r   r{   r  s       r(   2test__get_kube_config_loader_for_yaml_file_persistzGTestKubeConfigLoader.test__get_kube_config_loader_for_yaml_file_persist8  s}    9$7:J$JL,,NN400136{FJL!9!9:;11::NKr*   c                     t        t        t        t        z        }| j	                  t        j                  | j                              }t        |      }| j                  |j                         y )Nr~  )r   )r   rv  r  r   ro   r  r  rw  r   r  rk  r  s       r(   ,test__get_kube_config_loader_file_no_persistzATestKubeConfigLoader.test__get_kube_config_loader_file_no_persistB  sX    9$7:J$JL,,NN40013(+>&223r*   c                 F   t        t        t        t        z        }| j	                  t        j                  | j                              }t        |d      }| j                  t        |j                               | j                  |j                  j                  d       y )Nr~  T)r   rn  ro  )r   rv  r  r   ro   r  r  rw  r   r   rp  rk  r   r{   r  s       r(   )test__get_kube_config_loader_file_persistz>TestKubeConfigLoader.test__get_kube_config_loader_file_persistJ  s|    9$7:J$JL,,NN40013(+8<>!9!9:;11::NKr*   c                     t        t        t        t        z        }t	        | j
                        }| j                  |j                         y )Nr~  r  )r   rv  r  r   r   rw  r  rk  ry  s      r(   ,test__get_kube_config_loader_dict_no_persistzATestKubeConfigLoader.test__get_kube_config_loader_dict_no_persistT  s?    9$7:J$JL(--/&223r*   N)Lr{   r|   r}   rv  r  r  TEST_CERTIFICATE_AUTH_BASE64r  r   TEST_USERNAMETEST_PASSWORDTEST_TOKEN_EXPIRY_PASTTEST_OIDC_LOGINTEST_AZURE_TOKENTEST_OIDC_EXPIRED_LOGINTEST_OIDC_CA&TEST_OIDC_CONTAINS_RESERVED_CHARACTERS TEST_OIDC_INVALID_PADDING_LENGTHr  r  TEST_CLIENT_CERT_BASE64TEST_CLIENT_KEY_BASE64rw  r|  r  r  r  r  r  r  r  r   patchr  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r"  r$  r-  r/  r1  r7  r<  r>  rB  rD  rG  rN  rR  rZ  r_  rf  ri  rl  rq  rs  ru  rw  r~   r*   r(   r  r    s   $ "y '(* (! &() .(1 ("  (# $(' $(' *(- *(- '(* 8(; .(1 ;(> 6(9 $(' $! .4! &,) )/, ,(/ )(, 5$8 -3- 232 232 *0!F
R "i &+-B )+-8 +405	 .+04 -
 *+405';	S3
l '- - -  !&*,<#& . - -
 & !&,<&<#& . - -$ . !&,<&<#& . - -  # &&#&
  #,<-;+=-;)O# !(
&" $#,<-;+=*-*5-;)O	# !(&& $#,<-;+=*-*F-;)O	# !(&& *#,<-;+=*-*<-;)O	# !(&& *#,<-;+=*-*.-;)O	# !(&& '# &);-:(?>J.L B#&$ 8# &);-:(?9N.L B#&$ .# &);-:(?.L B#
&" ;# &);-:(N.L B#
&" 6# &);-:(H.L B#
&" $ - - &-*:"1 )!-*7". -/F'= )&L#: @	 5&L#E "	 *# %&
#&
 /# %&#&
 /# %(-&-#&k	A
{B++O?''"'48 TZZKLTZZAB8 C M8. TZZKLTZZAB8 C M80 TZZKLTZZAB8 C M80

><<JJ+9+++ 511$6++.+.%,HH++ TZZ@A+ B+ TZZ@A> B>> TZZ@A+ B+" TZZ@4P3 Q3+E)4L4L4r*   r  c                       e Zd Zd Zd Zy)!TestKubernetesClientConfigurationc                 J    | j                  t        t               d             y )Nr  )r   hasattrr   r^   s    r(    test_refresh_api_key_hook_existszBTestKubernetesClientConfiguration.test_refresh_api_key_hook_existsb  s    1GHIr*   c                      ddd}t        |idi       fd}|_         j                  dz   j                               y )Nr  expected_token	old_tokenBearer)r  api_key_prefixc                 H    j                  |        | j                  <   y r!   )r   r  )client_configr@   r  
identifierr_   s    r(   r  zkTestKubernetesClientConfiguration.test_get_api_key_calls_refresh_api_key_hook.<locals>.refresh_api_key_hookn  s#    ]F30>M!!*-r*   rY   )r   r  r   get_api_key_with_prefix)r_   r  r  r@   r  r  s   `  @@@r(   +test_get_api_key_calls_refresh_api_key_hookzMTestKubernetesClientConfiguration.test_get_api_key_calls_refresh_api_key_hooke  s_    $
)	+&1

	? ';#^377
C	Er*   N)r{   r|   r}   r  r  r~   r*   r(   r  r  \  s    JEr*   r  c                      e Zd Zddddidgddeidgg ddd	d	d	d
ddddd
dgd	eeddgd	eeeddgdddddd
dd	ddd
dgg ddddde	e
ddddiddeeeddgdddidddd
dgdi dgdddd d!ididgd"ddddidgddeidgd#dgZd$ddeidgiddddd
dgd%d&deeeddgigZd' Zd( Zd) Zd* Zd+ Zy#),TestKubeConfigMergerr  r  r   r!  rB  rC  rl  rz   r3  r#  r"  )rB  rE  rc  rJ  r-  z"skipped-part2-defined-this-contextskippedr?   r'  rV  rW  rX  rY  rZ  rL  rG  rm  r:  r;  r<  r$  rg  rh  )rn  ro  r=   Nro  )rm  rn  r=   c                     g }|D ]5  }|j                  | j                  t        j                  |                   7 t	        j
                  |      S r!   )ri   ro   r  r  r   r  )r_   partsfilesparts       r(   _create_multi_configz)TestKubeConfigMerger._create_multi_config6  sB    DLL//t0DEF ,11%88r*   c                     | j                  | j                        }ddidddddddddddddddddd	d
dddg}t        |      \  }}| j                  ||       | j                  ||d          y )Nr  r   r  rx   r7   r3  r#  r"  r-  r;  r<  r:  r3  r   )r  TEST_KUBE_CONFIG_SET1r   r   )r_   kubeconfigsr  rn  r;   s        r(   r7  z3TestKubeConfigMerger.test_list_kube_config_contexts<  s    //0J0JK"I.	B$)595I$-~F#%$-~F#%$8!24)+	, $=#$% . 	#45):1)=>r*   c                    | j                  | j                        }t        |d      }| j                  t        |j
                  j                         | j                  t        t        z  |j
                  j                  d          y r9  )
r  r  r   r   rv  r:  rr  r  r   r  )r_   r  r;  s      r(   r<  z0TestKubeConfigMerger.test_new_client_from_configO  so    //0J0JK'#^=F$8$8$=$=>,/??--55oF	Hr*   c                    | j                  | j                        }t        |      }dddddg}t        |      \  }}| j	                  ||       | j	                  ||d          | j	                  t
        |j                  j                         | j	                  t        t        z  |j                  j                  d          y )Nr3  r   r"  r#  r  r   r  )r  TEST_KUBE_CONFIG_SET2r   r   r   rv  r:  rr  r  r   r  )r_   r  r;  r  rn  r;   s         r(   )test_merge_with_context_in_different_filez>TestKubeConfigMerger.test_merge_with_context_in_different_fileW  s    //0J0JK'K@ %.~F#%
 $=#$% .#45):1)=>F$8$8$=$=>,/??--55oF	Hr*   c                    | j                  | j                        }t        |      }|j                  d   j	                  d      d   }|d   d   }d|j
                  d<   |j                          t        |      }|j                  d   j	                  d      d   }|d   d   }| j                  |j
                  d   d       y )Nr=   r-  r>   r?   r@   ztoken-changedrM  )r  r  r   r@   r   rC   ro  r   )r_   r  kconfr>   r  s        r(   test_save_changesz&TestKubeConfigMerger.test_save_changesg  s    //0J0JK !-||G$22>B6J(2%4z" !-||G$22>B6J(2 	
3_Er*   )r{   r|   r}   rv  r  rx  r   r  r  r~  r  ry  rz  r  r  r  r7  r<  r  r  r~   r*   r(   r  r  w  s   $ "y
 "i
 %(  $! '(*
$ +4	
 -/F'=	
9&N % '(* C%
 
 '# &);-:(?>J.L B#&$ '- - -%
)/` 	9 -3-
 -
 *# %&
#&

#> % "y
 "i
 %Q[| 	!i
	 * '(*
 	&- - -	
)B9?&HH Fr*   r  __main__)cr"   r  r  r  rb   r   r  rg   unittestcollectionsr   r   r  sixr   r   kubernetes.clientr   config_exceptionr
   dateutilr   r   r   kube_configr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r2   PAST_EXPIRY_TIMEDELTAFUTURE_EXPIRY_TIMEDELTAr   r)   r/   r4   rF   rJ   r   r   TEST_FILENAMEr   r   r   r  rv  ry  rz  r  r  r  	timedeltar  r  r{  r  r  rx  r  r  r  r  r  r  TEST_OIDC_INFOr  TEST_OIDC_BASEr|  TEST_OIDC_EXPTEST_OIDC_EXP_BASEr~  r  r  r  TEST_AZURE_LOGINr}  r  TestCaser[   r   r   r   r  r  r  r{   mainr~   r*   r(   <module>r     sT     	  	     "    + - 8 8k k k k k " -   4 ?J/% 	9% ' "#45 	' ((,,, //6wdw/CFXhFXFXavFwx !**..#. 1181EHZHZHZczH{| 01EF ## &'<=  1   !"23 & #'0/  (( 78  /908GH (( 01$   *-0/77SA 013 * &
 $'880 01- $   ,-" % !$44 <8$$ <,g,\ g,TI,\ I,X4$ 4$nG4< G4T&E E6@F< @FF zHMMO r*   