
    =KiS                         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Jr  SSK	J
r
JrJrJr  SrSrSrS	rS
rSrSrSr\
\\\0r\
\\\0r " S S\R0                  5      r\S:X  a  \R6                  " 5         gg)    N)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                       \ rS rSrS rS rSS jrSS\4S j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)InClusterConfigTest.   c                     / U l         g N_temp_filesselfs    i/var/www/html/dynamic-report/venv/lib/python3.13/site-packages/kubernetes/config/incluster_config_test.pysetUpInClusterConfigTest.setUp/   s
        c                 V    U R                    H  n[        R                  " U5        M     g r   )r   osremove)r   fs     r   tearDownInClusterConfigTest.tearDown2   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   appendr   writestrencodeclose)r   contenthandlernames       r   _create_file_with_temp_content2InClusterConfigTest._create_file_with_temp_content6   sN     ((*%
#**W-.
r   Nc                     U(       d  U R                  [        5      nU(       d  U R                  [        5      n[        UUSUS9$ )NT)token_filenamecert_filenametry_refresh_tokenenviron)r,   _TEST_TOKEN
_TEST_CERTr   )r   r/   r0   r2   s       r   get_test_loader#InClusterConfigTest.get_test_loader=   sB     !@@MN ??
KM$N3@7;-46 	6r   c                     U R                  [        [        [        [        5      5        U R                  [
        [        [        [        5      5        g r   )assertEqual_TEST_HOST_PORTr	   
_TEST_HOST
_TEST_PORT_TEST_IPV6_HOST_PORT_TEST_IPV6_HOSTr   s    r   test_join_host_port'InClusterConfigTest.test_join_host_portJ   s9    (Z@	B-(*E	Gr   c                 .   U R                  [        5      nU R                  US9nUR                  5         U R	                  S[
        -   UR                  5        U R	                  XR                  5        U R	                  S[        -   UR                  5        g )Nr0   zhttps://bearer )
r,   r4   r5   _load_configr8   r9   hostssl_ca_certr3   token)r   r0   loaders      r   test_load_config$InClusterConfigTest.test_load_configP   sw    ;;JG%%M%Bo5v{{C(:(:;[0&,,?r   c                    U R                  5       n[        5       nUR                  U5        U R                  S[        -   UR                  S5      5        U R                  S[        -   UR                  5        U R                  UR                  5        UR                  nUR                  nU R                  [        5      Ul        U R                  S[        -   UR                  S5      5        [        R                  R                  5       Ul        U R                  S[        -   UR                  S5      5        U R                  S[        -   UR                  5        U R                  UR                  U5        g )NrB   authorization)r5   r   load_and_setr8   r3   get_api_key_with_prefixrF   assertIsNotNonetoken_expires_atr,   _TEST_NEW_TOKEN_token_filenamedatetimenowassertGreater)r   rG   config	old_tokenold_token_expires_ats        r   test_refresh_token&InClusterConfigTest.test_refresh_tokenX   s2   %%'F#[077H	J[0&,,?V445LL	%66!%!D!D"[077H	J #+"3"3"7"7"9_477H	J_4fllC6224HIr   c                 n     UR                  5         U R                  SU-  5        g ! [         a     g f = f)NzShould fail because %s)rL   failr   )r   config_loaderreasons      r   _should_fail_load%InClusterConfigTest._should_fail_loado   s7    	&&(II.78 		s   $' 
44c                 Z    U R                  [        [        0S9nU R                  US5        g )Nr2   zno port specified)r5   r   r:   r^   r   rG   s     r   test_no_port InClusterConfigTest.test_no_portw   0    %%*J7 & 9v':;r   c                 f    U R                  [        [        [        S0S9nU R	                  US5        g )N ra   zempty port specified)r5   r   r:   r   r^   rb   s     r   test_empty_port#InClusterConfigTest.test_empty_port|   s7    %%!:!2/
%  	v'=>r   c                 Z    U R                  [        [        0S9nU R                  US5        g )Nra   zno host specified)r5   r   r;   r^   rb   s     r   test_no_host InClusterConfigTest.test_no_host   re   r   c                 f    U R                  [        S[        [        0S9nU R	                  US5        g )Nrg   ra   zempty host specified)r5   r   r   r;   r^   rb   s     r   test_empty_host#InClusterConfigTest.test_empty_host   s7    %%!2!:/
%  	v'=>r   c                 F    U R                  SS9nU R                  US5        g )Nnot_exists_file_1123rA   zcert file does not existr5   r^   rb   s     r   test_no_cert_file%InClusterConfigTest.test_no_cert_file   s'    %%4J%Kv'ABr   c                 b    U R                  U R                  5       S9nU R                  US5        g )NrA   zempty cert file providedr5   r,   r^   rb   s     r   test_empty_cert_file(InClusterConfigTest.test_empty_cert_file   s5    %%==? & Av'ABr   c                 F    U R                  SS9nU R                  US5        g )Nrq   r/   ztoken file does not existrr   rb   s     r   test_no_token_file&InClusterConfigTest.test_no_token_file   s'    %%5K%Lv'BCr   c                 b    U R                  U R                  5       S9nU R                  US5        g )Nrz   zempty token file providedrv   rb   s     r   test_empty_token_file)InClusterConfigTest.test_empty_token_file   s5    %%>>@ & Bv'BCr   r   )rg   )__name__
__module____qualname____firstlineno__r   r   r,   _TEST_ENVIRONr5   r>   rH   rX   r^   rc   rh   rk   rn   rs   rw   r{   r~   __static_attributes__ r   r   r   r   .   sd     (,&* -6G@J.<
?<
?CC
DDr   r   __main__)rR   r   r"   timeunittestkubernetes.clientr   config_exceptionr   incluster_configr   r   r   r	   r3   rP   r4   r:   r;   r9   r=   r<   r   _TEST_IPV6_ENVIRONTestCaser   r   mainr   r   r   <module>r      s     	    + -G G "


 !  ::
 ?: qD(++ qDh zMMO r   