+
    DfjT                        ^ RI t ^ RIt^ RIHt ^ RIHt ^ RIHt ^ RIt	^ RI
HtHtHtHtHt ^ RIHt ^ RIHtHtHt ^ RIHt ^ R	IHtHt ^ R
IHt ^ RIHt  ^ RI H!t!H"t"  ! R R]4      t$RRRRRRRRRRRR/t%R2R lt&R t' ! R R]4      t( ! R R4      t) ! R R4      t* ! R R ]4      t+ ! R! R"]4      t, ! R# R$]4      t- ! R% R&]4      t. ! R' R(4      t/ ! R) R*]P`                  4      t1]! ]!'       * R+4      ]! ]Pd                  ! ]R4      '       * R+4       ! R, R-]4      4       4       t3 ! R. R/]/]4      t4 ! R0 R1]4      t5R#   ]# d    Rt!Rt" Li ; i)3    N)List)skipIf)directlyProvides)defererror
interfacesprotocolreactor)StringTransport)AdvancedPOP3Client InsecureAuthenticationDisallowedServerErrorResponse)pop3testserver)basicloopback)log)TestCase)ClientTLSContextServerTLSContextc                   &   a  ] tR t^ t o R tRtV tR# )#StringTransportWithConnectionLosingc                b    V P                   P                  \        P                  ! 4       4       R # N)r	   connectionLostr   ConnectionDoneselfs   &C/usr/lib/python3/dist-packages/twisted/mail/test/test_pop3client.pyloseConnection2StringTransportWithConnectionLosing.loseConnection!   s    $$U%9%9%;<     N)__name__
__module____qualname____firstlineno__r   __static_attributes____classdictcell____classdict__s   @r   r   r       s     = =r!   r   s   TOPs   LOGIN-DELAYs   180s   UIDL   STLSs   USERs   SASLs   LOGINc                     \        4       p\        Vn        \        4       pWn        VP                  V4       V '       d   VP                  R 4       W3# )s   +OK Hello!
)
POP3ClientcapCache	_capCacher   r	   makeConnectiondataReceived)greetpts   &  r   setUpr5   /   sD    A AK+-AJQ	()4Kr!   c                     V 3R  l# )c                     V! 4       # r   r"   )resultfs   &&r   <lambda>strip.<locals>.<lambda>A   s    qsr!   r"   )r9   s   &r   stripr<   @   s    ""r!   c                   n   a  ] tR t^Dt o R tR tR tR tR tR t	R t
R tR	 tR
 tR tR tR tRtV tR# )POP3ClientLoginTestsc                   a  \        R R7      w  rRVn        VP                  RR4      pVP                  R4       S P	                  V\
        4      P                  V 3R l4      # )Fr2   T   username   passwords   -ERR Offline for maintenance
c                 J   < SP                  V P                  ^ ,          R4      # )r   s   Offline for maintenanceassertEqualargsexcr   s   &r   r:   ;POP3ClientLoginTests.testNegativeGreeting.<locals>.<lambda>K   s    ((!6PQr!   )r5   allowInsecureLoginloginr1   assertFailurer   addCallbackr   r3   r4   ds   f   r   testNegativeGreeting)POP3ClientLoginTests.testNegativeGreetingE   sX    5!#GGK-	:;!!!%89EEQ
 	
r!   c                    \        4       w  rVP                  R 4      pV P                  VP                  4       R4       VP	                  R4       VP                  V P                  R4      # )rA      USER username
s   +OK send password
s   send password)r5   userrE   valuer1   rM   rN   s   &   r   
testOkUserPOP3ClientLoginTests.testOkUserN   sU    wFF;$89	/0}}T--/?@@r!   c                   a  \        4       w  rVP                  R 4      pS P                  VP                  4       R4       VP	                  R4       S P                  V\        4      P                  V 3R l4      # )rA   rS   s   -ERR account suspended
c                 J   < SP                  V P                  ^ ,          R4      # )r   s   account suspendedrD   rG   s   &r   r:   2POP3ClientLoginTests.testBadUser.<locals>.<lambda>[   s    ((!6JKr!   )r5   rT   rE   rU   r1   rL   r   rM   rN   s   f   r   testBadUser POP3ClientLoginTests.testBadUserU   sb    wFF;$89	45!!!%89EEK
 	
r!   c                    \        4       w  rVP                  R 4      pV P                  VP                  4       R4       VP	                  R4       VP                  V P                  R4      # )rB      PASS password
s   +OK you're in!
s
   you're in!)r5   passwordrE   rU   r1   rM   rN   s   &   r   
testOkPassPOP3ClientLoginTests.testOkPass^   sT    wJJ{#$89	,-}}T--}==r!   c                   a  \        4       w  rVP                  R 4      pS P                  VP                  4       R4       VP	                  R4       S P                  V\        4      P                  V 3R l4      # )rB   r^   s   -ERR go away
c                 J   < SP                  V P                  ^ ,          R4      # )r   s   go awayrD   rG   s   &r   r:   2POP3ClientLoginTests.testBadPass.<locals>.<lambda>k   s    ((!jAr!   )r5   r_   rE   rU   r1   rL   r   rM   rN   s   f   r   testBadPass POP3ClientLoginTests.testBadPasse   sb    wJJ{#$89	*+!!!%89EEA
 	
r!   c                H   \        4       w  rR Vn        VP                  RR4      pV P                  VP	                  4       R4       VP                  R4       V P                  VP	                  4       R4       VP                  R4       VP                  V P                  R4      # )TrA   rB   rS   s   +OK go ahead
   USER username
PASS password
s   +OK password accepted
s   password accepted)r5   rJ   rK   rE   rU   r1   rM   rN   s   &   r   testOkLogin POP3ClientLoginTests.testOkLoginn   s    w#GGK-$89	*+$IJ	34}}T--/CDDr!   c                d  a  \        4       w  rR Vn        VP                  RR4      pS P                  VP	                  4       R4       VP                  R4       S P                  VP	                  4       R4       VP                  R4       S P                  V\        4      P                  V 3R l4      # )TrA   rB   rS   s   +OK waiting on you
rh      -ERR bogus login
c                 J   < SP                  V P                  ^ ,          R4      # r   s   bogus loginrD   rG   s   &r   r:   ;POP3ClientLoginTests.testBadPasswordLogin.<locals>.<lambda>       ((!nEr!   	r5   rJ   rK   rE   rU   r1   rL   r   rM   rN   s   f   r   testBadPasswordLogin)POP3ClientLoginTests.testBadPasswordLoginx   s    w#GGK-$89	01$IJ	./!!!%89EEE
 	
r!   c                  a  \        4       w  rR Vn        VP                  RR4      pS P                  VP	                  4       R4       VP                  R4       S P                  V\        4      P                  V 3R l4      # )TrA   rB   rS   rl   c                 J   < SP                  V P                  ^ ,          R4      # rn   rD   rG   s   &r   r:   ;POP3ClientLoginTests.testBadUsernameLogin.<locals>.<lambda>   rp   r!   rq   rN   s   f   r   testBadUsernameLogin)POP3ClientLoginTests.testBadUsernameLogin   sl    w#GGK-$89	./!!!%89EEE
 	
r!   c                |    \        R R7      w  rVP                  R4       V P                  VP                  R4       R# )Fr@   s"   +OK lalala this has no challenge
Nr5   r1   rE   serverChallenger   r3   r4   s   &  r   testServerGreeting'POP3ClientLoginTests.testServerGreeting   s1    5!	>?**D1r!   c                |    \        R R7      w  rVP                  R4       V P                  VP                  R4       R# )Fr@   s   +OK <here is the challenge>
s   <here is the challenge>Nrz   r|   s   &  r   testServerGreetingWithChallenge4POP3ClientLoginTests.testServerGreetingWithChallenge   s2    5!	9:**,FGr!   c                    \        R R7      w  rVP                  R4       VP                  RR4      pV P                  VP	                  4       R4       VP                  R4       VP                  V P                  R4      # )Fr@   s"   +OK <challenge string goes here>
rA   rB   s0   APOP username f34f1e464d0d7927607753129cabe39a
s   +OK Welcome!
s   Welcome!)r5   r1   rK   rE   rU   rM   rN   s   &   r   testAPOPPOP3ClientLoginTests.testAPOP   sk    5!	>?GGK-GGIL	
 	
*+}}T--{;;r!   c                    \        R R7      w  rVP                  R4       VP                  RR4      pV P                  VP	                  4       4       V P                  V\        4      # )Fr@      +OK Howdy
rA   rB   )r5   r1   rK   assertFalserU   rL   r   rN   s   &   r    testInsecureLoginRaisesException5POP3ClientLoginTests.testInsecureLoginRaisesException   sS    5!	'(GGK-#!!!%EFFr!   c                   \        RR7      w  r\        V\        P                  4       VP	                  R4       VP                  RR4      pV P                  VP                  4       R4       VP                  4        VP	                  R4       V P                  VP                  4       R4       VP	                  R4       V# )	z
If a server doesn't offer APOP but the transport is secured using
SSL or TLS, a plaintext login should be allowed, not rejected with
an InsecureAuthenticationDisallowed exception.
Fr@   r   rA   rB   rS   s   +OK
r^   )	r5   r   r   ISSLTransportr1   rK   rE   rU   clearrN   s   &   r    testSSLTransportConsideredSecure5POP3ClientLoginTests.testSSLTransportConsideredSecure   s     5!J445	'(GGK-$89			z"$89	z"r!   r"   N)r#   r$   r%   r&   rP   rV   r[   r`   re   ri   rr   rw   r}   r   r   r   r   r'   r(   r)   s   @r   r>   r>   D   sO     
A
>
E


2
H
<G r!   r>   c                   ,   a  ] tR t^t o R tR tRtV tR# )ListConsumerc                    / V n         R # r   datar   s   &r   __init__ListConsumer.__init__   	    	r!   c                d    Vw  r#V P                   P                  V. 4      P                  V4       R # r   )r   
setdefaultappend)r   r8   itemrU   s   &&  r   consumeListConsumer.consume   s(    		T2&--e4r!   r   Nr#   r$   r%   r&   r   r   r'   r(   r)   s   @r   r   r      s     5 5r!   r   c                   ,   a  ] tR t^t o R tR tRtV tR# )MessageConsumerc                    . V n         R # r   r   r   s   &r   r   MessageConsumer.__init__   r   r!   c                <    V P                   P                  V4       R # r   )r   r   r   lines   &&r   r   MessageConsumer.consume   s    		r!   r   Nr   r)   s   @r   r   r      s      r!   r   c                   D   a  ] tR t^t o R tR tR tR tR tR t	Rt
V tR# )	POP3ClientListTestsc                    \        4       w  rVP                  4       pV P                  VP                  4       R 4       VP	                  R4       VP	                  R4       VP                  V P                  . RO4      # )   LIST
   +OK Here it comes
s   1 3
2 2
3 1
.
)         )r5   listSizerE   rU   r1   rM   rN   s   &   r   testListSize POP3ClientListTests.testListSize   s]    wJJLK0	/0	45}}T--y99r!   c                   \        4       w  r\        4       pVP                  pVP                  V4      pV P	                  VP                  4       R 4       VP                  R4       VP                  R4       V P	                  VP                  ^ ^.^^.^^./4       VP                  R4       V P	                  VP                  ^ ^.^^.^^.^^.^^.^^./4       VP                  R4       VP                  V P                  V4      # )r   r   s   1 3
2 2
3 1
s   5 3
6 2
7 1
   .
)
r5   r   r   r   rE   rU   r1   r   rM   assertIdenticalr   r3   r4   cr9   rO   s   &     r   testListSizeWithConsumer,POP3ClientListTests.testListSizeWithConsumer   s    wNIIJJqMK0	/0	/0!aS!aS!aS!9:	/0!aS!aS!aS!aS!aS!aS!QR	x }}T11155r!   c                   a  \        4       w  rVP                  4       pS P                  VP                  4       R 4       VP	                  R4       S P                  V\        4      P                  V 3R l4      # )r   !   -ERR Fatal doom server exploded
c                 J   < SP                  V P                  ^ ,          R4      # r   s   Fatal doom server explodedrD   rG   s   &r   r:   8POP3ClientListTests.testFailedListSize.<locals>.<lambda>       ((!6STr!   )r5   r   rE   rU   r1   rL   r   rM   rN   s   f   r   testFailedListSize&POP3ClientListTests.testFailedListSize   s^    wJJLK0	=>!!!%89EET
 	
r!   c                    \        4       w  rVP                  4       pV P                  VP                  4       R 4       VP	                  R4       VP	                  R4       VP                  V P                  . RO4      # )   UIDL
r   s   1 abc
2 def
3 ghi
.
)   abcs   defs   ghi)r5   listUIDrE   rU   r1   rM   rN   s   &   r   testListUIDPOP3ClientListTests.testListUID   s^    wIIKK0	/0	:;}}T--/GHHr!   c           	        \        4       w  r\        4       pVP                  pVP                  V4      pV P	                  VP                  4       R 4       VP                  R4       VP                  R4       V P	                  VP                  ^ R.^R.^R./4       VP                  R4       VP                  V P                  V4      # )r   r   s   1 xyz
2 abc
5 mno
s   xyzr   s   mnor   )
r5   r   r   r   rE   rU   r1   r   rM   r   r   s   &     r   testListUIDWithConsumer+POP3ClientListTests.testListUIDWithConsumer   s    wNIIIIaLK0	/0	56!fXq6(Ax!HI	x }}T11155r!   c                   a  \        4       w  rVP                  4       pS P                  VP                  4       R 4       VP	                  R4       S P                  V\        4      P                  V 3R l4      # )r   r   c                 J   < SP                  V P                  ^ ,          R4      # r   rD   rG   s   &r   r:   7POP3ClientListTests.testFailedListUID.<locals>.<lambda>  r   r!   )r5   r   rE   rU   r1   rL   r   rM   rN   s   f   r   testFailedListUID%POP3ClientListTests.testFailedListUID   s^    wIIKK0	=>!!!%89EET
 	
r!   r"   N)r#   r$   r%   r&   r   r   r   r   r   r   r'   r(   r)   s   @r   r   r      s)     :6
I
6
 
r!   r   c                   P   a  ] tR tRt o R tR tR tR tR tR t	R t
R	 tR
tV tR# )POP3ClientMessageTestsi
  c                @   \        4       w  rVP                  ^4      pV P                  VP                  4       R4       VP	                  R4       VP	                  R4       VP	                  R4       VP	                  R4       VP                  V P                  RR.4      # )      RETR 8
   +OK Message incoming
   La la la here is message text
s"   ..Further message text tra la la
r      La la la here is message texts   .Further message text tra la lar5   retrieverE   rU   r1   rM   rN   s   &   r   testRetrieve#POP3ClientMessageTests.testRetrieve  s    wJJqMM2	23	;<	>?	x }}-/QR
 	
r!   c                H   \        4       w  r\        4       pVP                  pVP                  ^V4      pV P	                  VP                  4       R4       VP                  R4       VP                  R4       VP                  R4       VP                  V P                  WC4      # )r   r   r   r   s   ..Further message text
.
)	r5   r   r   r   rE   rU   r1   rM   _cbTestRetrieveWithConsumerr   s   &     r   testRetrieveWithConsumer/POP3ClientMessageTests.testRetrieveWithConsumer  s    wIIJJq!M2	23	;<	9:}}T==qDDr!   c                d    V P                  W4       V P                  VP                  R R.4       R# )r   s   .Further message textNr   rE   r   r   r8   r9   r   s   &&&&r   r   2POP3ClientMessageTests._cbTestRetrieveWithConsumer#  s.    V'FF57OP	
r!   c                D   \        4       w  rVP                  ^^R7      pV P                  VP                  4       R4       VP	                  R4       VP	                  R4       VP	                  R4       VP	                  R4       VP                  V P                  RR.4      # )	r   lines	   TOP 8 2
   +OK 2 lines on the way
   Line the first!  Woop
   Line the last!  Bye
r      Line the first!  Woop   Line the last!  Byer   rN   s   &   r   testPartialRetrieve*POP3ClientMessageTests.testPartialRetrieve)  s    wJJqJ"N3	45	34	12	x }}79OP
 	
r!   c                n   \        4       w  r\        4       pVP                  pVP                  ^V^R7      pV P	                  VP                  4       R4       VP                  R4       VP                  R4       VP                  R4       VP                  R4       VP                  V P                  WC4      # )r   r   r   r   r   r   r   )	r5   r   r   r   rE   rU   r1   rM   "_cbTestPartialRetrieveWithConsumerr   s   &     r   testPartialRetrieveWithConsumer6POP3ClientMessageTests.testPartialRetrieveWithConsumer5  s    wIIJJq!1J%N3	45	34	12	x }}TDDaKKr!   c                d    V P                  W4       V P                  VP                  R R.4       R# )r   r   Nr   r   s   &&&&r   r   9POP3ClientMessageTests._cbTestPartialRetrieveWithConsumerA  s+    V'":<R!STr!   c                   a  \        4       w  rVP                  ^ 4      pS P                  VP                  4       R4       VP	                  R4       S P                  V\        4      P                  V 3R l4      # )r   s   RETR 1
r   c                 J   < SP                  V P                  ^ ,          R4      # r   rD   rG   s   &r   r:   ;POP3ClientMessageTests.testFailedRetrieve.<locals>.<lambda>K  r   r!   )r5   r   rE   rU   r1   rL   r   rM   rN   s   f   r   testFailedRetrieve)POP3ClientMessageTests.testFailedRetrieveE  s`    wJJqMM2	=>!!!%89EET
 	
r!   c           
        \        4       w  r\        ^4       Uu. uFN  pVP                  V4      P                  V P                  RV^,           3,          RV^,           3,          .4      NKP  	  pp\        ^^4       F  pV P	                  VP                  4       RV3,          4       VP                  4        VP                  R4       VP                  RV3,          4       VP                  RV3,          4       V P	                  VP                  4       R4       VP                  R4       K  	  \        P                  ! VR	R
7      # u upi )zy
Issue three retrieve calls immediately without waiting for any to
succeed and make sure they all do succeed eventually.
s   First line of %d.s   Second line of %d.s	   RETR %d
r   s   First line of %d.
s   Second line of %d.
r!   r   T)fireOnOneErrback)
r5   ranger   rM   rE   rU   r   r1   r   DeferredList)r   r3   r4   imessagess   &    r   test_concurrentRetrieves/POP3ClientMessageTests.test_concurrentRetrievesN  s   
 w 1X

 	 JJqM%%  %Q02G1q5(2RS  	 
 q!AQWWY!(=>GGINN89NN3qd:;NN4t;<QWWY,NN8$  !!(TBB#
s   AEr"   N)r#   r$   r%   r&   r   r   r   r   r   r   r   r   r'   r(   r)   s   @r   r   r   
  s7     
	E



LU
C Cr!   r   c                   \   a  ] tR tRt o R tR tR tR tR tR t	R t
R	 tR
 tR tRtV tR# )POP3ClientMiscTestsih  c                   \        4       w  rVP                  ^ R7      pV P                  VP                  4       R4       VP	                  R4       VP	                  R4       VP                  V P                  RRRRRRR	. RORR
R.RR
./4      # )r   useCache   CAPA
s   +OK Capabilities on the way
s!   X
Y
Z
A 1 2 3
B 1 2
C 1
.
   XN   Y   Z   A   1   2   B   C)r
  r     3r5   capabilitiesrE   rU   r1   rM   rN   s   &   r   testCapability"POP3ClientMiscTests.testCapabilityi  s    wNNAN&K0	9:	IJ}}ddd(tTltf

 
	
r!   c                    \        4       w  rVP                  ^ R7      pV P                  VP                  4       R4       VP	                  R4       VP                  V P                  / 4      # )r   r  r     -ERR This server is lame!
r  rN   s   &   r   testCapabilityError'POP3ClientMiscTests.testCapabilityError{  sU    wNNAN&K0	78}}T--r22r!   c                    \        4       w  rVP                  4       pV P                  VP                  4       R 4       VP	                  R4       VP                  V P                  R4      # )   STAT
s   +OK 1 1212
)r   i  )r5   statrE   rU   r1   rM   rN   s   &   r   testStatPOP3ClientMiscTests.testStat  sP    wFFHK0	()}}T--y99r!   c                   a  \        4       w  rVP                  4       pS P                  VP                  4       R 4       VP	                  R4       S P                  V\        4      P                  V 3R l4      # )r  r  c                 J   < SP                  V P                  ^ ,          R4      # r   s   This server is lame!rD   rG   s   &r   r:   3POP3ClientMiscTests.testStatError.<locals>.<lambda>      ((!6MNr!   )r5   r  rE   rU   r1   rL   r   rM   rN   s   f   r   testStatError!POP3ClientMiscTests.testStatError  ^    wFFHK0	78!!!%89EEN
 	
r!   c                    \        4       w  rVP                  4       pV P                  VP                  4       R 4       VP	                  R4       VP                  V P                  R4      # )   NOOP
s   +OK No-op to you too!
s   No-op to you too!)r5   nooprE   rU   r1   rM   rN   s   &   r   testNoopPOP3ClientMiscTests.testNoop  sQ    wFFHK0	34}}T--/CDDr!   c                   a  \        4       w  rVP                  4       pS P                  VP                  4       R 4       VP	                  R4       S P                  V\        4      P                  V 3R l4      # )r%  r  c                 J   < SP                  V P                  ^ ,          R4      # r  rD   rG   s   &r   r:   3POP3ClientMiscTests.testNoopError.<locals>.<lambda>  r   r!   )r5   r&  rE   rU   r1   rL   r   rM   rN   s   f   r   testNoopError!POP3ClientMiscTests.testNoopError  r#  r!   c                    \        4       w  rVP                  4       pV P                  VP                  4       R 4       VP	                  R4       VP                  V P                  R4      # )   RSET
s   +OK Reset state
s   Reset state)r5   resetrE   rU   r1   rM   rN   s   &   r   testRsetPOP3ClientMiscTests.testRset  sP    wGGIK0	-.}}T--~>>r!   c                   a  \        4       w  rVP                  4       pS P                  VP                  4       R 4       VP	                  R4       S P                  V\        4      P                  V 3R l4      # )r/  r  c                 J   < SP                  V P                  ^ ,          R4      # r  rD   rG   s   &r   r:   3POP3ClientMiscTests.testRsetError.<locals>.<lambda>  r   r!   )r5   r0  rE   rU   r1   rL   r   rM   rN   s   f   r   testRsetError!POP3ClientMiscTests.testRsetError  s^    wGGIK0	78!!!%89EEN
 	
r!   c                    \        4       w  rVP                  ^4      pV P                  VP                  4       R4       VP	                  R4       VP                  V P                  R4      # )r      DELE 4
s   +OK Hasta la vista
s   Hasta la vista)r5   deleterE   rU   r1   rM   rN   s   &   r   
testDeletePOP3ClientMiscTests.testDelete  sS    wHHQKM2	01}}T--/@AAr!   c                   a  \        4       w  rVP                  ^4      pS P                  VP                  4       R4       VP	                  R4       S P                  V\        4      P                  V 3R l4      # )r   r9  s   -ERR Winner is not you.
c                 J   < SP                  V P                  ^ ,          R4      # )r   s   Winner is not you.rD   rG   s   &r   r:   5POP3ClientMiscTests.testDeleteError.<locals>.<lambda>  s    ((!6KLr!   )r5   r:  rE   rU   r1   rL   r   rM   rN   s   f   r   testDeleteError#POP3ClientMiscTests.testDeleteError  s`    wHHQKM2	56!!!%89EEL
 	
r!   r"   N)r#   r$   r%   r&   r  r  r  r!  r'  r,  r1  r6  r;  r@  r'   r(   r)   s   @r   r  r  h  s>     
$3:
E
?
B
 
r!   r  c                   0   a  ] tR tRt o RR ltR tRtV tR# )SimpleClienti  Nc                     Wn         R V n        R# )TN)deferredrJ   )r   rE  contextFactorys   &&&r   r   SimpleClient.__init__  s     "&r!   c                <    V P                   P                  R 4       R # r   )rE  callback)r   	challenges   &&r   serverGreetingSimpleClient.serverGreeting  s    t$r!   )rJ   rE  r   )r#   r$   r%   r&   r   rK  r'   r(   r)   s   @r   rC  rC    s     '% %r!   rC  c                   F   a  ] tR tRt o RtRtR tR tR tR t	R t
RtV tR# )	POP3HelperMixini  Nc                    \         P                  ! 4       p\        P                  ! V P                  R 7      V n        \        WP                  R 7      V n        ^V P                  n	        Wn
        R# ))rF  N)r   Deferredr   POP3TestServer	serverCTXserverrC  	clientCTXclienttimeout	connected)r   rO   s   & r   r5   POP3HelperMixin.setUp  sE    NN$334>>R"1^^D r!   c                    V = V =V =R # r   )rS  rU  rW  r   s   &r   tearDownPOP3HelperMixin.tearDown  s    KKNr!   c                N    V P                   P                  P                  4        R # r   )rU  	transportr   )r   ignores   &&r   _cbStopClientPOP3HelperMixin._cbStopClient  s    ,,.r!   c                    V P                   P                  P                  4        V P                  P                  P                  4        V# r   )rU  r]  r   rS  )r   failures   &&r   
_ebGeneralPOP3HelperMixin._ebGeneral  s3    ,,.,,.r!   c                \    \         P                  ! V P                  V P                  R R7      # )F)noisy)r   loopbackTCPrS  rU  r   s   &r   r   POP3HelperMixin.loopback  s    ##DKKEJJr!   )rU  rW  rS  )r#   r$   r%   r&   rR  rT  r5   rZ  r_  rc  r   r'   r(   r)   s   @r   rN  rN    s/     II
/
K Kr!   rN  c                   @    ] tR tRt ! R R]P
                  4      tRtR# )TLSServerFactoryi  c                   @   a  ] tR tRt o Rt. tR tR tV 3R ltRt	V t
R# )TLSServerFactory.protocoli  Nc                    . V P                   n        V P                  R ,          V n        V P                  P                  ^ 4       F  pV P	                  V4       K  	  R# ):NNNN)factoryinputoutputpopsendLiner   s   & r   connectionMade(TLSServerFactory.protocol.connectionMade  s@    !#DLL++a.DK*d# +r!   c                &   V P                   P                  P                  V4       V P                  P	                  ^ 4       Uu. uF  q P                  V4      NK  	   pVR8X  d(   V P                  P                  V P                  4       R# R# u upi )r   r+   N)	rn  ro  r   rp  rq  rr  r]  startTLScontext)r   r   ls   && r   lineReceived&TLSServerFactory.protocol.lineReceived  si    LL%%d+'+{{q'9:'9!]]1'9:w''5  ;s   Bc                6   < V ^8  d   Qh/ S[ S[,          ;R&   # )r   rp  )r   bytes)formatr*   s   "r   __annotate__&TLSServerFactory.protocol.__annotate__  s     U  r!   )rp  )r#   r$   r%   r&   rw  rp  rs  ry  __annotate_func__r'   r(   r)   s   @r   r	   rl    s       	$	6  r!   r	   r"   N)r#   r$   r%   r&   r   LineReceiverr	   r'   r"   r!   r   rj  rj    s    65%% 6 6r!   rj  zOpenSSL not presentc                   *   a  ] tR tRt o RtR tRtV tR# )POP3TLSTestsi  z5
Tests for POP3Client's support for TLS connections.
c                  a a
aaa \        4       oR.. ROR.RR.R..SP                  n        \        4       SP                  n        \
        P                  ! ^ SRR7      pS P                  VP                  4       VP                  4       P                  pVP                  4       P                  p\        P                  ! 4       o\        \        P                  ! 4       \        4       4      oVV3R lpVSn        \        P"                  ! 4       pV3R lVn        \
        P$                  ! W#V4      o
V3R lpV3R lpV V3R	 lpV
V3R
 lp	SP&                  P)                  V4       SP&                  P)                  V4       SP&                  P)                  V4       SP&                  P+                  V	4       SP&                  # )zL
POP3Client.startTLS starts a TLS session over its existing TCP
connection.
   +OK   .z	127.0.0.1)	interfacec                 V   < \         P                  SV 4       SP                  R 4       R # r   )rC  r   rI  )reasonconnLostDeferredcps   &r   r   2POP3TLSTests.test_startTLS.<locals>.connectionLost  s!    ''F3%%d+r!   c                     < S # r   r"   )r  s   r   r:   ,POP3TLSTests.test_startTLS.<locals>.<lambda>  s    br!   c                 P   < \         P                  ! R 4       SP                  4       # )z!Connected to server; starting TLS)r   msgrv  ignoredr  s   &r   cbConnected/POP3TLSTests.test_startTLS.<locals>.cbConnected!  s    GG78;;= r!   c                 P   < \         P                  ! R 4       SP                  4       # )zStarted TLS; disconnecting)r   r  quitr  s   &r   cbStartedTLS0POP3TLSTests.test_startTLS.<locals>.cbStartedTLS%  s    GG01779r!   c                 p   < \         P                  ! R 4       SP                  SP                  . RO4       R# )z.Disconnected; asserting correct input receivedN)   CAPAr+   r  s   QUIT)r   r  rE   ro  )ignr   sfs   &r   cbDisconnected2POP3TLSTests.test_startTLS.<locals>.cbDisconnected)  s%    GGDERXX'KLr!   c                 T   < \         P                  ! R 4       SP                  4        S# )zEAsserted correct input; disconnecting client and shutting down server)r   r  
disconnect)r8   connr  s   &r   cleanup+POP3TLSTests.test_startTLS.<locals>.cleanup-  s&    GG2 OO##r!   )r  r+   r  )rj  r	   rp  r   rw  r
   	listenTCP
addCleanupstopListeninggetHosthostportr   rP  rC  r   r   ClientFactory
connectTCPrE  rM   addBoth)r   r  HPr   cfr  r  r  r  r  r  r  r  s   f         @@@@r   test_startTLSPOP3TLSTests.test_startTLS  sP   
 H#HTNH
 /0  B+>**+LLNLLN >>+%..*,<,>?	, +##% !!!+	!		M	$ 	,
-
/
G${{r!   r"   N)r#   r$   r%   r&   __doc__r  r'   r(   r)   s   @r   r  r    s     9 9r!   r  c                   &   a  ] tR tRt o R tRtV tR# )POP3TimeoutTestsi=  c                  a aa VV V3R  lpV 3R loV 3R loV 3R lpRS P                   n        R\        n        W.p\	        S P
                  P                  \	        \        V4      4       S P
                  P                  S P                  4       S P
                  P                  S P                  4       S P                  4       # )c                     < SP                   P                  R R4      p V P                  S4       V P                  S4       V # )testtwisted)rU  rK   rM   
addErrback)rO   loggedInr   timedOuts    r   rK   +POP3TimeoutTests.testTimeout.<locals>.login?  s6    !!&)4AMM(#LL"Hr!   c                 *   < SP                  R 4       R# )z%Successfully logged in!?  Impossible!N)fail)r8   r   s   &r   r  .POP3TimeoutTests.testTimeout.<locals>.loggedInE  s    II=>r!   c                 h   < V P                  \        P                  4       SP                  R 4       R # r   )trapr   TimeoutErrorr_  )rb  r   s   &r   r  .POP3TimeoutTests.testTimeout.<locals>.timedOutH  s#    LL++,t$r!   c                  8   < S P                   P                  4       # r   )rU  r  r   s   r   r  *POP3TimeoutTests.testTimeout.<locals>.quitL  s    ;;##%%r!   g{Gz?T)rU  rV  r   TIMEOUT_RESPONSEmaprW  rM   r<   r_  r  rc  r   )r   rK   r  methodsr  r  s   f   @@r   testTimeoutPOP3TimeoutTests.testTimeout>  s    		?	%	& # +/'-DNN&&E7(;<""4#5#56!!$//2}}r!   r"   N)r#   r$   r%   r&   r  r'   r(   r)   s   @r   r  r  =  s      r!   r  c                   0   a  ] tR tRt o RtR tR tRtV tR# )POP3ClientModuleStructureTestsi\  zh
Miscellaneous tests more to do with module/package structure than
anything to do with the POP3 client.
c                n    V P                  \        P                  P                  P                  . 4       R# )zt
twisted.mail._pop3client.__all__ should be empty because all classes
should be imported through twisted.mail.pop3.
N)rE   r  mail_pop3client__all__r   s   &r   test_all'POP3ClientModuleStructureTests.test_allb  s$    
 	11992>r!   c                
   \         P                  ! \        P                  R,          \         P                  4       Uu. uF#  pV^ ,          ^ ,          R8X  d   K  V^ ,          NK%  	  ppV F  pVR8X  gT   V P                  \        \        P                  P                  V4      V R\        P                  P                   24       K]  V P                  \        \        P                  P                  R4      4       K  	  R# u upi )z
Every public class in twisted.mail._pop3client should be available as
a member of twisted.mail.pop3 with the exception of
twisted.mail._pop3client.POP3Client which should be available as
twisted.mail.pop3.AdvancedClient.
ztwisted.mail._pop3client_r-   z not in r   N)
inspect
getmemberssysmodulesisclass
assertTruehasattrr  r  pop3)r   r   publicClassespcs   &   r   test_import*POP3ClientModuleStructureTests.test_importi  s     ''67
 Q47c>	 AaDD 	 
  B%GLL--r2d(7<<#4#4"56
 (9(9;O PQ  
s   D D r"   N)	r#   r$   r%   r&   r  r  r  r'   r(   r)   s   @r   r  r  \  s     
?R Rr!   r  )T)6r  r  typingr   unittestr   zope.interfacer   twisted.mail._pop3clientr  twisted.internetr   r   r   r	   r
   twisted.internet.testingr   twisted.mail.pop3r   r-   r   r   twisted.mail.testr   twisted.protocolsr   r   twisted.pythonr   twisted.trial.unittestr   twisted.test.ssl_helpersr   r   ImportErrorr   r.   r5   r<   r>   r   r   r   r   r  rC  rN  ServerFactoryrj  IReactorSSLr  r  r  r"   r!   r   <module>r     s|  
  
   +  H H 4 
 - -  +K=/ = DFTTTX"#t8 tn5 5 ;
( ;
|[CX [C|X
( X
v%: %K K86x-- 6$ 34J""7D113HI>8 > J 5>B >#RX #RC  s   E EE