403Webshell
Server IP : 172.67.131.151  /  Your IP : 104.23.243.32
Web Server : Apache
System : Linux keen-cori.18-142-40-148.plesk.page 5.15.0-1084-aws #91~20.04.1-Ubuntu SMP Fri May 2 06:59:36 UTC 2025 x86_64
User : simottodesign.com_2tntp341vs7 ( 10011)
PHP Version : 8.3.31
Disable Function : opcache_get_status
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3/dist-packages/fail2ban/tests/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/fail2ban/tests/__pycache__/misctestcase.cpython-38.pyc
U

�m5y>Hg��@s�dZdZdZddlZddlZddlZddlZddlZddlZddl	Z	ddl
m
Z
ddlmZddl
mZmZd	d
lmZmZmZmZmZmZmZmZmZd	dlmZGdd
�d
ej�Zdd�Zdd�Z Gdd�dej�Z!Gdd�de�Z"Gdd�dej�Z#dS)zYaroslav Halchenkoz%Copyright (c) 2013 Yaroslav Halchenko�GPL�N)�glob)�StringIO�)�LogCaptureTestCase�logSys�)	�formatExceptionInfo�	mbasename�	TraceBack�FormatterWithTraceBack�	getLogger�getVerbosityFormat�
splitwords�
uni_decode�
uni_string)�MyTimec@s$eZdZdd�Zdd�Zdd�ZdS)�HelpersTestcCs@ztd��Wn.t�\}}|�|d�|�|d�YnXdS)NzVery bad exception�
ValueError�rr	�assertEqual��self�name�args�r�=/usr/lib/python3/dist-packages/fail2ban/tests/misctestcase.py�testFormatExceptionInfoBasic+s
z(HelpersTest.testFormatExceptionInfoBasiccCsBztdd��Wn.t�\}}|�|d�|�|d�YnXdS)NzVery badrz('Very bad', None)rrrrr�testFormatExceptionConvertArgs3s
z*HelpersTest.testFormatExceptionConvertArgscCs�|�td�g�|�td�g�|�td�g�|�td�dg�|�td�ddg�|�td�ddg�|�td�ddg�|�td�ddd	g�|�td
�ddd	g�dS)N�z  �1z 1 2 �2z 1, 2 , z 1
  2z	 1
  2, 3�3z	1	  2,
 3
)rr�rrrr�testsplitwords<szHelpersTest.testsplitwordsN)�__name__�
__module__�__qualname__rrr$rrrrr)s	rcCs"ddl}|j|dd�}t|���S)NrT)�shell)�
subprocess�check_outputr�rstrip)�cmdr)�retrrr�_sh_callHsr.cCstd�S)Nz?fail2ban-python -c 'import sys; print(tuple(sys.version_info))')r.rrrr�_getSysPythonVersionMsr/cs,eZdZ�fdd�Zdd�Zdd�Z�ZS)�	SetupTestcs�tt|���tj��tj�tj�	t
�ddd�}tj�|�rB|pDd|_|jsXt�
d��t�}|tttj��kr�t�
dtttj��|f��dS)Nz..zsetup.pyzLSeems to be running not out of source distribution -- cannot locate setup.pyziSeems to be running with python distribution %s -- install can be tested only with system distribution %s)�superr0�setUp�unittest�F2BZ
SkipIfFast�os�path�join�dirname�__file__�exists�setupZSkipTestr/�str�tuple�sys�version_info)rr;ZsysVer��	__class__rrr2Ss
���zSetupTest.setUpc	Csj|js
dSt��}tjjtjkr$dnd}z0t
�dtj
|j||f�|�t
�|��W5t�	|�XdS)Nz >/dev/null 2>&1rz#%s %s --dry-run install --root=%s%s)r;�tempfile�mkdtempr3r4�	log_level�logging�DEBUG�shutil�rmtreer5�systemr>�
executable�
assertTrue�listdir)r�tmp�	supdbgoutrrr�testSetupInstallDryRuncs�z SetupTest.testSetupInstallDryRunc
s�|js
dSt���tj�d�}tjjt	j
kr2dnd}�zN|�t�
dtj|j�|f�d��fdd	�}|ttd
����}ddd
g}t|��|��rdd�}i}t|��|�D]4}tj��|�}	tj�|	�r�|||	d��p�d||<q�|j||d||�|fd�dD]*}
|jtj�tj��|
��d|
d��qtd�d��d�}|�t|�dk�|D]$}|�tj�|�tj�tj���q^W5t���t�
dtj|j|�r�|dndf�|�r�tj�d��r�t�d�XdS)N�buildz >/dev/nullrz%s %s clean --all%sz 2>&1z%s %s install --root=%s%srcs�fdd�|D�S)Ncs g|]}|t��dd��qS)rN)�len)�.0�x�rMrr�
<listcomp>szESetupTest.testSetupInstallRoot.<locals>.strippath.<locals>.<listcomp>r)�lrTrr�	strippath~sz1SetupTest.testSetupInstallRoot.<locals>.strippathz%s/*�etcZusr�varcsFg}t�|�D]2\�}}t�|||�}|��fdd�|D��q|S)Nc3s|]}tj��|�VqdS�N)r5r6r7)rR�f��baserr�	<genexpr>�szISetupTest.testSetupInstallRoot.<locals>.recursive_glob.<locals>.<genexpr>)r5�walk�fnmatch�filter�extend)Ztreeroot�pattern�results�dirs�filesZ	goodfilesrr\r�recursive_glob�s
z6SetupTest.testSetupInstallRoot.<locals>.recursive_glob�*z6Got: %s Needed: %s under %s. Files under new paths: %s��msg)zetc/fail2ban/fail2ban.confzetc/fail2ban/jail.confz
Can't find %szfind z -name fail2ban-python�
)r;rBrCr5r6r:r3r4rDrErFrGrHrIr>rJr�sortedr�set�
differencer7rKr.�splitrQ�realpath)rZremove_buildrNrWZgotZneedrgrf�missingZmissing_fullr[Z
installedPathrrTr�testSetupInstallRootss`
��
��
���

�
�zSetupTest.testSetupInstallRoot)r%r&r'r2rOrr�
__classcell__rrr@rr0Qsr0c@s\eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)�TestsUtilsTestcCsT|�td�d�|�td�d�|�td�d�|�td�d�|�td�d�dS)	Nz	sample.py�samplez/long/path/sample.pyz/long/path/__init__.pyz
path.__init__z/long/path/base.pyz	path.basez/long/path/base)rr
r#rrr�
testmbasename�s
zTestsUtilsTest.testmbasenamecCs,|�ttdd�td�td�td�dS)Nstestzf2b-test::non-existing-encodingstest�utestÏ)�assertRaises�	Exceptionrrr#rrr�testUniConverters�s�z TestsUtilsTest.testUniConverterscCs"t}Gdd�d�}|�}|�tjd|�|�dd�|��|�d|�|�dd�|�dt���|d�}|�tjd	||�|jd
ddd
�|�d||�|jdddd
�|�d�Gdd�dtj	�}|j
}z:t|j
�|_
|j
|�g7_
|�tjd�|�d�W5||_
X|�d�dS)Nc@seZdZddd�Zdd�ZdS)z,TestsUtilsTest.testSafeLogging.<locals>.TestrcSs
||_dSrZ)�err)rrzrrr�__init__�sz5TestsUtilsTest.testSafeLogging.<locals>.Test.__init__cSs|jrtd��ndSdS)N�no representation for test!u.conv-error (òðåòèé), unterminated utf Ï)rzrxr#rrr�__repr__�s
z5TestsUtilsTest.testSafeLogging.<locals>.Test.__repr__N)r)r%r&r'r{r}rrrr�Test�s
r~ztest 1a: %r�	Tracebackr|ztest 1b: %rz.[phase 2] test error conversion by encoding %srztest 2a: %r, %sztest 2azError by logging handlerF��allztest 2b: %r, %sztest 2bz*[phase 3] test unexpected error in handlerc@seZdZdd�ZdS)z5TestsUtilsTest.testSafeLogging.<locals>._ErrorHandlercSstd��dS)Nzerror in handler test!)rx)r�recordrrr�handle�sz<TestsUtilsTest.testSafeLogging.<locals>._ErrorHandler.handleN)r%r&r'r�rrrr�
_ErrorHandler�sr�ztest 3aztest 3bZOK)�	DefLogSys�logrE�NOTICE�assertLogged�pruneLog�noticer>�getdefaultencoding�Handler�handlers�list)rrr~�testr�Z_org_handlerrrr�testSafeLogging�s0
zTestsUtilsTest.testSafeLoggingc	s�dD]�}t|d�}dd����fdd��zt�d��Wntk
rR|�}YnXd|krj|�d	|�nd
|kr~|�d	|�|�d|�qdS)N)TF)�compresscSs
t��dSrZ)rrrrr�
func_raise�sz0TestsUtilsTest.testTraceBack.<locals>.func_raisecs|r�|d�n��dS)Nrr)�i��
deep_functionr�rrr��sz3TestsUtilsTest.testTraceBack.<locals>.deep_function�zfail2ban-testcases�>Zcoverage�:)r�printr�assertIn�assertNotIn)rr��tb�srr�r�
testTraceBack�s
zTestsUtilsTest.testTraceBackcOs|jt||f|�|�dSrZ)�assertRaisesRegex�AssertionError)rZregexpZfunr�kwargsrrr�_testAssertionErrorREsz$TestsUtilsTest._testAssertionErrorREcsrdd�}��t�jd|d���t�jd�jd���d�fdd����t�jd	td
���d�fdd��dS)
NcSst|��dSrZ)�KeyErrorrirrr�_key_errsz;TestsUtilsTest.testExtendedAssertRaisesRE.<locals>._key_err�^failed$�failed�
__failed__z$failed.* does not match .*__failed__cs��d�jd�S)Nr�r�)r��failrr#rr�<lambda>s�z;TestsUtilsTest.testExtendedAssertRaisesRE.<locals>.<lambda>rrzJ0 AssertionError not raised X.* does not match .*AssertionError not raisedcs��d�fdd��S)Nz^0 AssertionError not raised X$cs��dtd�S)Nrr)r��intrr#rrr�&�zMTestsUtilsTest.testExtendedAssertRaisesRE.<locals>.<lambda>.<locals>.<lambda>)r�rr#rrr�%s
�)rwr�r�r�r�r�)rr�rr#r�testExtendedAssertRaisesREs2��
��
�z)TestsUtilsTest.testExtendedAssertRaisesREcs0��dddddg���dd���dd���ddd�dD����ddddg���dd	���dd
���ddd�dD����d�jdd���d
�jdtd����d�jddd�dD����d�jdd���d�jdtd����d�jddd�dD��t}���|�d���d��jdddd��jdddd��jdddd��jdddd����|�d ���d��jdddd��jddddd�t	j
jd}t	j
_��t
t	j
�d�t����t	j
�d!d"���d#���t	j
�d$�d$���t	j
�d%�d%�dt	j
_zF��t	j
�d&d"���d#���t	j
�d$�d'���t	j
�d%�d%�W5|t	j
_X��t	j
�d�����|�d���d(�jd���d)�jdd��jd*�jdddd��jd+�jdddd��jd,�jdddd-d.��jd/�jdddd��jd0�jdddd-d.��jd)�jdddd���ddd1giddd1gi���t�jddd1gidd1dgi���dd2gd2dg��jdd2ggd2dggd1d3��jdd2ggd2dggdd4���t�fd5d"���jddd2gidd2dgidd4���t�fd6d"���jd7d2d8gd9d:gd;�gd:d9gd8d2gd<�d7gdd4��jd7d2d8gd9d:gd;�gd:d9gd8d2gd<�d7gd=d3���t�fd>d"����d?d@gdAd@gggfd?d@gd@dAgggf���tdB�tdC����t�jdBgdCg���t�jdBggdCgg���dD�jdgd8d2g���dE�jdd2gd8d2g�dS)FN�a�b�c�d)r�r�r�r�Zcbacss|]}|dkr|VqdS�r�Nr�rRr�rrrr^.sz;TestsUtilsTest.testExtendedAssertMethods.<locals>.<genexpr>)r�r�r�Zcbdcss|]}|dkr|��VqdSr���upperr�rrrr^2sz'a' unexpectedly found in 'cba'z#1 unexpectedly found in \[0, 1, 2\]rr�z&'A' unexpectedly found in \['C', 'A'\]�Acss|]}|dkr|��VqdSr�r�r�rrrr^9sz'a' was not found in 'xyz'Zxyzz5 was not found in \[0, 1, 2\]�z!'A' was not found in \['C', 'B'\]css|]}|dkr|��VqdS)r�Nr�r�rrrr^?sz
test "xyz"r�Tr�ZzyxFZtest_zyxz
xxxx "xxx"cSsdS�N�2rrrrrr�Qr�z:TestsUtilsTest.testExtendedAssertMethods.<locals>.<lambda>r��g9@cSsdSr�rrrrrr�Vr�g@z.* was found in the logz+All of the .* were found present in the logzwas found in the logzwas not found in the logz&was not found in the log, waited 1e-06g���ư>)r��waitz"None among .* was found in the logz0None among .* was found in the log, waited 1e-06r�B)�level��
nestedOnlycs�jddggddggddd�S�Nr�r�rT)r�r���assertSortedEqualrr#rrr�ws
�cs"�jdddgidddgiddd�Sr�r�rr#rrr�zs


��Z�C�E�F�r�r��r�r����cs4�jdddgddgd�gddgddgd�dgdd	�S)
Nr�r�r�r�r�r�r�Tr�r�rr#rrr��s�rZA1ZA2�ABCZCBAz\['A'\] != \['C', 'B'\]z\['A', 'B'\] != \['B', 'C'\])r�r�r��ranger�r��debugr�ZassertNotLoggedr3r4�fastZassertFalse�
isinstanceZmaxWaitTime�boolrZassertDictEqualrwr�r�r�)rrZorgfastrr#r�testExtendedAssertMethods)s&������





��������


� ,�,����z(TestsUtilsTest.testExtendedAssertMethodscCs>|�td�d�|�tddd�d�|�tdddd�d�dS)NrzA%(asctime)s %(name)-24s[%(process)d]: %(levelname)-7s %(message)sF)�paddingz<%(asctime)s %(name)s[%(process)d]: %(levelname)s %(message)s)Zaddtimer�z0%(name)s[%(process)d]: %(levelname)s %(message)s)rrr#rrr�testVerbosityFormat�s
���z"TestsUtilsTest.testVerbosityFormatcCs�t�}t}d}td�}t�|�}|�||��|�|�|�d�|��}|�	|�
��d��|�d�}|�	|dk�|�
|d|�||d|dd��dS)	Nz %(tb)s | %(tbc)s : %(message)sZfail2ban_testsZXXXz: XXX�|�
rr)rrr
rE�
StreamHandler�setFormatter�
addHandler�error�getvaluerKr+�endswith�indexr)rZstrout�	Formatter�fmtr�outr�Zpindexrrr�testFormatterWithTraceBack�s



z)TestsUtilsTest.testFormatterWithTraceBackcCs2t}|�dtjj�|�dddd�|�d�dS)Nzlazy logging: %rr�rrr�znot all arguments converted)r�r�r3r4Zlog_lazyr�r�)rrrrr�testLazyLogging�szTestsUtilsTest.testLazyLoggingN)
r%r&r'rvryr�r�r�r�r�r�r�r�rrrrrt�s* frtc@seZdZdd�Zdd�ZdS)�
MyTimeTestcCs�tj}|�|d�d�|�|d�d�|�|d�d�|�|d�d�|�|d�d	�|�|d
�d	�|�|d�d�|�t|d
��dddd�|�t|d��dddd�dS)NZ1y6mo30w15d12h35m25si]��z2yy 3mo 4ww 10dd 5hh 30mm 20ssi$�mz>2 years 3 months 4 weeks 10 days 5 hours 30 minutes 20 secondsz!1 year + 1 month - 1 week + 1 dayi��zI2 * 0.5 yea + 1*1 mon - 3*1/3 wee + 2/2 day - (2*12 hou 3*20 min 80 sec) g@��Az(2*.5y+1*1mo-3*1/3w+2/2d-(2*12h3*20m80s) z!1ye -2mo -3we -4da -5ho -6mi -7seiQ	pz1 month�<�gp>@z1 yearg�v@)rZstr2secondsr�float)rZstr2secrrr�testStr2Seconds�s zMyTimeTest.testStr2SecondscCs�dd�}|�|d�d�|�|d�d�|�|d�d�|�|d	�d
�|�|d�d�|�|d
�d�|�|d�d�|�|d�d�|�|d�d�|�|d�d�|�|d�d�|�|d�d�|�|d�d�dS)NcSstt�|��SrZ)r<rZseconds2str)r�rrrr��r�z(MyTimeTest.testSec2Str.<locals>.<lambda>i)z1y 3w 4di(�z1y 3dg�~AZ1yi��z2w 1di�tZ2wi�z	2d 7h 15mi�z2d 1hg��@z3h 31miZ2hiZ1hiz59m 50s�;Z59sr�0)r)rZsec2strrrr�testSec2Str�szMyTimeTest.testSec2StrN)r%r&r'r�r�rrrrr��sr�)$�
__author__�
__copyright__�__license__rEr5r>r3rBrGr`r�ior�utilsrrr�Zhelpersr	r
rrr
rrrrZ
server.mytimerZTestCaserr.r/r0rtr�rrrr�<module>s,,d

Youez - 2016 - github.com/yon3zu
LinuXploit