config root man

Current Path : /compat/linux/proc/self/root/usr/share/fail2ban/testcases/

FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64
Upload File :
Current File : //compat/linux/proc/self/root/usr/share/fail2ban/testcases/servertestcase.pyc

ESc
@sVdZdZdZddkZddkZddkZddkZddkZddkZddk	l
Z
lZlZddk
lZlZddklZddklZd	eifd
YZdefdYZd
eifdYZdefdYZdefdYZdeifdYZdeifdYZdS(s
Cyril Jaquiers Copyright (c) 2004 Cyril JaquiertGPLiN(tRegext	FailRegextRegexException(tServertlogSys(tJail(tUnknownJailExceptiont	StartStopcBs#eZdZdZdZRS(cCs0t|_|iid|iitdS(sCall before every test case.iN(Rt_StartStop__servertsetLogLeveltstarttFalse(tself((s//usr/share/fail2ban/testcases/servertestcase.pytsetUp#scCs|iidS(sCall after every test case.N(R	tquit(R
((s//usr/share/fail2ban/testcases/servertestcase.pyttearDown)scCsGd}|ii||ii|tid|ii|dS(NtTestCasei(R	taddJailt	startJailttimetsleeptstopJail(R
tname((s//usr/share/fail2ban/testcases/servertestcase.pyttestStartStopJail-s

(t__name__t
__module__RRR(((s//usr/share/fail2ban/testcases/servertestcase.pyR!s		t
TestServercBseZdZdZRS(cOsdS(N((R
targstkwargs((s//usr/share/fail2ban/testcases/servertestcase.pyR
5scOsdS(N((R
RR((s//usr/share/fail2ban/testcases/servertestcase.pytsetLogTarget7s(RRR
R(((s//usr/share/fail2ban/testcases/servertestcase.pyR4s	tTransmitterBasecBsGeZdZdZdddZddZdZdZRS(cCs|ii|_tidd\}}ti|tidd\}}ti||ii||dtd|_	|ii
|i	ddS(sCall before every test case.s
fail2ban.sockttransmittersfail2ban.pidtforcet	TestJail1tautoN(tservert_Server__transmttransmttempfiletmkstemptostcloseRRtjailNameR(R
tsock_fdt	sock_namet
pidfile_fdtpidfile_name((s//usr/share/fail2ban/testcases/servertestcase.pyR<s

	cCs|iidS(sCall after every test case.N(R$R(R
((s//usr/share/fail2ban/testcases/servertestcase.pyRHscCsd||g}d|g}|dj	o$|id||id|n|djo
|}n|i|ii|d|f|i|ii|d|fdS(Ntsettgetii(tNonetinserttassertEqualR&tproceed(R
tcmdtinValuetoutValuetjailtsetCmdtgetCmd((s//usr/share/fail2ban/testcases/servertestcase.pyt
setGetTestLs


"cCsd||g}d|g}|dj	o$|id||id|n|ii|d}|i|ii|dd|i|ii|d|fdS(NR0R1ii(R2R3R&R5R4(R
R6R7R9R:R;t	initValue((s//usr/share/fail2ban/testcases/servertestcase.pyt
setGetTestNOKXs
 c
CsOd|}d|}|i|iid||gdgfxt|D]u\}}|i|iid|||gd||d f|i|iid||gd||d fqLWxt|D]u\}}|i|iid|||gd||df|i|iid||gd||dfqWdS(NtaddtdelR1iR0i(R4R&R5t	enumerate(R
R6tvaluesR9tcmdAddtcmdDeltntvalue((s//usr/share/fail2ban/testcases/servertestcase.pytjailAddDelTestes(

%

c	
Csfd|}d|}|djo
|}n|i|iid||gdgfxt|D]u\}}|i|iid|||gd||d f|i|iid||gd||d fqcWxt|D]u\}}|i|iid||dgd||df|i|iid||gd||dfqWdS(NR?R@R1iR0i(R2R4R&R5RA(	R
R6tinValuest	outValuesR9RCRDRERF((s//usr/share/fail2ban/testcases/servertestcase.pytjailAddDelRegexTestzs,



%

N(	RRRRR2R<R>RGRJ(((s//usr/share/fail2ban/testcases/servertestcase.pyR:s		
	tTransmittercBseZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZdZdZdZdZdZdZdZdZdZdZdZdZdZRS(cCs#t|_tt|idS(N(RR$tsuperRKR(R
((s//usr/share/fail2ban/testcases/servertestcase.pyRscCs#|i|iidgddS(Ntstopi(iN(R4R&R5R2(R
((s//usr/share/fail2ban/testcases/servertestcase.pyttestStopServerscCs#|i|iidgddS(Ntpingitpong(iRP(R4R&R5(R
((s//usr/share/fail2ban/testcases/servertestcase.pyttestPingscCsXti}|i|iiddgdti}|i||ddddS(NRt1iitplaces(iN(RR4R&R5R2tassertAlmostEqual(R
tt0tt1((s//usr/share/fail2ban/testcases/servertestcase.pyt	testSleeps"cCsd}d}d}|i|iid|dgd|f|i|iid|gd|f|i|iid|dgdd|i|iid|d	gd|f|i|iid|idgdd|i|iidd
dgdddS(Nt	TestJail2t	TestJail3t	TestJail4R?tpollingisinvalid backendiR#tall(R4R&R5R+(R
tjail2tjail3tjail4((s//usr/share/fail2ban/testcases/servertestcase.pyttestAddJails%(#%&cCsw|i|iid|igdtid|i|iid|igd|it|i	i
|idS(NRiiRM(iN(iN(R4R&R5R+R2RRtassertRaisesRR$tisAlive(R
((s//usr/share/fail2ban/testcases/servertestcase.pyRs
cCs|iidd|i|iid|igd	|i|iiddgd
tid|i|iiddgdtid|i	t
|ii|i|i	t
|iiddS(NRXR#Rig?RMR\i(iN(iN(iN(R$RR4R&R5R+R2RRRaRRb(R
((s//usr/share/fail2ban/testcases/servertestcase.pyttestStartStopAllJails
"
cCs|i|iid|iddgdtf|i|iid|iddgdtf|i|iid|iddgdddS(NR0tidletonitofftCATi(R4R&R5R+tTrueR(R
((s//usr/share/fail2ban/testcases/servertestcase.pyttestJailIdles

"cCsq|idddd|i|idddd|i|idddd|i|idd	d|idS(
Ntfindtimet120ixR9t60i<s-60itDog(R<R+R>(R
((s//usr/share/fail2ban/testcases/servertestcase.pyttestJailFindTimescCsq|idddd|i|idddd|i|idddd|i|idd	d|idS(
Ntbantimet600iXR9t50i2s-50itCat(R<R+R>(R
((s//usr/share/fail2ban/testcases/servertestcase.pyttestJailBanTimescCs|iddd|i|iddd|i|iddd|id}|i|iid|id|gd	dS(
NtusednstyesR9twarntnotFishR0i(isno(R<R+R4R&R5(R
RF((s//usr/share/fail2ban/testcases/servertestcase.pyttestJailUseDNSscCs|ii|i|i|iid|iddgd	tid|i|iid|iddgd
tid|i|iid|iddgd|i|iid|iddgdddS(NR0tbanips	127.0.0.1iitBadgertunbanips192.168.1.1(is	127.0.0.1(iR{(is	127.0.0.1(R$RR+R4R&R5RR(R
((s//usr/share/fail2ban/testcases/servertestcase.pyt
testJailBanIPs 

		cCsq|idddd|i|idddd|i|idddd|i|idd	d|idS(
Ntmaxretryt5iR9t2is-2itDuck(R<R+R>(R
((s//usr/share/fail2ban/testcases/servertestcase.pyttestJailMaxRetryscCs|iddddg|id}|i|iid|id|gd|gf|i|iid|id|gd|gf|i|iid	|idgd|gf|i|iid|id
|gdgfdS(Ntlogpathstestcases/files/testcase01.logstestcases/files/testcase02.logstestcases/files/testcase03.logstestcases/files/testcase04.logR0t
addlogpathiR1t
dellogpath(RGR+R4R&R5(R
RF((s//usr/share/fail2ban/testcases/servertestcase.pyttestJailLogPaths&
cCsEd}|iid|id|g}|it|dtdS(Nsthis_file_shouldn't_existR0Ri(R&R5R+t
assertTruet
isinstancetIOError(R
RFtresult((s//usr/share/fail2ban/testcases/servertestcase.pyttestJailLogPathInvalidFile(s	cCsxtidd}|d}ti|||iid|id|g}|it|dt	ti
|dS(Ntprefixttmp_fail2ban_broken_symlinks.slinkR0Ri(R'tmktempR)tsymlinkR&R5R+RRRtunlink(R
RtsnameR((s//usr/share/fail2ban/testcases/servertestcase.pyttestJailLogPathBrokenSymlink/s
	cCs|iddddg|id}|i|iid|id|gd|gf|i|iid|id|gd||gf|i|iid|idgd||gf|i|iid|id	|gd|gfdS(
Ntignoreips	127.0.0.1s192.168.1.1s8.8.8.8R0taddignoreipiR1tdelignoreip(RGR+R4R&R5(R
RF((s//usr/share/fail2ban/testcases/servertestcase.pyttestJailIgnoreIP9s&
cCs|iddd|idS(Nt
ignorecommandsbin R9(R<R+(R
((s//usr/share/fail2ban/testcases/servertestcase.pyttestJailIgnoreCommandUscCs|iddddgdddg|i|i|iid|id	d
gdd|i|iid|id	d
gdddS(Nt	failregexsuser john at <HOST>sAdmin user login from <HOST>s failed attempt from <HOST> agains1user john at (?:::f{4,6}:)?(?P<host>[\w\-.^_]*\w)s:Admin user login from (?:::f{4,6}:)?(?P<host>[\w\-.^_]*\w)s>failed attempt from (?:::f{4,6}:)?(?P<host>[\w\-.^_]*\w) againR0taddfailregexs
No host regexiii(RJR+R4R&R5(R
((s//usr/share/fail2ban/testcases/servertestcase.pyt
testJailRegexXs 	
		cCs|iddddgdddg|i|i|iid|iddgd	d
|i|iid|iddgd	d
dS(Ntignoreregexs	user johnsAdmin user login from <HOST>sDont match me!s:Admin user login from (?:::f{4,6}:)?(?P<host>[\w\-.^_]*\w)R0taddignoreregexsInvalid [regexiii2(RJR+R4R&R5(R
((s//usr/share/fail2ban/testcases/servertestcase.pyttestJailIgnoreRegexps 	
		cCs|ig}|i|iidgddt|fddi|fgf|iidd|id|i|iidgddt|fddi|fgfdS(NtstatusisNumber of jails	Jail lists, RXR#(	R+R4R&R5tlentjoinR$Rtappend(R
tjails((s//usr/share/fail2ban/testcases/servertestcase.pyt
testStatuss.
c	Cs_|i|iid|igdddddgfgfdd
dd
gfgfgfdS(NRitfiltersCurrently failedsTotal faileds	File listtactionsCurrently bannedsTotal bannedsIP list(sCurrently failedi(sTotal failedi(sCurrently bannedi(sTotal bannedi(R4R&R5R+(R
((s//usr/share/fail2ban/testcases/servertestcase.pyttestJailStatusscCsTd}dddddg}ddd	d
dg}|i|iid|id
|gd|f|i|iid|id
|gd|fxQt||D]@\}}|i|iid|i|||gd|fqWxNt||D]=\}}|i|iid|i||gd|fqW|i|iid|id|ddgd|i|iid|id|dgd|i|iid|id|dgdd|i|iid|id|dgd|i|iid|id|gd|i|iid|iddgdddS(NtTestCaseActiontactionstartt
actionstoptactioncheckt	actionbantactionunbansAction StartsAction StopsAction Checks
Action BansAction UnbanR0t	addactioniR1tsetcinfotKEYtVALUEtcinfot
InvalidKeyitdelcinfot	delactions
Doesn't exist(iR(iR(iN(iN(R4R&R5R+tzipR2(R
RtcmdListtcmdValueListR6RF((s//usr/share/fail2ban/testcases/servertestcase.pyt
testActionsd		

						cCs*|i|iiddgdddS(NtINVALIDtCOMMANDii(R4R&R5(R
((s//usr/share/fail2ban/testcases/servertestcase.pyttestNOKscCs-|i|iidddgdddS(NR0RRii(R4R&R5(R
((s//usr/share/fail2ban/testcases/servertestcase.pyt
testSetNOKscCs-|i|iidddgdddS(NR1RRii(R4R&R5(R
((s//usr/share/fail2ban/testcases/servertestcase.pyt
testGetNOKscCs-|i|iidddgdddS(NRRRii(R4R&R5(R
((s//usr/share/fail2ban/testcases/servertestcase.pyt
testStatusNOKs(RRRRNRQRWR`RRcRiRnRsRyR}RRRRRRRRRRRRRRR(((s//usr/share/fail2ban/testcases/servertestcase.pyRKs6																	
								7			tTransmitterLoggingcBs5eZdZdZdZdZdZRS(cCsCt|_|iid|iidtt|idS(Ns	/dev/nulli(RR$RR
RLRR(R
((s//usr/share/fail2ban/testcases/servertestcase.pyRsc	Csg}xHtdD]:}tidd}|i|dti|dqWx|D]}|id|qXWd}|id||ii	dd	gx|D]}ti
|qW|idd
|idddS(Nitfail2banR iit	logtargets/this/path/should/not/existR0s	/dev/nulltSTDOUTtSTDERR(txrangeR'R(RR)R*R<R>R&R5tremove(R
t
logTargetst_ttmpFilet	logTargetRF((s//usr/share/fail2ban/testcases/servertestcase.pyt
testLogTargets"
cCsftiido#tidjotidntiidpdSn|idddS(Ns/dev/logiis'/dev/log' not presentRtSYSLOG(ii(R)tpathtexiststsystversion_infotunittesttSkipTestR<(R
((s//usr/share/fail2ban/testcases/servertestcase.pyttestLogTargetSYSLOGs
$cCs|iddd|iddd|iddd|iddd	|idd
d|iddd
|idddS(Ntloglevelt4it3iRiRRis-1it0itBird(R<R>(R
((s//usr/share/fail2ban/testcases/servertestcase.pyttestLogLevelscCs(|i|iidgdztid\}}ti||iid|i|iidd|gd|ft	i
dz1tid\}}ti|ti||t	i
d	|i|iidgdt	i
d
t|d}t
oY|i|iid|i|iid
|it|i|int|d}t
o=|i|iid|it|i|inWdti|XWdti|X|i|iidddgd|i|iidgddS(Nt	flushlogsisrolled oversfail2ban.logiR0RsBefore file movedsAfter file movedsAfter flushlogstrsBefore file moved
sAfter file moved
sAfter flushlogs
Rtflushed(isrolled over(isrolled over(isSTDERR(iR(R4R&R5R'R(R)R*R$R
RRvtrenametopenRhRtnexttendswithRat
StopIterationR(R
tftfntf2tfn2((s//usr/share/fail2ban/testcases/servertestcase.pyt
testFlushLogss:
+



%(RRRRRRR(((s//usr/share/fail2ban/testcases/servertestcase.pyRs
					t	JailTestscBseZdZRS(cCs,d}t|}|i|i|dS(Ntveryveryverylongname(RR4tgetName(R
tlongnameR9((s//usr/share/fail2ban/testcases/servertestcase.pyttestLongName;s(RRR(((s//usr/share/fail2ban/testcases/servertestcase.pyR9st
RegexTestscBs#eZdZdZdZRS(cCs=|ittd|ittd|ittddS(Ntt s	(RaRR(R
((s//usr/share/fail2ban/testcases/servertestcase.pyttestInitCscCsN|ittdiddd|ittdiddS(Ntat"t's
Regex('a')s<HOST>s
FailRegex((R4tstrRtreplaceRRt
startswith(R
((s//usr/share/fail2ban/testcases/servertestcase.pyttestStrIs(cCsi|ittdtd}|i|i|id|i|i|it|idS(NRs	%%<HOST>?s%%(RaRRtassertFalset
hasMatchedtsearchRtgetHost(R
tfr((s//usr/share/fail2ban/testcases/servertestcase.pyttestHostOs
(RRRRR(((s//usr/share/fail2ban/testcases/servertestcase.pyRAs		(t
__author__t
__copyright__t__license__RtsocketRR'R)Rtserver.failregexRRRt
server.serverRRtserver.jailRtcommon.exceptionsRRRRRRKRRR(((s//usr/share/fail2ban/testcases/servertestcase.pys<module>sHXXP

Man Man