Ë
    dQêj$  ã                   óä   — 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mZ ddlm	Z	 ddl
mZmZmZmZ dZdZd	Zd
ZdZdZdZdZeeeeiZeeeeiZ G d„ de«      Zedk(  r ej6                  «        yy)é    N)ÚIsolatedAsyncioTestCase)ÚConfigurationé   )ÚConfigException)ÚSERVICE_HOST_ENV_NAMEÚSERVICE_PORT_ENV_NAMEÚInClusterConfigLoaderÚ_join_host_portÚ
temp_tokenÚtemp_new_tokenÚ	temp_certz	127.0.0.1Ú80z127.0.0.1:80z::1z[::1]:80c                   ó|   — e Zd Zd„ Zd„ Zdd„Zddef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)ÚInClusterConfigTestc                 ó   — g | _         y ©N)Ú_temp_files©Úselfs    úp/home/oem/CyberBrain26-unified/.venv/lib/python3.12/site-packages/kubernetes/aio/config/incluster_config_test.pyÚsetUpzInClusterConfigTest.setUp0   s
   € ØˆÕó    c                 óP   — | j                   D ]  }t        j                  |«       Œ y r   )r   ÚosÚremove)r   Úfs     r   ÚtearDownzInClusterConfigTest.tearDown3   s"   € Ø×!Ñ!ò 	ˆAÜ�I‰I�a�Lñ	r   c                 óæ   — t        j                  «       \  }}| j                  j                  |«       t	        j
                  |t        j                  |«      «       t	        j                  |«       |S r   )	ÚtempfileÚmkstempr   Úappendr   ÚwriteÚstrÚencodeÚclose)r   ÚcontentÚhandlerÚnames       r   Ú_create_file_with_temp_contentz2InClusterConfigTest._create_file_with_temp_content7   sP   € Ü ×(Ñ(Ó*‰ˆ�Ø×Ñ×Ñ Ô%Ü
�‰�œ#Ÿ*™* WÓ-Ô.Ü
�‰�ÔØˆr   Nc                 ó|   — |s| j                  t        «      }|s| j                  t        «      }t        ||d|¬«      S )NT)Útoken_filenameÚcert_filenameÚtry_refresh_tokenÚenviron)r)   Ú_TEST_TOKENÚ
_TEST_CERTr	   )r   r+   r,   r.   s       r   Úget_test_loaderz#InClusterConfigTest.get_test_loader>   sB   € ñ Ø!×@Ñ@ÄÓMˆNÙØ ×?Ñ?Ä
ÓKˆMÜ$°NØ3@Ø7;Ø-4ô6ð 	6r   c                 ó¤   — | j                  t        t        t        t        «      «       | j                  t
        t        t        t        «      «       y r   )ÚassertEqualÚ_TEST_HOST_PORTr
   Ú
_TEST_HOSTÚ
_TEST_PORTÚ_TEST_IPV6_HOST_PORTÚ_TEST_IPV6_HOSTr   s    r   Útest_join_host_portz'InClusterConfigTest.test_join_host_portK   s9   € Ø×ÑœÜ(¬´ZÓ@ô	Bà×ÑÔ-Ü(¬¼*ÓEõ	Gr   c                 ó6  — | j                  t        «      }| j                  |¬«      }|j                  «        | j	                  dt
        z   |j                  «       | j	                  ||j                  «       | j	                  dt        z   |j                  «       y )N©r,   zhttps://úbearer )
r)   r0   r1   Ú_load_configr3   r4   ÚhostÚssl_ca_certr/   Útoken)r   r,   Úloaders      r   Útest_load_configz$InClusterConfigTest.test_load_configQ   sy   € Ø×;Ñ;¼JÓGˆØ×%Ñ%°MÐ%ÓBˆØ×ÑÔØ×Ñ˜¤oÑ5°v·{±{ÔCØ×Ñ˜¨×(:Ñ(:Ô;Ø×Ñ˜¤[Ñ0°&·,±,Õ?r   c              ƒ   ó4  K  — | j                  «       }t        «       }|j                  |«       | j                  dt        z   |j                  d«      ƒ d {  –—† «       | j                  dt        z   |j                  «       | j                  |j                  «       |j                  }|j                  }| j                  t        «      |_        | j                  dt        z   |j                  d«      ƒ d {  –—† «       t        j                  j                  «       |_        | j                  dt        z   |j                  d«      ƒ d {  –—† «       | j                  dt        z   |j                  «       | j                  |j                  |«       y 7 �Œ<7 Œž7 ŒM­w)Nr<   ÚBearerToken)r1   r   Úload_and_setr3   r/   Úget_api_key_with_prefixr@   ÚassertIsNotNoneÚtoken_expires_atr)   Ú_TEST_NEW_TOKENÚ_token_filenameÚdatetimeÚnowÚassertGreater)r   rA   ÚconfigÚ	old_tokenÚold_token_expires_ats        r   Útest_refresh_tokenz&InClusterConfigTest.test_refresh_tokenY   sS  è ø€ Ø×%Ñ%Ó'ˆÜ“ˆØ×Ñ˜FÔ#à×Ñ˜¤[Ñ0Ø%×=Ñ=¸mÓL×Lô	Nà×Ñ˜¤[Ñ0°&·,±,Ô?Ø×Ñ˜V×4Ñ4Ô5à—L‘Lˆ	Ø%×6Ñ6ÐØ!%×!DÑ!DÜó"ˆÔà×Ñ˜¤[Ñ0Ø%×=Ñ=¸mÓL×Lô	Nô #+×"3Ñ"3×"7Ñ"7Ó"9ˆÔØ×Ñ˜¤_Ñ4Ø%×=Ñ=¸mÓL×Lô	Nà×Ñ˜¤_Ñ4°f·l±lÔCØ×Ñ˜6×2Ñ2Ð4HÕIð Mùð Møð Mús9   ‚AFÁF
ÁBFÃ5F
Ã6AFÅF
Å	A	FÆFÆFc              ƒ   óÀ   K  — t        «       }d|j                  d<   d|j                  d<   |j                  «       ƒ d{  –—† }| j	                  |d   d   d«       y7 Œ­w)a$  Legacy callers that split the token and prefix across
        api_key['authorization'] and api_key_prefix['authorization'] (rather
        than embedding "Bearer " in the token itself) must still get the
        prefix applied. https://github.com/kubernetes-client/python/issues/2592
        Úabc123ÚauthorizationÚBearerNrD   ÚvaluezBearer abc123)r   Úapi_keyÚapi_key_prefixÚauth_settingsr3   )r   rN   Úsettingss      r   Ú4test_auth_settings_with_authorization_key_and_prefixzHInClusterConfigTest.test_auth_settings_with_authorization_key_and_prefixp   s]   è ø€ ô “ˆØ*2ˆ�‰�Ñ'Ø19ˆ×Ñ˜oÑ.Ø×-Ñ-Ó/×/ˆØ×Ñ˜ -Ñ0°Ñ9¸?ÕKð 0ús   ‚<A¾A¿Ac                 ól   — 	 |j                  «        | j                  d|z  «       y # t        $ r Y y w xY w)NzShould fail because %s)rE   Úfailr   )r   Úconfig_loaderÚreasons      r   Ú_should_fail_loadz%InClusterConfigTest._should_fail_load|   s7   € ð	Ø×&Ñ&Ô(Ø�I‰IÐ.°Ñ7Õ8øÜò 	áð	ús   ‚$' §	3²3c                 ó`   — | j                  t        t        i¬«      }| j                  |d«       y )N©r.   zno port specified)r1   r   r5   r`   ©r   rA   s     r   Útest_no_portz InClusterConfigTest.test_no_port„   ó0   € Ø×%Ñ%Ü*¬JÐ7ð &ó 9ˆà×Ñ˜vÐ':Õ;r   c                 ól   — | j                  t        t        t        di¬«      }| j	                  |d«       y )NÚ rb   zempty port specified)r1   r   r5   r   r`   rc   s     r   Útest_empty_portz#InClusterConfigTest.test_empty_port‰   s7   € Ø×%Ñ%Ü!¤:Ü! 2ð/
Ð%ó ˆð 	×Ñ˜vÐ'=Õ>r   c                 ó`   — | j                  t        t        i¬«      }| j                  |d«       y )Nrb   zno host specified)r1   r   r6   r`   rc   s     r   Útest_no_hostz InClusterConfigTest.test_no_host�   re   r   c                 ól   — | j                  t        dt        t        i¬«      }| j	                  |d«       y )Nrg   rb   zempty host specified)r1   r   r   r6   r`   rc   s     r   Útest_empty_hostz#InClusterConfigTest.test_empty_host•   s7   € Ø×%Ñ%Ü! 2Ü!¤:ð/
Ð%ó ˆð 	×Ñ˜vÐ'=Õ>r   c                 óL   — | j                  d¬«      }| j                  |d«       y )NÚnot_exists_file_1123r;   zcert file does not exist©r1   r`   rc   s     r   Útest_no_cert_filez%InClusterConfigTest.test_no_cert_fileœ   s'   € Ø×%Ñ%Ð4JÐ%ÓKˆØ×Ñ˜vÐ'AÕBr   c                 óh   — | j                  | j                  «       ¬«      }| j                  |d«       y )Nr;   zempty cert file provided©r1   r)   r`   rc   s     r   Útest_empty_cert_filez(InClusterConfigTest.test_empty_cert_file    s5   € Ø×%Ñ%Ø×=Ñ=Ó?ð &ó Aˆà×Ñ˜vÐ'AÕBr   c                 óL   — | j                  d¬«      }| j                  |d«       y )Nrn   ©r+   ztoken file does not existro   rc   s     r   Útest_no_token_filez&InClusterConfigTest.test_no_token_file¥   s'   € Ø×%Ñ%Ð5KÐ%ÓLˆØ×Ñ˜vÐ'BÕCr   c                 óh   — | j                  | j                  «       ¬«      }| j                  |d«       y )Nru   zempty token file providedrr   rc   s     r   Útest_empty_token_filez)InClusterConfigTest.test_empty_token_file©   s5   € Ø×%Ñ%Ø×>Ñ>Ó@ð &ó Bˆà×Ñ˜vÐ'BÕCr   )rg   )Ú__name__Ú
__module__Ú__qualname__r   r   r)   Ú_TEST_ENVIRONr1   r9   rB   rQ   r[   r`   rd   rh   rj   rl   rp   rs   rv   rx   © r   r   r   r   /   sj   „ òòóð (,Ø&*Ø -ó6òGò@òJò.
Lòò<ò
?ò<ò
?òCòCò
DóDr   r   Ú__main__)rK   r   r   ÚtimeÚunittestr   Úkubernetes.aio.clientr   Úconfig_exceptionr   Úincluster_configr   r   r	   r
   r/   rI   r0   r5   r6   r4   r8   r7   r|   Ú_TEST_IPV6_ENVIRONr   ry   Úmainr}   r   r   ú<module>r†      s©   ðó Û 	Û Û Û Ý ,å /å -÷Gó Gð €Ø"€Ø€
Ø€
Ø€
Ø €Ø€Ø!Ð ð ˜:Ø˜:ð€ð
 ˜?Ø˜:ðÐ ô}DÐ1ô }Dð@ ˆzÒØ€H‡M�M…Oð r   