AnonSec Shell
Server IP : 209.38.156.173  /  Your IP : 216.73.216.122   [ Reverse IP ]
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.1.2-1ubuntu2.22
Disable Function : NONE
Domains : 2 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3/dist-packages/twisted/words/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /usr/lib/python3/dist-packages/twisted/words/test/__pycache__/test_irc_service.cpython-310.pyc
o

�b:'�@s�dZddlmZmZddlmZddlmZddlm	Z	m
Z
mZddlm
Z
Gdd�de
�ZGd	d
�d
e�ZdZGdd
�d
e
�ZdS)z5
Tests for IRC portions of L{twisted.words.service}.
�)�checkers�portal)�
proto_helpers)�irc)�InMemoryWordsRealm�
IRCFactory�IRCUser)�IRCTestCasec@s`eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�IRCUserTestsz'
    Isolated tests for L{IRCUser}
    cCsptd�|_t��|_t�|j|jg�|_|j�dd�t|j|j�|_	|j	�
d�|_t�
�|_|j�|j�dS)zm
        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��self�r�E/usr/lib/python3/dist-packages/twisted/words/test/test_irc_service.py�setUps


zIRCUserTests.setUpcCs<|j�ddg�|j��|j�d�|�|j��d�dS)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�valuerrrr�test_sendMessage"s

�zIRCUserTests.test_sendMessagecCsLd��}|j�dd��g�|j��|j�d���|�|j��|�dS)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 тест ник
ruникuтестN)�encoderr!rr"r#r$r%)r�expectedResultrrr�test_utf8Messages.s

zIRCUserTests.test_utf8MessagescCs|j�ddg�|�t�dS)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.
        rs����N)rr!�assertRaises�UnicodeErrorrrrr�test_invalidEncodingNick;sz%IRCUserTests.test_invalidEncodingNickcCsJ|jj��}|jj��ttkrt|t�r|�d�}|��}dd�|D�S)zC
        Grabs our responses and then clears the transport
        zutf-8cSsg|]}t�|��qSr)r�parsemsg)�.0�rrrr�
<listcomp>Msz)IRCUserTests.response.<locals>.<listcomp>)	r�	transportr%r"�bytes�str�
isinstance�decode�
splitlines�r�responserrrr8Ds
zIRCUserTests.responseccs.�t|�D]\}}|d|kr||fVqdS)a8
        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)rr8�messageType�n�messagerrr�scanResponseOs�
��zIRCUserTests.scanResponsecCsx|j�ddg�|��}t|�|tj��}t|�|tj��}|�|dddddgffg�|�|ddddd	gffg�d
S)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.
        rrrr�375�#- example.com Message of the Day - r9�376�End of /MOTD command.N)	rr!r8�listr>r�
RPL_MOTDSTART�
RPL_ENDOFMOTD�assertEqual)rr8�start�endrrr�test_sendNickSendsGreeting^s"����
�z'IRCUserTests.test_sendNickSendsGreetingcCs�|j�ddg�|j�ddg�|j�ddg�d�|jjd�}d�|jjd�}|�|��d	d
ddgfd	ddd
gfd	dddgfd	dd|gfd	dd|gfd	ddd	|jjdddgfg�dS)zz
        Receiving USER, PASS, NICK will log in the user, and transmit the
        appropriate response messages.
        rzjohn doer
rz,Your host is example.com, running version {}�serviceVersionzThis server was created on {}�creationDaterr?r@rArB�001zconnected to Twisted IRC�002�003�004�wr<N)	r�irc_USER�irc_PASSr!�formatr�_serverInforFr8)r�version�creationrrr�test_fullLoginys6
�
�
����zIRCUserTests.test_fullLogincCs�|j�ddg�|��}|jj��|�|ddtj�|j�ddg�|��}|jj��|�|ddtj	�|j�
dddg�|��}|jj��|�|ddtj�|j�
dddg�|��}|jj��|�|ddtj�d	S)
z
        irc_PART
        �testuserrrr9�somechannelssomechannelsbooga�boogaN)rr!r8r1r"rFrrD�irc_JOIN�ERR_NOSUCHCHANNEL�irc_PART�ERR_NOTONCHANNELr7rrr�	test_PART�s zIRCUserTests.test_PARTcCs^|j�ddg�|j�ddg�|jj��|j�ddg�|��}|�|ddtj	�dS)z
        irc_NAMES
        rrXrYrr9N)
rr!r[r1r"�	irc_NAMESr8rFr�RPL_ENDOFNAMESr7rrr�
test_NAMES�szIRCUserTests.test_NAMESN)�__name__�
__module__�__qualname__�__doc__rr&r)r,r8r>rIrWr_rbrrrrr
s
	'r
c@seZdZdd�Zdd�ZdS)�
MocksyIRCUsercCstd�|_g|_dS)Nr)rr�mockedCodesrrrr�__init__�s

zMocksyIRCUser.__init__cOs|j�|�dS�N)rh�append)r�code�_�__rrrr#�szMocksyIRCUser.sendMessageN)rcrdrerir#rrrrrg�srg��c@sheZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�IRCUserBadEncodingTestszw
    Verifies that L{IRCUser} sends the correct error messages back to clients
    when given indecipherable bytes
    cCst�|_dSrj)rgrrrrrr�szIRCUserBadEncodingTests.setUpcCs.t|jd|�dtg�|�|jj|g�dS)ak
        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
        zirc_%sN)�getattrr�BADTEXTrFrh)r�irc_x�errorrrr�assertChokesOnBadBytes�sz.IRCUserBadEncodingTests.assertChokesOnBadBytescC�|�dtj�dS)zk
        Tests that irc_JOIN sends ERR_NOSUCHCHANNEL if the channel name can't
        be decoded.
        �JOINN�rurr\rrrr�	test_JOIN��z!IRCUserBadEncodingTests.test_JOINcCrv)zl
        Tests that irc_NAMES sends ERR_NOSUCHCHANNEL if the channel name can't
        be decoded.
        �NAMESNrxrrrrrb�rzz"IRCUserBadEncodingTests.test_NAMEScCrv)zl
        Tests that irc_TOPIC sends ERR_NOSUCHCHANNEL if the channel name can't
        be decoded.
        �TOPICNrxrrrr�
test_TOPIC�rzz"IRCUserBadEncodingTests.test_TOPICcCrv)zk
        Tests that irc_LIST sends ERR_NOSUCHCHANNEL if the channel name can't
        be decoded.
        �LISTNrxrrrr�	test_LIST�rzz!IRCUserBadEncodingTests.test_LISTcCrv)zg
        Tests that irc_MODE sends ERR_NOSUCHNICK if the target name can't
        be decoded.
        �MODEN�rur�ERR_NOSUCHNICKrrrr�	test_MODErzz!IRCUserBadEncodingTests.test_MODEcCrv)zj
        Tests that irc_PRIVMSG sends ERR_NOSUCHNICK if the target name can't
        be decoded.
        �PRIVMSGNr�rrrr�test_PRIVMSG
rzz$IRCUserBadEncodingTests.test_PRIVMSGcCrv)zh
        Tests that irc_WHOIS sends ERR_NOSUCHNICK if the target name can't
        be decoded.
        �WHOISNr�rrrr�
test_WHOISrzz"IRCUserBadEncodingTests.test_WHOIScCrv)zi
        Tests that irc_PART sends ERR_NOTONCHANNEL if the target name can't
        be decoded.
        �PARTN)rurr^rrrrr_rzz!IRCUserBadEncodingTests.test_PARTcCrv)zo
        Tests that irc_WHO immediately ends the WHO list if the target name
        can't be decoded.
        �WHON)rur�RPL_ENDOFWHOrrrr�test_WHO&rzz IRCUserBadEncodingTests.test_WHON)rcrdrerfrruryrbr}rr�r�r�r_r�rrrrrp�s			rpN)rf�twisted.credrr�twisted.testr�twisted.words.protocolsr�twisted.words.servicerrr�twisted.words.test.test_ircr	r
rgrrrprrrr�<module>s3	

Anon7 - 2022
AnonSec Team