+
    Dfj                         R t ^ RIHtHt ^ RIHt ^ RIHtHt ^ RI	H
t
 ^ RIHt  ! R R]4      t ! R R	4      t ! R
 R]4      tR# )z 
Tests for L{twisted.mail.tap}.
)defer	endpoints)	protocols)OptionsmakeService)
UsageError)TestCasec                   f   a  ] tR t^t 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V tR# )OptionsTestszC
Tests for the command line option parser used for I{twistd mail}.
c                    V P                  4       V n        \        V P                  R 4      ;_uu_ 4       pVP                  R4       RRR4       R#   + '       g   i     R# ; i)wzsomeuser:	differentuser
N)mktempaliasFilenameopenwrite)self	aliasFiles   & @/usr/lib/python3/dist-packages/twisted/mail/test/test_options.pysetUpOptionsTests.setUp   sA    ![[]$$$c**iOO89 +***s   AA!	c                p    V P                  \        \        4       P                  RV P                  .4       R# )zQ
Test that adding an aliases(5) file before adding a domain raises a
UsageError.
	--aliasesN)assertRaisesr   r   parseOptionsr   r   s   &r   testAliasesWithoutDomain%OptionsTests.testAliasesWithoutDomain   s,    
 		..d>P>P0Q	
    c                T    \        4       P                  RRRV P                  .4       R# )zk
Test that adding an aliases(5) file to an IAliasableDomain at least
doesn't raise an unhandled exception.
z--maildirdbmdomainzexample.com=example.comr   N)r   r   r   r   s   &r   testAliasesOptionsTests.testAliases"   s+    
 		$)""		
r   c                    \        4       pVP                  RV,           R.4       V P                  \        W!,          4      ^4       V P	                  W!,          ^ ,          \
        P                  4       R# )z
Use L{Options} to parse a single service configuration parameter and
verify that an endpoint of the correct type is added to the list for
that service.
z--ztcp:1234Nr   r   assertEquallenassertIsInstancer   TCP4ServerEndpoint)r   serviceoptionss   && r   _endpointTestOptionsTests._endpointTest0   sX     )dWnj9:W-.2g.q193O3OPr   c                (    V P                  R4       R# )z
When I{--smtp} is given a TCP endpoint description as an argument, a
TCPServerEndpoint is added to the list of SMTP endpoints.
smtpNr)   r   s   &r   test_endpointSMTPOptionsTests.test_endpointSMTP;       
 	6"r   c                (    V P                  R4       R# )z
When I{--pop3} is given a TCP endpoint description as an argument, a
TCPServerEndpoint is added to the list of POP3 endpoints.
pop3Nr-   r   s   &r   test_endpointPOP3OptionsTests.test_endpointPOP3B   r0   r   c                |   \        4       pVP                  . 4       V P                  \        VR,          4      ^4       V P	                  VR,          ^ ,          \
        P                  4       V P                  \        VR,          4      ^4       V P	                  VR,          ^ ,          \
        P                  4       R# )z?
POP3 and SMTP each listen on a TCP4ServerEndpoint by default.
r2   r,   Nr"   r   r(   s   & r   test_protoDefaultsOptionsTests.test_protoDefaultsI   s     )R WV_-q1gfoa0)2N2NOWV_-q1gfoa0)2N2NOr   c                   \        4       pVP                  R.4       V P                  VP                  RR4      . 4       V P	                  VP                  RR4      . 4       \        4       pVP                  R.4       V P	                  VP                  RR4      . 4       V P                  VP                  RR4      . 4       R# )zO
The I{--no-pop3} and I{--no-smtp} options disable POP3 and SMTP
respectively.
	--no-pop3Nr2   r,   	--no-smtp)r   r   r#   _getEndpointsassertNotEqualr6   s   & r   test_protoDisableOptionsTests.test_protoDisableV   s    
 )k]+..tV<bAG11$?D)k]+G11$?D..tV<bAr   c                `    \        4       pV P                  \        VP                  RR.4       R# )z9
If all protocols are disabled, L{UsageError} is raised.
r:   r;   N)r   r   r   r   r6   s   & r   test_allProtosDisabledError(OptionsTests.test_allProtosDisabledErrore   s+     ),,[/I	
r   c                    \        4       pV P                  \        VP                  R.4      pV P	                  R\        V4      4       R# )z]
If I{--esmtp} is given without I{--hostname}, L{Options.parseOptions}
raises L{UsageError}.
z--esmtpz--esmtp requires --hostnameN)r   r   r   r   r#   str)r   r(   excs   &  r   test_esmtpWithoutHostname&OptionsTests.test_esmtpWithoutHostnamen   s<    
 )
G,@,@9+N6CAr   c                >   \        4       pVP                  RR.4       V P                  \        VR,          4      ^4       VR,          ^ ,          pVP                  pVP
                  P                  P                  pV F  pV P                  W$V,          4       K  	  R# )z3
Tests that the --auth option registers a checker.
z--authzmemory:admin:admin:bob:passwordcredCheckersN)r   r   r#   r$   credentialInterfacesr'   
smtpPortalcheckers)r   r(   checker
interfacesregistered_checkersifaces   &     r   	test_authOptionsTests.test_authw   s     )h(IJKW^45q9.)!,11
%oo88AAEW%&@A  r   )r   N)__name__
__module____qualname____firstlineno____doc__r   r   r   r)   r.   r3   r7   r>   rA   rF   rQ   __static_attributes____classdictcell____classdict__s   @r   r
   r
      sL     :


	Q##PB
BB Br   r
   c                   .   a  ] tR t^t o RtRtR tRtV tR# )SpyEndpointz?
SpyEndpoint remembers what factory it is told to listen with.
Nc                :    Wn         \        P                  ! R 4      # )N)listeningWithr   succeed)r   factorys   &&r   listenSpyEndpoint.listen   s    $}}T""r   )r_   )	rS   rT   rU   rV   rW   r_   rb   rX   rY   rZ   s   @r   r]   r]      s      M# #r   r]   c                   6   a  ] tR t^t o RtR tR tR tRtV t	R# )MakeServiceTestsz+
Tests for L{twisted.mail.tap.makeService}
c                H   \        4       p\        4       p\        4       pW4.WQ&   \        V4      pVP                  4        VP	                  4        V P                  VP                  4       V P                  VP                  V4       V P                  VP                  V4       R# )z
Configure a service with two endpoints for the protocol associated with
C{key} and verify that when the service is started a factory of type
C{factoryClass} is used to listen on each of them.
N)	r]   r   r   privilegedStartServicestartService
addCleanupstopServicer%   r_   )r   keyfactoryClass	cleartextsecureconfigr'   s   &&&    r   _endpointServerTest$MakeServiceTests._endpointServerTest   s      M	 )f%&&(++,i55|Df22LAr   c                F    V P                  R\        P                  4       R# )z
If one or more endpoints is included in the configuration passed to
L{makeService} for the C{"pop3"} key, a service for starting a POP3
server is constructed for each of them and attached to the returned
service.
r2   N)rp   r   POP3Factoryr   s   &r   	test_pop3MakeServiceTests.test_pop3        	  )>)>?r   c                F    V P                  R\        P                  4       R# )z
If one or more endpoints is included in the configuration passed to
L{makeService} for the C{"smtp"} key, a service for starting an SMTP
server is constructed for each of them and attached to the returned
service.
r,   N)rp   r   SMTPFactoryr   s   &r   	test_smtpMakeServiceTests.test_smtp   rv   r    N)
rS   rT   rU   rV   rW   rp   rt   ry   rX   rY   rZ   s   @r   re   re      s"     B"@@ @r   re   N)rW   twisted.internetr   r   twisted.mailr   twisted.mail.tapr   r   twisted.python.usager   twisted.trial.unittestr   r
   r]   re   r{   r   r   <module>r      sD    . " 1 + +sB8 sBl	# 	#&@x &@r   