
    _Ej                        S SK Jr  S SKrS SKJs  Jr  S SKrS SK	J
r
Jr  S SKrS SKJr  S rS r\" S5      S 5       r\" S5      S	 5       rS
 rg)    )annotationsN)	MagicMockpatch)handle_log_readc                 .   [        SS05      n U S   nSo!UL o3(       do  [        R                  " SU4SX45      [        R                  " U5      [        R                  " U5      S.-  nSS	U0-  n[	        [        R
                  " U5      5      eS =n=p2S
oS   o!U;   o3(       do  [        R                  " SU4SX45      [        R                  " U5      [        R                  " U5      S.-  nSS	U0-  n[	        [        R
                  " U5      5      eS =n=p2g )Nlog_typeapache_accesssuccessFisz%(py1)s is %(py4)spy1py4assert %(py6)spy6zInvalid log typeerrorinz%(py1)s in %(py4)s)r   
@pytest_ar_call_reprcompare	_safereprAssertionError_format_explanationres@py_assert0@py_assert3@py_assert2@py_format5@py_format7s         =D:\Programs\laragon\www\wolf\agent\tests\test_actions_logs.pytest_invalid_log_typer$   
   s    
:7
8Cy>"U"U""""">""">"""U"""""""-W-------------------    c                    [        SSS9   [        SSS.5      n U S   nSo!UL o3(       do  [        R                  " S	U4S
X45      [        R                  " U5      [        R                  " U5      S.-  nSSU0-  n[        [        R                  " U5      5      eS =n=p2U S   n/ o!U:H  o3(       do  [        R                  " SU4SX45      [        R                  " U5      [        R                  " U5      S.-  nSSU0-  n[        [        R                  " U5      5      eS =n=p2S S S 5        [        SSS.5      n U S   nSo!UL o3(       do  [        R                  " S	U4S
X45      [        R                  " U5      [        R                  " U5      S.-  nSSU0-  n[        [        R                  " U5      5      eS =n=p2SoS   o!U;   o3(       do  [        R                  " SU4SX45      [        R                  " U5      [        R                  " U5      S.-  nSSU0-  n[        [        R                  " U5      5      eS =n=p2g ! , (       d  f       GN&= f)Nos.path.existsFreturn_valuenginx_accesszdomain#$.com)r   domainr
   Tr   r   r   r   r   lines==z%(py1)s == %(py4)sz###$$$zInvalid domain name formatr   r   r   r   r   r   r   r   r   r   r   s         r#   'test_domain_sanitization_and_validationr1      sq    
e	4>^TU9~%%%%%%%~%%%~%%%%%%%%%%7|!r!r!!!!!|!!!|!!!r!!!!!!! 
5 ~J
KCy>"U"U""""">""">"""U"""""""'7w<7<77777'777'777<7777777 
5	4s   DI
Izsubprocess.runc                (   [        SSSS9U l        [        SSS9   [        SSS9   [        S	S
SS.5      nUS   nSo2UL oD(       do  [        R
                  " SU4SX#45      [        R                  " U5      [        R                  " U5      S.-  nSSU0-  n[        [        R                  " U5      5      eS =n=pCUS   nSS/o2U:H  oD(       do  [        R
                  " SU4SX#45      [        R                  " U5      [        R                  " U5      S.-  nSSU0-  n[        [        R                  " U5      5      eS =n=pCUS   nS	o2U:H  oD(       do  [        R
                  " SU4SX#45      [        R                  " U5      [        R                  " U5      S.-  nSSU0-  n[        [        R                  " U5      5      eS =n=pCUS   nSo2U:H  oD(       do  [        R
                  " SU4SX#45      [        R                  " U5      [        R                  " U5      S.-  nSSU0-  n[        [        R                  " U5      5      eS =n=pCU R                  / SQSSSSSS9  S S S 5        S S S 5        g ! , (       d  f       N= f! , (       d  f       g = f)Nr   zline1
line2
 
returncodestdoutstderrr'   Tr(   zos.path.isfiler*   test.com
   r   r+   r,   r
   r   r   r   r   r   r,   line1line2r-   r/   r   path"/var/log/nginx/test.com.access.log)tail-n10r>   ignoreFcapture_outputtexterrorsshellcheck)
r   r)   r   r   r   r   r   r   r   assert_called_once_withmock_runr   r   r   r    r!   r"   s          r#   test_nginx_access_tail_calledrL      s   %;KTVWH	d	3U;KZ^5_& 
  9~%%%%%%%~%%%~%%%%%%%%%%7|111111111|111|11111111111:0.0.00000000000.00000006{BBBBBBBBB{BBB{BBBBBBBBBBB 	((F 	) 	
 6`	3	35_5_	3	3s#   JH;I2!J2
J 	<J
Jc           	        [        SSSS9U l        [        SSS.5      nUS   nS	o2UL oD(       do  [        R                  " S
U4SX#45      [        R
                  " U5      [        R
                  " U5      S.-  nSSU0-  n[        [        R                  " U5      5      eS =n=pCUS   nSS/o2U:H  oD(       do  [        R                  " SU4SX#45      [        R
                  " U5      [        R
                  " U5      S.-  nSSU0-  n[        [        R                  " U5      5      eS =n=pCUS   nSo2U:H  oD(       do  [        R                  " SU4SX#45      [        R
                  " U5      [        R
                  " U5      S.-  nSSU0-  n[        [        R                  " U5      5      eS =n=pCUS   nSo2U:H  oD(       do  [        R                  " SU4SX#45      [        R
                  " U5      [        R
                  " U5      S.-  nSSU0-  n[        [        R                  " U5      5      eS =n=pCU R                  / SQS	S	SSSS9  g )Nr   z	sys1
sys2r3   r4   system2   )r   r,   r
   Tr   r   r   r   r   r,   sys1sys2r-   r/   r   r=   journald)
journalctlr@   50z
--no-pagerrB   FrC   )	r   r)   r   r   r   r   r   r   rI   rJ   s          r#   test_system_journalctl_calledrU   :   s   %<PRSH
 C
 y>!T!T!!!!!>!!!>!!!T!!!!!!!w<+FF++++++++<+++<+++++++++++z?&h&h&&&&&?&&&?&&&h&&&&&&&v;$*$*$$$$$;$$$;$$$*$$$$$$$$$0 % r%   c                 |   [        SSS9   [        SSSS.5      n U S   nS	o!UL o3(       do  [        R                  " S
U4SX45      [        R                  " U5      [        R                  " U5      S.-  nSSU0-  n[        [        R                  " U5      5      eS =n=p2U S   n/ o!U:H  o3(       do  [        R                  " SU4SX45      [        R                  " U5      [        R                  " U5      S.-  nSSU0-  n[        [        R                  " U5      5      eS =n=p2S S S 5        g ! , (       d  f       g = f)Nr'   Fr(   r*   r8   r9   r:   r
   Tr   r   r   r   r   r,   r-   r/   r0   r   s         r#   &test_file_not_found_returns_empty_listrW   R   s    	e	4& 
 
 9~%%%%%%%~%%%~%%%%%%%%%%7|!r!r!!!!!|!!!|!!!r!!!!!!! 
5	4	4s   DD--
D;)
__future__r   builtins@py_builtins_pytest.assertion.rewrite	assertionrewriter   osunittest.mockr   r   pytestactions.logsr   r$   r1   rL   rU   rW    r%   r#   <module>rc      s[    "   	 *  (.8 
 
4  ."r%   