
    3i]                        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  S SKrS SKrS SKrS SK	J
r
  S SKJr  S SKrS SKJrJr  S SKJr  SSKJr  SS	KJrJrJr  SS
KJrJrJrJrJrJrJrJ r J!r!J"r"J#r#J$r$J%r%J&r&J'r'  Sr(Sr)Sr*Sr+Sr,S r-S r.S r/S r0S r1Sr2Sr3Sr4Sr5\-" \55      r6Sr7\-" \75      r8Sr9Sr:Sr;Sr<\R                  R{                  \S9R}                  SS9\R~                  " \*S 9-
  r@\R                  R{                  \S9R}                  SS9\R~                  " \+S 9-   rA\/" \@5      rBS!rCS"rD\-" \D5      rES#rF\-" \F5      rGS$rH\-" \H5      rIS%rJS&rKS'rLS(R                  \." \K5      \." \L5      /5      rNS(R                  \N\." \I5      /5      rOS\O-  rKS)rP\." \K5      S(-   \." \P5      -   rQS(R                  \Q\." \H5      /5      rRS(R                  \." \K5      \." \L5      R}                  S*S+5      \." \H5      /5      rSS(R                  \." \K5      S,\." \H5      /5      rT\-" \D5      rU\OrVS-rWS.\W-   rX " S/ S0\R                  5      rZ " S1 S2\Z5      r[ " S3 S4\Z5      r\ " S5 S65      r] " S7 S8\Z5      r^ " S9 S:\Z5      r_ " S; S<\Z5      r`\aS=:X  a  \R                  " 5         gg)>    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                 f    [         R                  " U R                  5       5      R                  5       $ N)base64standard_b64encodeencodedecodestrings    \/home/james-whalen/.local/lib/python3.13/site-packages/kubernetes/config/kube_config_test.py_base64r)   6   s"    $$V]]_5<<>>    c                     [         R                  " U R                  5       5      R                  5       R	                  S5      $ )N=)r"   urlsafe_b64encoder$   r%   rstripr&   s    r(   _urlsafe_unpadded_b64encoder/   :   s-    ##FMMO4;;=DDSIIr*   c                 ,    U R                  [        5      $ r!   )strftimeEXPIRY_DATETIME_FORMAT)dts    r(   _format_expiry_datetimer4   >   s    ;;-..r*   c                    ^ U4S jU R                   R                  R                  S5       5       n[        U5      R                  S5      R                  S5      R                  S5      R                  S5      $ )Nc              3   V   >#    U  H  nUR                  S 5      T:X  d  M  Uv   M      g7f)nameN)get).0itemactive_contexts     r(   	<genexpr>_get_expiry.<locals>.<genexpr>C   s+      ?)J88F+~= )Js   )	)usersuserauth-providerconfigexpiry)_configvaluer8   r   )loaderr;   expired_gcp_confs    ` r(   _get_expiryrG   B   s\    ?)=)=)A)A')J ? !%%f-11/B	Xss8}%r*   c                     [        U 5      er!   )	Exception)sts    r(   _raise_exceptionrK   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                   0    \ rS rSrS rS rSS jrS rSrg)	BaseTestCase   c                     / U l         g r!   _temp_filesselfs    r(   setUpBaseTestCase.setUp   s
    r*   c                 V    U R                    H  n[        R                  " U5        M     g r!   )r`   osremove)rb   fs     r(   tearDownBaseTestCase.tearDown   s    !!AIIaL "r*   c                     [         R                  " 5       u  p#U R                  R                  U5        [        R
                  " U[        R                  U5      5        [        R                  " U5        U$ r!   )	tempfilemkstempr`   appendrf   writestrr$   close)rb   contenthandlerr7   s       r(   _create_temp_fileBaseTestCase._create_temp_file   sN     ((*%
#**W-.
r*   c                     U R                  [        5       nU" U0 UD6  S S S 5        U R                  U[        WR                  5      5        g ! , (       d  f       N4= fr!   )assertRaisesr
   assertInrp   	exception)rb   funcmessage_partargskwargscontexts         r(   expect_exceptionBaseTestCase.expect_exception   sF    /7$!&! 0lC(9(9$:; 0/s   	A
Ar_   N) )	__name__
__module____qualname____firstlineno__rc   ri   rt   r   __static_attributes__ r*   r(   r\   r\      s    <r*   r\   c                   ~    \ rS rSr\S 5       rS rS rS rS r	S r
S rS	 rS
 rS rS rS rS rS rS rS rSrg)TestFileOrData   c                 n    [        U 5       nUR                  5       sS S S 5        $ ! , (       d  f       g = fr!   )openread)filenamerh   s     r(   get_file_contentTestFileOrData.get_file_content   s    (^q668 ^^s   &
4c                     [        [        5      n[        U0n[        U[        S9nU R	                  [        U R                  UR                  5       5      5        g )Nobjfile_key_name)r   	TEST_DATATEST_FILE_KEYr   assertEqualr   as_filerb   temp_filenamer   ts       r(   test_file_given_file#TestFileOrData.test_file_given_file   sC    6yAm,3m<D$9$9!))+$FGr*   c                 t    [         n[        U0n[        U[        S9nU R                  UR                  S5        g )Nr   does not exist)NON_EXISTING_FILEr   r   r   r   r   s       r(   !test_file_given_non_existing_file0TestFileOrData.test_file_given_non_existing_file   s2    )m,3m<aii)9:r*   c                     [         [        0n[        U[        [         S9nU R	                  [
        U R                  UR                  5       5      5        g Nr   r   data_key_name)TEST_DATA_KEYTEST_DATA_BASE64r   r   r   r   r   r   rb   r   r   s      r(   test_file_given_data#TestFileOrData.test_file_given_data   s?    ./3m%24D$9$9!))+$FGr*   c                     [         [        0n[        U[        [         SS9nU R	                  [        U R                  UR                  5       5      5        g NF)r   r   r   base64_file_content)r   r   r   r   r   r   r   r   s      r(   test_file_given_data_no_base64-TestFileOrData.test_file_given_data_no_base64   sA    i(3m%2OD$9$9!))+$FGr*   c                     [         [        0n[        U[        [         S9nU R	                  [        UR                  5       5        g r   )r   r   r   r   r   as_datar   s      r(   test_data_given_data#TestFileOrData.test_data_given_data   s5    ./3m%24)199;7r*   c                     [         U R                  [        S90n[        U[         S9nU R	                  [
        UR                  5       5        g )Nrr   r   )r   rt   r   r   r   r   r   r   s      r(   test_data_given_file#TestFileOrData.test_data_given_file   s@    411)1DF3m<)199;7r*   c                     [         U R                  [        S90n[        U[         SS9nU R	                  [        UR                  5       5        g )Nr   F)r   r   r   )r   rt   r   r   r   r   r   s      r(   test_data_given_file_no_base64-TestFileOrData.test_data_given_file_no_base64   sD    411)1DF3m+02AIIK0r*   c                     [         [        [        U R                  [        S90n[        U[        [         S9nU R                  [        UR                  5       5        g Nr   r   )r   r   r   rt   TEST_ANOTHER_DATAr   r   r   r   s      r(   test_data_given_file_and_data,TestFileOrData.test_data_given_file_and_data   sQ    +411) 2 +, 3m%24)199;7r*   c                     [         [        [        U R                  [        S90n[        U[        [         S9nU R                  [        U R                  UR                  5       5      5        g r   )
r   r   r   rt   r   r   r   r   r   r   r   s      r(   test_file_given_file_and_data,TestFileOrData.test_file_given_file_and_data   s[    +411) 2 +, 3m%24D$9$9!))+$FGr*   c                 :   U R                  [        S9n[        R                  R	                  U5      n[        R                  R                  U5      n[        U0n[        U[        US9nU R                  [        U R                  UR                  5       5      5        g )Nr   )r   r   file_base_path)rt   r   rf   pathdirnamebasenamer   r   r   r   r   )rb   rl   tempfile_dirtempfile_basenamer   r   s         r(   test_file_with_custom_dirname,TestFileOrData.test_file_with_custom_dirname   sy    ))))<wwx0GG,,X6/03m&24D$9$9!))+$FGr*   c                 |    U R                  [        U R                  [        [        5      5      5        [	        5         g r!   )r   r   r   r   r   ra   s    r(   "test_create_temp_file_with_content1TestFileOrData.test_create_temp_file_with_content   s2    ..;IFH	I 	r*   c                     [         [        R                  5       0n[        U[        [         S9nU R                  [        U R                  UR                  5       5      5        g r   )	r   r   r$   r   r   r   r   r   r   r   s      r(   test_file_given_data_bytes)TestFileOrData.test_file_given_data_bytes   sH    .55783m%24D$9$9!))+$FGr*   c                     [         [        R                  5       0n[        U[        [         SS9nU R                  [        U R                  UR                  5       5      5        g r   )r   r   r$   r   r   r   r   r   r   s      r(   $test_file_given_data_bytes_no_base643TestFileOrData.test_file_given_data_bytes_no_base64   sJ    i..013m%2OD$9$9!))+$FGr*   c                 j    [        S [        [        S9nU R                  UR	                  5       S 5        g r   )r   r   r   r   r   rb   r   s     r(   test_file_given_no_object(TestFileOrData.test_file_given_no_object  )    4}%24d+r*   c                 j    [        S [        [        S9nU R                  UR	                  5       S 5        g r   )r   r   r   r   r   r   s     r(   test_file_given_no_object_data-TestFileOrData.test_file_given_no_object_data	  r   r*   r   N)r   r   r   r   staticmethodr   r   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            	          ^  \ rS rSrS/ SQSS0SSS.S	S
S1S.S/ SQS./SSS.SS
S1S.S/ SQS./S.rU 4S jrS rS rS rS r	S r
S rS rSrU =r$ )TestConfigNodei  testrW   bc	inner_keyinner_value	test_name
test_value)r7   rD   
test_name2key1
test_name3)r	   r      )r   key2key3
with_nameswith_names_dupc                 `   > [         [        U ]  5         [        SU R                  5      U l        g )Ntest_obj)superr   rc   r   r   node)rb   	__class__s    r(   rc   TestConfigNode.setUp  s"    nd)+z4==9	r*   c                    U R                  SU R                  S   5        U R                  S[        U R                  5      5        U R                  SU R                  S   R                  5        U R                  / SQU R                  S   R                  5        U R                  SU R                  S   S   5        U R                  S	[        U R                  S   5      5        U R                  S
U R                  S   R                  5        U R                  SS0U R                  S   R                  5        U R                  SU R                  S   S   5        U R                  S[        U R                  S   5      5        g )Nr   r      ztest_obj/key2r   r   r   r	   r   ztest_obj/key3r   r   r   )r   r   lenr7   rD   ra   s    r(    test_normal_map_array_operations/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                    U R                   S   nU R                  SUR                  S5      S   5        U R                  [	        UR                  S5      [
        5      5        U R                  [	        UR                  S5      [
        5      5        U R                  SUR                  S5      R                  5        U R                  SUR                  S5      R                  5        g )	Nr   r   r   rD   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   )rb   r   s     r(   test_get_with_name!TestConfigNode.test_get_with_name1  s    yy&{+G4	6 	t)),7D	Ft)),7D	F?++L9>>	@?++L9>>	@r*   c                 ^   ^  T R                  U 4S jS5        T R                  U 4S jS5        g )Nc                  "   > T R                   S   $ )Nnot-exists-keyr   ra   s   r(   <lambda>9TestConfigNode.test_key_does_not_exists.<locals>.<lambda>@  s    dii0@&Ar*   z'Expected key not-exists-key in test_objc                  (   > T R                   S   S   $ )Nr   r  r  ra   s   r(   r  r  B  s    dii&78H&Ir*   z,Expected key not-exists-key in test_obj/key3r   ra   s   `r(   test_key_does_not_exists'TestConfigNode.test_key_does_not_exists?  s-    AG	IIL	Nr*   c                 2   ^  T R                  U 4S jS5        g )Nc                  @   > T R                   S   R                  S5      $ )Nr   no-namer   r   ra   s   r(   r  ETestConfigNode.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	  ra   s   `r(   $test_get_with_name_on_invalid_object3TestConfigNode.test_get_with_name_on_invalid_objectE  s    >L	Nr*   c                 2   ^  T R                  U 4S jS5        g )Nc                  @   > T R                   S   R                  S5      $ )Nr   r  r  ra   s   r(   r  FTestConfigNode.test_get_with_name_on_non_list_object.<locals>.<lambda>L  r  r*   z#Expected test_obj/key3 to be a listr	  ra   s   `r(   %test_get_with_name_on_non_list_object4TestConfigNode.test_get_with_name_on_non_list_objectJ  s    >1	3r*   c                 2   ^  T R                  U 4S jS5        g )Nc                  @   > T R                   S   R                  S5      $ )Nr   r  r  ra   s   r(   r  KTestConfigNode.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	  ra   s   `r(   *test_get_with_name_on_name_does_not_exists9TestConfigNode.test_get_with_name_on_name_does_not_existsO  s    DK	Mr*   c                 2   ^  T R                  U 4S jS5        g )Nc                  @   > T R                   S   R                  S5      $ )Nr   r   r  ra   s   r(   r  ETestConfigNode.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	  ra   s   `r(   $test_get_with_name_on_duplicate_name3TestConfigNode.test_get_with_name_on_duplicate_nameT  s    J+	,r*   r  )r   r   r   r   r   rc   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                   8    \ rS rSr/ SQrS/rS	S jrS rS rSr	g)

FakeConfigi[  )ssl_ca_certkey_file	cert_filerefresh_api_key_hookNc                     0 U l         S U l        U(       a  XR                   S'   U R                  R                  U5        g )Nauthorization)api_keyr)  __dict__update)rb   tokenr}   s      r(   __init__FakeConfig.__init__`  s2    $(!,1LL)V$r*   c                    [        U R                  5      [        UR                  5      :w  a  g U R                  R                  5        H  u  p#X R                  ;   a  M  X!R                  ;  a    g X R                  ;   a  U(       a  UR                  U   (       an   [        U5       n[        UR                  U   5       nUR                  5       UR                  5       :w  a   S S S 5        S S S 5          g  S S S 5        S S S 5        M  UR                  U   U:w  a    g M  UR                  U   U:w  d  M    g    g! , (       d  f       NI= f! , (       d  f       GM  = f! [         a    UR                  U   U:w  a     g  GM8  f = f)NT)r   r-  itemsIGNORE_KEYS	FILE_KEYSr   r   OSError)rb   otherkvf1f2s         r(   __eq__FakeConfig.__eq__i  s*   t}}U^^!44MM'')DA$$$&NN"*#!!WD1B,Cr!wwyBGGI5 & -DWW5 -DWW ~~a(A- . >>!$)+ *,  -D,CWW # # !>>!,1" 2#sT   E%E	>$D8"E	*E5E	=E8
EE		
E	EEF Fc                 v   SnU R                   R                  5        H_  u  p#UnX R                  ;   a;   [        U5       nS[        R                  UR                  5       5      -  nS S S 5        USU< SU< S3-  nMa     SU-  $ ! , (       d  f       N%= f! [         a  nS[	        U5      -  n S nANES nAff = f)N
zFILE: %sz	ERROR: %s	z: zConfig(%s
))r-  r3  r5  r   rp   r%   r   r6  )rb   repr8  r9  valrh   es          r(   __repr__FakeConfig.__repr__  s    MM'')DACNN"/aA(3::affh+?? ! 1c**C * ## ! /%A.C/s4   B'B&B
B	BB
B8 B33B8)r,  r)  r!   )
r   r   r   r   r5  r4  r0  r<  rD  r   r   r*   r(   r%  r%  [  s    8I)*K%6$r*   r%  c                    H   \ rS rSrSSSS0S.SSSS.S.SSSS.S.S	SS	S.S.S
SS
S.S.SSSS.S.SSSS.S.SSSS.S.SSSS.S.SSSS.S.SSSS.S.SSSS.S.SSSS.S.SSSS.S.SSSS.S.SSSS.S.SSSS.S.SSSS.S.SSSS.S.SSSS.S.SSSS.S.SSSS.S.SSSS.S.SSSS.S.SSS S.S.S!SS"S.S.S#SS$S.S.S%S%SS.S./SS&\0S'.S\\S(.S'.S\S)S(.S'.S\\S*S+.S'.S\S,S-.S'.S0 S'.S%\\S*\S..S'./S\	\
\S/.S0.SSS1\	0S2.\	\
\S3.S0.S	S\	\S4.S2.\	\
\S3.S0.S
S\	\S4.S2.\	\
\S3.S0.SS5SS6\0S2.0S0.SS5\S7S8S9S:S;.SS<.0S0.SS5\S7S8S=S>S9S:S?.SS<.0S0.SS5\S7S8S=S@S9S:S?.SS<.0S0.SS5\S7S8S=SAS9S:S?.SS<.0S0.SS5\S7S8S=SBS9S:S?.SS<.0S0.SS5SSCSD\\SESFSG.S2.0S0.SS5SSCSD\\SESFSH.S2.0S0.SS5SSCSD\SESFSI.S2.0S0.SS5SSCSD\SESFSI.S2.0S0.SS5SSCSD\SESFSI.S2.0S0.S\
\SJ.S0.S\	\\SK.S0.SSLSMSNSO.S0.S\	\\SP.S0.SSQSRSS/ STQSU.0S0.SSQSRSV/ SU.0S0.S S5SSWSX0S2.0S0.S"S5SSWSY0S2.0S0.S$S5SSZS[S\.S2.0S0./S].rS^ rS_ rS` rSa rSb rSc rSd rSe r\ RB                  " Sf5      \ RB                  " Sg5      Sh 5       5       r"\ RB                  " Sf5      \ RB                  " Sg5      Si 5       5       r#\ RB                  " Sf5      \ RB                  " Sg5      Sj 5       5       r$Sk r%Sl r&Sm r'Sn r(So r)Sp r*Sq r+Sr r,Ss r-St r.Su r/Sv r0Sw r1Sx r2Sy r3Sz r4S{ r5S| r6S} r7S~ r8S r9S r:S r;S r<S r=S r>S r?S r@\ RB                  " S5      S 5       rA\ RB                  " S5      S 5       rB\ RB                  " S5      S 5       rC\ RB                  " SS,S9S 5       rDS rES rFS rGS rHS rIS rJS rKS rLSrMg)TestKubeConfigLoaderi  no_userclusterdefaultr7   r~   simple_tokenrI  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   rI  )rl  zcertificate-authority	cert_testF)rl  certificate-authority-datainsecure-skip-tls-verifyT)rl  rp  )rl  ro  rp  rk  r/  usernamepasswordr7   r?   access-tokenr7   rA   )r@   r/  rr  rs  )ru  rB   r@   id-tokenz$00000002-0000-0000-c000-000000000000AzurePublicCloudrefreshTokenz$9d2ac018-e843-4e14-9e2b-4e0ddac75433)ru  apiserver-idenvironmentrefresh-token	tenant-id)rA   r7   0	156207275)ru  rz  r{  z
expires-inz
expires-onr|  r}  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-secretrw  zidp-certificate-authority-dataidp-issuer-urlr|  )r  r  rw  zidp-certificate-authorityr  r|  )r  r  rw  r  r|  )rr  rs  )r/  client-certificaterU   
token_fileclient_cert
client_key)	tokenFiler  rU   r/  zclient-certificate-datazclient-key-dataexecz$client.authentication.k8s.io/v1beta1zaws-iam-authenticator)r/  z-izdummy-cluster)
apiVersioncommandr|   z custom-certificate-authenticatorcmd-pathcmdtorunr   cmdscope)r  scopescurrent-contextcontextsclustersr>   c                     [        [        S9n[        5       n[        U R                  SS9R	                  U5        U R                  X5        g )NhostrH  config_dictr;   r%  	TEST_HOSTr   TEST_KUBE_CONFIGload_and_setr   rb   expectedactuals      r(   test_no_user_context)TestKubeConfigLoader.test_no_user_context  s?    9---$	&&2l6&:*r*   c                     [        [        [        [        -  S9n[        5       n[	        U R
                  SS9R                  U5        U R                  X5        g )Nr  r/  rL  r  )r%  r  BEARER_TOKEN_FORMATr   r   r  r  r   r  s      r(   test_simple_token&TestKubeConfigLoader.test_simple_token  sK    9$7:J$JL--)	++7<+?*r*   c                     [        U R                  SS9nU R                  UR                  5       5        U R	                  [
        [        -  UR                  5        g )NrL  r  )r   r  r   _load_user_tokenr   r  r   r/  rb   rE   s     r(   test_load_user_token)TestKubeConfigLoader.test_load_user_token  sJ    !--)+ 	//12,/??Nr*   c                 b   [        5       nU R                  UR                  5        [        U R                  SS S9R                  U5        U R                  UR                  5        U R                  [        UR                  5        U R                  [        [        -  UR                  S   5        g )NrN  c                      [        S5      $ NzSHOULD NOT BE CALLEDrK   r   r*   r(   r  :TestKubeConfigLoader.test_gcp_no_refresh.<locals>.<lambda>      +;&,(r*   r  r;   get_google_credentialsr+  )r%  assertIsNoner)  r   r  r  assertIsNotNoner   r  r  r  r   r,  )rb   fake_configs     r(   test_gcp_no_refresh(TestKubeConfigLoader.test_gcp_no_refresh  s     l+::;-- $(	) *6k)B[==>K$4$45,/??$,,_=	?r*   c                     [        U R                  SS S9nU R                  UR                  5       5        U R	                  [
        [        -  UR                  5        g )NrN  c                      [        S5      $ r  r  r   r*   r(   r  ETestKubeConfigLoader.test_load_gcp_token_no_refresh.<locals>.<lambda>  r  r*   r  )r   r  r   _load_auth_provider_tokenr   r  r   r/  r  s     r(   test_load_gcp_token_no_refresh3TestKubeConfigLoader.test_load_gcp_token_no_refresh  sR    !-- $()
 	88:;,/??	'r*   c                   ^ S m[         Tl        [        R                  R                  [        S9R                  S S9Tl        [        U R                  SU4S jS9n[        US5      nU R                  UR                  5       5        [        US5      nU R                  X2:  5        U R                  [        [         -  UR                  5        g )Nc                      g r!   r   r   r*   r(   credCTestKubeConfigLoader.test_load_gcp_token_with_refresh.<locals>.cred  s    4r*   rP   rR   rO  c                     > T $ r!   r   )r  s   r(   r  GTestKubeConfigLoader.test_load_gcp_token_with_refresh.<locals>.<lambda>  s    4r*   r  )TEST_ANOTHER_DATA_BASE64r/  datetimenowr   replacerB   r   r  rG   r   r  r   r  )rb   rE   original_expiry
new_expiryr  s       @r(    test_load_gcp_token_with_refresh5TestKubeConfigLoader.test_load_gcp_token_with_refresh  s    -
''++s+3;;4;H!--(#/1 &fm<88:; 7

45,/GG	'r*   c                     " S S5      n " S S5      n[        5       n[        R                  " 5       nX/Ul        [	        U R
                  SUS9nUR                  U5        [        US5      nUR                  U5        [        US5      nU R                  Xv:  5        U R                  [        [        -  UR                  5        g )Nc                       \ rS rSr\r\rSrg)DTestKubeConfigLoader.test_gcp_refresh_api_key_hook.<locals>.cred_oldi  r   N)	r   r   r   r   r   r/  DATETIME_EXPIRY_PASTrB   r   r   r*   r(   cred_oldr    s    $E)Fr*   r  c                       \ rS rSr\r\rSrg)DTestKubeConfigLoader.test_gcp_refresh_api_key_hook.<locals>.cred_newi  r   N)	r   r   r   r   r  r/  DATETIME_EXPIRY_FUTURErB   r   r   r*   r(   cred_newr    s    ,E+Fr*   r  rP  r  )r%  r   Mockside_effectr   r  r  rG   r)  r   r   r  r  r/  )rb   r  r  r  _get_google_credentialsrE   r  r  s           r(   test_gcp_refresh_api_key_hook2TestKubeConfigLoader.test_gcp_refresh_api_key_hook  s    	* 	*	, 	, !l"&))+/7.B+!--0#:< 	K(%f.CD((5 )>?

45,/GG	'r*   c                     [        U R                  SS9nU R                  UR                  5       5        U R	                  [
        UR                  5        g )NrQ  r  )r   r  r   r  r   TEST_OIDC_TOKENr/  r  s     r(   test_oidc_no_refresh)TestKubeConfigLoader.test_oidc_no_refresh/  sC    !--!
 	88:;&,,7r*   z9kubernetes.config.kube_config.OAuth2Session.refresh_tokenz/kubernetes.config.kube_config.ApiClient.requestc                    [         R                  " 5       n[         R                  " SS9[        U5      l        [         R                  " [
        R                  " SS05      S9[        U5      l        X1l        SSS.Ul        [        U R                  SS	9nU R                  UR                  5       5        U R                  S
UR                  5        g )N   return_valuetoken_endpoint"https://example.org/identity/tokenabc123newtoken123id_tokenrefresh_tokenrW  r  Bearer abc123r   	MagicMockPropertyMocktypestatusjsondumpsrM   r  r   r  r   r  r   r/  rb   mock_ApiClientmock_OAuth2Sessionmock_responserE   s        r(   test_oidc_with_refresh+TestKubeConfigLoader.test_oidc_with_refresh7  s     (%)%6%6&
]" $(#4#4 "F% $
]  '4#7?<I+K' "--)
 	88:;&,,7r*   c                    [         R                  " 5       n[         R                  " SS9[        U5      l        [         R                  " [
        R                  " SS05      S9[        U5      l        X1l        SSS.Ul        [        U R                  SS	9nU R                  UR                  5       5        U R                  S
UR                  5        g )Nr  r  r  r  r  r  r  rX  r  r  r  r  s        r(   "test_oidc_with_idp_ca_file_refresh7TestKubeConfigLoader.test_oidc_with_idp_ca_file_refreshP  s     (%)%6%6&
]" $(#4#4 "F% $
]  '4#7?<I+K' "--:

 	88:;&,,7r*   c                    [         R                  " 5       n[         R                  " SS9[        U5      l        [         R                  " [
        R                  " SS05      S9[        U5      l        X1l        SSS.Ul        [        U R                  SS	9nU R                  UR                  5       5        U R                  S
UR                  5        g )Nr  r  r  r  r  r  r  rY  r  r  r  r  s        r(   test_oidc_with_refresh_nocert2TestKubeConfigLoader.test_oidc_with_refresh_nocertj  s     (%)%6%6&
]" $(#4#4 "F% $
]  '4#7?<I+K' "--0
 	88:;&,,7r*   c                 n    [        U R                  SS9nU R                  UR                  S5      S 5        g )NrZ  r  r   r  r   _load_oid_tokenr  s     r(   *test_oidc_fails_if_contains_reserved_chars?TestKubeConfigLoader.test_oidc_fails_if_contains_reserved_chars  s:    !--=
 	""#EF	
r*   c                 n    [        U R                  SS9nU R                  UR                  S5      S 5        g )Nr[  r  r  r  s     r(   )test_oidc_fails_if_invalid_padding_length>TestKubeConfigLoader.test_oidc_fails_if_invalid_padding_length  s:    !--8
 	""#@A	
r*   c                     [        U R                  SS9nU R                  UR                  5       5        U R	                  [
        UR                  5        g )NrR  r  )r   r  r   r  r   TEST_AZURE_TOKEN_FULLr/  r  s     r(   test_azure_no_refresh*TestKubeConfigLoader.test_azure_no_refresh  sD    !--"
 	88:;.=r*   c                     [        U R                  SS9nUR                  S   nU R                  UR	                  U5      5        g )NrS  r  r@   r   r  _userr   _azure_is_expiredrb   rE   providers      r(   test_azure_with_expired_num0TestKubeConfigLoader.test_azure_with_expired_num  ?    !--&
 <<000:;r*   c                     [        U R                  SS9nUR                  S   nU R                  UR	                  U5      5        g )NrT  r  r@   r  r  s      r(   test_azure_with_expired_str0TestKubeConfigLoader.test_azure_with_expired_str  r  r*   c                     [        U R                  SS9nUR                  S   nU R                  [        UR
                  U5        g )NrV  r  r@   r   r  r  rw   
ValueErrorr  r  s      r(   !test_azure_with_expired_str_error6TestKubeConfigLoader.test_azure_with_expired_str_error  @    !--,
 <<0*f&>&>Ir*   c                     [        U R                  SS9nUR                  S   nU R                  [        UR
                  U5        g )NrU  r  r@   r  r  s      r(   !test_azure_with_expired_int_error6TestKubeConfigLoader.test_azure_with_expired_int_error  r!  r*   c                     [        [        [        S9n[        5       n[        U R                  SS9R                  U5        U R                  X5        g )Nr  r\  r  )r%  r  TEST_BASIC_TOKENr   r  r  r   r  s      r(   test_user_pass#TestKubeConfigLoader.test_user_pass  sB    94DE--&	((4V(<*r*   c                     [        U R                  SS9nU R                  UR                  5       5        U R	                  [
        UR                  5        g )Nr\  r  )r   r  r   _load_user_pass_tokenr   r&  r/  r  s     r(   test_load_user_pass_token.TestKubeConfigLoader.test_load_user_pass_token  sD    !--&( 	4467)6<<8r*   c                 v    [        U R                  SS9nU R                  UR                  S[	        5       5        g )Nr_  r  r   )r   r  r   r  r%  r  s     r(   test_ssl_no_cert_files+TestKubeConfigLoader.test_ssl_no_cert_files  s9    !--(* 	L	r*   c           	      ,   [        [        [        [        -  U R	                  [
        5      U R	                  [        5      U R	                  [        5      SS9n[        5       n[        U R                  SS9R                  U5        U R                  X5        g )NTr  r/  r(  r'  r&  
verify_sslr]  r  )r%  TEST_SSL_HOSTr  r   rt   TEST_CLIENT_CERTTEST_CLIENT_KEYTEST_CERTIFICATE_AUTHr   r  r  r   r  s      r(   test_sslTestKubeConfigLoader.test_ssl  s|    %(88,,-=>++O<../DE
 -- 	"".,v"6*r*   c           	         [        [        [        [        -  U R	                  [
        5      U R	                  [        5      SS S9n[        5       n[        U R                  SS9R                  U5        U R                  X5        g )NF)r  r/  r(  r'  r2  r&  r^  r  )r%  r3  r  r   rt   r4  r5  r   r  r  r   r  s      r(   test_ssl_no_verification-TestKubeConfigLoader.test_ssl_no_verification  sp    %(88,,-=>++O<
 --0	22>,v2F*r*   c           
      6   [        [        [        [        -  U R	                  [
        5      U R	                  [        5      U R	                  [        5      S[        S9n[        5       n[        U R                  SS9R                  U5        U R                  X5        g )NT)r  r/  r(  r'  r&  r2  tls_server_namerk  r  )r%  r3  r  r   rt   r4  r5  r6  TEST_TLS_SERVER_NAMEr   r  r  r   r  s      r(   test_tls_server_name)TestKubeConfigLoader.test_tls_server_name  s    %(88,,-=>++O<../DE0
 --,	..:l6.B*r*   c                     [        U R                  SS9nUR                  5       n[        SU R                  5      S   nU H3  nUR	                  US   5      nU R                  UR                  U5        M5     g )NrH  r  r   r  r7   )r   r  list_contextsr   r   r   rD   )rb   rE   actual_contextsexpected_contextsr  r  s         r(   test_list_contexts'TestKubeConfigLoader.test_list_contexts  sr    !--$& !..0&r4+@+@A*M%F(66vf~FHX^^V4 &r*   c                     [        U R                  S9n[        SU R                  5      S   nU R                  UR	                  S5      R
                  UR                  5        g )Nr  r   r  rH  )r   r  r   r   r   rD   current_contextrb   rE   rD  s      r(   test_current_context)TestKubeConfigLoader.test_current_context  sU    !d.C.CD&r4+@+@A*M*88CII//	1r*   c                     [        U R                  S9nUR                  S5        [        SU R                  5      S   nU R	                  UR                  S5      R                  UR                  5        g )NrH  r]  r   r  )r   r  set_active_contextr   r   r   rD   rI  rJ  s      r(   test_set_active_context,TestKubeConfigLoader.test_set_active_context  sc    !d.C.CD!!%(&r4+@+@A*M*88?EE//	1r*   c           	         [        [        [        [        -  U R	                  [
        5      U R	                  [        5      U R	                  [        5      S9n [        R                  " 5       n[        5       n[        [        R                  R                  US5      S5       nUR                  [        R                  5       5        S S S 5        [        [        R                  R                  US5      S5       nUR                  [
        R                  5       5        S S S 5        [        [        R                  R                  US5      S5       nUR                  [        R                  5       5        S S S 5        [        [        R                  R                  US5      S5       nUR                  [        R                  5       5        S S S 5        [!        U R"                  SUS9R%                  U5        U R'                  X5        [(        R*                  " U5        g ! , (       d  f       GN]= f! , (       d  f       GN= f! , (       d  f       N= f! , (       d  f       N= f! [(        R*                  " W5        f = f)	N)r  r/  r(  r'  r&  rn  wbr  r  r  r`  r  r;   config_base_path)r%  r3  r  r   rt   r4  r5  r6  rl   mkdtempr   rf   r   joinro   r$   r   r  r  r   shutilrmtree)rb   r  temp_dirr  fds        r(    test_ssl_with_relative_ssl_files5TestKubeConfigLoader.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<+?X.MM(# A@BBAAAA MM(#sm   A	I   $H2I  6$H,2I  $H>02I  "$I=I  
H)$I  ,
H;6I  >
II  
II   I8c                     [        [        [        [        -  S9nU R	                  [
        R                  " U R                  5      5      n[        5       n[        USUS9  U R                  X5        g )Nr  rL  config_filer~   client_configuration)
r%  r  r  r   rt   yaml	safe_dumpr  r   r   rb   r  r_  r  s       r(   $test_load_kube_config_from_file_path9TestKubeConfigLoader.test_load_kube_config_from_file_path8  s^    9$7:J$JL,,NN40013[..4	6*r*   c                    [        [        [        [        -  S9n[        R
                  " 5       n [        S5        UR                  [        [        R                  " U R                  5      SS95        [        5       n[        USUS9  U R                  X5        g ! [         a2    UR                  [        R                  " U R                  5      5         Nbf = f)Nr  r   r  )errorsrL  r^  )r%  r  r  r   ioStringIOunicodero   ra  rb  r  	NameErrorr   r   )rb   r  config_file_like_objectr  s       r(   +test_load_kube_config_from_file_like_object@TestKubeConfigLoader.test_load_kube_config_from_file_like_objectB  s    9$7:J$JL"$++-
	,BK#))NN--/$&' /"!'	) 	*  	,#))))+,	,s   AB 9CCc                     [        [        [        [        -  S9n[        5       n[	        U R
                  SUS9  U R                  X5        g )Nr  rL  )r  r~   r`  )r%  r  r  r   r   r  r   r  s      r(   test_load_kube_config_from_dict4TestKubeConfigLoader.test_load_kube_config_from_dictY  sF    9$7:J$JL"t/D/D+98>	@ 	*r*   c           	      x   [        [        [        [        -  U R	                  [
        5      U R	                  [        5      U R	                  [        5      SS9n[        5       n[        R                  R                  [        R                  R                  [        R                  R                  [        R                  R                  [        5      5      5      S5      n[        U R                  SUUS9  U R!                  [        R"                  " U5      (       d  SOS5        U R%                  X5        ['        5         g )NTr1  tmp_file_path_testr]  )r  r~   r`  temp_file_pathF)r%  r3  r  r   rt   r4  r5  r6  rf   r   rV  r   abspath__file__r   r  assertFalselistdirr   r   )rb   r  r  tmp_paths       r(   3test_load_kube_config_from_dict_with_temp_file_pathHTestKubeConfigLoader.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%9uE*r*   c                 d    [         R                  " 5       nU R                  [        [        U5        g r!   )rh  ri  rw   r
   r   )rb   rl  s     r(   1test_load_kube_config_from_empty_file_like_objectFTestKubeConfigLoader.test_load_kube_config_from_empty_file_like_objecty  s%    "$++-#	%r*   c                     U R                  [        R                  " S 5      5      nU R                  [        [
        U5        g r!   )rt   ra  rb  rw   r
   r   )rb   r_  s     r(   %test_load_kube_config_from_empty_file:TestKubeConfigLoader.test_load_kube_config_from_empty_file  s5    ,,NN4 "	r*   c                 P   U R                  [        R                  " U R                  5      5      n[	        US9u  p#U R                  U R                  S   S   U5        [        (       a   U R                  U R                  S   U5        g U R                  U R                  S   U5        g )Nr_  r  r   )	rt   ra  rb  r  r   assertDictEqualr   assertCountEqualassertItemsEqual)rb   r_  r  r;   s       r(   test_list_kube_config_contexts3TestKubeConfigLoader.test_list_kube_config_contexts  s    ,,NN40013#<#$% T22:>qA+	-3!!$"7"7
"C"*, !!$"7"7
"C"*,r*   c                 2   U R                  [        R                  " U R                  5      5      n[	        USS9nU R                  [        UR                  R                  5        U R                  [        [        -  UR                  R                  S   5        g NrL  )r_  r~   r+  )rt   ra  rb  r  r   r   r  configurationr  r  r   r,  )rb   r_  clients      r(   test_new_client_from_config0TestKubeConfigLoader.test_new_client_from_config  s{    ,,NN40013'#^=F$8$8$=$=>,/??--55oF	Hr*   c                     [        U R                  SS9nU R                  [        UR                  R
                  5        U R                  [        [        -  UR                  R                  S   5        g )NrL  )r  r~   r+  )	r   r  r   r  r  r  r  r   r,  )rb   r  s     r(    test_new_client_from_config_dict5TestKubeConfigLoader.test_new_client_from_config_dict  s`    ,--~GF$8$8$=$=>,/??--55oF	Hr*   c                     [        [        S9n[        5       nU R                  R                  5       nUS	 [	        USS9R                  U5        U R                  X5        g )Nr  r>   rN  r  )r%  r  r  copyr   r  r   )rb   r  r  test_kube_configs       r(   test_no_users_section*TestKubeConfigLoader.test_no_users_section  sV    9-00557W%( 	"".,v"6*r*   c                     [        [        S9n[        5       n[        U R                  SS9R	                  U5        U R                  X5        g )Nr  ra  r  r  r  s      r(   test_non_existing_user+TestKubeConfigLoader.test_non_existing_user  s?    9---.	00<V0D*r*   z.kubernetes.config.kube_config.ExecProvider.runc                     SnSU0Ul         [        [        S[        U-  0S9n[        5       n[	        U R
                  SS9R                  U5        U R                  X45        g )Ndummyr/  r+  )r  r,  rb  r  )r  r%  r  r  r   r  r  r   )rb   r   r/  r  r  s        r(   test_user_exec_auth(TestKubeConfigLoader.test_user_exec_auth  si    U
 9-/BU/J7L M--+	--9\&-A*r*   c                    SnSnU[        [        5      S.U[        [        5      S./Ul        [	        5       nU R                  UR                  5        [        U R                  SS9R                  U5        U R                  UR                  S   [        U-  5        U R                  UR                  5        UR                  U5        U R                  UR                  S   [        U-  5        g )Nexpiredcurrent)r/  expirationTimestamprb  r  r+  )r   r  r  r  r%  r  r)  r   r  r  r   r,  r  r  )rb   r   expired_tokencurrent_tokenr  s        r(   test_user_exec_auth_with_expiry4TestKubeConfigLoader.test_user_exec_auth_with_expiry  s    !! ''56J'K
 ''56L'M	
 !l+::;--+	--9\+-F 	,,_=,}<	> 	[==>((5,,_=,}<	>r*   c                 8   [         [        S.Ul        [        [        U R                  [         5      U R                  [        5      U R                  [        5      SS9n[        5       n[        U R                  SS9R                  U5        U R                  X#5        g )N)clientCertificateDataclientKeyDataT)r  r(  r'  r&  r2  rc  r  )r4  r5  r  r%  r3  rt   r6  r   r  r  r   )rb   r   r  r  s       r(    test_user_exec_auth_certificates5TestKubeConfigLoader.test_user_exec_auth_certificates  s     &6,
 ,,-=>++O<../DE --7	99Ef9M*r*   )autospecc                    ^ 0 mU4S jnX!l         Sn[        U R                  SUS9R                  [	        5       5        U R                  UTS   5        g )Nc                 $   > U R                   TS'   g )Ncwd)r  )exec_providercaptures    r(   capture_cwd<TestKubeConfigLoader.test_user_exec_cwd.<locals>.capture_cwd  s    *..GENr*   z/some/random/pathrb  rS  r  )r  r   r  r  r%  r   )rb   r   r  r  r  s       @r(   test_user_exec_cwd'TestKubeConfigLoader.test_user_exec_cwd  sQ    	/&&--+%	' (4|JL'A75>2r*   c                 Z   [        SSS/5      nSnU" U[        [        R                  R                  5       5      5      n[        R
                  " US9[        l        [        S[        U-  0S9n[        5       n[        U R                  SS	9R                  U5        U R                  XE5        g )
NAr/  rB   r  r  r+  r,  rd  r  )r   r   r  r  r   r  r   r/  r%  r  r   r  r  r   rb   r  r/  r  r  r  s         r(   test_user_cmd_path'TestKubeConfigLoader.test_user_cmd_path  s    sWh/0h.?.?.C.C.E FG#'99,#G -/BU/J'L M--/	11=f1E*r*   c                 $  ^ ^ [        SSS/5      nSnU" U[        [        R                  R                  5       5      5      n[        R
                  " US9[        l        [        S[        U-  0S9n[        5       mT R                  UU 4S jS	5        g )
Nr  r/  rB   r  r  r+  r  c                  J   > [        TR                  SS9R                  T 5      $ )Nrg  r  r   r  r  r  rb   s   r(   r  ?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  r   r  s   `    @r(   test_user_cmd_path_empty-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                 $  ^ ^ [        SSS/5      nSnU" U[        [        R                  R                  5       5      5      n[        R
                  " US9[        l        [        S[        U-  0S9n[        5       mT R                  UU 4S jS	5        g )
Nr  r/  rB   r  r  r+  r  c                  J   > [        TR                  SS9R                  T 5      $ )Nri  r  r  r  s   r(   r  DTestKubeConfigLoader.test_user_cmd_path_with_scope.<locals>.<lambda>*  r  r*   zGscopes can only be used when kubectl is using a gcp service account keyr  r  s   `    @r(   test_user_cmd_path_with_scope2TestKubeConfigLoader.test_user_cmd_path_with_scope"  s    sWh/0h.?.?.C.C.E FG#'99,#G -/BU/J'L M K(	)r*   c                     [        [        [        [        -  S9nU R	                  [
        R                  " U R                  5      5      n[        U5      nU R                  UR                  5        g )Nr  )r%  r  r  r   rt   ra  rb  r  r   r  _config_persisterrc  s       r(   5test__get_kube_config_loader_for_yaml_file_no_persistJTestKubeConfigLoader.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                 <   [        [        [        [        -  S9nU R	                  [
        R                  " U R                  5      5      n[        USS9nU R                  [        UR                  5      5        U R                  UR                  R                  S5        g )Nr  T)persist_configsave_changes)r%  r  r  r   rt   ra  rb  r  r   r   callabler  r   r   rc  s       r(   2test__get_kube_config_loader_for_yaml_file_persistGTestKubeConfigLoader.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                     [        [        [        [        -  S9nU R	                  [
        R                  " U R                  5      5      n[        US9nU R                  UR                  5        g )Nr  )r   )r%  r  r  r   rt   ra  rb  r  r   r  r  rc  s       r(   ,test__get_kube_config_loader_file_no_persistATestKubeConfigLoader.test__get_kube_config_loader_file_no_persistB  sX    9$7:J$JL,,NN40013(+>&223r*   c                 <   [        [        [        [        -  S9nU R	                  [
        R                  " U R                  5      5      n[        USS9nU R                  [        UR                  5      5        U R                  UR                  R                  S5        g )Nr  T)r   r  r  )r%  r  r  r   rt   ra  rb  r  r   r   r  r  r   r   rc  s       r(   )test__get_kube_config_loader_file_persist>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                     [        [        [        [        -  S9n[	        U R
                  S9nU R                  UR                  5        g )Nr  rH  )r%  r  r  r   r   r  r  r  r  s      r(   ,test__get_kube_config_loader_dict_no_persistATestKubeConfigLoader.test__get_kube_config_loader_dict_no_persistT  s?    9$7:J$JL(--/&223r*   r   N)Nr   r   r   r   r  r3  r6  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_LENGTHr4  r5  TEST_CLIENT_CERT_BASE64TEST_CLIENT_KEY_BASE64r  r  r  r  r  r  r  r  r  r   patchr  r  r  r  r
  r  r  r  r  r#  r'  r+  r.  r7  r:  r?  rE  rK  rO  r[  rd  rm  rp  rz  r}  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r   r*   r(   rG  rG    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 
ZZKL	ZZAB8 C M8. 
ZZKL	ZZAB8 C M80 
ZZKL	ZZAB8 C M80

><<JJ+9+++ 511$6++.+.%,HH++ 
ZZ@A+ B+ 
ZZ@A> B>> 
ZZ@A+ B+" 
ZZ@4P3 Q3+E)4L4L4r*   rG  c                        \ rS rSrS rS rSrg)!TestKubernetesClientConfigurationi\  c                 J    U R                  [        [        5       S5      5        g )Nr)  )r   hasattrr   ra   s    r(    test_refresh_api_key_hook_existsBTestKubernetesClientConfiguration.test_refresh_api_key_hook_existsb  s    1GHIr*   c                    ^ ^^^ SmSmSn[        TU0TS0S9mUUUU 4S jnUTl        T R                  ST-   TR                  T5      5        g )Nr+  expected_token	old_tokenBearer)r,  api_key_prefixc                 H   > TR                  U T5        TU R                  T'   g r!   )r   r,  )client_configrA   r  
identifierrb   s    r(   r)  kTestKubernetesClientConfiguration.test_get_api_key_calls_refresh_api_key_hook.<locals>.refresh_api_key_hookn  s#    ]F30>M!!*-r*   rZ   )r   r)  r   get_api_key_with_prefix)rb   r  r)  rA   r  r  s   `  @@@r(   +test_get_api_key_calls_refresh_api_key_hookMTestKubernetesClientConfiguration.test_get_api_key_calls_refresh_api_key_hooke  sd    $
)	+&1

	? 	? ';#^377
C	Er*   r   N)r   r   r   r   r  r  r   r   r*   r(   r  r  \  s    JEr*   r  c                      \ rS rSrSSSS0S./SS\0S.// S.S	S
S
S
S.S.SSSS.S./S
\\S.S./S
\\\	S.S./S.SSSSS.S.S
SSS.S.// SSSSS\
\SSS.S.0S.S\\\S.S./S.SS0SSSS.S./S0 S./SSS S!S"0S.0S./S#.SSSS0S./SS\0S./S$S./rS%SS\0S./0SSSSS.S./S&.S'S\\\S.S./0/rS( rS) rS* rS+ rS, rS-rg$).TestKubeConfigMergeriw  rH  rI  rJ  rK  rl  rm  r  r   r]  rM  rL  )rl  ro  r  rt  rW  z"skipped-part2-defined-this-contextskippedr@   rQ  r  r  r  r  r  rv  rq  r  rd  re  rf  rN  r  r  )r  r  r>   Nr  )r  r  r>   c                     / nU H7  nUR                  U R                  [        R                  " U5      5      5        M9     [        R
                  " U5      $ r!   )rn   rt   ra  rb  r   rV  )rb   partsfilesparts       r(   _create_multi_config)TestKubeConfigMerger._create_multi_config6  sB    DLL//t0DEF ,11%88r*   c                     U R                  U R                  5      nSS0SS.SSS.SS.SSS.SS.SSS.SS.S	S
S.SS./n[        US9u  p4U R                  X25        U R                  XBS   5        g )NrI  rJ  rH  r~   r7   r]  rM  rL  rW  re  rf  rd  r  r   )r  TEST_KUBE_CONFIG_SET1r   r   )rb   kubeconfigsrD  r  r;   s        r(   r  3TestKubeConfigMerger.test_list_kube_config_contexts<  s    //0J0JK"I.	B$)595I$-~F#%$-~F#%$8!24)+	, $=#$%  	51)=>r*   c                 
   U R                  U R                  5      n[        USS9nU R                  [        UR
                  R                  5        U R                  [        [        -  UR
                  R                  S   5        g r  )
r  r  r   r   r  r  r  r  r   r,  )rb   r  r  s      r(   r  0TestKubeConfigMerger.test_new_client_from_configO  so    //0J0JK'#^=F$8$8$=$=>,/??--55oF	Hr*   c                 z   U R                  U R                  5      n[        US9nSSS.SS./n[        US9u  pEU R	                  XC5        U R	                  XSS   5        U R	                  [
        UR                  R                  5        U R	                  [        [        -  UR                  R                  S   5        g )Nr  rJ  rL  rM  r  r   r+  )r  TEST_KUBE_CONFIG_SET2r   r   r   r  r  r  r  r   r,  )rb   r  r  rD  r  r;   s         r(   )test_merge_with_context_in_different_file>TestKubeConfigMerger.test_merge_with_context_in_different_fileW  s    //0J0JK'K@ %.~F#%
 $=#$% 51)=>F$8$8$=$=>,/??--55oF	Hr*   c                    U R                  U R                  5      n[        U5      nUR                  S   R	                  S5      S   nUS   S   nSUR
                  S'   UR                  5         [        U5      nUR                  S   R	                  S5      S   nUS   S   nU R                  UR
                  S   S5        g )Nr>   rW  r?   r@   rA   ztoken-changedrw  )r  r  r   rA   r   rD   r  r   )rb   r  kconfr?   r  s        r(   test_save_changes&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   r   r   r  r3  r  r   r  r  r  r  r  r  r  r  r  r  r  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  rh  r  rf   r   rW  rl   unittestcollectionsr   r   ra  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   rG   rK   r   r   TEST_FILENAMEr   r   r   r  r  r  r  r&  r  r  	timedeltar  r  r  r3  r6  r  r5  r  r4  r  r>  r  TEST_OIDC_INFOrV  TEST_OIDC_BASEr  TEST_OIDC_EXPTEST_OIDC_EXP_BASEr  r  r  r  TEST_AZURE_LOGINr  r  TestCaser\   r   r   r%  rG  r  r  r   mainr   r*   r(   <module>r&     sL     	  	     "    + - 8 8k k k k k " -   4 ?J/% 	9% ' "#45 	' ((,,, //6wdw/ChFXFXavFwx !**..#. 1181E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MMO r*   