ó
    Ö›‘h  ã                   óŒ   • S r SSKJrJr  SSKJr  SSKJrJr  SSK	J
r
  SSKJr   " S S\5      r " S	 S
5      r " S S\5      rg)z 
Tests for L{twisted.mail.tap}.
é    )ÚdeferÚ	endpoints)Ú	protocols)ÚOptionsÚmakeService)Ú
UsageError)ÚTestCasec                   óZ   • \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rS rSrg)ÚOptionsTestsé   zC
Tests for the command line option parser used for I{twistd mail}.
c                 ó°   • U R                  5       U l        [        U R                  S5       nUR                  S5        S S S 5        g ! , (       d  f       g = f)NÚwzsomeuser:	differentuser
)ÚmktempÚaliasFilenameÚopenÚwrite)ÚselfÚ	aliasFiles     ÚbC:\Users\psant\Downloads\Noiseback\school\venv\Lib\site-packages\twisted/mail/test/test_options.pyÚsetUpÚOptionsTests.setUp   s;   € Ø!Ÿ[™[›]ˆÔÜ�$×$Ñ$ cÔ*¨iØ�O‰OÐ8Ô9÷ +×*Ö*ús   ¬AÁ
Ac                 ón   • U R                  [        [        5       R                  SU R                  /5        g)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Ñ>PÐ0Qõ	
ó    c                 óR   • [        5       R                  SSSU R                  /5        g)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                 óÈ   • [        5       nUR                  SU-   S/5        U R                  [        X!   5      S5        U R	                  X!   S   [
        R                  5        g)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:1234é   r   N©r   r   ÚassertEqualÚlenÚassertIsInstancer   ÚTCP4ServerEndpoint)r   ÚserviceÚoptionss      r   Ú_endpointTestÚOptionsTests._endpointTest0   sX   € ô “)ˆØ×Ñ˜d W™n¨jÐ9Ô:Ø×Ñœ˜WÑ-Ó.°Ô2Ø×Ñ˜gÑ.¨qÑ1´9×3OÑ3OÕPr   c                 ó&   • U R                  S5        g)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                 ó&   • U R                  S5        g)z€
When I{--pop3} is given a TCP endpoint description as an argument, a
TCPServerEndpoint is added to the list of POP3 endpoints.
Úpop3Nr0   r   s    r   Útest_endpointPOP3ÚOptionsTests.test_endpointPOP3B   r3   r   c                 óJ  • [        5       nUR                  / 5        U R                  [        US   5      S5        U R	                  US   S   [
        R                  5        U R                  [        US   5      S5        U R	                  US   S   [
        R                  5        g)z?
POP3 and SMTP each listen on a TCP4ServerEndpoint by default.
r5   r$   r   r/   Nr%   ©r   r+   s     r   Útest_protoDefaultsÚOptionsTests.test_protoDefaultsI   s‰   € ô “)ˆØ×Ñ˜RÔ à×Ñœ˜W V™_Ó-¨qÔ1Ø×Ñ˜g f™o¨aÑ0´)×2NÑ2NÔOà×Ñœ˜W V™_Ó-¨qÔ1Ø×Ñ˜g f™o¨aÑ0´)×2NÑ2NÕOr   c                 ó„  • [        5       nUR                  S/5        U R                  UR                  SS5      / 5        U R	                  UR                  SS5      / 5        [        5       nUR                  S/5        U R	                  UR                  SS5      / 5        U R                  UR                  SS5      / 5        g)zO
The I{--no-pop3} and I{--no-smtp} options disable POP3 and SMTP
respectively.
ú	--no-pop3Nr5   r/   ú	--no-smtp)r   r   r&   Ú_getEndpointsÚassertNotEqualr9   s     r   Útest_protoDisableÚOptionsTests.test_protoDisableV   s¦   € ô
 “)ˆØ×Ñ˜k˜]Ô+Ø×Ñ˜×.Ñ.¨t°VÓ<¸bÔAØ×Ñ˜G×1Ñ1°$¸Ó?ÀÔDä“)ˆØ×Ñ˜k˜]Ô+Ø×Ñ˜G×1Ñ1°$¸Ó?ÀÔDØ×Ñ˜×.Ñ.¨t°VÓ<¸bÕAr   c                 ó^   • [        5       nU R                  [        UR                  SS/5        g)z9
If all protocols are disabled, L{UsageError} is raised.
r=   r>   N)r   r   r   r   r9   s     r   Útest_allProtosDisabledErrorÚ(OptionsTests.test_allProtosDisabledErrore   s+   € ô “)ˆØ×ÑÜ˜×,Ñ,°¸[Ð/Iõ	
r   c                 ó’   • [        5       nU R                  [        UR                  S/5      nU R	                  S[        U5      5        g)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                 ó  • [        5       nUR                  SS/5        U R                  [        US   5      S5        US   S   nUR                  nUR
                  R                  R                  nU H  nU R                  X$U   5        M     g)z3
Tests that the --auth option registers a checker.
z--authzmemory:admin:admin:bob:passwordÚcredCheckersr$   r   N)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Ó5°qÔ9Ø˜.Ñ)¨!Ñ,ˆØ×1Ñ1ˆ
Ø%Ÿo™o×8Ñ8×AÑAÐÛˆEØ×Ñ˜W¸%Ñ&@ÖAò  r   )r   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r   r!   r,   r1   r6   r:   rA   rD   rI   rT   Ú__static_attributes__© r   r   r   r      sC   † ñò:ò

ò
ò	Qò#ò#òPòBò
òBõBr   r   c                   ó"   • \ rS rSrSrSrS rSrg)ÚSpyEndpointé…   z?
SpyEndpoint remembers what factory it is told to listen with.
Nc                 ó:   • Xl         [        R                  " S 5      $ )N)ÚlisteningWithr   Úsucceed)r   Úfactorys     r   ÚlistenÚSpyEndpoint.listenŒ   s   € Ø$ÔÜ�}Š}˜TÓ"Ð"r   )ra   )rV   rW   rX   rY   rZ   ra   rd   r[   r\   r   r   r^   r^   …   s   † ñð €Mõ#r   r^   c                   ó*   • \ rS rSrSrS rS rS rSrg)ÚMakeServiceTestsé‘   z+
Tests for L{twisted.mail.tap.makeService}
c                 óF  • [        5       n[        5       n[        5       nX4/XQ'   [        U5      nUR                  5         UR	                  5         U R                  UR                  5        U R                  UR                  U5        U R                  UR                  U5        g)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(   ra   )r   ÚkeyÚfactoryClassÚ	cleartextÚsecureÚconfigr*   s          r   Ú_endpointServerTestÚ$MakeServiceTests._endpointServerTest–   sƒ   € ô  “Mˆ	Ü“ˆÜ“ˆØ Ð)ˆ‰Ü˜fÓ%ˆØ×&Ñ&Ô(Ø×ÑÔØ�‰˜×+Ñ+Ô,Ø×Ñ˜i×5Ñ5°|ÔDØ×Ñ˜f×2Ñ2°LÕAr   c                 óD   • U R                  S[        R                  5        g)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.
r5   N)rs   r   ÚPOP3Factoryr   s    r   Ú	test_pop3ÚMakeServiceTests.test_pop3§   ó   € ð 	× Ñ  ¬×)>Ñ)>Õ?r   c                 óD   • U R                  S[        R                  5        g)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)rs   r   ÚSMTPFactoryr   s    r   Ú	test_smtpÚMakeServiceTests.test_smtp°   ry   r   r\   N)	rV   rW   rX   rY   rZ   rs   rw   r|   r[   r\   r   r   rg   rg   ‘   s   † ñòBò"@õ@r   rg   N)rZ   Útwisted.internetr   r   Útwisted.mailr   Útwisted.mail.tapr   r   Útwisted.python.usager   Útwisted.trial.unittestr	   r   r^   rg   r\   r   r   Ú<module>rƒ      sD   ðñ÷ .Ý "ß 1Ý +Ý +ôsB�8ô sB÷l	#ñ 	#ô&@�xõ &@r   