+
    Dfj                     *  a  Rb tj0 t R t^ RIt^ RIt^ RIt^ RIHt ^ RIHtH	t	H
t
HtHt ^ RIHtHt ^ RIt^ RIt^ RIt^ RI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
IHtHtHtH t H!t!H"t"H#t# ^ RI$H%t%H&t& ^ RI'H(t( ^ RI)H*t* ^ RI+H,t,H-t- ^ RI.H/t/ ^ RI0H1t1 ] ^ k  ^ RI2H3t3H4t4 Rt5] Pn                  Pq                  ]"4      '       g   Rt5R t9]! ](Pt                  4       ! R R4      4       t; ! R R4      t< ! R R4      t=Rt> ! R R4      t? ! R R]?](P                  4      tA ! R  R!]?](P                  4      tC ! R" R#4      tD ! R$ R%],P                  4      tF ! R& R']1]D4      tG ! R( R)4      tH ! R* R+4      tI ! R, R-]I](P                  4      tK ! R. R/]I](P                  4      tM ! R0 R14      tN ! R2 R3]N]14      tO ! R4 R5]N]14      tP]! ]P                  P.                  4       ! R6 R74      4       tR]! ](P                  4       ! R8 R94      4       tT ! R: R;4      tU ! R< R=]1]D4      tV ! R> R?]14      tW ! R@ RA]C4      tX ! RB RC]1]D4      tY ! RD RE]14      tZ ! RF RG]1]D4      t[ ! RH RI]!P                  4      t] ! RJ RK]14      t^ ! RL RM]14      t_]! ]4       ! RN RO4      4       t` ! RP RQ4      ta ! RR RS]14      tb ! RT RU]14      tc ! RV RW]14      td ! RX RY]14      te ! RZ R[]14      tf ! R\ R]]14      tg ! R^ R_]&4      th ! R` Ra]14      tiR#   ]6 d    Rt5 ELei ; i)cz*
Test cases for twisted.mail.smtp module.
N)BytesIO)AnyListOptionalTupleType)directlyProvidesimplementer)cred)AllowAnonymousAccessICredentialsChecker)
IAnonymous)UnauthorizedLogin)IRealmPortal)addressdefererror
interfacesprotocolreactortask)MemoryReactorStringTransport)smtp)LOGINCredentials)basicloopback)LineLog)TestCase)ClientTLSContextServerTLSContextzOpenSSL not presentzReactor doesn't support SSLc                      R # N )spameggss   *,=/usr/lib/python3/dist-packages/twisted/mail/test/test_smtp.py	spameaterr(   /   s        c                   <   a  ] tR t^3t o RtR tR tR tR tRt	V t
R# )BrokenMessagez
L{BrokenMessage} is an L{IMessage} which raises an unexpected exception
from its C{eomReceived} method.  This is useful for creating a server which
can be used to test client retry behavior.
c                    R # r#   r$   selfusers   &&r'   __init__BrokenMessage.__init__;       r)   c                    R # r#   r$   r.   lines   &&r'   lineReceivedBrokenMessage.lineReceived>   r2   r)   c                    \        R 4      h)z"Some problem, delivery is failing.)RuntimeErrorr.   s   &r'   eomReceivedBrokenMessage.eomReceivedA   s    ?@@r)   c                    R # r#   r$   r:   s   &r'   connectionLostBrokenMessage.connectionLostD   r2   r)   r$   N)__name__
__module____qualname____firstlineno____doc__r0   r6   r;   r>   __static_attributes____classdictcell____classdict__s   @r'   r+   r+   3   s$     A r)   r+   c                   6   a  ] tR t^Ht o RtR tR tR tRtV t	R# )DummyMessagez
L{BrokenMessage} is an L{IMessage} which saves the message delivered to it
to its domain object.

@ivar domain: A L{DummyDomain} which will be used to store the message once
    it is received.
c                ,    Wn         W n        . V n        R # r#   )domainr/   buffer)r.   rL   r/   s   &&&r'   r0   DummyMessage.__init__Q   s    	r)   c                z    \         P                  ! R V4      '       g   V P                  P                  V4       R# R# )s/   Received: From yyy.com \(\[.*\]\) by localhost;N)rematchrM   appendr4   s   &&r'   r6   DummyMessage.lineReceivedV   s,    xxKTRRKKt$ Sr)   c                *   R P                  V P                  4      R ,           pV P                  P                  V P                  P
                  P                  ,          P                  V4       \        P                  ! 4       pVP                  R4       V#    
s   saved)joinrM   rL   messagesr/   destlocalrR   r   Deferredcallback)r.   messagedeferreds   &  r'   r;   DummyMessage.eomReceived[   sc    **T[[)E1TYY^^11299'B>>#(#r)   )rM   rL   r/   N)
r@   rA   rB   rC   rD   r0   r6   r;   rE   rF   rG   s   @r'   rJ   rJ   H   s     
%
 r)   rJ   c                   0   a  ] tR t^ct o RtR tR tRtV tR# )DummyDomainzZ
L{DummyDomain} is an L{IDomain} which keeps track of messages delivered to
it in memory.
c                D    / V n         V F  p. V P                   V&   K  	  R # r#   rX   )r.   namesnames   && r'   r0   DummyDomain.__init__i   s!    D"$DMM$ r)   c                   a a SP                   P                  S P                  9   d   \        P                  ! V V3R  l4      # \        P
                  ! \        P                  ! S4      4      # )c                     < \        S S4      # r#   rJ   r-   s   r'   <lambda>$DummyDomain.exists.<locals>.<lambda>p   s    dD)Ar)   )rY   rZ   rX   r   succeedfailr   SMTPBadRcptr-   s   ffr'   existsDummyDomain.existsn   sA    99??dmm+==!ABBzz$**4011r)   rc   N)	r@   rA   rB   rC   rD   r0   ro   rE   rF   rG   s   @r'   ra   ra   c   s     
%
2 2r)   ra   s   Subject: hello

Goodbye
c                   H   a  ] tR t^{t o R	R ltR tR tR tR tR t	Rt
V tR# )
MyClientNc                    Vf   RR.\        \        4      3pV^ ,          V n        V^,          V n        V^,          V n        R # )Nzmoshez@foo.bar)r   mail_sender
_recipient_datar.   messageInfos   &&r'   r0   MyClient.__init__|   s=    +.>-?OK"1~%a. ^
r)   c                    V P                   # r#   )ru   r:   s   &r'   getMailFromMyClient.getMailFrom   s    ||r)   c                    V P                   # r#   )rv   r:   s   &r'   	getMailToMyClient.getMailTo   s    r)   c                    V P                   # r#   )rw   r:   s   &r'   getMailDataMyClient.getMailData   s    zzr)   c                    Wn         R # r#   )_error)r.   excs   &&r'   	sendErrorMyClient.sendError   s    r)   c                0    R V n         R V n        R V n        R # r#   )ru   rv   rw   )r.   coderespnumOk	addresseslogs   &&&&&&r'   sentMailMyClient.sentMail   s    
r)   )rw   r   rv   ru   r#   )r@   rA   rB   rC   r0   r|   r   r   r   r   rE   rF   rG   s   @r'   rr   rr   {   s(     $ r)   rr   c                   *   a  ] tR t^t o RR ltRtV tR# )MySMTPClientNc                p    \         P                  P                  V R 4       \        P                  W4       R# s   foo.bazN)r   
SMTPClientr0   rr   rx   s   &&r'   r0   MySMTPClient.__init__   s$      z2$,r)   r$   r#   r@   rA   rB   rC   r0   rE   rF   rG   s   @r'   r   r      s     - -r)   r   c                   *   a  ] tR t^t o RR ltRtV tR# )MyESMTPClientNc                r    \         P                  P                  WVR 4       \        P                  V 4       R# r   )r   ESMTPClientr0   rr   )r.   secretcontextFactorys   &&&r'   r0   MyESMTPClient.__init__   s(    !!$
K$r)   r$   )r)   Nr   rG   s   @r'   r   r      s        r)   r   c                   &   a  ] tR t^t o R tRtV tR# )LoopbackMixinc                .    \         P                  ! W4      # r#   )r   loopbackTCP)r.   serverclients   &&&r'   r   LoopbackMixin.loopback   s    ##F33r)   r$   N)r@   rA   rB   rC   r   rE   rF   rG   s   @r'   r   r      s     4 4r)   r   c                   4   a  ] tR t^t o . ROtR tR tRtV tR# )FakeSMTPServerc                    . V n         V P                  R ,          V n        V P                  P                  4        V P                  V P                  P	                  4       4       R# )NNNN)rM   
clientDatareversesendLinepopr:   s   &r'   connectionMadeFakeSMTPServer.connectionMade   sB    //!,!doo))+,r)   c                   V P                   P                  V4       VR 8X  d7   V P                  P                  R4       V P                  P	                  4        MDVR8X  d   V P                  P                  R4       M!VR8X  d   V P                  P	                  4        V P
                  '       d,   V P                  V P
                  P                  4       4       R# R# )s   QUITs   221 see ya around
   .s   250 gotcha
   RSETN)rM   rR   	transportwriteloseConnectionr   r   r   r4   s   &&r'   r6   FakeSMTPServer.lineReceived   s    4 7?NN  !9:NN))+T\NN  !23W_NN))+???MM$//--/0 r)   )rM   r   N)	   220 hellos   250 nice to meet you	   250 greatr   s   354 go on, lad)	r@   rA   rB   rC   r   r   r6   rE   rF   rG   s   @r'   r   r      s     J-1 1r)   r   c                   P   a  ] tR t^t o RtR t. R
OtR tR tR t	R t
R tRtV tR	# )SMTPClientTestsz
Tests for L{smtp.SMTPClient}.
c                   . p\        4       pVP                  Vn        VP                  \	        4       4       VP                  R4       VP                  4        V P                  V^ ,          \        P                  4       V P                  V^ ,          P                  4       V P                  \        V^ ,          4      R4       R# )z~
L{smtp.SMTPClient.timeoutConnection} calls the C{sendError} hook with a
fatal L{SMTPTimeoutError} with the current line log.
r   sH   Timeout waiting for SMTP server response
<<< 220 hello
>>> HELO foo.baz
N)r   rR   r   makeConnectionr   r6   timeoutConnectionassertIsInstancer   SMTPTimeoutError
assertTrueisFatalassertEqualbytes)r.   errorsr   s   &  r'   test_timeoutConnection&SMTPClientTests.test_timeoutConnection   s    
 !==o/0L)  "fQi)>)>?q	))*&)"	
r)   c                   a a \        4       p\        4       oS P                  SV4      pVP                  V V3R l4       V# )z
L{smtp.SMTPClient} sends I{HELO}, I{MAIL FROM}, I{RCPT TO}, and I{DATA}
commands based on the return values of its C{getMailFrom},
C{getMailTo}, and C{getMailData} methods.
c                 P   < SP                  SP                  SP                  4      # r#   )r   rM   expected_outputxr.   r   s   &r'   rj   /SMTPClientTests.test_messages.<locals>.<lambda>   s     0 0@T@T Ur)   )r   r   r   addCallback)r.   r   dr   s   f  @r'   test_messagesSMTPClientTests.test_messages   s6     !MM&&)	UVr)   c                p   \        RR.\        R4      34      p\        4       pVP                  V4       VP	                  R4       V P                  VP                  R4       V P                  VP                  4       VP                  P                  4        V P                  VP                  \        4       R# )zp
If there is an error while producing the message body to the
connection, the C{sendError} callback is invoked.
zalice@example.comzbob@example.com   foo(   220 Ok
250 Ok
250 Ok
250 Ok
354 Ok
N)r   r   r   r   dataReceivedassertNotIdenticalproducerassertFalse	streamingstopProducingr   r   	Exceptionr.   r   r   s   &  r'   test_transferError"SMTPClientTests.test_transferError   s    
  #4"5wvG
 $%	i(	
 		 2 2D9,,- 	((* 	fmmY7r)   c                .   \         P                  ! R4      p\        4       pVP                  V4       VP	                  \         P
                  ! ^{RRR7      4       V P                  VP                  4       R4       V P                  VP                  4       R# )z
If L{smtp.SMTPClient.sendError} is called with an L{SMTPClientError}
which is fatal, it disconnects its transport without writing anything
more to it.
NfooTr   r)   )
r   r   r   r   r   SMTPClientErrorr   valuer   disconnectingr   s   &  r'   test_sendFatalError#SMTPClientTests.test_sendFatalError  sn     &#%	i(--c5$GH*C0	//0r)   c                .   \         P                  ! R4      p\        4       pVP                  V4       VP	                  \         P
                  ! ^{RRR7      4       V P                  VP                  4       R4       V P                  VP                  4       R# )z
If L{smtp.SMTPClient.sendError} is called with an L{SMTPClientError}
which is not fatal, it sends C{"QUIT"} and waits for the server to
close the connection.
Nr   Fr      QUIT
)
r   r   r   r   r   r   r   r   r   r   r   s   &  r'   test_sendNonFatalError&SMTPClientTests.test_sendNonFatalError  sp     &#%	i(--c5%HI*K8001r)   c                   \         P                  ! R4      p\        4       pVP                  V4       VP	                  \        R4      4       V P                  VP                  4       R4       V P                  VP                  4       R# )z
If L{smtp.SMTPClient.sendError} is called with an exception which is
not an L{SMTPClientError}, it disconnects its transport without
writing anything more to it.
Nr   r)   )
r   r   r   r   r   r   r   r   r   r   r   s   &  r'   test_sendOtherError#SMTPClientTests.test_sendOtherError+  sd     &#%	i(5)**C0	//0r)   r$   N)	s   HELO foo.bazs   MAIL FROM:<moshez@foo.bar>s   RCPT TO:<moshez@foo.bar>s   DATAs   Subject: hellor)   s   Goodbyer   r   )r@   rA   rB   rC   rD   r   r   r   r   r   r   r   rE   rF   rG   s   @r'   r   r      s4     
(
O
88121 1r)   r   c                   2   a  ] tR tRt o R tR tR tRtV tR# )DummySMTPMessagei9  c                ,    Wn         W n        . V n        R # r#   )r   usersrM   )r.   r   r   s   &&&r'   r0   DummySMTPMessage.__init__:  s     
r)   c                <    V P                   P                  V4       R # r#   )rM   rR   r4   s   &&r'   r6   DummySMTPMessage.lineReceived?  s    4 r)   c                   R P                  V P                  4      R ,           pV P                  ^ ,          P                  ^ ,          \	        V P                  ^ ,          P
                  4      r2. pV P                   F  pVP                  \	        V4      4       K  	  W#WA3V P                  P                  \        V4      &   \        P                  ! R4      # rU   )rW   rM   r   helor   origrR   r   r]   tupler   rl   )r.   r]   r   origin
recipientsr/   s   &     r'   r;   DummySMTPMessage.eomReceivedB  s    **T[[)E1zz!}))!,eDJJqM4F4F.Gf
JJDeDk* 48*3VeJ/0}}X&&r)   )rM   r   r   N)	r@   rA   rB   rC   r0   r6   r;   rE   rF   rG   s   @r'   r   r   9  s     
!' 'r)   r   c                   8   a  ] tR tRt o R tR tR tR tRtV t	R# )
DummyProtoiL  c                J    V P                   P                  V 4       / V n        R # r#   )dummyMixinBaser   r]   r:   s   &r'   r   DummyProto.connectionMadeM  s    **40r)   c                     R # r#   r$   )r%   s   *r'   receivedHeaderDummyProto.receivedHeaderQ      r)   c                4   a a \        R 4      S n        V V3R l# )Nc                     < \        S S.4      # r#   )r   r-   s   r'   rj   'DummyProto.validateTo.<locals>.<lambda>V  s    'tf5r)   )SimpleDeliverydeliveryr-   s   ffr'   
validateToDummyProto.validateToT  s    &t,55r)   c                    V# r#   r$   r.   r   r   s   &&&r'   validateFromDummyProto.validateFromX      r)   )r  r]   N)
r@   rA   rB   rC   r   r  r	  r  rE   rF   rG   s   @r'   r   r   L  s     6 r)   r   c                   .    ] tR tRt]P
                  tRtR# )	DummySMTPi\  r$   N)r@   rA   rB   rC   r   SMTPr   rE   r$   r)   r'   r  r  \  s    YYNr)   r  c                   .    ] tR tRt]P
                  tRtR# )
DummyESMTPi`  r$   N)r@   rA   rB   rC   r   ESMTPr   rE   r$   r)   r'   r  r  `  s    ZZNr)   r  c                   t  a  ] tR tRt o RtRtRRR.RR.R3RRRR	.RRR	.R
3RRR.RR.R3.t. ROt] Ft  w  tt	t
ttt]P                  R]	,           R,           RRR34       ]
 F&  t]P                  R],           R,           RRR34       K(  	  ]P                  RR]R]]]]3334       Kv  	  R tV 3R ltRtV tR# )AnotherTestCaseid  N   foo.coms   moshez@foo.coms   moshez@bar.coms(   From: Moshe
To: Moshe

Hi,
how are you?
s   tttt@rrr.coms   uuu@ooos   yyy@eees   Subject: pass

..rrrr..
s   @this,@is,@ignored:foo@bar.coms   @ignore,@this,@too:bar@foo.coms   foo@bar.coms   bar@foo.coms    Subject: apa
To: foo

123
.
456
s   MAIL FROM:<s   >
s   250.*
s	   RCPT TO:<s   DATA
s   354.*
c                   \        4       pV P                  4       p ! R R4      pV! 4       Vn        VP                  V4       V P                   EFw  w  rErgV'       d   VP                  V4       VP                  4       pVP                  4        \        P                  ! WX4      '       g   \        WEV4      hVR,          R8X  g   Kx  VP                  4        F:  p	V	'       d   V	R,          R8X  d
   RV	,           p	VP                  V	R,           4       K<  	  VP                  R4       VP                  4       pVP                  4        Vw  r\        P                  ! W4      '       g   \        W4      hV^,           FH  p\        VR	,          4      pV.V^&   V P                  VP                  V3,          \        V4      4       KJ  	  EKz  	  VP!                  R
4       R
# )z
Exercise a lot of the SMTP client code.  This is a "shotgun" style unit
test.  It does a lot of things and hopes that something will go really
wrong if it is going to go wrong.  This test should be replaced with a
suite of nicer tests.
c                       ] tR tRtRtRtR# )/AnotherTestCase.test_buffer.<locals>.fooFactoryi  r  r$   N)r@   rA   rB   rC   rL   rE   r$   r)   r'   
fooFactoryr    s    Fr)   r  :N   Ns   354:       Nr      
s   .
r   N)r   serverClassfactoryr   datar   r   clearrP   rQ   AssertionError
splitlineslistr   r]   r   
setTimeout)r.   r   ar  sendexpectmsg	msgexpectr#  r5   r   msgdatarecipexpecteds   &             r'   test_bufferAnotherTestCase.test_buffer  sr    $%		  	  L		#,0II(D#t$??$DOO88F))$T488Bx6!NN,DS	T 1#d{NN4'>2 - x( !(! )xx++(44$QZZE#GAJ/H#('HQK$$QYYx%8%/J () -60 	
Tr)   c                   < V ^8  d   Qh/ S[ S[S[P                  ,          ,          ;R&   S[ S[S[P
                  ,          ,          ;R&   S[S[S[S[S[	S[	3,          ,          ;R&   # )   r!  clientClassr#  )
r   r   r   Protocolr   r   r   r   r   r   )formatrH   s   "r'   __annotate__AnotherTestCase.__annotate__d  s]     $x00129 $t/07 ` uUE3+,
- a r)   r$   ))r)   s   220.*
$NN)s   HELO foo.com
   250.*
$NN)s   RSET
r:  NN)r@   rA   rB   rC   r!  r5  rX   r#  helo_from_to_realfromrealtor,  rR   rcptr1  __annotate_func__rE   rF   rG   s   @r'   r  r  d  s     59K37K 	
 $$	
 -./	
7*HX1D
 5=0uc8VS^e+h6dDQRDKK,x7tTRS  	x=>		
 5='G  r)   r  c                       ] tR tRt]t]tRtR# )AnotherESMTPTestsi  r$   N)	r@   rA   rB   rC   r  r!  r   r5  rE   r$   r)   r'   rC  rC    s    KKr)   rC  c                       ] tR tRt]t]tRtR# )AnotherSMTPTestsi  r$   N)	r@   rA   rB   rC   r  r!  r   r5  rE   r$   r)   r'   rE  rE    s    KKr)   rE  c                      a  ] tR tRt o RR/t]P                  P                  ]P                  P                  3t	R t
R tRtV tR# )DummyCheckeri     testuser   testpasswordc                    \         P                  ! VP                  V P                  VP                  ,          4      P                  V P                  VP                  4      # r#   )r   maybeDeferredcheckPasswordr   usernamer   _cbCheckr.   credentialss   &&r'   requestAvatarIdDummyChecker.requestAvatarId  sE    ""%%tzz+2F2F'G

+dmm[%9%9
:	;r)   c                R    V'       d   V# \         P                  P                  4       hr#   )r
   r   r   )r.   resultrM  s   &&&r'   rN  DummyChecker._cbCheck  s    Ojj**,,r)   r$   N)r@   rA   rB   rC   r   r
   rP  IUsernamePasswordIUsernameHashedPasswordcredentialInterfacesrQ  rN  rE   rF   rG   s   @r'   rG  rG    sF     /*E 	**00
;
- -r)   rG  c                   <   a  ] tR tRt o RtR tR tR tR tRt	V t
R# )	r  i  zO
L{SimpleDelivery} is a message delivery factory with no interesting
behavior.
c                    Wn         R # r#   _messageFactory)r.   messageFactorys   &&r'   r0   SimpleDelivery.__init__  s    -r)   c                    R # r#   r$   r.   r   r   r   s   &&&&r'   r  SimpleDelivery.receivedHeader  r  r)   c                    V# r#   r$   r  s   &&&r'   r  SimpleDelivery.validateFrom  r  r)   c                   a a V V3R  l# )c                  &   < S P                  S4      # r#   r[  r-   s   r'   rj   +SimpleDelivery.validateTo.<locals>.<lambda>   s    t++D1r)   r$   r-   s   ffr'   r	  SimpleDelivery.validateTo  s	    11r)   r[  N)r@   rA   rB   rC   rD   r0   r  r  r	  rE   rF   rG   s   @r'   r  r    s#     
.2 2r)   r  c                   &   a  ] tR tRt o R tRtV tR# )
DummyRealmi  c                <    \         P                  \        R 4      R 3# )Nc                      R # r#   r$   r$   r)   r'   rj   *DummyRealm.requestAvatar.<locals>.<lambda>  s    Dr)   )r   IMessageDeliveryr  )r.   avatarIdmindr   s   &&&*r'   requestAvatarDummyRealm.requestAvatar  s    $$nT&:LHHr)   r$   N)r@   rA   rB   rC   rp  rE   rF   rG   s   @r'   ri  ri    s     I Ir)   ri  c                   2   a  ] tR tRt o R tR tR tRtV tR# )	AuthTestsi  c                  a a \        4       p\        P                  P                  V4      pVP	                  \        4       4       \        R\        P                  P                  /4      oVSn        \        R4      p\        P                  ! R4      pVP                  V4       S P                  SV4      pVP                  V V3R l4       V# )zt
L{ESMTPClient} can authenticate using the I{CRAM-MD5} SASL mechanism.

@see: U{http://tools.ietf.org/html/rfc2195}
s   CRAM-MD5rI  rH  c                 <   < SP                  SP                  ^4      # )r  )r   authenticatedr   s   &r'   rj   ,AuthTests.test_crammd5Auth.<locals>.<lambda>  s     0 01E1Eq Ir)   )ri  r
   portalr   registerCheckerrG  r  rP  CramMD5Credentialsr   r   CramMD5ClientAuthenticatorregisterAuthenticatorr   r   r.   realmpr   cAuthr   r   s   f     @r'   test_crammd5AuthAuthTests.test_crammd5Auth	  s     KKu%	,.)[$*:*:*M*MNO///<$$U+MM&&)	IJr)   c                r  a a \        4       p\        P                  P                  V4      pVP	                  \        4       4       \        R\        /4      oVSn        \        R4      p\        P                  ! R4      pVP                  V4       S P                  SV4      pVP                  V V3R l4       V# )z
L{ESMTPClient} can authenticate using the I{LOGIN} SASL mechanism.

@see: U{http://sepp.oetiker.ch/sasl-2.1.19-ds/draft-murchison-sasl-login-00.txt}
   LOGINrI  rH  c                 :   < SP                  SP                  4      # r#   r   rv  r   s   &r'   rj   *AuthTests.test_loginAuth.<locals>.<lambda>0      0D0D Er)   )ri  r
   rx  r   ry  rG  r  r   r   r   LOGINAuthenticatorr|  r   r   r}  s   f     @r'   test_loginAuthAuthTests.test_loginAuth  s     KKu%	,.)X'789/''4$$U+MM&&)	EFr)   c                  a a \        4       p\        P                  P                  V4      pVP	                  \        4       4       \        R\        P                  /4      oVSn        \        R4      p\        P                  ! R4      pVP                  V4       S P                  SV4      pVP                  V V3R l4       V# )z
When communicating with a server which implements the I{LOGIN} SASL
mechanism using C{"Username:"} as the challenge (rather than C{"User
Name\0"}), L{ESMTPClient} can still authenticate successfully using
the I{LOGIN} mechanism.
r  rI  rH  c                 :   < SP                  SP                  4      # r#   r  r   s   &r'   rj   8AuthTests.test_loginAgainstWeirdServer.<locals>.<lambda>F  r  r)   )ri  r
   rx  r   ry  rG  r  r   r   r   r  r|  r   r   r}  s   f     @r'   test_loginAgainstWeirdServer&AuthTests.test_loginAgainstWeirdServer3  s     KKu%	,.)Xt'<'<=>/''4$$U+MM&&)	EFr)   r$   N)	r@   rA   rB   rC   r  r  r  rE   rF   rG   s   @r'   rs  rs    s     ** r)   rs  c                   D   a  ] tR tRt o R tR tR tR tR tR t	Rt
V tR	# )
SMTPHelperTestsiJ  c                    / p\        R 4       F0  p\        P                  ! R4      pV P                  W19   4       RW&   K2  	  R# )i  testcaseN)ranger   	messageidr   )r.   r   ims   &   r'   testMessageIDSMTPHelperTests.testMessageIDK  s:    tAz*AQV$AD r)   c                    R R.RR.\         P                  ! R4      R.RR.\         P                  ! R4      R..pV F+  w  r#V P                  \         P                  ! V4      V4       K-  	  R# )s   user@host.names   <user@host.name>s   "User Name" <user@host.name>s   someguy@someplaces   <someguy@someplace>r)   s   <>N)r   Addressr   	quoteaddr)r.   casesces   &   r'   testQuoteAddrSMTPHelperTests.testQuoteAddrR  sm     34,.AB\\./1GH%L\\#&
 DAT^^A.2 r)   c                n    \         P                  ! R RRR4      pV P                  \        V4      R4       R# )s	   user@hosts   helo.host.nameNz	user@host)r   Userr   str)r.   us   & r'   testUserSMTPHelperTests.testUser^  s+    IIl$5tTBQ-r)   c                l   . ROpV F  w  r#V P                  \        P                  ! V4      V\        V4      34       V P                  VP	                  R4      V4       V P                  \        P
                  ! V4      V\        V4      34       V P                  VP                  R4      V4       K  	  R# )Hello worldxtextN))r  s   Hello+20world)zHello+worlds   Hello+2Bworld)z s   +00+01+02+03+04+05)ze=mc2@example.coms   e+3Dmc2@example.com)r   r   xtext_encodelenencodextext_decodedecode)r.   r  caser0  s   &   r'   testXtextEncoding!SMTPHelperTests.testXtextEncodingb  s    
 $NDT..t4xT6KLT[[18<T..x84X:OPX__W5t<	 $r)   c                    RpV P                  \        P                  ! VR4      VP                  R4      \	        V4      34       V P                  VP                  RR4      VP                  R4      4       R# )z
Specifying an error policy to C{unicode.encode} with the
I{xtext} codec should produce the same result as not
specifying the error policy.
r  strictr  N)r   r   r  r  r  )r.   texts   & r'   test_encodeWithErrors%SMTPHelperTests.test_encodeWithErrorsp  sa     dH-G0Dc$i/P	
 	Wh7W9MNr)   c                    RpV P                  \        P                  ! VR4      VP                  R4      \	        V4      34       V P                  VP                  RR4      VP                  R4      4       R# )z?
Similar to L{test_encodeWithErrors}, but for C{bytes.decode}.
s   Hello worldr  r  N)r   r   r  r  r  )r.   r   s   & r'   test_decodeWithErrors%SMTPHelperTests.test_decodeWithErrors|  sa     eX.g1FE
0S	
 	gx8%,,w:OPr)   r$   N)r@   rA   rB   rC   r  r  r  r  r  r  rE   rF   rG   s   @r'   r  r  J  s+     
3.=
OQ Qr)   r  c                   *   a  ] tR tRt o RtR tRtV tR# )NoticeTLSClienti  Fc                @    \         P                  WV4       R V n        R# TN)r   esmtpState_starttlstls)r.   r   r   s   &&&r'   r  #NoticeTLSClient.esmtpState_starttls  s    ))$d;r)   )r  N)r@   rA   rB   rC   r  r  rE   rF   rG   s   @r'   r  r    s     
C r)   r  c                   *   a  ] tR tRt o ]tR tRtV tR# )TLSTestsi  c                   a aa \        4       p\        4       p\        VR 7      o\        VR 7      oVV V3R lpS P	                  SS4      P                  V4      # ))r   c                 x   < SP                  SP                  R 4       SP                  SP                  R 4       R# r  )r   r  
startedTLS)ignoredr   r.   r   s   &r'   checkTLSTests.testTLS.<locals>.check  s-    VZZ.V..5r)   )r    r!   r  r  r   r   )r.   	clientCTX	serverCTXr  r   r   s   f   @@r'   testTLSTLSTests.testTLS  sJ    $&	$&	 	:95	6 }}VV,88??r)   r$   N)	r@   rA   rB   rC   sslSkipskipr  rE   rF   rG   s   @r'   r  r    s     D@ @r)   r  c                   &   a  ] tR tRt o R tRtV tR# )EmptyLineTestsi  c                   \         P                  ! 4       p\        4       pVP                  V4       VP	                  R4       VP                  R4       VP                  4       P                  4       pV P                  \        V4      ^4       V P                  V^ ,          P                  R4      4       V P                  V^,          R4       R# )zx
If L{smtp.SMTP} receives an empty line, it responds with a 500 error
response code and a message about a syntax error.
r)   Ns   220s   500 Error: bad syntax)r   r  r   r   r6   r(  r   r&  r   r  r   
startswith)r.   protor   outs   &   r'   test_emptyLineSyntaxError(EmptyLineTests.test_emptyLineSyntaxError  s    
 		#%	Y'3oo**,S1%A))&12Q!9:r)   r$   N)r@   rA   rB   rC   r  rE   rF   rG   s   @r'   r  r    s     ; ;r)   r  c                   H   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
# )TimeoutTestsi  z=
Check that SMTP client factories correctly use the timeout.
c                  a a \         P                  ! 4       oVP                  \        P                  ! RR^4      4      pSP
                  Vn        \        4       pVP                  V4       W4n        VV 3R lpS P                  V\        P                  4      P                  V4      pSP                  R4       SP                  R4       V# )zB
Connect the clientFactory, and check the timeout on the request.
TCPexample.netc                 H   < SP                  SP                  4       R 4       R# )      ?N)r   seconds)ignclockr.   s   &r'   r  (TimeoutTests._timeoutTest.<locals>.check  s    U]]_c2r)   g?g?)r   ClockbuildProtocolr   IPv4Address	callLaterr   r   r   assertFailurer   r   r   advance)r.   onDoneclientFactoryr   tr  r   r  s   f&&    @r'   _timeoutTestTimeoutTests._timeoutTest  s     

,,}b9
 !??a 
	3 vt'<'<=II%Pccr)   c           	         \         P                  ! 4       p\        P                  ! RR\	        R4      V^ RR7      pV P                  W4      # )zy
Test timeout for L{smtp.SMTPSenderFactory}: the response L{Deferred}
should be errback with a L{smtp.SMTPTimeoutError}.
source@addresss   recipient@address   Message bodyr  retriestimeoutr   r[   r   SMTPSenderFactoryr   r  r.   r  r  s   &  r'   test_SMTPClientRecipientBytes*TimeoutTests.test_SMTPClientRecipientBytes  sJ    
 !.. O$
   77r)   c           	         \         P                  ! 4       p\        P                  ! RR\	        R4      V^ RR7      pV P                  W4      # )z
Use a L{unicode} recipient.
r  recipient@addressr  r  r  r  r  s   &  r'   test_SMTPClientRecipientUnicode,TimeoutTests.test_SMTPClientRecipientUnicode  sJ     !..O$
   77r)   c           	         \         P                  ! 4       p\        P                  ! RR\	        R4      V^ RR7      pV P                  W4      # )z
Use a L{list} of recipients.
r  r  r  r  )zrecipient1@addresss   recipient2@addressr  r  s   &  r'   test_SMTPClientRecipientList)TimeoutTests.test_SMTPClientRecipientList  sJ     !..9O$
   77r)   c                    \         P                  ! 4       p\        P                  ! RRRR\	        R4      V^ RR7      pV P                  W4      # )zz
Test timeout for L{smtp.ESMTPSenderFactory}: the response L{Deferred}
should be errback with a L{smtp.SMTPTimeoutError}.
rM  passwordr  r  r  r  r  )r   r[   r   ESMTPSenderFactoryr   r  r  s   &  r'   test_ESMTPClientTimeoutTests.test_ESMTPClient  sP    
 !//O$	
   77r)   c           	         ! R R4      p. p\         P                  ! 4       pVP                  VP                  4       \        P
                  ! RRV! ^4      V^ ^R7      pRVn        \        P                  ! 4       pVP                  \        P                  ! RR^4      4      pVP                  Vn        \        4       pVP                  V4       VP                  R	4       V P!                  VP"                  R
4       V P%                  VP&                  4       VP)                  ^4       V P+                  V. 4       VP"                  P-                  4        VP)                  ^4       V P+                  V. 4       VP"                  P-                  4        VP                  R4       V P+                  V. 4       V P+                  VP/                  4       R4       R
# )z
The timeout is not allowed to expire after the server has accepted a
DATA command and the client is actively sending data to it.
c                   4   a  ] tR tRt o RtR tRR ltRtV tR# )<TimeoutTests.test_resetTimeoutWhileSending.<locals>.SlowFilei  zp
A file-like which returns one byte from each read call until the
specified number of bytes have been returned.
c                    Wn         R # r#   _size)r.   sizes   &&r'   r0   ETimeoutTests.test_resetTimeoutWhileSending.<locals>.SlowFile.__init__  s    !
r)   Nc                `    V P                   '       d   V ;P                   ^,          un         R# R# )r     xr)   r
  )r.   maxs   &&r'   readATimeoutTests.test_resetTimeoutWhileSending.<locals>.SlowFile.read  s    :::JJ!OJr)   r
  r#   )	r@   rA   rB   rC   rD   r0   r  rE   rF   rG   s   @r'   SlowFiler    s     
" r)   r  r  r  r     example.orgr  r  r   Ns   250 Ok
s]   HELO example.org
MAIL FROM:<source@address>
RCPT TO:<recipient@address>
DATA
x
.
RSET
)r   r[   
addErrbackrR   r   r  rL   r   r  r  r   r  r  r   r   r   r   r   r   r   r  r   resumeProducingr   )r.   r  failedr  r  r  r   r   s   &       r'   test_resetTimeoutWhileSending*TimeoutTests.test_resetTimeoutWhileSending  s   	 	 !&--(..QK
  .

,,}b9
 !??#%	i(	
 		 2 2D9,,- 	a 	$ 	**,a$ 	**,M*$ 	OO	
r)   r$   N)r@   rA   rB   rC   rD   r  r  r  r  r  r  rE   rF   rG   s   @r'   r  r    s/     .8 888$W
 W
r)   r  c                   0   a  ] tR tRt o RtR tR tRtV tR# )(MultipleDeliveryFactorySMTPServerFactoryih  z
L{MultipleDeliveryFactorySMTPServerFactory} creates SMTP server protocol
instances with message delivery factory objects supplied to it.  Each
factory is used for one connection and then discarded.  Factories are used
in the order they are supplied.
c                    Wn         R # r#   _messageFactories)r.   messageFactoriess   &&r'   r0   1MultipleDeliveryFactorySMTPServerFactory.__init__p  s    !1r)   c                    \         P                  P                  W4      p\        V P                  P                  ^ 4      4      Vn        V# )r  )r   ServerFactoryr  r  r  r   r  )r.   addrr  s   && r'   r  6MultipleDeliveryFactorySMTPServerFactory.buildProtocols  s:    ""00<#D$:$:$>$>q$AB
r)   r  N)	r@   rA   rB   rC   rD   r0   r  rE   rF   rG   s   @r'   r  r  h  s     2 r)   r  c                   0   a  ] tR tRt o RtR tR tRtV tR# )SMTPSenderFactoryTestsiy  z&
Tests for L{smtp.SMTPSenderFactory}.
c                V   \        4       p\        P                  ! 4       p\        P                  ! RR\        R4      V4      pVP                  ! R^V4      pVP                  R4       VP                  V\        P                  ! R4      4       V P                  VP                  R4       R# )z\
L{smtp.SMTPSenderFactory} removes the current protocol when the client
connection is lost.
r  r     message	localhostNBye.)r   r   r[   r   r  r   
connectTCPr  clientConnectionLostr   ConnectionDoner   currentProtocolr.   r   sentDeferredr  	connectors   &    r'   2test_removeCurrentProtocolWhenClientConnectionLostISMTPSenderFactoryTests.test_removeCurrentProtocolWhenClientConnectionLost~  s    
  /~~'..17:3F
 &&{BF	##D)**9e6J6J66RS66=r)   c                V   \        4       p\        P                  ! 4       p\        P                  ! RR\        R4      V4      pVP                  ! R^V4      pVP                  R4       VP                  V\        P                  ! R4      4       V P                  VP                  R4       R# )z^
L{smtp.SMTPSenderFactory} removes the current protocol when the client
connection is failed.
r  r  r(  r)  Nr*  )r   r   r[   r   r  r   r+  r  clientConnectionFailedr   r-  r   r.  r/  s   &    r'   4test_removeCurrentProtocolWhenClientConnectionFailedKSMTPSenderFactoryTests.test_removeCurrentProtocolWhenClientConnectionFailed  s    
  /~~'..17:3F
 &&{BF	##D),,Y8L8LV8TU66=r)   r$   N)	r@   rA   rB   rC   rD   r2  r6  rE   rF   rG   s   @r'   r&  r&  y  s     >> >r)   r&  c                   *   a  ] tR tRt o RtR tRtV tR# )SMTPSenderFactoryRetryTestsi  z<
Tests for the retry behavior of L{smtp.SMTPSenderFactory}.
c                p  a a	a
a RoRo
\        S.4      o	 ! V 3R lR\        P                  4      p\        \        V	3R l.4      pWn        \        P                  ! ^ VRR7      pVP                  4       pS P                  VP                  4       \        P                  ! 4       p\        P                  ! RSR	,           \        S
4      V4      pR
Vn        \        P                   ! VP"                  VP$                  V4      pS P                  VP&                  4       V	V
VV 3R lpVP)                  V4       V# )z
If the protocol created by L{SMTPSenderFactory} loses its connection
before receiving confirmation of message delivery, it reconnects and
tries to deliver the message again.
s   alices   some message textc                   2   <a  ] tR tRt o RtV3R ltRtV tR# )HSMTPSenderFactoryRetryTests.test_retryAfterDisconnect.<locals>.CleanSMTPi  z^
An SMTP subclass which ensures that its transport will be
disconnected before the test ends.
c                |   < SP                  VP                  4       \        P                  P	                  W4       R # r#   )
addCleanupr   r   r  r   )	innerSelfr   r.   s   &&r'   r   WSMTPSenderFactoryRetryTests.test_retryAfterDisconnect.<locals>.CleanSMTP.makeConnection  s'    	 8 89		((>r)   r$   N)r@   rA   rB   rC   rD   r   rE   rF   )rH   r.   s   @r'   	CleanSMTPr<    s     
? ?r)   rA  c                    < \        SV 4      # r#   ri   )r/   rL   s   &r'   rj   GSMTPSenderFactoryRetryTests.test_retryAfterDisconnect.<locals>.<lambda>  s    fd)Cr)   	127.0.0.1)	interfaces   bob@example.orgs   @example.comr  c                   < SP                  SP                  SRS,           R,           ./4       SP                  \        SP                  \        4      4      ^4       R# )zp
Verify that the message was successfully delivered and flush the
error which caused the first attempt to fail.
rV   N)r   rX   r  flushLoggedErrorsr9   )r  rL   r]   	recipientr.   s   &r'   cbSentESMTPSenderFactoryRetryTests.test_retryAfterDisconnect.<locals>.cbSent  sJ    
 V__y57?U;R:S.TUS!7!7!EFJr)   )ra   r   r  r  r+   r   r   	listenTCPgetHostr>  stopListeningr   r[   r  r   rL   r+  hostport
disconnectr   )r.   rA  serverFactory
serverPort
serverHostr0  r  clientConnectorrI  rL   r]   rH  s   f        @@@r'   test_retryAfterDisconnect5SMTPSenderFactoryRetryTests.test_retryAfterDisconnect  s    	&i[)	?		 	? ACD
 "+&&q-;O
'')

001 ~~'..'G	
  .!,,OOZ__m
 	223	K 	K 	  (r)   r$   N)r@   rA   rB   rC   rD   rU  rE   rF   rG   s   @r'   r9  r9    s     8 8r)   r9  c                   0   a  ] tR tRt o RtR tR tRtV tR# )SingletonRealmi  z
Trivial realm implementation which is constructed with an interface and an
avatar and returns that avatar when asked for that interface.
c                    Wn         W n        R # r#   rE  avatar)r.   rE  r[  s   &&&r'   r0   SingletonRealm.__init__  s    "r)   c                X    V F#  pW@P                   J g   K  W@P                  R  3u # 	  R# )c                      R # r#   r$   r$   r)   r'   rj   .SingletonRealm.requestAvatar.<locals>.<lambda>  s    4r)   NrZ  )r.   rn  ro  r   ifaces   &&&* r'   rp  SingletonRealm.requestAvatar  s%    E&kk<77  r)   )r[  rE  N)	r@   rA   rB   rC   rD   r0   rp  rE   rF   rG   s   @r'   rX  rX    s     
8 8r)   rX  c                   6   a  ] tR tRt o RtR tR tR tRtV t	R# )NotImplementedDeliveryi  z
Non-implementation of L{smtp.IMessageDelivery} which only has methods which
raise L{NotImplementedError}.  Subclassed by various tests to provide the
particular behavior being tested.
c                    \        R 4      hz3This oughtn't be called in the course of this test.NotImplementedErrorr  s   &&&r'   r  #NotImplementedDelivery.validateFrom      !"WXXr)   c                    \        R 4      hre  rf  r-   s   &&r'   r	  !NotImplementedDelivery.validateTo  ri  r)   c                    \        R 4      hre  rf  r`  s   &&&&r'   r  %NotImplementedDelivery.receivedHeader  ri  r)   r$   N)
r@   rA   rB   rC   rD   r  r	  r  rE   rF   rG   s   @r'   rc  rc    s"     YYY Yr)   rc  c                      a  ] tR tRt o Rt]P                  3R ltR tR t	R t
R tR tR	 t]! ]4      R
 4       tR tRtV tR# )SMTPServerTestsi  zU
Test various behaviors of L{twisted.mail.smtp.SMTP} and
L{twisted.mail.smtp.ESMTP}.
c                    V! 4       pRVn         \        4       pVP                  V4       VP                  \        P
                  ! 4       4       V P                  RVP                  4       4       R# )zJ
Test that the specified hostname shows up in the SMTP server's
greeting.
s   example.comN)rN  r   r   r>   r   r-  assertInr   )r.   r!  sr  s   &&  r'   testSMTPGreetingHost$SMTPServerTests.testSMTPGreetingHost  sS    
 M		--/0naggi0r)   c                    \         P                  ! 4       p\        4       pVP                  V4       VP	                  \
        P                  ! 4       4       V P                  RVP                  4       4       R# )z
Test that the string "ESMTP" does not appear in the SMTP server's
greeting since that string strongly suggests the presence of support
for various SMTP extensions which are not supported by L{smtp.SMTP}.
   ESMTPN)	r   r  r   r   r>   r   r-  assertNotInr   r.   rr  r  s   &  r'   testSMTPGreetingNotExtended+SMTPServerTests.testSMTPGreetingNotExtended  sR     IIK		--/01779-r)   c                D    V P                  \        P                  4       R# )zC
Similar to testSMTPGreetingHost, but for the L{smtp.ESMTP} class.
N)rs  r   r  r:   s   &r'   testESMTPGreetingHost%SMTPServerTests.testESMTPGreetingHost  s     	!!$**-r)   c                    \         P                  ! 4       p\        4       pVP                  V4       VP	                  \
        P                  ! 4       4       V P                  RVP                  4       4       R# )z
Test that the string "ESMTP" does appear in the ESMTP server's
greeting since L{smtp.ESMTP} does support the SMTP extensions which
that advertises to the client.
rv  N)	r   r  r   r   r>   r   r-  rq  r   rx  s   &  r'   testESMTPGreetingExtended)SMTPServerTests.testESMTPGreetingExtended#  sP     JJL		--/0h	*r)   c                   \         P                  ! 4       p\        4       pVP                  V4       VP	                  R4       VP                  \        P                  ! 4       4       V P                  RVP                  4       4       R# )z>
Sending an unimplemented command is responded to with a 500.
s   DOAGOODTHINGs   500 Command not implementedN)
r   r  r   r   r6   r>   r   r-  rq  r   rx  s   &  r'   test_SMTPUnknownCommand'SMTPServerTests.test_SMTPUnknownCommand/  s]     IIK		'	--/04aggi@r)   c                    ! R R\         4      p\        \        P                  V! 4       4      p\	        V\        4       .4      p\        P                  ! 4       pW4n        \        4       pVP                  V4       VP                  R4       VP                  4        VP                  R4       VP                  \        P                  ! 4       4       V P                  VP!                  4       R4       R# )zl
Test that a C{MAIL FROM} command with an acceptable address is
responded to with the correct success code.
c                   *   a  ] tR tRt o RtR tRtV tR# )DSMTPServerTests.test_acceptSenderAddress.<locals>.AcceptanceDeliveryi@  z5
Delivery object which accepts all senders as valid.
c                    V# r#   r$   r  s   &&&r'   r  QSMTPServerTests.test_acceptSenderAddress.<locals>.AcceptanceDelivery.validateFromE  s    r)   r$   Nr@   rA   rB   rC   rD   r  rE   rF   rG   s   @r'   AcceptanceDeliveryr  @  s      r)   r     HELO example.com
   MAIL FROM:<alice@example.com>
s   250 Sender address accepted
Nrc  rX  r   rm  r   r   r  rx  r   r   r   r$  r>   r   ConnectionLostr   r   )r.   r  r~  rx  r  transs   &     r'   test_acceptSenderAddress(SMTPServerTests.test_acceptSenderAddress:  s    	!7 	 t446H6JK 4 678		!U# 	23 	?@ 	U1134 	(JKr)   c                    ! R R\         4      p\        \        P                  V! 4       4      p\	        V\        4       .4      p\        P                  ! 4       pW4n        \        4       pVP                  V4       VP                  R4       VP                  4        VP                  R4       VP                  \        P                  ! 4       4       V P                  VP!                  4       R4       R# )z
Test that a C{MAIL FROM} command with an address rejected by a
L{smtp.IMessageDelivery} instance is responded to with the correct
error code.
c                   *   a  ] tR tRt o RtR tRtV tR# )MSMTPServerTests.test_deliveryRejectedSenderAddress.<locals>.RejectionDeliveryid  z7
Delivery object which rejects all senders as invalid.
c                .    \         P                  ! V4      hr#   )r   SMTPBadSenderr  s   &&&r'   r  ZSMTPServerTests.test_deliveryRejectedSenderAddress.<locals>.RejectionDelivery.validateFromi  s    ((00r)   r$   Nr  rG   s   @r'   RejectionDeliveryr  d  s     1 1r)   r  r  r  V   550 Cannot receive from specified address <alice@example.com>: Sender not acceptable
Nr  )r.   r  r~  rx  r  r  s   &     r'   "test_deliveryRejectedSenderAddress2SMTPServerTests.test_deliveryRejectedSenderAddress]  s    	1 6 	1 t446G6IJ 4 678		!U# 	23 	?@ 	U1134 	KKM>	
r)   c                    ! R R4      p\        \        P                  \        4       4      p\	        W!! 4       .4      p\        P
                  ! 4       pW4n        \        4       pVP                  V4       VP                  R4       VP                  4        VP                  R4       VP                  \        P                  ! 4       4       V P                  VP                  4       R4       R# )z
Test that a C{MAIL FROM} command with an address rejected by an
L{smtp.SMTP} instance's portal is responded to with the correct error
code.
c                   0   a  ] tR tRt o Rt]3tR tRtV t	R# )QSMTPServerTests.test_portalRejectedSenderAddress.<locals>.DisallowAnonymousAccessi  zB
Checker for L{IAnonymous} which rejects authentication attempts.
c                >    \         P                  ! \        4       4      # r#   )r   rm   r   rO  s   &&r'   rQ  aSMTPServerTests.test_portalRejectedSenderAddress.<locals>.DisallowAnonymousAccess.requestAvatarId  s    zz"3"566r)   r$   N)
r@   rA   rB   rC   rD   r   rX  rQ  rE   rF   rG   s   @r'   DisallowAnonymousAccessr    s      %/= 7 7r)   r  r  r  r  NrX  r   rm  rc  r   r  rx  r   r   r   r$  r>   r   r  r   r   )r.   r  r~  rx  r  r  s   &     r'    test_portalRejectedSenderAddress0SMTPServerTests.test_portalRejectedSenderAddress  s    	7 	7 t446L6NO 7 9:;		!U# 	23 	?@ 	U1134 	KKM>	
r)   c                   \        \        P                  \        4       4      p\	        V. 4      p\        P
                  ! 4       pW#n        \        4       pVP                  V4       VP                  R4       VP                  4        VP                  R4       VP                  \        P                  ! 4       4       V P                  VP                  4       R4       R# )z
Test that a C{MAIL FROM} command issued without first authenticating
when a portal has been configured to disallow anonymous logins is
responded to with the correct error code.
r  r  sd   550 Cannot receive from specified address <alice@example.com>: Unauthenticated senders not allowed
Nr  )r.   r~  rx  r  r  s   &    r'   "test_portalRejectedAnonymousSender2SMTPServerTests.test_portalRejectedAnonymousSender  s     t446L6NOr"		!U# 	23 	?@ 	U1134 	KKML	
r)   r$   N)r@   rA   rB   rC   rD   r   r  rs  ry  r|  r  r  r  r  r	   r   r  r  rE   rF   rG   s   @r'   ro  ro    s_     
 04yy 
1
..
+	A!LF&
P $%(
 &(
T
 
r)   ro  c                   r   a  ] tR tRt o R tRR l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# )ESMTPAuthenticationTestsi  c                    V P                   P                  4        V P                  P                  V4       V P	                  W P                   P                  4       P                  4       4       R# )z
Assert that when the given bytes are delivered to the ESMTP server
instance, it responds with the indicated lines.

@type bytes: str
@type response: list of str
N)r   r$  r   r   r   r   r&  )r.   r   responses   &&&r'   assertServerResponse-ESMTPAuthenticationTests.assertServerResponse  sJ     	  '>>#7#7#9#D#D#FGr)   c                   VP                  4       w  rErgV P                  V. 4       V P                  \        P                  P
                  P                  P                  V4      4       V P                  VP                  V4       V P                  VP                  V4      4       V P                  \        P                  V4       V P                  \        P                  V4       VP                  \        P                  RR 34       V P                  R.V P                  P!                  4       P#                  4       4       R# )a^  
Assert that a login attempt has been made, that the credentials and
interfaces passed to it are correct, and that when the login request
is satisfied, a successful response is sent by the ESMTP server
instance.

@param loginArgs: A C{list} previously passed to L{portalFactory}.
@param username: The login user.
@param password: The login password.
Nc                      R # r#   r$   r$   r)   r'   rj   DESMTPAuthenticationTests.assertServerAuthenticated.<locals>.<lambda>  s    r)   s   235 Authentication successful.)r   r   r   twistedr
   rP  rV  
providedByrM  rL  rq  r   IMessageDeliveryFactoryrm  r\   r   r   r&  )r.   	loginArgsrM  r  r   rP  ro  r   s   &&&&    r'   assertServerAuthenticated2ESMTPAuthenticationTests.assertServerAuthenticated  s     ,5==?(B'LL$$66AA+N	
 	--x811(;<d22J?d++Z8	

D00$EF./1E1E1G1R1R1T	
r)   c                   \         P                  ! R\        /4      V n        RV P                  n        \        \        P                  ! RRR4      R7      V n        V P                  P                  V P                  4       R# )z9
Create an ESMTP instance attached to a StringTransport.
r  s	   localhostr  rD  i90  )peerAddressN)
r   r  r   r   rN  r   r   r  r   r   r:   s   &r'   setUpESMTPAuthenticationTests.setUp  s\     jj(,<!=>'(++E;F
 	""4>>2r)   c                b    V P                   P                  \        P                  ! 4       4       R# )zD
Disconnect the ESMTP instance to clean up its timeout DelayedCall.
N)r   r>   r   r-  r:   s   &r'   tearDown!ESMTPAuthenticationTests.tearDown  s     	""5#7#7#9:r)   c                ,   a  ! V3R  lR4      pV! 4       # )c                   .   <a  ] tR tRt o V3R ltRtV tR# );ESMTPAuthenticationTests.portalFactory.<locals>.DummyPortali  c                X   < \         P                  ! 4       pSP                  WAW#34       V# r#   )r   r[   rR   )r.   rP  ro  r   r   	loginLists   &&&* r'   loginAESMTPAuthenticationTests.portalFactory.<locals>.DummyPortal.login  s'    NN$  !$!CDr)   r$   N)r@   rA   rB   rC   r  rE   rF   )rH   r  s   @r'   DummyPortalr    s      r)   r  r$   )r.   r  r  s   &f r'   portalFactory&ESMTPAuthenticationTests.portalFactory
  s    	 	 }r)   c                Z   V P                   P                  4        V P                  P                  R4       V P                   P	                  4       P                  4       pV P                  V^ ,          R4       V P                  V^,          R4       V P                  \        V4      ^4       R# )zF
Test that AUTH is advertised to clients which issue an EHLO command.
   EHLO
s/   250-localhost Hello 127.0.0.1, nice to meet yous   250 AUTH LOGINN)r   r$  r   r   r   r&  r   r  )r.   responseLiness   & r'   'test_authenticationCapabilityAdvertised@ESMTPAuthenticationTests.test_authenticationCapabilityAdvertised  s     	  -,,.99;!P	
 	q)+<=]+Q/r)   c                r   . pV P                  V4      V P                  n        V P                  P                  R4       V P                  P                  4        V P                  RR\        P                  ! R4      P                  4       ,           .4       V P                  \        P                  ! R4      R,           R\        P                  ! R4      P                  4       ,           .4       V P                  \        P                  ! R4      P                  4       R,           . 4       V P                  V4       R	# )
z:
Test that the LOGIN authentication mechanism can be used
r     AUTH LOGIN
   334 
   User Name    usernamer   	   Password    passwordNr  r   rx  r   r   r$  r  base64	b64encodestripr  r.   r  s   & r'   test_plainAuthentication1ESMTPAuthenticationTests.test_plainAuthentication   s     	!//	:  -!!&*:*:>*J*P*P*R RS	
 	!![)G3v''6<<>>?	

 	!!&"2"2;"?"E"E"G'"QSUV&&y1r)   c                $   . pV P                  V4      V P                  n        V P                  P                  R4       V P                  P                  4        V P                  RR\        P                  ! R4      P                  4       ,           .4       V P                  \        P                  ! R4      R,           R\        P                  ! R4      P                  4       ,           .4       V P                  R. 4       V P                  VRR	7       R
# )z=
Test that giving an empty password for plain auth succeeds.
r  r  r  r  r  r   r  r)   )r  Nr  r  s   & r'   %test_plainAuthenticationEmptyPassword>ESMTPAuthenticationTests.test_plainAuthenticationEmptyPassword7  s     	!//	:  -!!&*:*:>*J*P*P*R RS	
 	!![)G3v''6<<>>?	

 	!!'2.&&y3&?r)   c                $   . pV P                  V4      V P                  n        V P                  P                  R4       V P                  P                  4        V P                  R\        P                  ! R4      P                  4       ,           R,           R\        P                  ! R4      P                  4       ,           .4       V P                  \        P                  ! R4      P                  4       R,           . 4       V P                  V4       R# )	zr
The response to the first challenge may be included on the AUTH command
line.  Test that this is also supported.
r     AUTH LOGIN r  r   r  r  r  Nr  r  s   & r'   'test_plainAuthenticationInitialResponse@ESMTPAuthenticationTests.test_plainAuthenticationInitialResponseM  s    
 	!//	:  -!!V--k:@@BBWLv''6<<>>?	

 	!!&"2"2;"?"E"E"G'"QSUV&&y1r)   c                    . pV P                  V4      V P                  n        V P                  P                  R4       V P                  P                  R4       V P	                  RR.4       R# )zG
Test that a challenge/response sequence can be aborted by the client.
r  r  s   *
s   501 Authentication abortedN)r  r   rx  r   r  r  s   & r'   test_abortAuthentication1ESMTPAuthenticationTests.test_abortAuthenticationa  sY     	!//	:  -  !23!!(-J,KLr)   c                    . pV P                  V4      V P                  n        V P                  P                  R4       V P                  P                  R4       V P	                  RR.4       V P                  V. 4       R# )zb
Test that a response which is not properly Base64 encoded results in
the appropriate error code.
r  r  s   x
+   501 Syntax error in parameters or argumentsNr  r   rx  r   r  r   r  s   & r'   !test_invalidBase64EncodedResponse:ESMTPAuthenticationTests.test_invalidBase64EncodedResponsem  sn    
 	!//	:  -  !23!!EF	
 	B'r)   c                    . pV P                  V4      V P                  n        V P                  P                  R4       V P	                  RR.4       V P                  V. 4       R# )zv
Like L{test_invalidBase64EncodedResponse} but for the case of an
initial response included with the C{AUTH} command.
r  s   AUTH LOGIN x
r  Nr  r  s   & r'   (test_invalidBase64EncodedInitialResponseAESMTPAuthenticationTests.test_invalidBase64EncodedInitialResponse~  s[    
 	!//	:  -!!"P!Q	
 	B'r)   c                   . pV P                  V4      V P                  n        V P                  P                  R4       V P                  P                  4        V P                  R\        P                  ! R4      P                  4       ,           R,           R\        P                  ! R4      P                  4       ,           .4       V P                  \        P                  ! R4      P                  4       R,           . 4       VP                  4       w  r#rEVP                  \        R4      4       V P                  R	V P                  P                  4       4       V P                  \        V P!                  \        4      4      ^4       R
# )z
If the L{Deferred} returned by L{Portal.login} fires with an
exception of any type other than L{UnauthorizedLogin}, the exception
is logged and the client is informed that the authentication attempt
has failed.
r  r  r  r   r  r  r  zSomething wrong with the servers9   451 Requested action aborted: local error in processing
N)r  r   rx  r   r   r$  r  r  r  r  r   errbackr9   r   r   r  rG  )r.   r  r   rP  ro  r   s   &     r'   test_unexpectedLoginFailure4ESMTPAuthenticationTests.test_unexpectedLoginFailure  s!    	!//	:  -!!V--k:@@BBWLv''6<<>>?	
 	!!&"2"2;"?"E"E"G'"QSUV+4==?(			,@ABJNN  "	

 	T33LABAFr)   )r   r   N)r  r  )r@   rA   rB   rC   r  r  r  r  r  r  r  r  r  r  r  r  r  rE   rF   rG   s   @r'   r  r    sP     
H
8	3;02.@,2(
M("(G Gr)   r  c                   6   a  ] tR tRt o RtR tR tR tRtV t	R# )SMTPClientErrorTestsi  z$
Tests for L{smtp.SMTPClientError}.
c                j    \         P                  ! ^{R4      pV P                  \        V4      R4       R# )zl
The string representation of a L{SMTPClientError} instance includes
the response code and response string.
z	some textz123 some textNr   r   r   r  r.   errs   & r'   test_strSMTPClientErrorTests.test_str  s*    
 ""34S?3r)   c                j    \         P                  ! RR4      pV P                  \        V4      R4       R# )zq
If the response code supplied to L{SMTPClientError} is negative, it
is excluded from the string representation.
s   foo barzfoo barNr  r  s   & r'   test_strWithNegativeCode-SMTPClientErrorTests.test_strWithNegativeCode  s*    
 ""2z2S9-r)   c                    \        ^
4      pVP                  R4       VP                  R4       \        P                  ! ^dRVP	                  4       R7      pV P                  \	        V4      R4       R# )z
If a line log is supplied to L{SMTPClientError}, its contents are
included in the string representation of the exception instance.
s   testlogs
   secondlinez
test error)r   z"100 test error
testlog
secondline
N)r   rR   r   r   r  r   )r.   r   r  s   &  r'   test_strWithLog$SMTPClientErrorTests.test_strWithLog  sT    
 bk

:

=!""3#'')DS#PQr)   r$   N)
r@   rA   rB   rC   rD   r  r  r  rE   rF   rG   s   @r'   r  r    s      4.	R 	Rr)   r  c                   *   a  ] tR tRt o RtR tRtV tR# )SenderMixinSentMailTestsi  zy
Tests for L{smtp.SenderMixin.sentMail}, used in particular by
L{smtp.SMTPSenderFactory} and L{smtp.ESMTPSenderFactory}.
c           	     t  a  S P                  \        P                  ! 4       \        P                  4      pVP                  V 3R l4       \        P                  ! RR\        R4      V^ RR7      pVP                  \        P                  ! RR^4      4      pR
R.pVP                  ^R	^WCP                  4       V# )z
L{smtp.SenderMixin.sentMail} adds only the addresses with failing
SMTP response codes to the log passed to the factory's errback.
c                 <   < SP                  V P                  R 4      # )s'   bob@example.com: 199 Error in sending.
)r   r   )r  r.   s   &r'   rj   FSenderMixinSentMailTests.test_onlyLogFailedAddresses.<locals>.<lambda>  s    d&&Br)   r  r  r  r  r  r  r  s   Test response)s   alice@example.com   s   No errors here!)s   bob@example.com   s   Error in sending.)r  r   r[   r   SMTPDeliveryErrorr   r  r   r  r   r  r   r   )r.   r  r  r   r   s   f    r'   test_onlyLogFailedAddresses4SenderMixinSentMailTests.test_onlyLogFailedAddresses  s    
 ##ENN$4d6L6LM	
 ..O$
 ,,}b9

 <;
	 	-q)ZZHr)   r$   N)r@   rA   rB   rC   rD   r  rE   rF   rG   s   @r'   r  r    s     
 r)   r  c                   B   a  ] tR tRt o RtR tR tR tR tR t	Rt
V tR	# )
ESMTPDowngradeTestCasei  zM
Tests for the ESMTP -> SMTP downgrade functionality in L{smtp.ESMTPClient}.
c                @    \         P                  ! R RR4      V n        R# )rI  NrH  )r   r   clientProtocolr:   s   &r'   r  ESMTPDowngradeTestCase.setUp  s    "..kRr)   c                   \        4       pRV P                  n        RV P                  n        RV P                  n        V P                  P                  V4       V P                  P                  R4       VP                  4        V P                  P                  R4       V P                  RVP                  4       4       R# )zz
If both authentication and transport security are not required, and it
is asked for, it will fall back to allowing HELO.
FT   220 localhost
   500 not an esmtp server
   HELO testuser
N
r   r  requireAuthenticationrequireTransportSecurityheloFallbackr   r   r$  r   r   r.   r   s   & r'    test_requireHELOFallbackOperates7ESMTPDowngradeTestCase.test_requireHELOFallbackOperates  s    
 $%	4917<4+/(**95(()=>(()GH-y/@Ar)   c                   \        4       pRV P                  n        RV P                  n        RV P                  n        V P                  P                  V4       V P                  P                  R4       VP                  4        V P                  P                  R4       V P                  RVP                  4       4       R# )z
If authentication is required, and HELO fallback is on, HELO fallback
must not be honoured, as authentication requires EHLO to succeed.
TFr  r  r   Nr  r  s   & r'   !test_requireAuthFailsHELOFallback8ESMTPDowngradeTestCase.test_requireAuthFailsHELOFallback  s    
 $%	4817<4+/(**95(()=>(()GHioo&78r)   c                   \        4       pRV P                  n        RV P                  n        RV P                  n        V P                  P                  V4       V P                  P                  R4       VP                  4        V P                  P                  R4       V P                  RVP                  4       4       R# )z~
If TLS is required and the connection is insecure, HELO fallback must
not be honoured, as STARTTLS requires EHLO to succeed.
FTr  r  r   Nr  r  s   & r'    test_requireTLSFailsHELOFallback7ESMTPDowngradeTestCase.test_requireTLSFailsHELOFallback  s    
 $%	4917;4+/(**95(()=>(()GHioo&78r)   c                   \        4       p\        V\        P                  4       RV P                  n        RV P                  n        RV P                  n        V P                  P                  V4       V P                  P                  R4       VP                  4        V P                  P                  R4       V P                  RVP                  4       4       R# )zi
If TLS is provided at the transport level, we can honour the HELO
fallback if we're set to require TLS.
FTr  r  r  N)r   r   r   ISSLTransportr  r  r  r  r   r   r$  r   r   r  s   & r'   /test_requireTLSAndHELOFallbackSucceedsIfOverTLSFESMTPDowngradeTestCase.test_requireTLSAndHELOFallbackSucceedsIfOverTLS,  s    
 $%	J$<$<=4917;4+/(**95(()=>(()GH-y/@Ar)   r  N)r@   rA   rB   rC   rD   r  r  r  r  r"  rE   rF   rG   s   @r'   r  r    s,     SB 9 9 B Br)   r  c                   f   a  ] tR tRt o Rt]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# )SSLTestCasei>  z<
Tests for the TLS negotiation done by L{smtp.ESMTPClient}.
s3   220 localhost NO UCE NO UBE NO RELAY PROBES ESMTP
s1   250-localhost Hello 127.0.0.1, nice to meet you
c                    \         P                  ! R \        4       R4      V n        RV P                  n        R V P                  n        R# )rI  rH  Tc                      R # )ztest@example.orgr$   r$   r)   r'   rj   #SSLTestCase.setUp.<locals>.<lambda>M  s    2Dr)   N)r   r   r    r  r  r|   r:   s   &r'   r  SSLTestCase.setUpH  s>    "..-/
 8<4*D'r)   c                   \        4       p\        V\        P                  4       V P                  P                  V4       V P                  P                  V P                  4       VP                  4        V P                  P                  V P                  V,           4       V P                  RVP                  4       4       R# )as  
Verify that when L{smtp.ESMTPClient} connects to a server over a
transport providing L{ISSLTransport}, C{requireTransportSecurity} is
C{True}, and it is presented with the given capabilities, it will try
to send its mail and not first attempt to negotiate TLS using the
I{STARTTLS} protocol action.

@param capabilities: Bytes to include in the test server's capability
    response.  These must be formatted exactly as required by the
    protocol, including a line which ends the capability response.
@type param: L{bytes}

@raise: C{self.failureException} if the behavior of
    C{self.clientProtocol} is not as described.
s   MAIL FROM:<test@example.org>
N)r   r   r   r!  r  r   r   SERVER_GREETINGr$  EHLO_RESPONSEr   r   )r.   capabilitiesr   s   && r'   $_requireTransportSecurityOverSSLTest0SSLTestCase._requireTransportSecurityOverSSLTestO  s      $%	J$<$<=**95 	(()=)=> 	((););l)JK 	<ioo>OPr)   c                (    V P                  R4       R# )zw
When C{requireTransportSecurity} is C{True} and the client is connected
over an SSL transport, mail may be delivered.
   250 AUTH LOGIN
Nr/  r:   s   &r'   $test_requireTransportSecurityOverSSL0SSLTestCase.test_requireTransportSecurityOverSSLn  s    
 	112GHr)   c                R   \        4       pV P                  P                  V4       V P                  P                  V P                  4       VP                  4        V P                  P                  V P                  R,           4       V P                  RVP                  4       4       R# )z
When C{requireTransportSecurity} is C{True} and the client is connected
over a non-SSL transport, if the server offers the I{STARTTLS}
extension, it is used before mail is delivered.
   250-AUTH LOGIN
250 STARTTLS
s
   STARTTLS
N	r   r  r   r   r,  r$  r-  r   r   r  s   & r'   'test_requireTransportSecurityTLSOffered3SSLTestCase.test_requireTransportSecurityTLSOfferedu  s     $%	**95 	(()=)=> 	((!JJ	

 	)//*;<r)   c                (    V P                  R4       R# )z
When C{requireTransportSecurity} is C{True} and the client is connected
over an SSL transport, if the server offers the I{STARTTLS}
extension, it is not used before mail is delivered.
r7  Nr3  r:   s   &r'   .test_requireTransportSecurityTLSOfferedOverSSL:SSLTestCase.test_requireTransportSecurityTLSOfferedOverSSL  s     	115	
r)   c                R   \        4       pV P                  P                  V4       V P                  P                  V P                  4       VP                  4        V P                  P                  V P                  R,           4       V P                  RVP                  4       4       R# )z
When C{requireTransportSecurity} is C{True} and the client is connected
over a non-SSL transport, if the server does not offer the I{STARTTLS}
extension, mail is not delivered.
r2  r   Nr8  r  s   & r'   *test_requireTransportSecurityTLSNotOffered6SSLTestCase.test_requireTransportSecurityTLSNotOffered  s     $%	**95 	(()=)=> 	((););>S)ST 	ioo&78r)   c                ,   V P                   P                  p?V P                  V P                  .R7      pV P	                  \        V4      ^4       V P                  V^ ,          R,          \        4       V P	                  V^ ,          R,          R4       R# ),
L{smtp.ESMTPClient.tlsMode} is deprecated.
offendingFunctionscategoryr]   StlsMode attribute of twisted.mail.smtp.ESMTPClient is deprecated since Twisted 13.0N)r  tlsModeflushWarnings%test_esmtpClientTlsModeDeprecationGetr   r  assertIdenticalDeprecationWarning)r.   valwarningsShowns   &  r'   rI  1SSLTestCase.test_esmtpClientTlsModeDeprecationGet  s     !!))** $ J JK + 
 	]+Q/]1-j9;MN!Y'/	
r)   c                <   a  S P                  \        V 3R l4       R# )zi
L{smtp.ESMTPClient.__getattr__} raises an attribute error for other
attribute names which do not exist.
c                  0   < S P                   P                  # r#   )r  doesNotExistr:   s   r'   rj   QSSLTestCase.test_esmtpClientTlsModeDeprecationGetAttributeError.<locals>.<lambda>  s    $2E2E2R2Rr)   N)assertRaisesAttributeErrorr:   s   fr'   3test_esmtpClientTlsModeDeprecationGetAttributeError?SSLTestCase.test_esmtpClientTlsModeDeprecationGetAttributeError  s    
 	.*RSr)   c                    RV P                   n        V P                  V P                  .R7      pV P	                  \        V4      ^4       V P                  V^ ,          R,          \        4       V P	                  V^ ,          R,          R4       R# )rB  FrC  rE  r]   rF  N)r  rG  rH  %test_esmtpClientTlsModeDeprecationSetr   r  rJ  rK  )r.   rM  s   & r'   rX  1SSLTestCase.test_esmtpClientTlsModeDeprecationSet  s     ',#** $ J JK + 
 	]+Q/]1-j9;MN!Y'/	
r)   r$  N)r@   rA   rB   rC   rD   r  r  r,  r-  r  r/  r4  r9  r<  r?  rI  rU  rX  rE   rF   rG   s   @r'   r&  r&  >  sQ      DNOJMEQ>I=*
9&
"T
 
r)   r&  c                   .   a  ] tR tRt o RtRtR tRtV tR# )AbortableStringTransporti  zC
A version of L{StringTransport} that supports C{abortConnection}.
Fc                4    RV n         V P                  4        R# )z
A testable version of the C{ITCPTransport.abortConnection} method.

Since this is a special case of closing the connection,
C{loseConnection} is also called.
TN)abortingr   r:   s   &r'   abortConnection(AbortableStringTransport.abortConnection  s     r)   )r]  N)	r@   rA   rB   rC   rD   r]  r^  rE   rF   rG   s   @r'   r[  r[    s     
 H r)   r[  c                   Z   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# )SendmailTestsi  z*
Tests for L{twisted.mail.smtp.sendmail}.
c                    \         P                  ! \        P                  4      pV^,          pV P	                  \
        V^,          4       R# )zc
The default C{reactor} parameter of L{twisted.mail.smtp.sendmail} is
L{twisted.internet.reactor}.
N)inspectgetfullargspecr   sendmailr   r   )r.   fullSpecdefaultss   &  r'   "test_defaultReactorIsGlobalReactor0SendmailTests.test_defaultReactorIsGlobalReactor  s5    
 ))$--8A;(1+.r)   c                l   \        4       p\        P                  ! RRRRVVVRRR7	       VP                  ^ ,          ^,          pV P	                  VP
                  R4       V P	                  VP                  R4       V P	                  VP                  R4       V P	                  VP                  R4       R	# )
zS
L{twisted.mail.smtp.sendmail} creates the ESMTP factory with the ESMTP
arguments.
r)  r  r  r(  T)r   rM  r  r  r  r      barN)	r   r   re  
tcpClientsr   _requireTransportSecurity_requireAuthenticationrM  r  )r.   rM  r  r   r"  s   &&&  r'   _honorsESMTPArguments#SendmailTests._honorsESMTPArguments  s    
  /%)"&
	
 $$Q'*::DA77>))62))62r)   c                (    V P                  RRR7      # )z_
L{twisted.mail.smtp.sendmail} should accept C{username} and C{password}
which are L{unicode}.
r   barrM  r  ro  r:   s   &r'   &test_honorsESMTPArgumentsUnicodeUserPW4SendmailTests.test_honorsESMTPArgumentsUnicodeUserPW  s    
 ))55)IIr)   c                (    V P                  RRR7      # )z]
L{twisted.mail.smtp.sendmail} should accept C{username} and C{password}
which are L{bytes}.
r   rk  rs  rt  r:   s   &r'   $test_honorsESMTPArgumentsBytesUserPW2SendmailTests.test_honorsESMTPArgumentsBytesUserPW  s    
 ))6F)KKr)   c                    \        4       p\        R4      p\        P                  ! RRRVVR7       VP                  ^ ,          ^,          pV P                  VP                  V4       R# )zd
L{twisted.mail.smtp.sendmail} will pass through the message untouched
if it is a file-like object.
s   File!r)  r  r  r   N)r   r   r   re  rl  assertIsfile)r.   r   messageFiler"  s   &   r'   test_messageFilePassthrough)SendmailTests.test_messageFilePassthrough  sY    
  /h'	
 $$Q'*gllK0r)   c                    \        4       p\        P                  ! RRRRVR7       VP                  ^ ,          ^,          pVP                  pVP                  ^ 4       V P                  VP                  4       R4       R# )zt
L{twisted.mail.smtp.sendmail} will turn non-file-like objects
(eg. strings) into file-like objects before sending.
r)  r  r  r(  r{  N)r   r   re  rl  r}  seekr   r  )r.   r   r"  r~  s   &   r'   test_messageStringMadeFile(SendmailTests.test_messageStringMadeFile(  sm    
  /	
 $$Q'*ll))+Z8r)   c           	         \        4       p\        P                  ! RRRRVRR7       VP                  ^ ,          ^,          pV P	                  VP
                  R4       R# )	zS
L{twisted.mail.smtp.sendmail} passes through the sender domain name, if
provided.
r)  r  r  r(  r   )r   senderDomainNamer   N)r   r   re  rl  r   rL   )r.   r   r"  s   &  r'   test_senderDomainName#SendmailTests.test_senderDomainName:  sT    
  /"	
 $$Q'*0r)   c                *   \        4       p\        P                  ! RRRRVR7      pVP                  4        V P	                  VP
                  ^ ,          P                  R4       V P                  V4      pVP                  \        P                  4       R# )z
When a user cancels L{twisted.mail.smtp.sendmail} before the connection
is made, the connection is closed by
L{twisted.internet.interfaces.IConnector.disconnect}.
r)  r  r  r(  r{  TN)r   r   re  cancelr   
connectors_disconnectedfailureResultOftrapr   CancelledError)r.   r   r   failures   &   r'   test_cancelBeforeConnectionMade-SendmailTests.test_cancelBeforeConnectionMadeK  sv      /MM
 	

++A.<<dC&&q)U))*r)   c                   \        4       p\        4       p\        P                  ! RRRRVR7      pVP                  ^ ,          ^,          pVP                  R4      pVP                  V4       VP                  4        V P                  VP                  R4       V P                  VP                  R4       V P                  V4      pVP                  \        P                  4       R# )z
When a user cancels L{twisted.mail.smtp.sendmail} after the connection
is made, the connection is closed by
L{twisted.internet.interfaces.ITransport.abortConnection}.
r)  r  r  r(  r{  NT)r   r[  r   re  rl  r  r   r  r   r]  r   r  r  r   r  )r.   r   r   r   r"  r  r  s   &      r'   test_cancelAfterConnectionMade,SendmailTests.test_cancelAfterConnectionMade^  s      /,.	MM
 $$Q'*!!$'	#	
++T200$7&&q)U))*r)   r$   N)r@   rA   rB   rC   rD   rh  ro  ru  rx  r  r  r  r  r  rE   rF   rG   s   @r'   ra  ra    s>     /3.JL1$9$1"+&+ +r)   ra  c                V    V ^8  d   Qh/ ^ \         9   d   \        \        ,          ;R&   # )r4  r  )__conditional_annotations__r   r  )r7  s   "r'   r8  r8     s"      <  # =r)   )kr  rD   r  rc  rP   ior   typingr   r   r   r   r   zope.interfacer   r	   twisted.cred.checkersr  twisted.cred.credentialstwisted.cred.errortwisted.cred.portalr
   r   r   r   r   r   r   twisted.internetr   r   r   r   r   r   r   twisted.internet.testingr   r   twisted.mailr   twisted.mail._credr   twisted.protocolsr   r   twisted.python.utilr   twisted.trial.unittestr   twisted.test.ssl_helpersr    r!   r  ImportErrorIReactorSSLr  r(   IMessager+   rJ   ra   rt   rr   r   r   r   r   r   LineReceiverr   r   r   r   r  r  r  r  r  rC  rE  checkersrG  rm  r  ri  rs  r  r  r  r  r  r"  r  r&  r9  rX  rc  ro  r  r  r  r  r&  r[  ra  r8  )r  s   @r'   <module>r     s  
   	  3 3 8      K / 0 . W W W C  / - ' + K G ((11+G T]]  ( 62 2" 6-8T__ - Hd..  4 4
1U'' 1:r1h r1j' '&  
DII  TZZ  j jZ   
 
 T]]../- - 0-& T""#2 2 $2&I I
?- ?D:Qh :Qzm @x @";X ;$s
8] s
lx/E/E "!>X !>H=( =@ V8 8 8 Y Y"N
h N
bXGx XGvR8 RB%x %PGBX GBTO
( O
d &Q+H Q+}5  $#G$s   "L 	LL