HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux ip-172-26-0-120 6.17.0-1009-aws #9~24.04.2-Ubuntu SMP Fri Mar 6 23:50:29 UTC 2026 x86_64
User: ubuntu (1000)
PHP: 8.3.6
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/twisted/test/__pycache__/test_sip.cpython-312.pyc
�

oj�c���dZddlmZmZddlmZmZddlmZddl	m
Z
	ddlmZddlmZd	d
j!dd�zZd
j!dd�Zdj!dd�Zdj!dd�Zdj!dd�Zdj!dd�Zdj!dd�Zdj!dd�ZGd�d�ZGd�de
j4�ZGd�de�ZGd�de
j4�ZGd�de
j4�ZGd�de
j4�ZGd �d!e
j4�Z eejB�Gd"�d#��Z"eejB�Gd$�d%��Z#Gd&�d'e
j4�Z$Gd(�d)e
j4�Z%Gd*�d+ejL�Z'Gd,�d-e
j4�Z(y#e
$rdZY���wxYw).z(
Session Initialization Protocol tests.
�)�checkers�portal)�defer�reactor)�sip)�unittest)�AsyncioSelectorReactorN)�implementerz



z?INVITE sip:foo SIP/2.0
From: mo
To: joe
Content-Length: 4

abcd�
z
z-INVITE sip:foo SIP/2.0
From: mo
To: joe

1234zHINVITE sip:foo SIP/2.0
From: mo
To: joe
Content-Length: 4

1234

lalalalz�INVITE sip:foo SIP/2.0
From: mo
To: joe
Content-Length: 0

INVITE sip:loop SIP/2.0
From: foo
To: bar
Content-Length: 4

abcdINVITE sip:loop SIP/2.0
From: foo
To: bar
Content-Length: 4

1234z4SIP/2.0 200 OK
From:  foo
To:bar
Content-Length: 0

z.INVITE sip:foo SIP/2.0
f: mo
t: joe
l: 4

abcdz=INVITE sip:foo SIP/2.0
Via: SIP/2.0/UDP 10.0.0.1:5060;rport

a�SIP/2.0 200 OK
Via: SIP/2.0/UDP server10.biloxi.com
    ;branch=z9hG4bKnashds8;received=192.0.2.3
Via: SIP/2.0/UDP bigbox3.site3.atlanta.com
    ;branch=z9hG4bK77ef4c2312983.1;received=192.0.2.2
Via: SIP/2.0/UDP pc33.atlanta.com
    ;branch=z9hG4bK776asdhds ;received=192.0.2.1
To: Bob <sip:[email protected]>;tag=a6c85cf
From: Alice <sip:[email protected]>;tag=1928301774
Call-ID: [email protected]
CSeq: 314159 INVITE
Contact: <sip:[email protected]>
Content-Type: application/sdp
Content-Length: 0

c��eZdZd�Zy)�	TestRealmc�*�tjdd�fS)Nc��y�N�r��7/usr/lib/python3/dist-packages/twisted/test/test_sip.py�<lambda>z)TestRealm.requestAvatar.<locals>.<lambda>�s�r)r�IContact)�self�avatarId�mind�
interfacess    r�
requestAvatarzTestRealm.requestAvatars���|�|�T�<�/�/rN)�__name__�
__module__�__qualname__rrrrr
r
~s��0rr
c�H�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zy)�MessageParsingTestsc�n�g|_tj|jj�|_yr)�lr�MessagesParser�append�parser�rs r�setUpzMessageParsingTests.setUp�s#������(�(������7��rc�n�|jj|�|jj�yr�r$�dataReceived�dataDone)r�messages  r�feedMessagezMessageParsingTests.feedMessage�s$����� � ��)������rc�8�|j|j|�|j|jj�|�|j|j|�|j|j
|�|j|jd�y)z$
        Validate Requests.
        �N)�assertEqual�method�uri�toString�headers�body�finished)r�mr0r1r3r4s      r�validateMessagez#MessageParsingTests.validateMessage�so��	
������6�*���������)�3�/�������G�,��������&�������Q�'rc	��|j}|jt�|jt	|�d�|j|ddddgdgdgd�d	�y�
Nr.r�INVITE�sip:foo�mo�joe�4��from�tozcontent-length�abcd)r!r,�request1r/�lenr7�rr!s  r�
testSimplezMessageParsingTests.testSimple��[���F�F������"�����Q���#����
�a�D����V�E�7�s�e�D��	
rc	��|j}|jt�|jt�|j	t|�d�|j
|ddddgdgdgd�d	�|j
|d
dddgdgd�d�y)
N�rr:r;r<r=r>r?rBr.)r@rA�1234)r!r,rC�request2r/rDr7rEs  r�testTwoMessagesz#MessageParsingTests.testTwoMessages�s����F�F������"�����"�����Q���#����
�a�D����V�E�7�s�e�D��	
�	
���
�a�D�(�I���u�g�'F��	
rc	��|j}|jt�|jt	|�d�|j|ddddgdgdgd�d	�y)
Nr.rr:r;r<r=r>r?rJ)r!r,�request3r/rDr7rEs  r�testGarbagezMessageParsingTests.testGarbage�rGrc	�6�|j}|jt�|jt	|�d�|j|ddddgdgdgd�d	�|j|d
dddgd
gdgd�d�|j|ddddgd
gdgd�d�y)N�rr:r;r<r=�0r?�r.zsip:loop�foo�barr>rBrIrJ)r!r,�request4r/rDr7rEs  r�testThreeInOnez"MessageParsingTests.testThreeInOne�s����F�F������"�����Q���#����
�a�D����V�E�7�s�e�D��	
�	
���
�a�D����W�U�G��u�E��	
�	
���
�a�D����W�U�G��u�E��	
rc	��|j}|jt�|jt	|�d�|j|ddddgdgdgd�d	�yr9)r!r,�
request_shortr/rDr7rEs  r�	testShortzMessageParsingTests.testShort�s[���F�F������'�����Q���#����
�a�D����V�E�7�s�e�D��	
rc��|j}|jt�|jt	|�d�|d}|j|j
d�|j|jd�|j|jdgdgdgd��|j|jd	�|j|jd�y)
Nr.r���OKrTrUrRr?rS)
r!r,�	response1r/rD�code�phraser3r4r5�rr!r6s   r�testSimpleResponsez&MessageParsingTests.testSimpleResponse�s����F�F������#�����Q���#�
�a�D���������%�������4�(����
�I�I����w�3�%�P�	
�	
�������$�������Q�'rc�R�|j}|jt�|jt	|�d�|d}|j|j
ddd�|j|j
ddd�|j|j
ddd�y)	zv
        A header may be split across multiple lines.  Subsequent lines begin
        with C{" "} or C{"\t"}.
        r.r�viazHSIP/2.0/UDP server10.biloxi.com;branch=z9hG4bKnashds8;received=192.0.2.3zVSIP/2.0/UDP bigbox3.site3.atlanta.com;branch=z9hG4bK77ef4c2312983.1;received=192.0.2.2rIzHSIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bK776asdhds ;received=192.0.2.1N)r!r,�response_multiliner/rDr3ras   r�test_multiLinez"MessageParsingTests.test_multiLine�s���

�F�F�����+�,�����Q���#�
�a�D�����
�I�I�e��Q��
7�	
�
	
���
�I�I�e��Q��
?�	
�
	
���
�I�I�e��Q��
:�	
rN)
rrrr&r,r7rFrLrOrWrZrbrfrrrrr�s4��8��(�

�
� 

�
�4

�(�
rrc��eZdZdZd�Zy)�%MessageParsingFeedDataCharByCharTestsz9
    Same as base class, but feed data char by char.
    c�|�|D]}|jj|��|jj�yrr()rr+�cs   rr,z1MessageParsingFeedDataCharByCharTests.feedMessages3���	(�A��K�K�$�$�Q�'�	(������rN)rrr�__doc__r,rrrrhrhs���rrhc��eZdZd�Zd�Zd�Zy)�MakeMessageTestsc��tjdd�}|jdd�|j|j	�d�y)Nr:r;rTrUz$INVITE sip:foo SIP/2.0
Foo: bar

)r�Request�	addHeaderr/r2�r�rs  r�testRequestzMakeMessageTests.testRequests7���K�K��)�,��	���E�5�!��������'S�Trc���tjdd�}|jdd�|jdd�|jd�|j	|j�d�y)	Nr\r]rTrUzContent-Lengthr>rJz3SIP/2.0 200 OK
Foo: bar
Content-Length: 4

1234)r�Responserp�bodyDataReceivedr/r2rqs  r�testResponsezMakeMessageTests.testResponsesW���L�L��d�#��	���E�5�!�	���$�c�*�	���6�"����
�J�J�L�W�	
rc�n�tjd�}|j|j�d�y)Nr\zSIP/2.0 200 OK

)rrur/r2rqs  r�testStatusCodezMakeMessageTests.testStatusCode%s'���L�L�����������'?�@rN)rrrrsrwryrrrrmrms��U�

�Arrmc�H�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zy)�ViaTestsc��|j�}|j|tj|�j��yr)r2r/r�parseViaHeader)r�v�ss   r�checkRoundtripzViaTests.checkRoundtrip+s1��
�J�J�L������C�.�.�q�1�:�:�<�=rc�<�tjd�}tjd�}|j|j|j�|j|j|j�|j|j
|j
�y)NzSIP/2.0/UDP 192.168.1.1:5060z SIP/2.0/UDP     192.168.1.1:5060)rr}r/�	transport�host�port)r�v1�v2s   r�testExtraWhitespacezViaTests.testExtraWhitespace/sl��
�
�
� >�
?��
�
�
� B�
C��������r�|�|�4�������"�'�'�*�������"�'�'�*rc��d}tj|�}|j|jd�|j|jd�|j|j
d�|j
|j�|j
|j�|j|j�|j|jd�|j|jd�|j|jd�|j|jd�|j|j�d	�|j!|�y
)zC
        Test parsing a Via header with one of everything.
        zVSIP/2.0/UDP first.example.com:4000;ttl=16;maddr=224.2.0.1 ;branch=a7c6a8dlze (Example)�UDPzfirst.example.comi��z	224.2.0.1�
a7c6a8dlzerzKSIP/2.0/UDP first.example.com:4000;ttl=16;branch=a7c6a8dlze;maddr=224.2.0.1N)rr}r/r�r�r��assertIsNone�rport�
rportValue�assertFalse�rportRequested�ttl�maddr�branch�hiddenr2r��rrr~s   r�test_complexzViaTests.test_complex6s��

,�	
�
���q�!��������e�,�������!4�5��������&����!�'�'�"����!�,�,�'�����)�)�*��������#�������+�.�������<�0�������1�%����
�J�J�L�
8�	
�
	
���A�rc��d}tj|�}|j|jd�|j|jd�|j|j
d�|j
|j�|j
|j�|j|j�|j
|j�|j
|j�|j
|j�|j|j�|j|j!�d�|j#|�y)z3
        Test parsing a simple Via header.
        zSIP/2.0/UDP example.com;hiddenr��example.com��z#SIP/2.0/UDP example.com:5060;hiddenN)rr}r/r�r�r�r�r�r�r�r�r�r�r��
assertTruer�r2r�r�s   r�test_simplezViaTests.test_simplePs���
-�����q�!��������e�,��������/��������&����!�'�'�"����!�,�,�'�����)�)�*����!�%�%� ����!�'�'�"����!�(�(�#�������!��������'L�M����A�rc�P�tjd�}|j|�y)Nr�)r�Viar��rr~s  r�testSimplerzViaTests.testSimplercs���G�G�M�"�����A�rc���tjdd��}|j|jg��}|j	t|�d�|j	|ddd�|j	|dd	t�|j	|j�d
�|j|j�|j|j�|j|j�y)z|
        Setting rport to True is deprecated, but still produces a Via header
        with the expected properties.
        �foo.barT�r���offendingFunctionsr.rr+�+rport=True is deprecated since Twisted 9.0.�category�SIP/2.0/UDP foo.bar:5060;rportN)
rr��
flushWarnings�test_deprecatedRPortr/rD�DeprecationWarningr2r�r�r�r�r�)rr~�warningss   rr�zViaTests.test_deprecatedRPortgs���

�G�G�I�T�*���%�%�$�:S�:S�9T�%�U������X���*�����Q�K�	�"�$Q�	
�	
����!��Z�0�2D�E��������'G�H������� �����(�(�)����!�,�,�'rc���tjdd��}|j|j�d�|j	|j
�|j
|j�y)zU
        An rport setting of None should insert the parameter with no value.
        r�Nr�r�)rr�r/r2r�r�r�r�r�s  r�
test_rportzViaTests.test_rportzsO��
�G�G�I�T�*���������'G�H�����(�(�)����!�,�,�'rc��tjdd��}|j|j�d�|j	|j
�|j|jd�|j|jd�y)zk
        An rport numeric setting should insert the parameter with the number
        value given.
        r�r.r�z SIP/2.0/UDP foo.bar:5060;rport=1N)rr�r/r2r�r�r�r�r�s  r�test_rportValuezViaTests.test_rportValue�sg��

�G�G�I�Q�'���������'I�J�����)�)�*�������q�)�������!�$rc��d}tj|�}|j|jd�|j|jd�|j|j
d�|j|jd�|j|jd�|j|j�jd�d�y)	Nz8SIP/2.0/UDP 10.0.0.1:5060;received=22.13.1.5;rport=12345r��10.0.0.1r�z	22.13.1.5i90zrport=12345���)rr}r/r�r�r��receivedr��assertNotEqualr2�findr�s   r�testNATzViaTests.testNAT�s���F�����q�!��������e�,��������,��������&�������[�1�������%�(����A�J�J�L�-�-�m�<�b�Arc�r�d}tj|�}|j|j�|�y)zZ
        Parsing and serializing Via headers with unknown parameters should work.
        z?SIP/2.0/UDP example.com:5060;branch=a12345b;bogus;pie=deliciousN)rr}r/r2r�s   r�test_unknownParamszViaTests.test_unknownParams�s0��
N�����q�!���������q�)rN)
rrrr�r�r�r�r�r�r�r�r�r�rrrr{r{*s5��>�+��4�&�(�&(�	%�	B�*rr{c��eZdZd�Zd�Zy)�URLTestsc�x�dD]5}|jtj|�j�|��7y)N)zsip:[email protected]&sip:j.doe:[email protected];transport=tcpz!sip:[email protected]?subject=projectzsip:example.com)r/r�parseURLr2)r�urls  r�
testRoundtripzURLTests.testRoundtrip�s9��
�	@�C�
���S�\�\�#�.�7�7�9�3�?�
	@rc��d}tj|�}dddddddd	d
ddd
gfdddd�ffD]!\}}|jt||�|��#y)Nzesip:user:pass@hosta:123;transport=udp;user=phone;method=foo;ttl=12;maddr=1.2.3.4;blah;goo=bar?a=b&c=d)�username�user)�password�pass)r��hosta)r��{)r��udp)�usertype�phone)r0rT)r��)r��1.2.3.4�other�blahzgoo=barr3�b�d)�arj)rr�r/�getattr)rrr��kr~s     r�testComplexzURLTests.testComplex�s}��
8�	
��l�l�1�o�� � ��� �!��� �
�v�y�)�*�
�c��,�-�
�
	1�D�A�q�
���W�S�!�_�a�0�
	1rN)rrrr�r�rrrr�r��s
��@�1rr�c��eZdZd�Zy)�
ParseTestsc
��dddifdddifdddifdddifdd	dd
dd�ffD]d\}}}}tj|�\}}}|j||�|j|j�|�|j||��fy)
Nz""A. G. Bell" <sip:[email protected]>z
A. G. Bellzsip:[email protected]Anon <sip:[email protected]>�AnonrSz<sip:[email protected]>z)foo <sip:[email protected]>;tag=bar;foo=bazrTrU�baz)�tagrT)r�parseAddressr/r2)r�address�name�urls�params�gname�gurl�gparamss        r�testParseAddresszParseTests.testParseAddress�s���5��%��	
�*�6�3H�"�M�
"�B�(=�r�B�
$�b�*?��D�;��%��e�,�	
�,
�	.�'�G�T�4��"$'�#3�#3�G�#<� �E�4�����T�5�)����T�]�]�_�d�3����W�f�-�)	.rN)rrrr�rrrr�r��s��.rr�c��eZdZd�Zy)�DummyLocatorc�V�tjtjdd���S)N�
server.comr��r�)r�succeedr�URL�r�
logicalURLs  r�
getAddresszDummyLocator.getAddress�s���}�}�S�W�W�\��=�>�>rN�rrrr�rrrr�r��s��?rr�c��eZdZd�Zy)�FailingLocatorc�<�tjt��Sr)r�fail�LookupErrorr�s  rr�zFailingLocator.getAddress�s���z�z�+�-�(�(rNr�rrrr�r��s��)rr�c�B�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zy
)�
ProxyTestsc���tjd��_t��j_g�_�fd��j_y)N�	127.0.0.1c�>���jj||f�Sr��sentr#��dest�msgrs  �rrz"ProxyTests.setUp.<locals>.<lambda>�����4�9�9�3C�3C�T�3�K�3P�r)r�Proxy�proxyr��locatorr��sendMessager%s`rr&zProxyTests.setUp�s4����Y�Y�{�+��
�)�^��
�
����	�!P��
�
�rc�h�tjdd�}|jdtjd�j	��|jdtjd�j	��|jdd�|jdd	�|jd
d�|j
j
|j	�d�|jt|j�d
�|jd\}}|j|jd�|j|jd�|j|jj	�d�|j|jd�|j|jdgd��y)Nr:r;rdr�z1.2.3.5rTrUrA�<sip:[email protected]>�contactz<sip:[email protected]>�r�r�r.rr�r�)�SIP/2.0/UDP 127.0.0.1:5060�SIP/2.0/UDP 1.2.3.4:5060zSIP/2.0/UDP 1.2.3.5:5060)rrorpr�r2r��datagramReceivedr/rDr�r�r�r1r0r3�rrrr�r6s    r�testRequestForwardzProxyTests.testRequestForward�s8���K�K��)�,��	���E�3�7�7�9�-�6�6�8�9�	���E�3�7�7�9�-�6�6�8�9�	���E�5�!�	���D�0�1�	���I�2�3��
�
�#�#�A�J�J�L�2C�D�����T�Y�Y���+��)�)�A�,���a�������D�)�������L�1���������)�9�5�������8�,����
�I�I�e��
�	
rc��tjdd�}|jdtjd�j	��|jdd�|jdd�|jd	d
�|j
j
|j	�d�|jd\}}|j|jdd
dg�y)Nr:r;rdr�rTrUrArrz<sip:[email protected]>�z1.1.1.1r�rrz)SIP/2.0/UDP 1.2.3.4:5060;received=1.1.1.1)
rrorpr�r2r�rr�r/r3rs    r�testReceivedRequestForwardz%ProxyTests.testReceivedRequestForwards����K�K��)�,��	���E�3�7�7�9�-�6�6�8�9�	���E�5�!�	���D�0�1�	���I�2�3��
�
�#�#�A�J�J�L�2C�D��)�)�A�,���a����
�I�I�e��
)�+V�W�	
rc�2�tjd�}|jdtjd�j	��|j
j
|j	�d�|jt|j�d�y)Nr\rd�foo.comrr)
rrurpr�r2r�rr/rDr�rqs  r�testResponseWrongViazProxyTests.testResponseWrongViasc���L�L����	���E�3�7�7�9�-�6�6�8�9��
�
�#�#�A�J�J�L�2C�D�����T�Y�Y���+rc��tjd�}|jdtjd�j	��|jdtjdd��j	��|j
j
|j	�d�|jt|j�d�|jd	\}}|j|j|jfd
�|j|jd�|j|jddg�y)Nr\rdr��
client.com��r�rr.r)rrzSIP/2.0/UDP client.com:1234)rrurpr�r2r�rr/rDr�r�r�r_r3rs    r�testResponseForwardzProxyTests.testResponseForwards����L�L����	���E�3�7�7�;�/�8�8�:�;�	���E�3�7�7�<�d�;�D�D�F�G��
�
�#�#�A�J�J�L�2C�D�����T�Y�Y���+��)�)�A�,���a����$�)�)�T�Y�Y�/�1E�F��������%�������5�)�,I�+J�Krc��tjd�}|jdtjd�j	��|jdtjdd��j	��|j
j
|j	�d�|jt|j�d�|jd	\}}|j|j|jfd
�y)Nr\rdr�r�r)r�rr.r�rr�)rrurpr�r2r�rr/rDr�r�r�rs    r�testReceivedResponseForwardz&ProxyTests.testReceivedResponseForward$s����L�L����	���E�3�7�7�;�/�8�8�:�;�	���E�3�7�7�:��E�N�N�P�Q��
�
�#�#�A�J�J�L�2C�D�����T�Y�Y���+��)�)�A�,���a����$�)�)�T�Y�Y�/�1E�Frc���tjd�}|jdtjd�j	��g��fd�|j
_|j
j|j	�d�|jt��d��d\}}|jt|jjdg��d�|j|jd�y)Nr\rdr�c�&���j|�Sr)r#)r�r!s �rrz-ProxyTests.testResponseToUs.<locals>.<lambda>1s���A�H�H�Q�K�rrr.r)
rrurpr�r2r��gotResponserr/rDr3�getr_)rrrr6�addrr!s    @r�testResponseToUszProxyTests.testResponseToUs-s�����L�L����	���E�3�7�7�;�/�8�8�:�;���!7��
�
���
�
�#�#�A�J�J�L�2C�D�����Q���#��A�$���4�����Q�Y�Y�]�]�5�"�5�6��:��������%rc��tjdd�}|jdtjd�j	��|jdtjd�j	��|j
j
|j	�d�|j|jg�y)Nr:r;rdr�r�r)	rrorpr�r2r�rr/r�rqs  r�testLoopzProxyTests.testLoop8s����K�K��)�,��	���E�3�7�7�9�-�6�6�8�9�	���E�3�7�7�;�/�8�8�:�;��
�
�#�#�A�J�J�L�2F�G�������B�'rc�v�tjdd�}|jdtjd�j	��|jdd�t�|j_|jj|j	�d�|jt|j�d�|jd	\}}|j|j|jfd�|j|jd
�|j|jddg�y)Nr:r;rdr�rArrr.ri�r)rrorpr�r2r�r�r�rr/rDr�r�r�r_r3rs    r�testCantForwardRequestz!ProxyTests.testCantForwardRequest?s����K�K��)�,��	���E�3�7�7�9�-�6�6�8�9�	���D�0�1�+�-��
�
���
�
�#�#�A�J�J�L�2C�D�����T�Y�Y���+��)�)�A�,���a����$�)�)�T�Y�Y�/�1B�C��������%�������5�)�,F�+G�HrN)rrrr&r	rrrrrrr rrrr�r��s3��Q�
�.
�,�	L�G�	&�(�
Irr�c�T�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zy
)�RegistrationTestsc���tjd���_tjd��_�jx�j_�j_g�_�fd��j_y)Nr��r��bell.example.comc�>���jj||f�Srr�r�s  �rrz)RegistrationTests.setUp.<locals>.<lambda>Rr�r)r�
RegisterProxyr��InMemoryRegistry�registryr�r�rr%s`rr&zRegistrationTests.setUpMsW����&�&�K�8��
��,�,�-?�@��
�37�=�=�@��
�
��d�j�j�0���	�!P��
�
�rc��|jjj�D]\}}|j��|`yr)r)�users�values�cancelr�)rr�r1s   r�tearDownzRegistrationTests.tearDownTs6���m�m�)�)�0�0�2�	�F�A�s�
�H�H�J�	��Jrc�2�tjdd�}|jdd�|jdd�|jdtjd�j	��|j
j
|j	�d	�y)
N�REGISTER�sip:bell.example.comrA�sip:[email protected]�sip:[email protected]:1234rdrr�rrorpr�r2r�rrqs  r�registerzRegistrationTests.registerYsl���K�K�
�$:�;��	���D�4�5�	���I�8�9�	���E�3�7�7�<�0�9�9�;�<��
�
�#�#�A�J�J�L�2F�Grc�V�tjdd�}|jdd�|jdd�|jdtjd�j	��|jd	d
�|j
j
|j	�d�y)Nr0r1rAr2r�*rdr�expiresrRrr4rqs  r�
unregisterzRegistrationTests.unregister`sy���K�K�
�$:�;��	���D�4�5�	���I�s�#�	���E�3�7�7�<�0�9�9�;�<�	���I�s�#��
�
�#�#�A�J�J�L�2F�Grc��|j�|jd\}}|j|j|jfd�|j|j
d�|j|jddg�|j|jddg�|j|jdd	g�tt�tk7r,|jt|jd
d�dv�|jt|jj�d�|jjd
\}}|j|j�d	�|j j"j%t'j(d
d���}|j+d��|j+|jd�|S)Nrrr\rd�SIP/2.0/UDP client.com:5060rAr2r�sip:[email protected]:5060r8)iiiir.r=r%�r�r�c�2�|j|jfSr�r�r�)�desturls rrz0RegistrationTests.testRegister.<locals>.<lambda>{s��w�|�|�W�\�\�&B�r)r5r�r/r�r�r_r3�typerr	r��intrDr)r+r2r�r�r�rr��addCallback)rr�r6�dcr1r�s      r�testRegisterzRegistrationTests.testRegisterhsx���
�
���)�)�A�,���a����$�)�)�T�Y�Y�/�1E�F��������%�������5�)�,I�+J�K�������4��+E�*F�G�������9�-�0I�/J�K���=�2�2��O�O�C��	�	�)� 4�Q� 7�8�<T�T�U�����T�]�]�0�0�1�1�5��-�-�%�%�e�,���C��������)B�C��J�J���)�)��G�G�U�);�<�
��	
�
�
�B�C�	�
�
�d�&�&�(<�=��rc�<�|j�|j�|jd\}}|j|j|j
fd�|j|jd�|j|jddg�|j|jddg�|j|jdd	g�|j|jd
dg�|j|jji�y)Nr.rr\rdr;rAr2rr<r8rR)
r5r9r�r/r�r�r_r3r)r+�rr�r6s   r�testUnregisterz RegistrationTests.testUnregisters����
�
�������)�)�A�,���a����$�)�)�T�Y�Y�/�1E�F��������%�������5�)�,I�+J�K�������4��+E�*F�G�������9�-�0I�/J�K�������9�-��u�5�������,�,�b�1rc���t�}tj|�}tj�}|jdd�|j
|�||j_y)Nz[email protected]�	passXword)r
r�Portalr�'InMemoryUsernamePasswordDatabaseDontUse�addUser�registerCheckerr�)rrr�prjs    r�	addPortalzRegistrationTests.addPortal�sN���K���M�M�!����<�<�>��	�	�	�'��5�	���!����
�
�rc�H�|j�|j�|jt|jj
�d�|jt|j�d�|jd\}}|j|jd�y)Nrr.i�)rPr5r/rDr)r+r�r_rGs   r�testFailedAuthenticationz*RegistrationTests.testFailedAuthentication�sq�������
�
������T�]�]�0�0�1�1�5�����T�Y�Y���+��)�)�A�,���a��������%rc�|�tjdd�}|jdd�|jdd�|jdtjd�j	��|j
j
|j	�d	�|jt|j�d
�y)Nr0z
sip:wrong.comrAr2rr3rdrrr�
rrorpr�r2r�rr/rDr�rqs  r�testWrongDomainRegisterz)RegistrationTests.testWrongDomainRegister�s����K�K�
�O�4��	���D�4�5�	���I�8�9�	���E�3�7�7�<�0�9�9�;�<��
�
�#�#�A�J�J�L�2F�G�����T�Y�Y���+rc�|�tjdd�}|jdd�|jdd�|jdtjd�j	��|j
j
|j	�d	�|jt|j�d
�y)Nr0r1rAzsip:[email protected]r3rdrrrrTrqs  r�testWrongToDomainRegisterz+RegistrationTests.testWrongToDomainRegister�s����K�K�
�$:�;��	���D�+�,�	���I�8�9�	���E�3�7�7�<�0�9�9�;�<��
�
�#�#�A�J�J�L�2F�G�����T�Y�Y���+rc���|j�tjdd��}|jjj|�}|j
|t�|S)Nr=rr=�r5rr�r�r�r��
assertFailurer��rr�r�s   r�testWrongDomainLookupz'RegistrationTests.testWrongDomainLookup�sJ���
�
���g�g�u�9�5���J�J���)�)�#�.�����1�k�*��rc���|j�tjdd��}|jjj|�}|j
|t�|S)N�janer%r=rYr[s   r�testNoContactLookupz%RegistrationTests.testNoContactLookup�sK���
�
���g�g�v�,>�?���J�J���)�)�#�.�����1�k�*��rN)rrrr&r.r5r9rErHrPrRrUrWr\r_rrrr"r"LsA��Q��
H�H��.
2��&�,�,��rr"c��eZdZd�Zd�Zy)�Clientc��tjj|�g|_t	j
�|_yr)r�Base�__init__r�r�Deferred�deferredr%s rrdzClient.__init__�s)�������$����
����(��
rc��|jj|�|jj|j�yr)r�r#rf�callback)r�responsers   r�handle_responsezClient.handle_response�s*���
�
���X�&��
�
���t�}�}�-rN)rrrrdrjrrrrara�s��)�
.rrac�$�eZdZd�Zd�Zd�Zd�Zy)�	LiveTestsc��tjd��|_tjd�|_|jx|j_|j_t
jd|jd��|_t�|_
t
jd|jd��|_|jj�j|jj�jf|_y)Nr�r$r%r)�	interface)rr'r�r(r)r�r�	listenUDP�
serverPortra�client�
clientPort�getHostr�r��
serverAddressr%s rr&zLiveTests.setUp�s����&�&�K�8��
��,�,�-?�@��
�37�=�=�@��
�
��d�j�j�0�!�+�+�A�t�z�z�[�Q����h���!�+�+�A�t�{�{�k�R����O�O�#�#�%�*�*��O�O�#�#�%�*�*�
��rc�L�|jjj�D]\}}|j��t	j
|jj�}t	j
|jj�}t	j||g�Sr)
r)r+r,r-r�
maybeDeferredrr�
stopListeningrp�
gatherResults)rr�r1�d1�d2s     rr.zLiveTests.tearDown�sz���m�m�)�)�0�0�2�	�F�A�s�
�H�H�J�	�
�
 �
 ����!>�!>�
?��
�
 �
 ����!>�!>�
?���"�"�B��8�,�,rc����jj�j}tjdd�}|jdd�|jdd|z�|jdtjd|�	�j���jjtjd�jd
��|��jj}�fd�}|j|�|S)
Nr0r1rAr2r�sip:[email protected]:%drdr�r�r.r?c�~���jt|�d�|d}�j|jd�y�Nr.rr\�r/rDr_�r�rrrs  �r�checkz%LiveTests.testRegister.<locals>.check��4������S��]�A�.����A����Q�V�V�S�)r)rrrsr�rrorpr�r2rqrr�rtrfrC)rrOrrr�r�s`    rrEzLiveTests.testRegister�s�����O�O�#�#�%�*�*���K�K�
�$:�;��	���D�4�5�	���I�5��9�:�	���E�3�7�7�;�Q�7�@�@�B�C�������G�G��4�+=�+=�a�+@�A�1�	
�
�K�K� � ��	*�
	
�
�
�e���rc�����jj�j}tjdd�}|jdd�|jdd|z�|jdtjd|d	�
�j���j�jg��}�jt|�d��j|d
dd��j|d
dt��jjtjd�j d��|��jj"}�fd�}|j%|�|S)ap
        rport is allowed without a value, apparently because server
        implementors might be too stupid to check the received port
        against 5060 and see if they're equal, and because client
        implementors might be too stupid to bind to port 5060, or set a
        value on the rport parameter they send if they bind to another
        port.
        r0r1rAr2rr|rdr�T)r�r�r�r.rr+r�r�r?c�~���jt|�d�|d}�j|jd�yr~rr�s  �rr�z)LiveTests.test_amoralRPort.<locals>.checkr�r)rrrsr�rrorpr�r2r��test_amoralRPortr/rDr�rqrr�rtrfrC)rrOrrr�r�r�s`     rr�zLiveTests.test_amoralRPort�s4���
�O�O�#�#�%�*�*���K�K�
�$:�;��	���D�4�5�	���I�5��9�:�	���E�3�7�7�;�Q�d�C�L�L�N�O��%�%�$�:O�:O�9P�%�Q������X���*�����Q�K�	�"�$Q�	
�	
����!��Z�0�2D�E�������G�G��4�+=�+=�a�+@�A�1�	
�
�K�K� � ��	*�
	
�
�
�e���rN)rrrr&r.rEr�rrrrlrl�s��

�-��&rrl))rk�twisted.credrr�twisted.internetrr�twisted.protocolsr�
twisted.trialr�twisted.internet.asyncioreactorr	�
BaseException�zope.interfacer
�replacerCrKrNrVr^rY�request_nattedrer
�TestCaserrhrmr{r�r��ILocatorr�r�r�r"rcrarlrrr�<module>r�s-��
�*�+�!�"�"�F�'���	���f�	�	�	��	���&�	�		���7��&��	��	���&�	�	�(
�
�G��&��
��	���&�	�
���G��&��	���g��&���(0�0�
E
�(�+�+�E
�P�,?��A�x�(�(�A�(u*�x� � �u*�p1�x� � �1�@.��"�"�.�2
�S�\�\��?�?��?�

�S�\�\��)�)��)�
bI��"�"�bI�Jl��)�)�l�^.�S�X�X�.�F��!�!�F��m�"�!��"�s�G�G�G