§
    Ètºf  ã                   ó    — d Z ddlmZmZ ddlmZ ddlmZmZ ddl	m
Z
 ddlmZ  G d„ de¦  «        Z G d	„ d
¦  «        Z G d„ de¦  «        ZdS )z 
Tests for L{twisted.mail.tap}.
é    )ÚdeferÚ	endpoints)Ú	protocols)ÚOptionsÚmakeService)Ú
UsageError)ÚTestCasec                   óT   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zd
„ Zd„ Zd„ ZdS )ÚOptionsTestszK
    Tests for the command line option parser used for I{twistd mail}.
    c                 ó¾   — |                       ¦   «         | _        t          | j        d¦  «        5 }|                     d¦  «         d d d ¦  «         d S # 1 swxY w Y   d S )NÚwzsomeuser:	differentuser
)ÚmktempÚaliasFilenameÚopenÚwrite)ÚselfÚ	aliasFiles     ú]/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/twisted/mail/test/test_options.pyÚsetUpzOptionsTests.setUp   s™   € Ø!Ÿ[š[™]œ]ˆÔÝ�$Ô$ cÑ*Ô*ð 	:¨iØ�OŠOÐ8Ñ9Ô9Ð9ð	:ð 	:ð 	:ñ 	:ô 	:ð 	:ð 	:ð 	:ð 	:ð 	:ð 	:ð 	:øøøð 	:ð 	:ð 	:ð 	:ð 	:ð 	:s   ¯AÁAÁAc                 ón   — |                       t          t          ¦   «         j        d| j        g¦  «         dS )zi
        Test that adding an aliases(5) file before adding a domain raises a
        UsageError.
        ú	--aliasesN)ÚassertRaisesr   r   ÚparseOptionsr   ©r   s    r   ÚtestAliasesWithoutDomainz%OptionsTests.testAliasesWithoutDomain   s<   € ð
 	×ÒÝ�™	œ	Ô.°¸dÔ>PÐ0Qñ	
ô 	
ð 	
ð 	
ð 	
ó    c                 óZ   — t          ¦   «                              ddd| j        g¦  «         dS )zƒ
        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   ÚtestAliaseszOptionsTests.testAliases"   s>   € õ
 	‰	Œ	×Òà$Ø)ØØÔ"ð	ñ	
ô 	
ð 	
ð 	
ð 	
r   c                 ó   — t          ¦   «         }|                     d|z   dg¦  «         |                      t          ||         ¦  «        d¦  «         |                      ||         d         t
          j        ¦  «         dS )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   Ú_endpointTestzOptionsTests._endpointTest0   sv   € õ ‘)”)ˆØ×Ò˜d W™n¨jÐ9Ñ:Ô:Ð:Ø×Ò�˜W WÔ-Ñ.Ô.°Ñ2Ô2Ð2Ø×Ò˜g gÔ.¨qÔ1µ9Ô3OÑPÔPÐPÐPÐPr   c                 ó0   — |                       d¦  «         dS )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_endpointSMTPzOptionsTests.test_endpointSMTP;   ó   € ð
 	×Ò˜6Ñ"Ô"Ð"Ð"Ð"r   c                 ó0   — |                       d¦  «         dS )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_endpointPOP3zOptionsTests.test_endpointPOP3B   r-   r   c                 ó   — t          ¦   «         }|                     g ¦  «         |                      t          |d         ¦  «        d¦  «         |                      |d         d         t
          j        ¦  «         |                      t          |d         ¦  «        d¦  «         |                      |d         d         t
          j        ¦  «         dS )zO
        POP3 and SMTP each listen on a TCP4ServerEndpoint by default.
        r/   r    r   r*   Nr!   ©r   r'   s     r   Útest_protoDefaultszOptionsTests.test_protoDefaultsI   s¯   € õ ‘)”)ˆØ×Ò˜RÑ Ô Ð à×Ò�˜W Vœ_Ñ-Ô-¨qÑ1Ô1Ð1Ø×Ò˜g fœo¨aÔ0µ)Ô2NÑOÔOÐOà×Ò�˜W Vœ_Ñ-Ô-¨qÑ1Ô1Ð1Ø×Ò˜g fœo¨aÔ0µ)Ô2NÑOÔOÐOÐOÐOr   c                 óæ  — t          ¦   «         }|                     dg¦  «         |                      |                     dd¦  «        g ¦  «         |                      |                     dd¦  «        g ¦  «         t          ¦   «         }|                     dg¦  «         |                      |                     dd¦  «        g ¦  «         |                      |                     dd¦  «        g ¦  «         dS )zg
        The I{--no-pop3} and I{--no-smtp} options disable POP3 and SMTP
        respectively.
        ú	--no-pop3Nr/   r*   ú	--no-smtp)r   r   r"   Ú_getEndpointsÚassertNotEqualr2   s     r   Útest_protoDisablezOptionsTests.test_protoDisableV   sà   € õ
 ‘)”)ˆØ×Ò˜k˜]Ñ+Ô+Ð+Ø×Ò˜×.Ò.¨t°VÑ<Ô<¸bÑAÔAÐAØ×Ò˜G×1Ò1°$¸Ñ?Ô?ÀÑDÔDÐDå‘)”)ˆØ×Ò˜k˜]Ñ+Ô+Ð+Ø×Ò˜G×1Ò1°$¸Ñ?Ô?ÀÑDÔDÐDØ×Ò˜×.Ò.¨t°VÑ<Ô<¸bÑAÔAÐAÐAÐAr   c                 óh   — t          ¦   «         }|                      t          |j        ddg¦  «         dS )zI
        If all protocols are disabled, L{UsageError} is raised.
        r5   r6   N)r   r   r   r   r2   s     r   Útest_allProtosDisabledErrorz(OptionsTests.test_allProtosDisabledErrore   s>   € õ ‘)”)ˆØ×ÒÝ˜Ô,°¸[Ð/Iñ	
ô 	
ð 	
ð 	
ð 	
r   c                 ó¬   — t          ¦   «         }|                      t          |j        dg¦  «        }|                      dt          |¦  «        ¦  «         dS )zu
        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_esmtpWithoutHostnamez&OptionsTests.test_esmtpWithoutHostnamen   sL   € õ
 ‘)”)ˆØ×Ò¥
¨GÔ,@À9À+ÑNÔNˆØ×ÒÐ6½¸C¹¼ÑAÔAÐAÐAÐAr   c                 ó0  — t          ¦   «         }|                     ddg¦  «         |                      t          |d         ¦  «        d¦  «         |d         d         }|j        }|j        j        j        }|D ]}|                      |||         ¦  «         ŒdS )zC
        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_authzOptionsTests.test_authw   s«   € õ ‘)”)ˆØ×Ò˜hÐ(IÐJÑKÔKÐKØ×Ò�˜W ^Ô4Ñ5Ô5°qÑ9Ô9Ð9Ø˜.Ô)¨!Ô,ˆØÔ1ˆ
Ø%œoÔ8ÔAÐØð 	Bð 	BˆEØ×Ò˜WÐ&9¸%Ô&@ÑAÔAÐAÐAð	Bð 	Br   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r(   r,   r0   r3   r9   r;   r?   rI   © r   r   r   r      sÔ   € € € € € ðð ð:ð :ð :ð

ð 
ð 
ð
ð 
ð 
ð	Qð 	Qð 	Qð#ð #ð #ð#ð #ð #ðPð Pð PðBð Bð Bð
ð 
ð 
ðBð Bð BðBð Bð Bð Bð Br   r   c                   ó   — e Zd ZdZdZd„ ZdS )ÚSpyEndpointzG
    SpyEndpoint remembers what factory it is told to listen with.
    Nc                 ó8   — || _         t          j        d ¦  «        S )N)ÚlisteningWithr   Úsucceed)r   Úfactorys     r   ÚlistenzSpyEndpoint.listenŒ   s   € Ø$ˆÔÝŒ}˜TÑ"Ô"Ð"r   )rJ   rK   rL   rM   rR   rU   rN   r   r   rP   rP   …   s4   € € € € € ðð ð €Mð#ð #ð #ð #ð #r   rP   c                   ó$   — e Zd ZdZd„ Zd„ Zd„ ZdS )ÚMakeServiceTestsz3
    Tests for L{twisted.mail.tap.makeService}
    c                 óv  — t          ¦   «         }t          ¦   «         }t          ¦   «         }||g||<   t          |¦  «        }|                     ¦   «          |                     ¦   «          |                      |j        ¦  «         |                      |j        |¦  «         |                      |j        |¦  «         dS )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)	rP   r   r   ÚprivilegedStartServiceÚstartServiceÚ
addCleanupÚstopServicer$   rR   )r   ÚkeyÚfactoryClassÚ	cleartextÚsecureÚconfigr&   s          r   Ú_endpointServerTestz$MakeServiceTests._endpointServerTest–   s«   € õ  ‘M”Mˆ	Ý‘”ˆÝ‘”ˆØ  &Ð)ˆˆs‰Ý˜fÑ%Ô%ˆØ×&Ò&Ñ(Ô(Ð(Ø×ÒÑÔÐØ�Š˜Ô+Ñ,Ô,Ð,Ø×Ò˜iÔ5°|ÑDÔDÐDØ×Ò˜fÔ2°LÑAÔAÐAÐAÐAr   c                 óF   — |                       dt          j        ¦  «         dS )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.
        r/   N)rb   r   ÚPOP3Factoryr   s    r   Ú	test_pop3zMakeServiceTests.test_pop3§   ó#   € ð 	× Ò  ­Ô)>Ñ?Ô?Ð?Ð?Ð?r   c                 óF   — |                       dt          j        ¦  «         dS )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)rb   r   ÚSMTPFactoryr   s    r   Ú	test_smtpzMakeServiceTests.test_smtp°   rf   r   N)rJ   rK   rL   rM   rb   re   ri   rN   r   r   rW   rW   ‘   sV   € € € € € ðð ðBð Bð Bð"@ð @ð @ð@ð @ð @ð @ð @r   rW   N)rM   Útwisted.internetr   r   Útwisted.mailr   Útwisted.mail.tapr   r   Útwisted.python.usager   Útwisted.trial.unittestr	   r   rP   rW   rN   r   r   ú<module>ro      s  ððð ð .Ð -Ð -Ð -Ð -Ð -Ð -Ð -Ø "Ð "Ð "Ð "Ð "Ð "Ø 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1Ø +Ð +Ð +Ð +Ð +Ð +Ø +Ð +Ð +Ð +Ð +Ð +ðsBð sBð sBð sBð sB�8ñ sBô sBð sBðl	#ð 	#ð 	#ð 	#ð 	#ñ 	#ô 	#ð 	#ð&@ð &@ð &@ð &@ð &@�xñ &@ô &@ð &@ð &@ð &@r   