Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/twisted/test/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/twisted/test/test_ident.pyc

ó
ê=Nc@s@dZddlZddlmZddlmZddlmZddlmZddl	m
Z
ddlmZd	e
j
fd
„ƒYZdejfd„ƒYZd
ejfd„ƒYZdefd„ƒYZde
j
fd„ƒYZejddƒddkrdZdZndZdZde
j
fd„ƒYZdS(s0
Test cases for twisted.protocols.ident module.
iÿÿÿÿN(tident(tfailure(terror(tdefer(tunittest(tStringTransporttClassParserTestCasecBsDeZdZd„Zd„Zd„Zd„Zd„Zd„ZRS(s*
    Test parsing of ident responses.
    cCstjƒ|_dS(s6
        Create a ident client used in tests.
        N(RtIdentClienttclient(tself((s;/usr/lib/python2.7/dist-packages/twisted/test/test_ident.pytsetUpscCsKtjƒ}|jjj|ddfƒ|jjdƒ|j|tjƒS(sX
        'UNKNOWN-ERROR' error should map to the L{ident.IdentError} exception.
        i{iÈs 123, 456 : ERROR : UNKNOWN-ERROR(	RtDeferredRtqueriestappendtlineReceivedt
assertFailureRt
IdentError(R	td((s;/usr/lib/python2.7/dist-packages/twisted/test/test_ident.pyttest_indentError!scCsKtjƒ}|jjj|ddfƒ|jjdƒ|j|tjƒS(sN
        'NO-USER' error should map to the L{ident.NoUser} exception.
        iêiÈs234, 456 : ERROR : NO-USER(	RRRRR
RRRtNoUser(R	R((s;/usr/lib/python2.7/dist-packages/twisted/test/test_ident.pyttest_noUSerError+scCsKtjƒ}|jjj|ddfƒ|jjdƒ|j|tjƒS(sX
        'INVALID-PORT' error should map to the L{ident.InvalidPort} exception.
        iYi7s 345, 567 :  ERROR : INVALID-PORT(	RRRRR
RRRtInvalidPort(R	R((s;/usr/lib/python2.7/dist-packages/twisted/test/test_ident.pyttest_invalidPortError5scCsKtjƒ}|jjj|ddfƒ|jjdƒ|j|tjƒS(sV
        'HIDDEN-USER' error should map to the L{ident.HiddenUser} exception.
        i7is567, 789 : ERROR : HIDDEN-USER(	RRRRR
RRRt
HiddenUser(R	R((s;/usr/lib/python2.7/dist-packages/twisted/test/test_ident.pyttest_hiddenUserError?scCsZtjƒ}|jjj|ddfƒ|jjtjtj	ƒƒƒ|j
|tjƒS(sy
        A pending query which failed because of a ConnectionLost should
        receive an L{ident.IdentError}.
        iýi°(
RRRRR
tconnectionLostRtFailureRtConnectionLostRRR(R	R((s;/usr/lib/python2.7/dist-packages/twisted/test/test_ident.pyttest_lostConnectionIs(	t__name__t
__module__t__doc__R
RRRRR(((s;/usr/lib/python2.7/dist-packages/twisted/test/test_ident.pyRs		
	
	
	
tTestIdentServercBseZd„ZRS(cCs|jS(N(tresultValue(R	t
serverAddresst
clientAddress((s;/usr/lib/python2.7/dist-packages/twisted/test/test_ident.pytlookupVs(RRR$(((s;/usr/lib/python2.7/dist-packages/twisted/test/test_ident.pyR UstTestErrorIdentServercBseZd„ZRS(cCs|jƒ‚dS(N(t
exceptionType(R	R"R#((s;/usr/lib/python2.7/dist-packages/twisted/test/test_ident.pyR$[s(RRR$(((s;/usr/lib/python2.7/dist-packages/twisted/test/test_ident.pyR%ZstNewExceptioncBseZRS((RR(((s;/usr/lib/python2.7/dist-packages/twisted/test/test_ident.pyR'_stServerParserTestCasecBseZd„Zd„ZRS(cCs“tƒ}|jtƒƒg}|j|_tj|_|jdƒ|j	|ddƒtj
|_|jdƒ|j	|ddƒtj|_|jdƒ|j	|dd	ƒtj|_|jd
ƒ|j	|ddƒt
|_|jd
ƒ|j	|ddƒ|jt
ƒ}|j	t|ƒdƒx^dD]V}|2|jd|fƒ|jd|fƒ|j	|d|fd|fgƒq5WdS(Ns123, 345is 123, 345 : ERROR : UNKNOWN-ERRORs432, 210is432, 210 : ERROR : NO-USERs987, 654is987, 654 : ERROR : INVALID-PORTs756, 827is756, 827 : ERROR : HIDDEN-USERs987, 789is 987, 789 : ERROR : UNKNOWN-ERRORiÿÿÿÿiis%d, 5s5, %ds%d, 5 : ERROR : INVALID-PORTs5, %d : ERROR : INVALID-PORT(iÿÿÿÿiii(R%tmakeConnectionRR
tsendLineRRR&RtassertEqualRRRR'tflushLoggedErrorstlen(R	tptLterrstport((s;/usr/lib/python2.7/dist-packages/twisted/test/test_ident.pyt
testErrorsds8	



	


cCsYtƒ}|jtƒƒg}|j|_d|_|jdƒ|j|ddƒdS(NtSYStUSERs123, 456is123, 456 : USERID : SYS : USER(R3R4(R R)RR
R*R!RR+(R	R.R/((s;/usr/lib/python2.7/dist-packages/twisted/test/test_ident.pyttestSuccessˆs		
(RRR2R5(((s;/usr/lib/python2.7/dist-packages/twisted/test/test_ident.pyR(cs	$s=Liist0100007Ft04030201t7F000001t01020304tProcMixinTestCasecBsEeZdeefZd„Zd„Zd„Zd„Zd„Z	RS(sj4: %s:0019 %s:02FA 0A 00000000:00000000 00:00000000 00000000     0        0 10927 1 f72a5b80 3000 0 0 2 -1cCs)tjƒ}|j|jtƒdƒdS(Ns	127.0.0.1(RtProcServerMixinR+tdottedQuadFromHexStringt_addr1(R	R.((s;/usr/lib/python2.7/dist-packages/twisted/test/test_ident.pyttestDottedQuadFromHexString scCs-tjƒ}|j|jtdƒdƒdS(Ns:0277s	127.0.0.1iw(s	127.0.0.1iw(RR;R+t
unpackAddressR=(R	R.((s;/usr/lib/python2.7/dist-packages/twisted/test/test_ident.pyttestUnpackAddress¤scCs5tjƒ}|j|j|jƒdddfƒdS(Ns	127.0.0.1is1.2.3.4iúi(s	127.0.0.1i(s1.2.3.4iú(RR;R+t	parseLinetline(R	R.((s;/usr/lib/python2.7/dist-packages/twisted/test/test_ident.pyttestLineParser©scsrg‰tjƒ}‡fd†|_‡fd†|_ˆj|jd	d
ƒ|jdfƒˆjˆdgƒdS(NcstˆjgƒS(N(titerRB((R	(s;/usr/lib/python2.7/dist-packages/twisted/test/test_ident.pyt<lambda>²scsˆj|ƒdfdS(Ntrooti(R
(tuid(tusername(s;/usr/lib/python2.7/dist-packages/twisted/test/test_ident.pyRE³ss	127.0.0.1is1.2.3.4iúRFi(s	127.0.0.1i(s1.2.3.4iú(RR;tentriestgetUsernameR+R$tSYSTEM_NAME(R	R.((RHR	s;/usr/lib/python2.7/dist-packages/twisted/test/test_ident.pyttestExistingAddress¯scsvtjƒ}‡fd†|_ˆjtj|jd	d
ƒˆjtj|jddƒˆjtj|jd
dƒdS(NcstˆjgƒS(N(RDRB((R	(s;/usr/lib/python2.7/dist-packages/twisted/test/test_ident.pyRE»ss	127.0.0.1is1.2.3.4iúis1.2.3.5iû(s	127.0.0.1i(s1.2.3.4iú(s	127.0.0.1i(s1.2.3.5iú(s	127.0.0.1i(s1.2.3.4iû(RR;RItassertRaisesRR$(R	R.((R	s;/usr/lib/python2.7/dist-packages/twisted/test/test_ident.pyttestNonExistingAddress¹s(
RRR=t_addr2RBR>R@RCRLRN(((s;/usr/lib/python2.7/dist-packages/twisted/test/test_ident.pyR:›s
				
(Rtstructttwisted.protocolsRttwisted.pythonRttwisted.internetRRt
twisted.trialRttwisted.test.proto_helpersRtTestCaseRtIdentServerR R%tRuntimeErrorR'R(tpackR=ROR:(((s;/usr/lib/python2.7/dist-packages/twisted/test/test_ident.pyt<module>s$@0