+
    üÐjý&  ã                   ó˜   € R t ^ RIHtHt ^ RIHt ^ RIHt ^ RIH	t	H
t
Ht ^ RIHt  ! R R]4      t ! R R	]4      tR
t ! R R]4      tR# )z5
Tests for IRC portions of L{twisted.words.service}.
)ÚcheckersÚportal)Úproto_helpers)Úirc)ÚInMemoryWordsRealmÚ
IRCFactoryÚIRCUser)ÚIRCTestCasec                   ó`   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V tR# )ÚIRCUserTestsz
Isolated tests for L{IRCUser}
c                óü  € \        R4      V n        \        P                  ! 4       V n        \
        P                  ! V P                  V P                  .4      V n        V P                  P                  RR4       \        V P                  V P
                  4      V n	        V P                  P                  R4      V n        \        P                  ! 4       V n        V P                  P                  V P                  4       R# )zU
Sets up a Realm, Portal, Factory, IRCUser, Transport, and Connection
for our tests.
úexample.comÚjohnÚpassN)r   Úrealmr   Ú'InMemoryUsernamePasswordDatabaseDontUseÚcheckerr   ÚPortalÚaddUserr   ÚfactoryÚbuildProtocolÚircUserr   ÚStringTransportÚstringTransportÚmakeConnection©Úselfs   &ÚE/usr/lib/python3/dist-packages/twisted/words/test/test_irc_service.pyÚsetUpÚIRCUserTests.setUp   s¥   € ô
 (¨Ó6ˆŒ
Ü×GÒGÓIˆŒÜ—m’m D§J¡J°·±°Ó?ˆŒØ�‰×Ñ˜V VÔ,Ü! $§*¡*¨d¯k©kÓ:ˆŒØ—|‘|×1Ñ1°$Ó7ˆŒÜ,×<Ò<Ó>ˆÔØ�‰×#Ñ# D×$8Ñ$8Ö9ó    c                óþ   € V P                   P                  RR.4       V P                  P                  4        V P                   P	                  R4       V P                  V P                  P                  4       R4       R# )z…
Sending a message to a user after they have sent NICK, but before they
have authenticated, results in a message from "example.com".
Ú ÚmynickÚfooz:example.com foo mynick
N)r   Úirc_NICKr   ÚclearÚsendMessageÚassertEqualBufferValueÚvaluer   s   &r   Útest_sendMessageÚIRCUserTests.test_sendMessage"   sa   € ð
 	�‰×Ñ˜b 8 *Ô-Ø×Ñ×"Ñ"Ô$Ø�‰× Ñ  Ô'Ø×#Ñ#Ø× Ñ ×&Ñ&Ó(Ð*Gö	
r    c                óV  € RP                  4       pV P                  P                  RRP                  4       .4       V P                  P	                  4        V P                  P                  RP                  4       4       V P                  V P                  P                  4       V4       R# )z¡
When a UTF8 message is sent with sendMessage and the current IRCUser
has a UTF8 nick and is set to UTF8 encoding, the message will be
written to the transport.
u   :example.com Ñ‚ÐµÑ�Ñ‚ Ð½Ð¸Ðº
r"   u   Ð½Ð¸Ðºu   Ñ‚ÐµÑ�Ñ‚N)Úencoder   r%   r   r&   r'   r(   r)   )r   ÚexpectedResults   & r   Útest_utf8MessagesÚIRCUserTests.test_utf8Messages.   s€   € ð <×BÑBÓDˆà�‰×Ñ˜bÐ#7×#>Ñ#>Ó#@Ð"AÔBØ×Ñ×"Ñ"Ô$Ø�‰× Ñ Ð!;×!BÑ!BÓ!DÔEØ×#Ñ# D×$8Ñ$8×$>Ñ$>Ó$@À.ÖQr    c                ój   € V P                   P                  RR.4       V P                  \        4       R# )z¶
A NICK command sent with a nickname that cannot be decoded with the
current IRCUser's encoding results in a PRIVMSG from NickServ
indicating that the nickname could not be decoded.
r"   s   ÔÅÓÔN)r   r%   ÚassertRaisesÚUnicodeErrorr   s   &r   Útest_invalidEncodingNickÚ%IRCUserTests.test_invalidEncodingNick;   s*   € ð 	�‰×Ñ˜bÐ#6Ð"7Ô8Ø×Ñœ,Ö'r    c                ó*  € V P                   P                  P                  4       pV P                   P                  P                  4        VP	                  R4      pVP                  4       pV Uu. uF  p\        P                  ! V4      NK  	  up# u upi )z3
Grabs our responses and then clears the transport
zutf-8)r   Ú	transportr)   r&   ÚdecodeÚ
splitlinesr   Úparsemsg)r   ÚresponseÚrs   &  r   r;   ÚIRCUserTests.responseD   sn   € ð —<‘<×)Ñ)×/Ñ/Ó1ˆØ�‰×Ñ×$Ñ$Ô&Ø—?‘? 7Ó+ˆØ×&Ñ&Ó(ˆÙ)1Ó2© A”—’˜Q–©Ñ2Ð2ùÒ2s   Á.Bc              #  ó`   "  € \        V4       F  w  r4V^,          V8X  g   K  W43x € K  	  R# 5i)a  
Gets messages out of a response

@param response: The parsed IRC messages of the response, as returned
by L{IRCUserTests.response}

@param messageType: The string type of the desired messages.

@return: An iterator which yields 2-tuples of C{(index, ircMessage)}
N)Ú	enumerate)r   r;   ÚmessageTypeÚnÚmessages   &&&  r   ÚscanResponseÚIRCUserTests.scanResponseN   s,   é € ô $ HÖ-‰JˆAØ�q�z˜[Ö(Ø�jÔ ó .ùs   ‚.£.c                ól  € V P                   P                  RR.4       V P                  4       p\        V P	                  V\
        P                  4      4      p\        V P	                  V\
        P                  4      4      pV P                  V^ RRRR.33.4       V P                  V^RRRR.33.4       R# )	zÐ
Receiving NICK without authenticating sends the MOTD Start and MOTD End
messages, which is required by certain popular IRC clients (such as
Pidgin) before a connection is considered to be fully established.
r"   r#   r   Ú375ú#- example.com Message of the Day - Ú376úEnd of /MOTD command.N)	r   r%   r;   ÚlistrC   r   ÚRPL_MOTDSTARTÚRPL_ENDOFMOTDÚassertEqual)r   r;   ÚstartÚends   &   r   Útest_sendNickSendsGreetingÚ'IRCUserTests.test_sendNickSendsGreeting]   s½   € ð 	�‰×Ñ˜b 8 *Ô-Ø—=‘=“?ˆÜ�T×&Ñ& x´×1BÑ1BÓCÓDˆÜ�4×$Ñ$ X¬s×/@Ñ/@ÓAÓBˆØ×ÑØð à%ØØ!Ð#HÐIððð	ô	
ð 	×ÑØ�1�} e¨hÐ8OÐ-PÐQÐRÐSö	
r    c                ó(  € V P                   P                  RR.4       V P                   P                  RR.4       V P                   P                  RR.4       RP	                  V P
                  P                  R,          4      pRP	                  V P
                  P                  R,          4      pV P                  V P                  4       R	R
RR.3R	RRR.3R	RRR.3R	RRV.3R	RRV.3R	RRR	V P
                  P                  R,          RR.3.4       R# )zb
Receiving USER, PASS, NICK will log in the user, and transmit the
appropriate response messages.
r"   zjohn doer   r   z,Your host is example.com, running version {}ÚserviceVersionzThis server was created on {}ÚcreationDater   rF   rG   rH   rI   Ú001zconnected to Twisted IRCÚ002Ú003Ú004ÚwrA   N)	r   Úirc_USERÚirc_PASSr%   Úformatr   Ú_serverInforM   r;   )r   ÚversionÚcreations   &  r   Útest_fullLoginÚIRCUserTests.test_fullLoginx   s(  € ð
 	�‰×Ñ˜b : ,Ô/Ø�‰×Ñ˜b 6 (Ô+Ø�‰×Ñ˜b 6 (Ô+à@×GÑGØ�L‰L×$Ñ$Ð%5Õ6ó
ˆð 3×9Ñ9Ø�L‰L×$Ñ$ ^Õ4ó
ˆð 	×ÑØ�M‰M‹Oà ¨Ð0UÐ'VÐWØ ¨Ð0GÐ'HÐIØ ¨Ð0JÐ'KÐLØ ¨°Ð'8Ð9Ø ¨°Ð'9Ð:à!ØàØ%ØŸ™×0Ñ0Ð1AÕBØØðð
ðö	
r    c                ó  € V P                   P                  RR.4       V P                  4       pV P                   P                  P	                  4        V P                  V^ ,          ^,          \        P                  4       V P                   P                  RR.4       V P                  4       pV P                   P                  P	                  4        V P                  V^ ,          ^,          \        P                  4       V P                   P                  RRR.4       V P                  4       pV P                   P                  P	                  4        V P                  V^ ,          ^,          \        P                  4       V P                   P                  RRR.4       V P                  4       pV P                   P                  P	                  4        V P                  V^ ,          ^,          \        P                  4       R# )z

irc_PART
Útestuserr#   Úsomechannels   somechannels   boogaÚboogaN)r   r%   r;   r7   r&   rM   r   rK   Úirc_JOINÚERR_NOSUCHCHANNELÚirc_PARTÚERR_NOTONCHANNEL©r   r;   s   & r   Ú	test_PARTÚIRCUserTests.test_PARTŸ   s^  € ð 	�‰×Ñ˜j¨8¨*Ô5Ø—=‘=“?ˆØ�‰×Ñ×$Ñ$Ô&Ø×Ñ˜ !� Q�¬×):Ñ):Ô;Ø�‰×Ñ˜j¨=¨/Ô:Ø—=‘=“?ˆØ�‰×Ñ×$Ñ$Ô&Ø×Ñ˜ !� Q�¬×)>Ñ)>Ô?Ø�‰×Ñ˜j¨>¸8Ð*DÔEØ—=‘=“?ˆØ�‰×Ñ×$Ñ$Ô&Ø×Ñ˜ !� Q�¬×)=Ñ)=Ô>Ø�‰×Ñ˜j¨=¸'Ð*BÔCØ—=‘=“?ˆØ�‰×Ñ×$Ñ$Ô&Ø×Ñ˜ !� Q�¬×)=Ñ)=Ö>r    c                óx  € V P                   P                  RR.4       V P                   P                  RR.4       V P                   P                  P	                  4        V P                   P                  RR.4       V P                  4       pV P                  V^ ,          ^,          \        P                  4       R# )z
irc_NAMES
r"   rc   rd   N)
r   r%   rf   r7   r&   Ú	irc_NAMESr;   rM   r   ÚRPL_ENDOFNAMESrj   s   & r   Ú
test_NAMESÚIRCUserTests.test_NAMES´   s…   € ð 	�‰×Ñ˜b : ,Ô/Ø�‰×Ñ˜b = /Ô2Ø�‰×Ñ×$Ñ$Ô&Ø�‰×Ñ˜r M ?Ô3Ø—=‘=“?ˆØ×Ñ˜ !� Q�¬×);Ñ);Ö<r    )r   r   r   r   r   r   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r*   r/   r4   r;   rC   rP   r`   rk   rp   Ú__static_attributes__Ú__classdictcell__©Ú__classdict__s   @r   r   r      sC   ø‡ € ñò:ò

òRò(ò3ò!ò
ò6%
òN?÷*	=ð 	=r    r   c                   ó,   a € ] tR t^Àt o R tR tRtV tR# )ÚMocksyIRCUserc                ó4   € \        R 4      V n        . V n        R# )r   N)r   r   ÚmockedCodesr   s   &r   Ú__init__ÚMocksyIRCUser.__init__Á   s   € Ü'¨Ó6ˆŒ
ØˆÖr    c                ó<   € V P                   P                  V4       R # ©N)r~   Úappend)r   ÚcodeÚ_Ú__s   &&*,r   r'   ÚMocksyIRCUser.sendMessageÅ   s   € Ø×Ñ×Ñ Ö%r    )r~   r   N)rr   rs   rt   ru   r   r'   rw   rx   ry   s   @r   r|   r|   À   s   ø‡ € ò÷&ð &r    r|   ó   ÿc                   ó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# )ÚIRCUserBadEncodingTestszk
Verifies that L{IRCUser} sends the correct error messages back to clients
when given indecipherable bytes
c                ó$   € \        4       V n        R # r‚   )r|   r   r   s   &r   r   ÚIRCUserBadEncodingTests.setUpÔ   s   € Ü$“ˆŽr    c                ó¦   € \        V P                  RV,          4      ! R\        .4       V P                  V P                  P                  V.4       R# )a3  
Asserts that IRCUser sends the relevant error code when a given irc_x
dispatch method is given undecodable bytes.

@param irc_x: the name of the irc_FOO method to test.
For example, irc_x = 'PRIVMSG' will check irc_PRIVMSG

@param error: the error code irc_x should send. For example,
irc.ERR_NOTONCHANNEL
zirc_%sN)Úgetattrr   ÚBADTEXTrM   r~   )r   Úirc_xÚerrors   &&&r   ÚassertChokesOnBadBytesÚ.IRCUserBadEncodingTests.assertChokesOnBadBytes×   s<   € ô 	�—‘˜h¨Õ.Ô/°´w°iÔ@Ø×Ñ˜Ÿ™×1Ñ1°E°7Ö;r    c                óF   € V P                  R\        P                  4       R# )zS
Tests that irc_JOIN sends ERR_NOSUCHCHANNEL if the channel name can't
be decoded.
ÚJOINN©r’   r   rg   r   s   &r   Ú	test_JOINÚ!IRCUserBadEncodingTests.test_JOINç   ó   € ð
 	×#Ñ# F¬C×,AÑ,AÖBr    c                óF   € V P                  R\        P                  4       R# )zT
Tests that irc_NAMES sends ERR_NOSUCHCHANNEL if the channel name can't
be decoded.
ÚNAMESNr–   r   s   &r   rp   Ú"IRCUserBadEncodingTests.test_NAMESî   ó   € ð
 	×#Ñ# G¬S×-BÑ-BÖCr    c                óF   € V P                  R\        P                  4       R# )zT
Tests that irc_TOPIC sends ERR_NOSUCHCHANNEL if the channel name can't
be decoded.
ÚTOPICNr–   r   s   &r   Ú
test_TOPICÚ"IRCUserBadEncodingTests.test_TOPICõ   r�   r    c                óF   € V P                  R\        P                  4       R# )zS
Tests that irc_LIST sends ERR_NOSUCHCHANNEL if the channel name can't
be decoded.
ÚLISTNr–   r   s   &r   Ú	test_LISTÚ!IRCUserBadEncodingTests.test_LISTü   r™   r    c                óF   € V P                  R\        P                  4       R# )zO
Tests that irc_MODE sends ERR_NOSUCHNICK if the target name can't
be decoded.
ÚMODEN©r’   r   ÚERR_NOSUCHNICKr   s   &r   Ú	test_MODEÚ!IRCUserBadEncodingTests.test_MODE  s   € ð
 	×#Ñ# F¬C×,>Ñ,>Ö?r    c                óF   € V P                  R\        P                  4       R# )zR
Tests that irc_PRIVMSG sends ERR_NOSUCHNICK if the target name can't
be decoded.
ÚPRIVMSGNr¨   r   s   &r   Útest_PRIVMSGÚ$IRCUserBadEncodingTests.test_PRIVMSG  s   € ð
 	×#Ñ# I¬s×/AÑ/AÖBr    c                óF   € V P                  R\        P                  4       R# )zP
Tests that irc_WHOIS sends ERR_NOSUCHNICK if the target name can't
be decoded.
ÚWHOISNr¨   r   s   &r   Ú
test_WHOISÚ"IRCUserBadEncodingTests.test_WHOIS  s   € ð
 	×#Ñ# G¬S×-?Ñ-?Ö@r    c                óF   € V P                  R\        P                  4       R# )zQ
Tests that irc_PART sends ERR_NOTONCHANNEL if the target name can't
be decoded.
ÚPARTN)r’   r   ri   r   s   &r   rk   Ú!IRCUserBadEncodingTests.test_PART  s   € ð
 	×#Ñ# F¬C×,@Ñ,@ÖAr    c                óF   € V P                  R\        P                  4       R# )zW
Tests that irc_WHO immediately ends the WHO list if the target name
can't be decoded.
ÚWHON)r’   r   ÚRPL_ENDOFWHOr   s   &r   Útest_WHOÚ IRCUserBadEncodingTests.test_WHO%  s   € ð
 	×#Ñ# E¬3×+;Ñ+;Ö<r    )r   N)rr   rs   rt   ru   rv   r   r’   r—   rp   r    r¤   rª   r®   r²   rk   rº   rw   rx   ry   s   @r   rŠ   rŠ   Ì   sN   ø‡ € ñò'ò<ò CòDòDòCò@òCòAòB÷=ð =r    rŠ   N)rv   Útwisted.credr   r   Útwisted.testr   Útwisted.words.protocolsr   Útwisted.words.servicer   r   r   Útwisted.words.test.test_ircr	   r   r|   r�   rŠ   © r    r   Ú<module>rÂ      sN   ðñ÷ *Ý &Ý 'ß IÑ IÝ 3ôn=�;ô n=ôb&�Gô &ð €ô^=˜kö ^=r    