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_pb.pyc


=Nc@s dZddlZddlZddlZddlZddlZddlmZddlm	Z	m
Z
ddlmZddl
mZddlmZmZmZmZddlmZmZmZdd	lmZdd
lmZmZmZddlmZddl m!Z!dd
l"m#Z#m$Z$ddl%m&Z&m'Z'ddl(m)Z)m*Z*m+Z+dej,fdYZ-dej.fdYZ/de0fdYZ1dfdYZ2e3dZ4dej5fdYZ6dej5fdYZ7dej8fdYZ9dej:fd YZ;ej<e9e;d!ej8fd"YZ=d#Z>ej?e=e>d$ej5fd%YZ@d&ejAfd'YZBd(ej5fd)YZCd*ejAfd+YZDd,ejEfd-YZFej<eDeFd.ejEfd/YZGej<eBeGd0ej5fd1YZHd2ej5fd3YZId4ej5fd5YZJd6ej5fd7YZKd8ej8ej:e0fd9YZLej<eLeLd:ej8ej:e0fd;YZMej<eMeMd<ejAejEe0fd=YZNej<eNeNd>ejOfd?YZPd@ejOfdAYZQdBejRfdCYZSdDejTfdEYZUdFejRfdGYZVdHejRfdIYZWdJdKZXe3aYe3aZdLZ[dMej5fdNYZ\dOej5fdPYZ]dQejRfdRYZ^dSej_fdTYZ`dUejafdVYZbdWej5fdXYZcej<e`ebdYejRfdZYZdd[eefd\YZfd]ej8fd^YZgd_ej5fd`YZhdaejifdbYZjdcej.fddYZkdee0fdfYZldgej,fdhYZmdielfdjYZndkejRfdlYZodmejRfdnYZpdofdpYZqdqejRfdrYZrdse
fdtYZsdufdvYZtdwejRfdxYZudyejRfdzYZvd{ejRfd|YZwdS(}s
Tests for Perspective Broker module.

TODO: update protocol level tests to use new connection API, leaving
only specific tests for old API.
iN(tStringIO(t
implementst	Interface(tVersion(tunittest(tpbtutiltpublishtjelly(tprotocoltmaintreactor(tConnectionRefusedError(tDeferredt
gatherResultstsucceed(tWrappingFactory(tloopback(tfailuretlog(tUnauthorizedLogintUnhandledCredentials(tportaltcheckerstcredentialstDummycBseZdZRS(cCst|trdSdSdS(Nshello world!sgoodbye, cruel world!(t
isinstancetDummyPerspective(tselftuser((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytview_doNothing!s(t__name__t
__module__R(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR sRcBseZdZdZRS(sE
    An L{IPerspective} avatar which will be used in some tests.
    cCstS(N(R(R((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytperspective_getDummyViewPoint,s(RR t__doc__R!(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR(st
DummyRealmcBseZeejdZRS(cGs:x3|D]+}|tjkr|t|dfSqWdS(NcSsdS(N(tNone(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt<lambda>7s(RtIPerspectiveR(RtavatarIdtmindt
interfacestiface((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt
requestAvatar4s
(RR RRtIRealmR+(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR#1s
tIOPumpcBs2eZdZdZdZdZdZRS(s
    Utility to pump data between clients and servers for protocol testing.

    Perhaps this is a utility worthy of being in protocol.py?
    cCs(||_||_||_||_dS(N(tclienttservertclientIOtserverIO(RR.R/R0R1((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt__init__@s			cCsPt|_tjd}x0|jrK|jrKtj|krdSqWdS(s
        Pump until there is no more input or output or until L{stop} is called.
        This does not run any timers, so don't use it with any code that calls
        reactor.callLater.
        iN(tFalset_stopttimetpump(Rttimeout((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytflushGs
	cCs
t|_dS(sd
        Stop a running L{flush} operation, even if data remains to be
        transferred.
        N(tTrueR4(R((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytstopUscCs|jjd|jjd|jj}|jj}|jjd|jjd|jj|jj|jjj|jjjx|D]}|jj	|qWx|D]}|jj	|qW|s|rdSdSdS(sX
        Move data back and forth.

        Returns whether any data was moved.
        iiN(
R0tseekR1treadttruncateR.t	transportt_checkProducerR/tdataReceived(RtcDatatsDatatbyte((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR6]s"



(RR R"R2R8R:R6(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR-:s
			cCs|pt}tj}tjdd}tjtj||g}|jd}t	}t	}|j
tj||j
tj|t
||||}|j|||fS(s
    Connect a client and server L{Broker} together with an L{IOPump}

    @param realm: realm to use, defaulting to a L{DummyRealm}

    @returns: a 3-tuple (client, server, pump).
    tguests	127.0.0.1(s	127.0.0.1(R#RtBrokerRt'InMemoryUsernamePasswordDatabaseDontUsetPBServerFactoryRtPortalt
buildProtocolRtmakeConnectionR	tFileWrapperR-R8(trealmtclientBrokertcheckertfactorytserverBrokertclientTransporttserverTransportR6((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytconnectedServerAndClientxs		
tSimpleRemotecBseZdZdZRS(cCs||_|dS(Ni(targ(RRU((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytremote_thunks	cCs
tdS(N(t	Exception(RRU((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytremote_knuths(RR RVRX(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRTs	tNestedRemotecBseZdZRS(cCstS(N(RT(R((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytremote_getSimples(RR RZ(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRYst
SimpleCopycBseZdZRS(cCs)d|_idd6|_dg|_dS(NitWorldtHellottest(txtytz(R((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR2s	(RR R2(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR[stSimpleLocalCopycBseZRS((RR (((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRbstSimpleFactoryCopycBseZdZiZdZRS(s]
    @cvar allIDs: hold every created instances of this class.
    @type allIDs: C{dict}
    cCs||_|tj|<dS(N(tidRctallIDs(RRd((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR2s	(RR R"ReR2(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRcscCs|jdd}|dkr:tdt|fn|tjkrbtdtjfntj|}|stdn|S(sl
    Factory of L{SimpleFactoryCopy}, getting a created instance given the
    C{id} found in C{state}.
    Rds(factory copy state has no 'id' member %ssfactory class has no ID: %ss&factory method found no object with idN(tgetR$tRuntimeErrortreprRcRe(tstatetstateIdtinst((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytcreateFactoryCopys
t
NestedCopycBseZdZdZRS(cCstS(N(R[(R((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytremote_getCopyscCs
t|S(N(Rc(Rtvalue((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytremote_getFactorys(RR RnRp(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRms	tSimpleCachecBseZdZRS(cCs)d|_idd6|_dg|_dS(NiR\R]R^(R_R`Ra(R((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt	__init___s	(RR Rr(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRqstNestedComplicatedCachecBseZdZdZRS(cCst|_dS(N(tVeryVeryComplicatedCacheabletc(R((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR2scCs|jS(N(Ru(R((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytremote_getCaches(RR R2Rv(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRss	RtcBs,eZdZdZdZdZRS(cCsd|_d|_d|_dS(Niii(R_R`tfoo(R((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR2s		cCs d|_|jjdddS(NiRw(Rwtobservert
callRemote(R((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytsetFoo4s	cCs+||_i|jd6|jd6|jd6S(NR_R`Rw(RxR_R`Rw(RtperspectiveRx((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytgetStateToCacheAndObserveFors	

cCs9tjd|jd||jkr5d|_ndS(Nsstopped observingtend(RtmsgRyRxR$(RR{Rx((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytstoppedObservings

(RR R2RzR|R(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRts			tRatherBaroqueCachecBseZdZdZRS(cCs
||_dS(N(Rw(RtnewFoo((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytobserve_fooscCstjddS(Nsthe end of things(RR~(R((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytobserve_ends(RR RR(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRs	tSimpleLocalCachecBs,eZdZdZdZdZRS(cCs|jj|dS(N(t__dict__tupdate(RRi((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytsetCopyableStatescCs|jS(N(tcheck(R((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytcheckMethodscCs|S(N((R((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt	checkSelf
scCsdS(Ni((R((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR
s(RR RRRR(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRs			tNestedCachecBs#eZdZdZdZRS(cCst|_dS(N(RqR_(R((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR2scCs|j|jgS(N(R_(R((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRvscCs
|j|kS(N(R_(Rtcache((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytremote_putCaches(RR R2RvR(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRs		t
ObservablecBs,eZdZdZdZdZRS(cCs
g|_dS(N(t	observers(R((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR2scCs|jj|dS(N(Rtappend(Rtobs((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytremote_observe"scCs|jj|dS(N(Rtremove(RR((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytremote_unobserve%scCs+x$|jD]}|jd||q
WdS(Ntnotify(RRy(RtobjRx((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR(s(RR R2RRR(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRs			tDeferredRemotecBs,eZdZdZdZdZRS(cCs
d|_dS(Ni(trun(R((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR2.scCs||_|dS(Ni(R(RRU((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytrunMe1s	cCsdstddS(Nisshouldn't have been run!(tAssertionError(RRU((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt	dontRunMe5scCs,t}|j|j|j||_|S(so
        Return a L{Deferred} to be fired on client side. When fired,
        C{self.runMe} is called.
        (R
taddCallbacksRRtd(RR((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytremote_doItLater8s		(RR R2RRR(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR-s			tObservercBseZdZdZdZRS(icCs-||_|jd|_|jd|dS(Nit	unobserve(RtnotifiedRy(RtotherR((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt
remote_notifyFs	N(RR RR$RR(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRCstNewStyleCopycBseZdZRS(cCs
||_dS(N(ts(RR((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR2Ms(RR R2(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRLst
NewStyleCopy2cBs,eZdZdZdZdZdZRS(iicCs+tjd7_tj|}d|_|S(Nii(Rt	allocatedtobjectt__new__Ro(RRk((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRWs	cCstjd7_dS(Ni(Rtinitialized(R((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR2]s(RR RRRoRR2(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRRs
	tNewStyleCacheCopycBseZdZRS(cCs|jS(N(R(RR{Rx((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR|ds(RR R|(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRcstEchoercBseZdZRS(cCs|S(N((Rtst((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytremote_echoks(RR R(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRjstCachedReturnercBseZdZdZRS(cCs
||_dS(N(R(RR((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR2pscCs|jS(N(R(RR((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytremote_giveMeCachers(RR R2R(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRos	tNewStyleTestCasecBs,eZdZdZdZdZRS(cstjt_tj_tjdj_tj	}tj
djjj|fd}|j
j|S(sY
        Create a pb server using L{Echoer} protocol and connect a client to it.
        it	localhostcs
|_dS(N(tref(R(R(s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytgotRoots(RRGRt
serverFactoryRtwrapperRt	listenTCPR/tPBClientFactoryt
connectTCPtgetHosttportt
getRootObjecttaddCallback(Rt
clientFactoryR((Rs8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytsetUpwscCs_dt_dt_dt_|jjjjx!|jj	D]}|jjq;W|j
jS(sp
        Close client and server connections, reset values of L{NewStyleCopy2}
        class variables.
        ii(RRRRoRtbrokerR>tloseConnectionRt	protocolsR/t
stopListening(Rtproto((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyttearDowns			csDtdjjd}fd}|j||S(sY
        Create a new style object, send it over the wire, and check the result.
        Rotechocs@jt|tj|jdj|kdS(NRo(t
failUnlessRRtassertEqualRtfailIf(tres(Rtorig(s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytcbs(RRRyR(RRR((RRs8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt
test_newStyles

csgtjtjdjtjdjjd}fd}|j||S(sN
        Send a new style object and check the number of allocations.
        iRcsfjt|tj|jdjtjdjtjdj|kdS(Niii(RRRRRoRRR(R(RR(s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRs
(RRRRRRyR(RRR((RRs8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt
test_allocs	
(RR RRRR(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRvs			
tConnectionNotifyServerFactorycBs&eZdZdZdZdZRS(sj
    A server factory which stores the last connection and fires a
    L{Deferred} on connection made. This factory can handle only one
    client connection.

    @ivar protocolInstance: the last protocol instance.
    @type protocolInstance: C{pb.Broker}

    @ivar connectionMade: the deferred fired upon connection.
    @type connectionMade: C{Deferred}
    cCs#tjj||t|_dS(s)
        Initialize the factory.
        N(RRGR2R
tconnectionMade(Rtroot((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR2scCs<||_|jd}|_|dk	r8|jdndS(sF
        Store the protocol and fire the connection deferred.
        N(tprotocolInstanceRR$tcallback(RR	R((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytclientConnectionMades	N(RR R"R$RR2R(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRs	tNewStyleCachedTestCasecBs#eZdZdZdZRS(cst_dj_tjdttj_tj	}tj
djjj|fd}|j
j|}jjj}t||gS(si
        Create a pb server using L{CachedReturner} protocol and connect a
        client to it.
        RoiRcs
|_dS(N(R(R(R(s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRs(RRRRRRRR/RRRRRRRRORR(RRRtd1td2((Rs8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRs	cCs6|jjjjj|jjjj|jjS(s6
        Close client and server connections.
        (R/RORR>RRRR(R((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRscsKjjdj}fd}|j|t|j|t|S(s
        A new-style cacheable object can be retrieved and re-retrieved over a
        single connection.  The value of an attribute of the cacheable can be
        accessed on the receiving side.
        tgiveMeCachecs_j|tjd|jjj||r[|_jjdjSdS(NRoR(	tassertIsInstanceRRRtassertNotIdenticalRRRRy(Rtagain(R(s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRs	(RRyRRR9R3(RRR((Rs8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyttest_newStyleCaches
(RR RRR(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRs			tBrokerTestCasecBseZdZdZdZdZdZdZdZ	dZ
dZdZd	Z
d
ZdZdZd
ZdZdZdZRS(cCs)ytjdWntk
r$nXdS(NsNone-None-TESTING.pub(tostunlinktOSError(R((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRs
cCs|jd|fdS(Ns(This should cause a return value, not %s(tfail(Rterror((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt
thunkErrorBadscCs
||_dS(N(tthunkResult(Rtresult((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytthunkResultGoodscCsdS(N((Rttb((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytthunkErrorGoodscCs|jd|fdS(Ns"This should cause an error, not %s(R(RR((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytthunkResultBad sc	Cst\}}}dtjfdY}dtjfdY}|jd||jd}|}|}|jd|||j|j|j|j|j|d|j	|j
d|j
ddS(NtXcBseZdZRS(cSs
||_dS(N(tcaught(RRU((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytremote_catch's(RR R(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR&stYcBseZdZRS(cSs|jd|dS(Ntcatch(Ry(Rtatb((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytremote_throw+s(RR R(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR*sR`tthrowsX should have caught Z(RSRt
ReferenceabletsetNameForLocalt
remoteForNameRyR6tassertIdenticalRRtremoteMethod(	RRuRR6RRR`R_Ra((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyttest_reference#s		


cCst\}}}x||f||ffD]\}}t}|jd||jd}d|_|jd|jdj|j|j|j	|j	|j
|j|jdq+WdS(NRwitthunkisresult wasn't received.(RSRTRRtexpectedThunkResultRyRRRR6RR(RRuRR6R_R`Rwtbar((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyttest_result;s%		

cCs
||_dS(N(tnestedRemote(RR((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytrefcountResultMsc
Csg}g}t\}}}t}|jd||jd}x`ttjdD]K}|jjsx|jjr|Pn|j	dj
|j|j|jqZWtjd}	|j
|jjd|jt||	d|	t|fdS(NRwi
t	getSimpleistransport was not closedsexpected %s got %s(RSRYRRtxrangeRtMAX_BROKER_REFSR>tclosedRyRRR6t
assertTrueRtlen(
RtlteRuRR6RwR_tignotexpected((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyttest_tooManyRefsPs	
cCst\}}}t}|jd||jd}|jdj|j|j|j|j|j	|j
jd|j	|j
jdd|j	|j
j
dddS(NRwtgetCopyiR]R\iR^(RSRmRRRyRRRR6RRR_R`Ra(RRuRR6RwR_((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt	test_copyas	

cCst\}}}t}t}|jd||jd}|jd||j|jd|j|j|jd|j|j|j|j	dd|j|j	dddS(NRtobserveii
s
didn't notifysnotified too much(RSRRRRRyR6RRRR$R(RRuRR6RRtra((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyttest_observens		






cCst\}}}t}|jd||jd}|j|jg}|jdj|j|j|j|j|j	d|j
jd|j|j	dd|j|j|j|ddddS(	NRt	doItLatersDeferred method run too early.isDeferred method run too late.iisIncorrect result.(
RSRRRR6RyRRtassertFalseRRRR(RRuRR6RRtresults((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt
test_defers 	





cCst\}}}t}|jd||jd}|jdj|j|j|j|j|j	j
}|j||j|`	t
jdkrtjn|j|j|j|j||jdS(NRwRi(RSRYRRRyRRRR6RtluidtassertIntlocalObjectstsyst
hexversiontgctcollecttassertNotIn(RRuRR6RwRtrluid((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt
test_refcounts"	





cCs	t\}}}t}t}|j}|jd||jd||jd}|jd}g}	|jdj|	jj	|	j|jdj|	jj	|	jg}
|jdj|
j|jdj|
j|j
|j|
djd|j|
dj
d|j|
djd|j|j
|j|
djd|jt|	d|	dd}|j|jj|d	|j|j|d
g}|jd|j|j|j
|j|d|j|jd|jd|j}
|
dj}|j|
|jd~	~|j
~
~|j
tjd
krtjn|j
|j|
|jd|j|
|jd|j||jd|j||jd|j|j dddS(NRtxxxtgetCacheiiiiispotential refcounting issues!other potential refcounting issuetputCachesremote cache doesn't have itisServer still had it after GCsClient still had it after GCs!Server still had complex after GCs!Client still had complex after GCsobserver was not removed("RSRRsRuRRRyRRt
addErrbackR8RR_R`RwRzRRRtim_selfRRRRRtremotelyCachedObjectsRRRRRtlocallyCachedObjectsRxR$(RRuRR6Rtobj2tvccto2to3tcolltcomplextcptcol2RtbaroqueLuid((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt
test_cachesr			



	




cCscytjdWntk
r$nXt\}}}t}|jd||jd}g}|jdj|j	|j
|j|j}|j
|jd|j
|jd|j
|jd|j
|jdt\}}}|jd||jd}|jdj|j	|j
|j|j}|j
|jddS(NsNone-None-TESTING.pubRwtgetPubii(RRRRStGetPublisherRRRyRRRR8tpopRtactivateCalledtisActivatedtyayIGotPublishedt_wasCleanWhenLoaded(RRuRR6RwRtaccumR((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyttest_publishables.
	

cCs|j|_dS(N(RdR(Rtval((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytgotCopyscCst\}}}d}t}|jd||jd}|jd|j|j|j|j|j|j|j	|j
|d|j
fdS(NicRwt
getFactorys#ID not correct on factory object %s(RSRmRRRyRR8RR6RR(RRuRR6tIDRR_((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyttest_factoryCopys	


N(RR R$RRRRRRRRRR	RRRRR-R6R8R;(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR
s$										
				F		t
helloworldi2cOs|a|adS(N(tcallbackArgstcallbackKeyword(targstkw((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytfinishedCallback'st	PagerizercBseZdZdZRS(cOs!||||_|_|_dS(N(RR?R@(RRR?R@((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR2.scCs9tj|td|j|j|jd|_|_dS(Nid(RtStringPagert	bigStringRR?R@R$(Rt	collector((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytremote_getPages1s(RR R2RF(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRB-s	t
FilePagerizercBs eZdZdZdZRS(cOs*||_||||_|_|_dS(N(tfilenameRR?R@(RRHRR?R@((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR2:s	cCsDtj|t|j|j|j|j|_d|_|_dS(N(	Rt	FilePagertfileRHRR?R@tpagerR$(RRE((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRF>sN(RR R$RKR2RF(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRG7s	tPagingTestCasecBsDeZdZdZdZdZdZdZdZRS(s0
    Test pb objects sending data by pages.
    cCs<|j|_t|jd}|jt|jdS(s?
        Create a file used to test L{util.FilePager}.
        twN(tmktempRHRJtwriteRDtclose(Rtfd((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRJs
cCst\}}}|jdttddd|jd}g}tj|dj|jx|sx|j	qeW|j
dj|dtd|j
t
dd	|j
tidd6d	d
S(sg
        Test L{util.StringPager}, passing a callback to fire when all pages
        are sent.
        RwthelloRoi
tgetPagestis'Pages received not equal to pages sent!sCompleted callback not invokedN(RR(RSRRBRARRtgetAllPagesRRR6RtjoinRDR=R>(RRuRR6R_R((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyttest_pagingWithCallbackTs	cCst\}}}|jdtd|jd}g}tj|dj|jx|so|j	q\W|j
dj|dtddS(s>
        Test L{util.StringPager} without a callback.
        RwRSRTis'Pages received not equal to pages sent!N(
RSRRBR$RRRURRR6RRVRD(RRuRR6R_R((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyttest_pagingWithoutCallbackhs	c
Cs|j}t|d}|jt\}}}t|d
}|jd||jd}g}tj	|dj
|jd}	x+|r|	dkr|j|	d8}	qW|	s|j
dn|jdj|ddd	d
S(s@
        Test L{util.FilePager}, sending an empty file.
        RMRRSi
iisgetAllPages timed outRTs'Pages received not equal to pages sent!N(RNRJRPRSRGR$RRRRURRR6RRRV(
Rt
filenameEmptyRQRuRR6t	pagerizerR_Rtttl((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyttest_emptyFilePagingws"

cCst\}}}t|jtddd}|jd||jd}g}tj|dj|j	x|s|j
qqW|jdj|dt
d|jtdd	|jtidd6d	|j|jjgd
S(s
        Test L{util.FilePager}, passing a callback to fire when all pages
        are sent, and verify that the pager doesn't keep chunks in memory.
        tfrodoRoi	RRSRTis'Pages received not equal to pages sent!sCompleted callback not invokedN(R](RSRGRHRARRRRURRR6RRVRDR=R>RKtchunks(RRuRR6RZR_R((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyttest_filePagingWithCallbacks 	cCst\}}}t|jd}|jd||jd}g}tj|dj|j	x|s{|j
qhW|jdj|dt
d|j|jjgdS(s<
        Test L{util.FilePager} without a callback.
        RRSRTis'Pages received not equal to pages sent!N(RSRGRHR$RRRRURRR6RRVRDRKR^(RRuRR6RZR_R((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyttest_filePagingWithoutCallbacks	(	RR R"RRWRXR\R_R`(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRLEs	
				tDumbPublishablecBseZdZRS(cCsidd6S(NiR3((R((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytgetStateToPublishs(RR Rb(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRastDumbPubcBseZdZRS(cCs
d|_dS(Ni(R1(R((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt	activateds(RR Rd(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRcsR/cBseZdZdZRS(cCstd|_dS(NtTESTING(Ratpub(R((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR2scCs|jS(N(Rf(R((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt
remote_getPubs(RR R2Rg(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR/s	tDisconnectionTestCasecBs;eZdZdZdZdZdZdZRS(s'
    Test disconnection callbacks.
    cGstd|fdS(Ns I shouldn't have been called: %s(Rg(RR?((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRscCs
d|_dS(s.
        Called on broker disconnect.
        iN(tgotCallback(R((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytgotDisconnectedscCs |j||jd|_dS(s7
        Called on RemoteReference disconnect.
        iN(RtremoteObjecttobjectCallback(Rto((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytobjectDisconnectedscCst\}}}|j|jdt|jd}g}|jdtj|j|j	|j
t|ddS(NRmt
setBadCopyi(RSR6Rt
BadCopySetRRytBadCopyableR RR8RR(RRuRR6tgR((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyttest_badSerializations

cCst\}}}|j|jdt|jd}|j|j|j|j|j|j|j|j|j	|j|j
|j|j|j|j|j|j|j|j|j|j|j	|j|j
|j|j|j
|j|j|j|j
|j|j||_|jtjtj|j|j|j|jdS(NRm(RSR6RRTRtnotifyOnDisconnectRRtdisconnectstdontNotifyOnDisconnectRt
_disconnectedtdisconnectCallbacksRjRnRktconnectionLostRtFailureR
tCONNECTION_DONERRiRl(RRuRR6tr((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyttest_disconnections.



	(RR R"RRjRnRsR}(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRhs				
tFreakOutcBseZRS((RR (((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR~sRqcBseZdZRS(cCs
tdS(N(R~(Rtp((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytgetStateToCopyFors(RR R(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRqsRpcBseZdZRS(cCsdS(N(R$(Rtbc((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytremote_setBadCopys(RR R(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRpstLocalRemoteTestcBs/eZdZdZdddZdZRS(icCs|dS(Ni((RR_((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt	sync_add1 sicCs||S(N((RR_R`((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt	async_add#scCs
tdS(N(Rg(R((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt
async_fail&s(RR treportAllTracebacksRRR(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRs	t
MyPerspectivecBsReZdZeejeZZdZ	dZ
dZdZdZ
RS(s
    @ivar loggedIn: set to C{True} when the avatar is logged in.
    @type loggedIn: C{bool}

    @ivar loggedOut: set to C{True} when the avatar is logged out.
    @type loggedOut: C{bool}
    cCs
||_dS(N(R'(RR'((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR27scCs|jS(sT
        Return the avatar identifier which was used to access this avatar.
        (R'(R((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytperspective_getAvatarId;scCstS(N(tMyView(R((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytperspective_getViewPointBscCs||S(s
        Add the given objects and return the result.  This is a method
        unavailable on L{Echoer}, so it can only be invoked by authenticated
        users who received their avatar from L{TestRealm}.
        ((RRR((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytperspective_addFscCs
t|_dS(N(R9t	loggedOut(R((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytlogoutOs(RR R"RRR&R3tloggedInRR2RRRR(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR+s

					t	TestRealmcBs#eZdZeZdZdZRS(s
    A realm which repeatedly gives out a single instance of L{MyPerspective}
    for non-anonymous logins and which gives out a new instance of L{Echoer}
    for each anonymous login.

    @ivar lastPerspective: The L{MyPerspective} most recently created and
        returned from C{requestAvatar}.

    @ivar perspectiveFactory: A one-argument callable which will be used to
        create avatars to be returned from C{requestAvatar}.
    cCs|tjkst|dks't|tjkrLtjtdfS|j||_t|j_	tj|j|jj
fSdS(s
        Verify that the mind and interface supplied have the expected values
        (this should really be done somewhere else, like inside a test method)
        and return an avatar appropriate for the given identifier.
        sBRAINS!cSsdS(N(R$(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR%msN(RR&RRt	ANONYMOUSRtperspectiveFactorytlastPerspectiveR9RR(RR'R(t	interface((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR+dsN(RR R"RRR$RR+(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRTsRcBseZdZRS(cCs
t|tS(N(RR(RR((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt
view_checkys(RR R(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRwst
LeakyRealmcBs eZdZdZdZRS(s]
    A realm which hangs onto a reference to the mind object in its logout
    function.
    cCs
||_dS(s
        Create a L{LeakyRealm}.

        @param mindEater: a callable that will be called with the C{mind}
        object when it is available
        N(t
_mindEater(Rt	mindEater((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR2scs8|j|j|tjfdfS(NcsjfS(N(R((tperspR((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR%s(RRRR&(RR'R(R((RR(s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR+s
(RR R"R2R+(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR~s	
tNewCredLeakTestscBseZdZdZRS(s/
    Tests to try to trigger memory leaks.
    csd_fd}tt|\}g|jd}|jdd}d}|j|fd}|j|jjdgt	j
jjddS(	s
        The server does not leak a reference when the client disconnects
        suddenly, even if the cred logout function forms a reference cycle with
        the perspective.
        cstj|_dS(N(tweakrefRtmindRef(R((R(s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt
setMindRefsRtloginRDcSs4|\}}t}|jdtj|d|S(NtrespondRD(RTRyRR(t.0t	challenget
challengerR(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt
cbResponses			cs7jjdjtjtddS(Nitboom(R:RRyRRzRg(t_(RPtconnectionBrokenR6(s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRys

iN(R$RRSRRRyRR8RRR(RRRMRRRRy((RRPR6Rs8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyttest_logoutLeaks		



(RR R"R(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRstNewCredTestCasecBseZdZdZdZejdZdZdZ	dZ
dZdZd	Z
d
ZdZdZd
ZdZdZdZdZdZRS(s=
    Tests related to the L{twisted.cred} support in PB.
    cCsjt|_tj|j|_t|j|_tjd|jdd|_|jj	j|_
dS(s
        Create a portal with no checkers and wrap it around a simple test
        realm.  Set up a PB server on a TCP port which serves perspectives
        using that portal.
        iRs	127.0.0.1N(RRLRRHRRORRRRtportno(R((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRs
cCs
|jjS(s=
        Shut down the TCP port created by L{setUp}.
        (RR(R((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRscCsG|}|j}tjd|j|}|j|j||fS(sG
        Create a connection to the test server.

        @param clientFactory: the factory class used to create the connection.

        @return: a tuple (C{factory}, C{deferred}), where factory is an
            instance of C{clientFactory} and C{deferred} the L{Deferred} firing
            with the PB root object.
        s	127.0.0.1(RRRRt
addCleanupt
disconnect(RRROtrootObjDeferredt	connector((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytgetFactoryAndRootObjects

	cs1j\}fd}|j|S(sw
        Assert only that L{PBClientFactory.getRootObject}'s Deferred fires with
        a L{RemoteReference}.
        cs:j|tjt}|j|jj|S(N(RRtRemoteReferenceR
RtRR(trootObjtdisconnectedDeferred(RRO(s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt
gotRootObjects
	
(RR(RRR((RROs8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyttest_getRootObjectscs1j\}fd}|j|S(s
        Test that when a connection is lost, calling a method on a
        RemoteReference obtained from it raises DeadReferenceError.
        csFt}j|jfd}|j|j|S(NcsjtjjddS(Ntmethod(tassertRaisesRtDeadReferenceErrorRy(tign(RR(s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytlostConnections(R
RtRRR(RRR(RRO(Rs8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRs	

(RR(RRR((RROs8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyttest_deadReferenceErrors
csMdtjfdY}j|\}fd}|j|S(s
        Test that if the L{reconnecting} flag is passed with a True value then
        a remote call made from a disconnection notification callback gets a
        result successfully.
        t
ReconnectOncecBseZeZdZRS(cSs?|j}t|_|r&|jntjj||||S(N(treconnectedAlreadyR9tconnectRRtclientConnectionLost(RRtreasontreconnecting((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRs
	
	(RR R3RR(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRscsUj|tjt}|j|jjfd}|j|S(Ncs+j}fd}|j|S(Ncs:j|tjt}|j|jj|S(N(RRRR
RtRR(tanotherRootObjR(RRO(s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytgotAnotherRootObject/s
	
(RR(RRR(RRO(s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytdisconnected,s(RRRR
RtRRR(RRR(RRO(s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR%s	
(RRRR(RRRR((RROs8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyttest_clientConnectionLosts
cCsH|jjd}|jtjt|jtjt	j
dS(s
        Test that if a Broker loses its connection without receiving any bytes,
        it doesn't raise any exceptions or log any errors.
        s	127.0.0.1i90N(s	127.0.0.1i90(RORIRJR	RKRRyRRzR
R{(RtserverProto((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyttest_immediateClose;scCsVtj}|jtjdd}|jdtjt	d|j
|t	S(s
        L{PBClientFactory.login} returns a L{Deferred} which is errbacked
        with the L{ConnectionRefusedError} if the underlying connection is
        refused.
        RwRs!Test simulated refused connectionN(RRRRtUsernamePasswordtclientConnectionFailedR$RRzRt
assertFailure(RRt
loginDeferred((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyttest_loginConnectionRefusedEscs3t|jjjfd|jS(s
        Helper method disconnecting the given client factory and returning a
        C{Deferred} that will fire when the server connection has noticed the
        disconnection.
        cs
jdS(N(RR$((R(s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR%]s(R
RORRtR(RtignoreRO((Rs8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt_disconnectUs
	
csjjtjddtjtjdd}d}j||}fd}|j	|fd}|j	|t
jdj}j
|j|S(s
        Test that login can be performed with IUsernamePassword credentials and
        that when the connection is dropped the avatar is logged out.
        RtpasssBRAINS!cs9jjjjj|tjjdS(N(	RRLRRRRRRR$(R{(RRO(s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytcbLogintscsjjjjdS(N(RRLRR(tignored(R(s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytcbLogoutzss	127.0.0.1(RtregisterCheckerRRFRRRRRRRRRRR(RtcredsR(RRRR((RROs8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyttest_loginLogoutbs	

cstdtjffdY}|j_jjtjddtj	}|j
tjddd}fd}|j
|fd}|j
||j
j|tjdj|}j|j|S(	s
        If a L{RemoteReference} to an L{IPerspective} avatar is decrefed and
        there remain no other references to the avatar on the server, the
        avatar is garbage collected and the logout method called.
        tEventPerspectivecs&eZdZdZfdZRS(sQ
            An avatar which fires a Deferred when it is logged out.
            cSsdS(N((RR'((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR2scsjddS(N(RR$(R(R(s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRs(RR R"R2R((R(s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRs	RwRsBRAINS!csS(N((tavatar(R(s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt
cbLoggedInscsjjjjidS(N(RRORt
_localCleanup(R(R(s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytcbLoggedOutss	127.0.0.1(R
RtAvatarRLRRRRRFRRRRRRRRRRR(RRRORRRR((RRs8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyttest_logoutAfterDecrefs 	
	

csjjtjddddtj}|jtjddd}|jtjddd}t	||g}d}|j
|fd}|j
||j
j|tj
dj|}j|j|S(	s
        Two different correct login attempts can be made on the same root
        object at the same time and produce two different resulting avatars.
        RwRtbaztquuxsBRAINS!cSs.|\}}t|jd|jdgS(NtgetAvatarId(RRy(Rtfirsttsecond((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRs	cs0|\}}j|dj|ddS(NRwR(R(RRR(R(s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytcbAvatarIdss	s	127.0.0.1(RRRRFRRRRRRRRRRRRR(RROt
firstLogintsecondLoginRRRR((Rs8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyttest_concurrentLogins"			

csjjtjddtjjtjdd}jtjdd}j	|t
j	|t
t||g}fd}|j|t
jdj}j|j|S(sz
        Test that a login attempt with an invalid user or invalid password
        fails in the appropriate way.
        RRt
nosuchusert	wrongpasscs5jt}jt|djdS(Ni(tflushLoggedErrorsRRRRR$(Rterrors(RRO(s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytcleanupss	127.0.0.1(RRRRFRRRRRRRRRRRRRR(RRRRRR((RROs8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyttest_badUsernamePasswordLogins	
cCs|jjtjtj}|jtjd}d}|j	||j	|j
d|j	|j|tj
d|j|}|j|j|S(s
        Verify that a PB server using a portal configured with an checker which
        allows IAnonymous credentials can be logged into using IAnonymous
        credentials.
        sBRAINS!cSs|jddS(NRi{(Ry(R{((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRsi{s	127.0.0.1(RRRtAllowAnonymousAccessRRRRt	AnonymousRRRRRRRR(RRORRR((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyttest_anonymousLogins	
csjjtjddtjjtjd}j	|t
fd}|j|tj
dj}j|j|S(sg
        Verify that without an anonymous checker set up, anonymous login is
        rejected.
        RRsBRAINS!cs5jt}jt|djdS(Ni(RRRRRR$(RR(RRO(s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR
ss	127.0.0.1(RRRRFRRRRRRRRRRRRR(RRRR((RROs8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyttest_anonymousLoginNotPermitteds	
cCs|jjtj|jjtjddtj}|jtj	d}d}|j
||j
|jd|j
|j|t
jd|j|}|j|j|S(s
        Like L{test_anonymousLogin} but against a portal with a checker for
        both IAnonymous and IUsernamePassword.
        RRsBRAINS!cSs|jddS(NRi{(Ry(R{((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR si{s	127.0.0.1(RRRRRFRRRRRRRRRRRRR(RRORRR((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt'test_anonymousLoginWithMultipleCheckerss		
cCs|jjtj|jjtjddtj}|jtj	ddd}d}|j
||j
|jd|j
|j|t
jd|j|}|j|j|S(s
        Like L{test_anonymousLoginWithMultipleCheckers} but check that
        username/password authentication works.
        RRsBRAINS!cSs|jdddS(Ntaddidi(Ry(R{((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR9si{s	127.0.0.1(RRRRRFRRRRRRRRRRRRR(RRORRR((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt+test_authenticatedLoginWithMultipleCheckers-s		
cCs|jjtjddtj}|jtjddd}d}|j	|d}|j	||j	|j
|j	|j|tj
d|j|}|j|j|S(sb
        Verify that a viewpoint can be retrieved after authenticating with
        cred.
        RRsBRAINS!cSs
|jdS(NtgetViewPoint(Ry(R{((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRQscSs
|jdS(NR(Ry(t	viewpoint((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytcbViewUss	127.0.0.1(RRRRFRRRRRRRRRRRRR(RRORRRR((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt	test_viewFs		
	
(RR R"RRRRRRRRRRRRRRRRRRRR(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRs&	
				(	
		
	!	)						tNonSubclassingPerspectivecBs0eZeejdZdZdZRS(cCsdS(N((RR'((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR2fscCs:|j||}|j||}|j|||fS(N(tunserializet	serialize(RRtmessageR?tkwargs((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytperspectiveMessageReceivedjscCs
t|_dS(N(R9R(R((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRps(RR RRR&R2RR(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRcs
		tNSPTestCasecBs eZdZdZdZRS(s
    Tests for authentication against a realm where the L{IPerspective}
    implementation is not a subclass of L{Avatar}.
    cCst|_t|j_tj|j|_tj|_|jj	dd|jj
|jttj
|j|_tjd|jdd|_|j|jj|jjj|_dS(NRRiRs	127.0.0.1(RRLRRRRHRRFRNtaddUserRRRRGRORRRRRRR(R((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRzscstjjtjddd}tjdj|jd|jj	ddidd	6ffd
}|j||S(s
        An L{IPerspective} implementation which does not subclass
        L{Avatar} can expose remote methods for the client to call.
        RRsBRAINS!s	127.0.0.1cSs|jddddS(NtANYTHINGthereRR(Ry(R((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR%sRRRRcs2jx!jjD]}|jjqWdS(N(RRORR>R(RR(RRO(s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRs
(shere(
RRRRRRRRRR(RRR((RROs8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyttest_NSPs	
(RR R"RR(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRus	
t
IForwardedcBs eZdZdZdZRS(sA
    Interface used for testing L{util.LocalAsyncForwarder}.
    cCsdS(s,
        Simple synchronous method.
        N((((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt	forwardMescCsdS(s-
        Simple asynchronous method.
        N((((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytforwardDeferreds(RR R"RR(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRs	t	ForwardedcBs?eZdZeeeZeZdZdZ	dZ
RS(s
    Test implementation of L{IForwarded}.

    @ivar forwarded: set if C{forwardMe} is called.
    @type forwarded: C{bool}
    @ivar unforwarded: set if C{dontForwardMe} is called.
    @type unforwarded: C{bool}
    cCs
t|_dS(s6
        Set a local flag to test afterwards.
        N(R9t	forwarded(R((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRscCs
t|_dS(sv
        Set a local flag to test afterwards. This should not be called as it's
        not in the interface.
        N(R9tunforwarded(R((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt
dontForwardMescCs
ttS(s0
        Asynchronously return C{True}.
        (RR9(R((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRs(RR R"RRR3RRRRR(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRs
		tSpreadUtilTestCasecBs;eZdZdZdZdZdZdZRS(s+
    Tests for L{twisted.spread.util}.
    cCs)t}|j|jddddS(sk
        Call a synchronous method of a L{util.LocalAsRemote} object and check
        the result.
        tadd1iiN(RRRy(RRm((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt	test_syncs	cCsQt}t}|jdddd}|j|t|j|jd|S(sm
        Call an asynchronous method of a L{util.LocalAsRemote} object and check
        the result.
        RiR`ii(RRyRR
RR(RRmR((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt
test_asyncs		csDt}|jd}fd}|jfd||S(sF
        Test a asynchronous failure on a remote method call.
        Rcs*jt|tj|jtdS(N(RRRRzttrapRg(tf(R(s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pytebscs
jdS(Nssupposed to fail(R(R(R(s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR%s(RRyR(RRmRR
((Rs8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyttest_asyncFails
	cCs2t}|jd}|j|dddS(sM
        Test the C{remoteMethod} facility of L{util.LocalAsRemote}.
        RiiN(RRR(RRmtm((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyttest_remoteMethods	cCst}tj|t}|jd|j|j|jd|j|j|jd}g}|j	|j
|j|dddS(se
        Test a call to L{util.LocalAsyncForwarder} using L{Forwarded} local
        object.
        RRRiiN(RRtLocalAsyncForwarderRRyRRRRRRR(RRtlftrrR((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyttest_localAsyncForwarders	

(RR R"R	R
RRR(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRs				tPBWithSecurityOptionsTestcBs2eZdZdZdZdZdZRS(s&
    Test security customization.
    cCs5tj}|jd}|j|jtjdS(sl
        By default, client broker should use C{jelly.globalSecurity} as
        security settings.
        N(RRRIR$RtsecurityRtglobalSecurity(RROR((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt!test_clientDefaultSecurityOptionsscCs;tjt}|jd}|j|jtjdS(sl
        By default, server broker should use C{jelly.globalSecurity} as
        security settings.
        N(	RRGRRIR$RRRR(RROR((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt!test_serverDefaultSecurityOptionsscCsDtj}tjd|}|jd}|j|j|dS(ss
        Check that the security settings are passed from the client factory to
        the broker object.
        RN(RtSecurityOptionsRRRIR$RR(RRROR((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt test_clientSecurityCustomization%scCsJtj}tjtd|}|jd}|j|j|dS(ss
        Check that the security settings are passed from the server factory to
        the broker object.
        RN(	RRRRGRRIR$RR(RRROR((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt test_serverSecurityCustomization0s(RR R"RRRR(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRs
	
	
	tDeprecationTestscBs eZdZdZdZRS(sS
    Tests for certain deprecations of free-functions in L{twisted.spread.pb}.
    c	Cs8|jtddddtjdddddd	d
S(s2
        L{pb.noOperation} is deprecated.
        ttwistediiiiR_iR`iN(tcallDeprecatedRRtnoOperation(R((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyttest_noOperationDeprecated@scCs)|jtddddtjddS(s5
        L{pb.printTraceback} is deprecated.
        Riiis/printTraceback deprecation fake traceback valueN(RRRtprintTraceback(R((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyttest_printTracebackIs(RR R"R!R#(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR<s		(xR"RRR5RRt	cStringIORtzope.interfaceRRttwisted.python.versionsRt
twisted.trialRttwisted.spreadRRRRttwisted.internetR	R
Rttwisted.internet.errorRttwisted.internet.deferR
RRttwisted.protocols.policiesRttwisted.protocolsRttwisted.pythonRRttwisted.cred.errorRRttwisted.credRRRtViewableRRRRR#R-R$RSRRTRYtCopyableR[t
RemoteCopyRbtsetUnjellyableForClassRcRltsetUnjellyableFactoryForClassRmt	CacheableRqRsRttRemoteCacheRRRRRRRRRtRootRRtTestCaseRRGRRRRDR=R>RARBRGRLtPublishableRatRemotePublishedRcR/RhRWR~RqRpt
LocalAsRemoteRRRRRRRRRRRRRR(((s8/usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt<module>	s<"		>			
	"""@!6
	
rD)#.'!?0