HEX
Server: LiteSpeed
System: Linux 112.webhostingindonesia.co.id 5.14.0-570.62.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Nov 11 10:10:59 EST 2025 x86_64
User: iyfwylsv (10313)
PHP: 8.2.30
Disabled: NONE
Upload Files
File: //lib/python3.9/site-packages/fail2ban/tests/__pycache__/clientbeautifiertestcase.cpython-39.pyc
a

���=u�f�@s^dZdZdZddlZddlmZddlmZddlmZdd	l	m
Z
mZGd
d�dej�Z
dS)zAlexander Koeppez>Copyright (c) 2016 Cyril Jaquier, 2011-2013 Yaroslav Halchenko�GPL�N�)�
Beautifier)�version)�IPAddr)�UnknownJailException�DuplicateJailExceptioncs�eZdZ�fdd�Z�fdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Z�ZS)7�BeautifierTestcstt|���t�|_dS)z Call before every test case N)�superr	�setUpr�b��self��	__class__��K/usr/lib/python3.9/site-packages/fail2ban/tests/clientbeautifiertestcase.pyr!szBeautifierTest.setUpcstt|���dS)z Call after every test case N)r
r	�tearDownr
rrrr&szBeautifierTest.tearDowncCs(dg}|j�|�|�|j��|�dS)N�test)r�setInputCmd�assertEqualZgetInputCmd)r�cmdrrr�testGetInputCmd*szBeautifierTest.testGetInputCmdcCs&|j�dg�|�|j�d�d�dS)NZpingZpongzServer replied: pong�rrr�beautifyr
rrr�testPing/szBeautifierTest.testPingcCs&|j�dg�|�|j�t�t�dS)Nr)rrrrrr
rrr�testVersion3szBeautifierTest.testVersioncCs&|j�dg�|�|j�d�d�dS)N�add�sshzAdded jail sshrr
rrr�testAddJail7szBeautifierTest.testAddJailcCs&|j�dg�|�|j�d�d�dS)N�startzJail startedrr
rrr�
testStartJail;szBeautifierTest.testStartJailcCs(|j�ddg�|�|j�d�d�dS)N�stoprzJail stoppedrr
rrr�testStopJail?szBeautifierTest.testStopJailcCs&|j�dg�|�|j�d�d�dS)Nr"zShutdown successfulrr
rrr�testShutdownCszBeautifierTest.testShutdowncCsd|j�dg�ddd�ddg�ff}d}|�|j�|�|�|j�ddg�dgd	�fd
ddd
td�td�td�gfgff}d}|d7}|d7}|d7}|d7}|d7}|d7}|d7}|d7}|�|j�|�|�|j�ddg�ddd�ddg�fdgd	�fd
ddd
td�td�td�gfgffdgd�fd
ddd
gfgffd�f}d}|�|j�|�|�dS) N�status)zNumber of jailsrz	Jail listz, r�exim4z5Status
|- Number of jails:	2
`- Jail list:	ssh, exim4�Filter))�Currently failedr)�Total failedr)�	File list�/var/log/auth.logZActions)�Currently banned�)�Total bannedr-zBanned IP listz192.168.0.1z::ffff:10.2.2.1z2001:db8::1zStatus for the jail: ssh
z
|- Filter
z|  |- Currently failed:	0
z|  |- Total failed:	0
z#|  `- File list:	/var/log/auth.log
z`- Actions
z   |- Currently banned:	3
z   |- Total banned:	3
z6   `- Banned IP list:	192.168.0.1 10.2.2.1 2001:db8::1z--all))r(r-)r)�)r*z/var/log/exim4/mainlog)r,r)r.r)rr&aSStatus
|- Number of jails:	2
|- Jail list:	ssh, exim4
`- Status for the jails:
   |- Jail: ssh
   |  |- Filter
   |  |  |- Currently failed:	0
   |  |  |- Total failed:	0
   |  |  `- File list:	/var/log/auth.log
   |  `- Actions
   |     |- Currently banned:	3
   |     |- Total banned:	3
   |     `- Banned IP list:	192.168.0.1 10.2.2.1 2001:db8::1
   `- Jail: exim4
      |- Filter
      |  |- Currently failed:	3
      |  |- Total failed:	6
      |  `- File list:	/var/log/exim4/mainlog
      `- Actions
         |- Currently banned:	0
         |- Total banned:	0
         `- Banned IP list:	)rr�joinrrr�r�response�outputrrr�
testStatusGsd
���
���
���%�zBeautifierTest.testStatuscCsT|j�dg�gd�gd�gd�d�}d}|j�|��dd��d�}|�||�dS)	NZstats)Zsystemd)r-r/)��)Z	pyinotify)r/r5)�r7)Zpolling�rrr8)rr&zjail-with-long-namea�                    ?           ? Filter    ? Actions  
Jail                ? Backend   ????????????????????????
                    ?           ? cur ? tot ? cur ? tot
????????????????????????????????????????????????????????
ssh                 ? systemd   ?   3 ?   6 ?  12 ?  24
exim4               ? pyinotify ?   6 ?  12 ?  20 ?  20
jail-with-long-name ? polling   ?   0 ?   0 ?   0 ?   0
????????????????????????????????????????????????????????�ascii�replace)rrr�encode�decoderr1rrr�testStatusStats�s�
zBeautifierTest.testStatusStatscCs&|j�dg�|�|j�d�d�dS)NZ	flushlogszrolled overzlogs: rolled overrr
rrr�
testFlushLogs�szBeautifierTest.testFlushLogscCs,|j�ddg�d}|�|j�d�|�dS)N�getZsyslogsocketz!Current syslog socket is:
`- auto�autor�rr3rrr�testSyslogSocket�szBeautifierTest.testSyslogSocketcCs,|j�ddg�d}|�|j�d�|�dS)Nr?Z	logtargetz3Current logging target is:
`- /var/log/fail2ban.logz/var/log/fail2ban.logrrArrr�
testLogTarget�szBeautifierTest.testLogTargetcCs,|j�ddg�d}|�|j�d�|�dS)Nr?ZloglevelzCurrent logging level is 'INFO'�INFOrrArrr�testLogLevel�szBeautifierTest.testLogLevelcCsH|j�ddg�d}d|}|�|j�|�|�|�|j�d�d�dS)Nr?Zdbfilez"/var/lib/fail2ban/fail2ban.sqlite3zCurrent database file is:
`- �Database currently disabledrr1rrr�
testDbFile�s
zBeautifierTest.testDbFilecCs@|j�ddg�d}|�|j�d�|�|�|j�d�d�dS)Nr?Z
dbpurgeagez.Current database purge age is:
`- 86400secondsi�QrFrrArrr�testDbPurgeAge�szBeautifierTest.testDbPurgeAgecCs�|j�gd��g}d}|�|j�|�|�dg}d}|�|j�|�|�|j�gd��ddg}d}|d7}|�|j�|�|�|j�gd	��dg}|�|j�|�|�dS)
N)r?�sshdZlogpathzNo file is currently monitoredr+z3Current monitored log file(s):
`- /var/log/auth.log)�setrIZ
addlogpath�/var/log/messagesrKzCurrent monitored log file(s):
z)|- /var/log/messages
`- /var/log/auth.log)rJrIZ
dellogpathrKr)rr2r3Z	outputaddrrr�testLogPath�szBeautifierTest.testLogPathcCs,|j�gd��d}|�|j�d�|�dS)N)r?rIZlogencodingz%Current log encoding is set to:
UTF-8zUTF-8rrArrr�testLogEncoding�szBeautifierTest.testLogEncodingcCs�|j�gd��|�|j�g�d�|j�gd��ddgg}d}|d7}|�|j�|�|�|�dd	g�|d
7}|�|j�|�|�|j�gd��|�|d�|�|j�|�|�d
�d�dS)N)r?rIZjournalmatchzNo journal match filter set)rJrIZaddjournalmatchZ
_SYSTEMD_UNITzsshd.servicezCurrent match filter:
z_SYSTEMD_UNIT sshd.serviceZ_COMMrIz
 + _COMM sshd)rJrIZdeljournalmatch�z + r)rrrr�append�remove�splitr1rrr�testJournalMatch�s
zBeautifierTest.testJournalMatchcCsd|j�gd��d}d}|�|j�d�|d�|�|j�|�|d�|�|j�d�|d�dS)N)r?rIZdatepatternzCurrent date pattern set to: )N�Default DetectorszNot set/requiredrS)rrztest (test)r�rr3r2rrr�testDatePattern
s���zBeautifierTest.testDatePatterncCs�|j�gd��d}|�|j�g�|�|j�gd��tdd�td�tdd�td	�g}d
}|d7}|d7}|d
7}|d7}|�|j�|�|�dS)N)r?rIZignoreipz No IP address/network is ignored)rJrIZaddignoreipz	127.0.0.0�z::1z
2001:db8::� z::ffff:10.0.2.1z)These IP addresses/networks are ignored:
z|- 127.0.0.0/8
z|- ::1
z|- 2001:db8::/32
z`- 10.0.2.1)rrrrrrTrrr�testIgnoreIPs�zBeautifierTest.testIgnoreIPcCsP|j�gd��d}|�|j�g�|�d}|d7}|�|j�ddg�|�dS)N)r?rIZ	failregexz No regular expression is definedz.The following regular expression are defined:
z|- [0]: ^$
`- [1]: .*z^$z.*rrArrr�
testFailRegex(szBeautifierTest.testFailRegexcCsN|j�gd��d}|�|j�g�|�d}|d7}|�|j�dg�|�dS)N)r?rIZactionszNo actions for jail sshdz)The jail sshd has the following actions:
ziptables-multiportrrArrr�testActions1szBeautifierTest.testActionscCsP|j�gd��d}|�|j�g�|�d}|d7}d}|�|j�|�|�dS)N)r?rIZactionproperties�iptablesz+No properties for jail sshd action iptablesz;The jail sshd action iptables has the following properties:z
actionban, actionunban)Z	actionbanZactionunbanrrTrrr�testActionProperties:sz#BeautifierTest.testActionPropertiescCsP|j�gd��d}|�|j�g�|�d}|d7}|�|j�ddg�|�dS)N)r?rIZ
actionmethodsr[z(No methods for jail sshd action iptablesz9The jail sshd action iptables has the following methods:
z
ban, unbanZbanZunbanrrArrr�testActionMethodsDsz BeautifierTest.testActionMethodscCs^td�}d}|�|j�|�|�td�}d}|�|j�|�|�d}|�|j�t��|�dS)NrIz(Sorry but the jail 'sshd' does not existzThe jail 'sshd' already existsz Sorry but the command is invalid)rrrZ
beautifyErrorr�
IndexErrorr1rrr�testBeautifyErrorQsz BeautifierTest.testBeautifyError)�__name__�
__module__�__qualname__rrrrrrr!r#r$r4r=r>rBrCrErGrHrLrMrRrUrXrYrZr\r]r_�
__classcell__rrrrr	s6d		

r	)�
__author__�
__copyright__�__license__ZunittestZclient.beautifierrrZserver.ipdnsr�
exceptionsrrZTestCaser	rrrr�<module>s