
    X                         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   " S S\R                  5      r
\S:X  a  \R                  " 5         gg)	    N   )ConfigException)ExecProvider)
ConfigNodec                      \ rS rSrS rS r\R                  " S5      S 5       r\R                  " S5      S 5       r	\R                  " S5      S 5       r
\R                  " S5      S 5       r\R                  " S5      S	 5       rS
rg)ExecProviderTest   c                 B    [        SS/ SQSS S.5      U l        SU l        g )Ntestzaws-iam-authenticator)tokenz-idummyz$client.authentication.k8s.io/v1beta1)commandargs
apiVersionenvz
        {
            "apiVersion": "client.authentication.k8s.io/v1beta1",
            "kind": "ExecCredential",
            "status": {
                "token": "dummy"
            }
        }
        )r   input_ok	output_ok)selfs    7lib/third_party/kubernetes/config/exec_provider_test.pysetUpExecProviderTest.setUp   s+    .,@	
DMDN    c                 *   [        S0 5      [        SSS05      [        SSS05      /nU HU  nU R                  [        5       n[        U5        S S S 5        U R	                  SWR
                  R                  S   5        MW     g ! , (       d  f       N<= f)	Ntest1test2r    test3r   z$exec: malformed request. missing keyr   )r   assertRaisesr   r   assertIn	exceptionr   )r   exec_configsexec_configcontexts       r   test_missing_input_keys(ExecProviderTest.test_missing_input_keys/   s    7B7YO,7\2./L
 $_-[! .
mm:%%**1-/ $--s   B
B	zsubprocess.Popenc                    UR                   nSUR                  l         SUR                  l         U R                  [        5       n[        U R                  5      nUR                  5         S S S 5        U R                  SUR                  R                   -  WR                  R                  S   5        g ! , (       d  f       NO= f)Nr   r   r   zexec: process returned %dr   return_valuewaitcommunicater   r   r   r   runr   r    r   r   mockinstancer#   eps        r   test_error_code_returned)ExecProviderTest.test_error_code_returned;   s      H!"HMM(0H%			?	+w&bffh 
, 	MM-0J0JJ##((+- 
,	+s   &B33
Cc                 Z   UR                   nSUR                  l         SUR                  l         U R                  [        5       n[        U R                  5      nUR                  5         S S S 5        U R                  SWR                  R                  S   5        g ! , (       d  f       N8= f)Nr   r'   z%exec: failed to decode process outputr(   r-   s        r   test_nonjson_output_returned-ExecProviderTest.test_nonjson_output_returnedF   s      H!"HMM(0H%			?	+w&bffh 
, 	MM9##((+- 
,	+s   &B
B*c                 x   UR                   nSUR                  l         / SQnU H  nUS4UR                  l         U R                  [        5       n[        U R                  5      nUR                  5         S S S 5        U R                  SWR                  R                  S   5        M     g ! , (       d  f       N<= f)Nr   )z
            {
                "kind": "ExecCredential",
                "status": {
                    "token": "dummy"
                }
            }
            z
            {
                "apiVersion": "client.authentication.k8s.io/v1beta1",
                "status": {
                    "token": "dummy"
                }
            }
            z
            {
                "apiVersion": "client.authentication.k8s.io/v1beta1",
                "kind": "ExecCredential"
            }
            r   z%exec: malformed response. missing keyr(   )r   r.   r/   outputsoutputr#   r0   s          r   test_missing_output_keys)ExecProviderTest.test_missing_output_keysQ   s      H!"HMMG, +12,h'_-$--(
 . mm;%%**1-/ --s   &B++
B9	c                 r   UR                   nSUR                  l         SnSU-  nUS4UR                  l         U R                  [        5       n[        U R                  5      nUR                  5         S S S 5        U R                  SU-  WR                  R                  S   5        g ! , (       d  f       N;= f)Nr   zclient.authentication.k8s.io/v1z
        {
            "apiVersion": "%s",
            "kind": "ExecCredential",
            "status": {
                "token": "dummy"
            }
        }
        r   z*exec: plugin api version %s does not matchr(   )r   r.   r/   wrong_api_versionr8   r#   r0   s          r   test_mismatched_api_version,ExecProviderTest.test_mismatched_api_versions   s      H!"HMM9   F *0H%			?	+w&bffh 
, 	MM47HHq!# 
,	+s   &B((
B6c                 (   UR                   nSUR                  l         U R                  S4UR                  l         [	        U R
                  5      nUR                  5       nU R                  [        U[        5      5        U R                  SU;   5        g )Nr   r   r   )
r)   r*   r   r+   r   r   r,   
assertTrue
isinstancedict)r   r.   r/   r0   results        r   
test_ok_01ExecProviderTest.test_ok_01   sm      H!"HMM)-(<H%	dmm	$BVVXFOOJvt,-OOGv%&r   )r   r   N)__name__
__module____qualname____firstlineno__r   r$   r.   patchr1   r4   r9   r=   rD   __static_attributes__ r   r   r   r      s    $
/ :: !- "- :: !- "- :: !/ "/B :: !# "#* :: !' "'r   r   __main__)osunittestr.   config_exceptionr   exec_providerr   kube_configr   TestCaser   rF   mainrL   r   r   <module>rU      sF   " 
   - ' #v'x(( v'r z
--/ r   