Your IP : 216.73.216.213


Current Path : /opt/alt/python37/lib64/python3.7/site-packages/twisted/test/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/site-packages/twisted/test/__pycache__/test_sip.cpython-37.pyc

B

;��]�b�@s�dZddlmZmZddlmZmZddlmZddl	m
Z
yddlmZWndZYnXddl
mZd	d
�dd�Zd
�dd�Zd�dd�Zd�dd�Zd�dd�Zd�dd�Zd�dd�Zd�dd�ZGdd�d�ZGdd�de
j�ZGdd�de�ZGdd�de
j�ZGdd�de
j�ZGdd�de
j�ZGd d!�d!e
j�Zeej �Gd"d#�d#��Z!eej �Gd$d%�d%��Z"Gd&d'�d'e
j�Z#Gd(d)�d)e
j�Z$Gd*d+�d+ej%�Z&Gd,d-�d-e
j�Z'dS).z(
Session Initialization Protocol tests.
�)�portal�checkers)�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:bob@biloxi.com>;tag=a6c85cf
From: Alice <sip:alice@atlanta.com>;tag=1928301774
Call-ID: a84b4c76e66710@pc33.atlanta.com
CSeq: 314159 INVITE
Contact: <sip:bob@192.0.2.4>
Content-Type: application/sdp
Content-Length: 0

c@seZdZdd�ZdS)�	TestRealmcGstjddd�fS)NcSsdS)N�rrr�H/opt/alt/python37/lib64/python3.7/site-packages/twisted/test/test_sip.py�<lambda>m�z)TestRealm.requestAvatar.<locals>.<lambda>)rZIContact)�selfZavatarIdZmindZ
interfacesrrr
�
requestAvatarlszTestRealm.requestAvatarN)�__name__�
__module__�__qualname__rrrrr
rksrc@s\eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)�MessageParsingTestscCsg|_t�|jj�|_dS)N)�lrZMessagesParser�append�parser)rrrr
�setUprszMessageParsingTests.setUpcCs|j�|�|j��dS)N)r�dataReceived�dataDone)r�messagerrr
�feedMessagewszMessageParsingTests.feedMessagecCsN|�|j|�|�|j��|�|�|j|�|�|j|�|�|jd�dS)z$
        Validate Requests.
        �N)�assertEqual�method�uri�toString�headers�body�finished)r�mr r!r#r$rrr
�validateMessage|s
z#MessageParsingTests.validateMessagec	CsH|j}|�t�|�t|�d�|�|ddddgdgdgd�d	�dS)
Nrr�INVITEzsip:foo�mo�joe�4)�from�tozcontent-length�abcd)rr�request1r�lenr')rrrrr
�
testSimple�s

zMessageParsingTests.testSimplec	Csr|j}|�t�|�t�|�t|�d�|�|ddddgdgdgd�d	�|�|d
dddgdgd�d�dS)
N�rr(zsip:foor)r*r+)r,r-zcontent-lengthr.r)r,r-�1234)rrr/�request2rr0r')rrrrr
�testTwoMessages�s


z#MessageParsingTests.testTwoMessagesc	CsH|j}|�t�|�t|�d�|�|ddddgdgdgd�d	�dS)
Nrrr(zsip:foor)r*r+)r,r-zcontent-lengthr3)rr�request3rr0r')rrrrr
�testGarbage�s

zMessageParsingTests.testGarbagec	Cs�|j}|�t�|�t|�d�|�|ddddgdgdgd�d	�|�|d
dddgd
gdgd�d�|�|ddddgd
gdgd�d�dS)N�rr(zsip:foor)r*�0)r,r-zcontent-length�rzsip:loop�foo�barr+r.r2r3)rr�request4rr0r')rrrrr
�testThreeInOne�s



z"MessageParsingTests.testThreeInOnec	CsH|j}|�t�|�t|�d�|�|ddddgdgdgd�d	�dS)
Nrrr(zsip:foor)r*r+)r,r-zcontent-lengthr.)rr�
request_shortrr0r')rrrrr
�	testShort�s

zMessageParsingTests.testShortcCs�|j}|�t�|�t|�d�|d}|�|jd�|�|jd�|�|jdgdgdgd��|�|jd	�|�|j	d�dS)
Nrr���OKr;r<r9)r,r-zcontent-lengthr:)
rr�	response1rr0�code�phraser#r$r%)rrr&rrr
�testSimpleResponse�s
z&MessageParsingTests.testSimpleResponsecCsn|j}|�t�|�t|�d�|d}|�|jddd�|�|jddd�|�|jddd�dS)	zv
        A header may be split across multiple lines.  Subsequent lines begin
        with C{" "} or C{"\t"}.
        rr�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.2r2zHSIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bK776asdhds ;received=192.0.2.1N)rr�response_multilinerr0r#)rrr&rrr
�test_multiLine�s
z"MessageParsingTests.test_multiLineN)
rrrrrr'r1r5r7r>r@rFrIrrrr
rqs


rc@seZdZdZdd�ZdS)�%MessageParsingFeedDataCharByCharTestsz9
    Same as base class, but feed data char by char.
    cCs(x|D]}|j�|�qW|j��dS)N)rrr)rr�crrr
r�s
z1MessageParsingFeedDataCharByCharTests.feedMessageN)rrr�__doc__rrrrr
rJ�srJc@s$eZdZdd�Zdd�Zdd�ZdS)�MakeMessageTestscCs,t�dd�}|�dd�|�|��d�dS)Nr(zsip:foor;r<z$INVITE sip:foo SIP/2.0
Foo: bar

)r�Request�	addHeaderrr")r�rrrr
�testRequest�s
zMakeMessageTests.testRequestcCsBt�dd�}|�dd�|�dd�|�d�|�|��d�dS)	NrArBr;r<zContent-Lengthr+r3z3SIP/2.0 200 OK
Foo: bar
Content-Length: 4

1234)r�ResponserOZbodyDataReceivedrr")rrPrrr
�testResponses
zMakeMessageTests.testResponsecCst�d�}|�|��d�dS)NrAzSIP/2.0 200 OK

)rrRrr")rrPrrr
�testStatusCodes
zMakeMessageTests.testStatusCodeN)rrrrQrSrTrrrr
rM�s
rMc@s\eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)�ViaTestscCs"|��}|�|t�|����dS)N)r"rr�parseViaHeader)r�v�srrr
�checkRoundtripszViaTests.checkRoundtripcCsHt�d�}t�d�}|�|j|j�|�|j|j�|�|j|j�dS)NzSIP/2.0/UDP 192.168.1.1:5060z SIP/2.0/UDP     192.168.1.1:5060)rrVr�	transport�host�port)rZv1Zv2rrr
�testExtraWhitespaces


zViaTests.testExtraWhitespacecCs�d}t�|�}|�|jd�|�|jd�|�|jd�|�|j�|�|j�|�	|j
�|�|jd�|�|jd�|�|j
d�|�|jd�|�|��d	�|�|�d
S)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.1Z
a7c6a8dlzerzKSIP/2.0/UDP first.example.com:4000;ttl=16;branch=a7c6a8dlze;maddr=224.2.0.1N)rrVrrZr[r\�assertIsNone�rport�
rportValue�assertFalse�rportRequested�ttl�maddr�branch�hiddenr"rY)rrXrWrrr
�test_complex s

zViaTests.test_complexcCs�d}t�|�}|�|jd�|�|jd�|�|jd�|�|j�|�|j�|�	|j
�|�|j�|�|j�|�|j
�|�|j�|�|��d�|�|�dS)z3
        Test parsing a simple Via header.
        zSIP/2.0/UDP example.com;hiddenr^zexample.comi�z#SIP/2.0/UDP example.com:5060;hiddenN)rrVrrZr[r\r`rarbrcrdrerfrg�
assertTruerhr"rY)rrXrWrrr
�test_simple7s

zViaTests.test_simplecCst�d�}|�|�dS)Nzexample.com)r�ViarY)rrWrrr
�testSimplerLs
zViaTests.testSimplercCs�tjddd�}|j|jgd�}|�t|�d�|�|ddd�|�|dd	t�|�|��d
�|�|j	�|�|j
�|�|j�dS)z|
        Setting rport to True is deprecated, but still produces a Via header
        with the expected properties.
        zfoo.barT)ra)�offendingFunctionsrrrz+rport=True is deprecated since Twisted 9.0.�categoryzSIP/2.0/UDP foo.bar:5060;rportN)
rrl�
flushWarnings�test_deprecatedRPortrr0�DeprecationWarningr"rjrardr`rb)rrW�warningsrrr
rqQs

zViaTests.test_deprecatedRPortcCs:tjddd�}|�|��d�|�|j�|�|j�dS)zU
        An rport setting of None should insert the parameter with no value.
        zfoo.barN)razSIP/2.0/UDP foo.bar:5060;rport)rrlrr"rjrdr`rb)rrWrrr
�
test_rporthszViaTests.test_rportcCsJtjddd�}|�|��d�|�|j�|�|jd�|�|jd�dS)zk
        An rport numeric setting should insert the parameter with the number
        value given.
        zfoo.barr)raz SIP/2.0/UDP foo.bar:5060;rport=1N)rrlrr"rcrdrbra)rrWrrr
�test_rportValuers
zViaTests.test_rportValuecCsnd}t�|�}|�|jd�|�|jd�|�|jd�|�|jd�|�|jd�|�|�	��
d�d�dS)	Nz8SIP/2.0/UDP 10.0.0.1:5060;received=22.13.1.5;rport=12345r^z10.0.0.1i�z	22.13.1.5i90zrport=12345���)rrVrrZr[r\�receivedraZassertNotEqualr"�find)rrXrWrrr
�testNAT~s
zViaTests.testNATcCs"d}t�|�}|�|��|�dS)zZ
        Parsing and serializing Via headers with unknown parameters should work.
        z?SIP/2.0/UDP example.com:5060;branch=a12345b;bogus;pie=deliciousN)rrVrr")rrXrWrrr
�test_unknownParams�s
zViaTests.test_unknownParamsN)
rrrrYr]rirkrmrqrtruryrzrrrr
rUs
rUc@seZdZdd�Zdd�ZdS)�URLTestscCs(x"dD]}|�t�|���|�qWdS)N)zsip:j.doe@big.comz&sip:j.doe:secret@big.com;transport=tcpz!sip:j.doe@big.com?subject=projectzsip:example.com)rr�parseURLr")r�urlrrr
�
testRoundtrip�s
zURLTests.testRoundtripcCs^d}t�|�}xJdddddddd	d
ddd
gfdddd�fgD]\}}|�t||�|�q<WdS)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[Zhosta)r\�{)rZZudp)ZusertypeZphone)r r;)re�)rfz1.2.3.4�otherZblahzgoo=barr#�b�d)�arK)rr|r�getattr)rrXr}�krWrrr
�testComplex�s
zURLTests.testComplexN)rrrr~r�rrrr
r{�s
r{c@seZdZdd�ZdS)�
ParseTestsc
Cs�x�dddifdddifdddifdddifdd	dd
dd�fgD]D\}}}}t�|�\}}}|�||�|�|��|�|�||�q>WdS)
Nz""A. G. Bell" <sip:foo@example.com>z
A. G. Bellzsip:foo@example.comzAnon <sip:foo@example.com>ZAnonr:z<sip:foo@example.com>z)foo <sip:foo@example.com>;tag=bar;foo=bazr;r<Zbaz)�tagr;)rZparseAddressrr")r�address�nameZurls�params�gnameZgurlZgparamsrrr
�testParseAddress�s


zParseTests.testParseAddressN)rrrr�rrrr
r��sr�c@seZdZdd�ZdS)�DummyLocatorcCst�tjddd��S)Nz
server.comi�)r\)rZsucceedr�URL)r�
logicalURLrrr
�
getAddress�szDummyLocator.getAddressN)rrrr�rrrr
r��sr�c@seZdZdd�ZdS)�FailingLocatorcCst�t��S)N)rZfail�LookupError)rr�rrr
r��szFailingLocator.getAddressN)rrrr�rrrr
r��sr�c@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�
ProxyTestscs0t�d��_t��j_g�_�fdd��j_dS)Nz	127.0.0.1cs�j�||f�S)N)�sentr)�dest�msg)rrr
r�rz"ProxyTests.setUp.<locals>.<lambda>)rZProxy�proxyr��locatorr��sendMessage)rr)rr
r�s
zProxyTests.setUpcCs�t�dd�}|�dt�d����|�dt�d����|�dd�|�dd	�|�d
d�|j�|��d�|�t|j	�d
�|j	d\}}|�|j
d�|�|jd�|�|j��d�|�|j
d�|�|jddddg�dS)Nr(zsip:foorGz1.2.3.4z1.2.3.5r;r<r-z<sip:joe@server.com>�contactz<sip:joe@1.2.3.5>)z1.2.3.4i�rri�z
server.comzSIP/2.0/UDP 127.0.0.1:5060zSIP/2.0/UDP 1.2.3.4:5060zSIP/2.0/UDP 1.2.3.5:5060)rrNrOrlr"r��datagramReceivedrr0r�r\r[r!r r#)rrPr�r&rrr
�testRequestForward�s"zProxyTests.testRequestForwardcCs�t�dd�}|�dt�d����|�dd�|�dd�|�d	d
�|j�|��d�|jd\}}|�|j	dd
dg�dS)Nr(zsip:foorGz1.2.3.4r;r<r-z<sip:joe@server.com>r�z<sip:joe@1.2.3.4>)z1.1.1.1i�rzSIP/2.0/UDP 127.0.0.1:5060z)SIP/2.0/UDP 1.2.3.4:5060;received=1.1.1.1)
rrNrOrlr"r�r�r�rr#)rrPr�r&rrr
�testReceivedRequestForward�sz%ProxyTests.testReceivedRequestForwardcCsHt�d�}|�dt�d����|j�|��d�|�t|j	�d�dS)NrArGzfoo.com)z1.1.1.1i�r)
rrRrOrlr"r�r�rr0r�)rrPrrr
�testResponseWrongVia�s
zProxyTests.testResponseWrongViacCs�t�d�}|�dt�d����|�dtjddd����|j�|��d�|�t|j	�d�|j	d	\}}|�|j
|jfd
�|�|jd�|�|j
ddg�dS)NrArGz	127.0.0.1z
client.comi�)r\)z1.1.1.1i�rr)z
client.comi�zSIP/2.0/UDP client.com:1234)rrRrOrlr"r�r�rr0r�r[r\rDr#)rrPr�r&rrr
�testResponseForwards
zProxyTests.testResponseForwardcCs�t�d�}|�dt�d����|�dtjddd����|j�|��d�|�t|j	�d�|j	d	\}}|�|j
|jfd
�dS)NrArGz	127.0.0.1z10.0.0.1z
client.com)rw)z1.1.1.1i�rr)z
client.comi�)rrRrOrlr"r�r�rr0r�r[r\)rrPr�r&rrr
�testReceivedResponseForward
s
z&ProxyTests.testReceivedResponseForwardcs�t�d�}|�dt�d����g��fdd�|j_|j�|��d�|�t	��d��d\}}|�t	|j
�dg��d�|�|jd�dS)	NrArGz	127.0.0.1cs
��|�S)N)r)r�)rrr
rrz-ProxyTests.testResponseToUs.<locals>.<lambda>)z1.1.1.1i�rr)
rrRrOrlr"r�ZgotResponser�rr0r#�getrD)rrPr&�addrr)rr
�testResponseToUss
zProxyTests.testResponseToUscCs\t�dd�}|�dt�d����|�dt�d����|j�|��d�|�|jg�dS)Nr(zsip:foorGz1.2.3.4z	127.0.0.1)z
client.comi�)	rrNrOrlr"r�r�rr�)rrPrrr
�testLoop%s
zProxyTests.testLoopcCs�t�dd�}|�dt�d����|�dd�t�|j_|j�|��d�|�	t
|j�d�|jd	\}}|�	|j|j
fd�|�	|jd
�|�	|jddg�dS)Nr(zsip:foorGz1.2.3.4r-z<sip:joe@server.com>)z1.2.3.4i�rri�zSIP/2.0/UDP 1.2.3.4:5060)rrNrOrlr"r�r�r�r�rr0r�r[r\rDr#)rrPr�r&rrr
�testCantForwardRequest-s
z!ProxyTests.testCantForwardRequestN)rrrrr�r�r�r�r�r�r�r�rrrr
r��s
r�c@sleZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�RegistrationTestscsFtjdd��_t�d��_�j�j_�j_g�_�fdd��j_dS)Nz	127.0.0.1)r[zbell.example.comcs�j�||f�S)N)r�r)r�r�)rrr
rBrz)RegistrationTests.setUp.<locals>.<lambda>)r�
RegisterProxyr��InMemoryRegistry�registryr�r�r�)rr)rr
r=s
zRegistrationTests.setUpcCs*x |jj��D]\}}|��qW|`dS)N)r��users�values�cancelr�)rr�r!rrr
�tearDownEszRegistrationTests.tearDowncCsPt�dd�}|�dd�|�dd�|�dt�d����|j�|��d	�dS)
N�REGISTERzsip:bell.example.comr-zsip:joe@bell.example.comr�zsip:joe@client.com:1234rGz
client.com)z
client.comi�)rrNrOrlr"r�r�)rrPrrr
�registerKs
zRegistrationTests.registercCs\t�dd�}|�dd�|�dd�|�dt�d����|�d	d
�|j�|��d�dS)Nr�zsip:bell.example.comr-zsip:joe@bell.example.comr��*rGz
client.com�expiresr9)z
client.comi�)rrNrOrlr"r�r�)rrPrrr
�
unregisterSszRegistrationTests.unregistercCs|��|jd\}}|�|j|jfd�|�|jd�|�|jddg�|�|jddg�|�|jdd	g�tt�t	kr�|�
t|jd
d�dk�|�t|j
j�d�|j
jd
\}}|�|��d	�|jj�tjd
dd��}|�dd��|�|jd�|S)Nr)z
client.comi�rArGzSIP/2.0/UDP client.com:5060r-zsip:joe@bell.example.comr�zsip:joe@client.com:5060r�)iiiirr*zbell.example.com)rr[cSs|j|jfS)N)r[r\)Zdesturlrrr
rorz0RegistrationTests.testRegister.<locals>.<lambda>)r�r�rr[r\rDr#�typerrrj�intr0r�r�r"r�r�r�rr��addCallback)rr�r&Zdcr!r�rrr
�testRegister\s$
zRegistrationTests.testRegistercCs�|��|��|jd\}}|�|j|jfd�|�|jd�|�|jddg�|�|jddg�|�|jdd	g�|�|jd
dg�|�|jj	i�dS)Nr)z
client.comi�rArGzSIP/2.0/UDP client.com:5060r-zsip:joe@bell.example.comr�zsip:joe@client.com:5060r�r9)
r�r�r�rr[r\rDr#r�r�)rr�r&rrr
�testUnregistertsz RegistrationTests.testUnregistercCs:t�}t�|�}t��}|�dd�|�|�||j_dS)NzuserXname@127.0.0.1Z	passXword)rrZPortalrZ'InMemoryUsernamePasswordDatabaseDontUseZaddUserZregisterCheckerr�)rrP�prKrrr
�	addPortal�s

zRegistrationTests.addPortalcCsV|��|��|�t|jj�d�|�t|j�d�|jd\}}|�|jd�dS)Nrri�)r�r�rr0r�r�r�rD)rr�r&rrr
�testFailedAuthentication�sz*RegistrationTests.testFailedAuthenticationcCsbt�dd�}|�dd�|�dd�|�dt�d����|j�|��d	�|�t|j	�d
�dS)Nr�z
sip:wrong.comr-zsip:joe@bell.example.comr�zsip:joe@client.com:1234rGz
client.com)z
client.comi�r)
rrNrOrlr"r�r�rr0r�)rrPrrr
�testWrongDomainRegister�sz)RegistrationTests.testWrongDomainRegistercCsbt�dd�}|�dd�|�dd�|�dt�d����|j�|��d	�|�t|j	�d
�dS)Nr�zsip:bell.example.comr-zsip:joe@foo.comr�zsip:joe@client.com:1234rGz
client.com)z
client.comi�r)
rrNrOrlr"r�r�rr0r�)rrPrrr
�testWrongToDomainRegister�sz+RegistrationTests.testWrongToDomainRegistercCs4|��tjddd�}|jj�|�}|�|t�|S)Nr*zfoo.com)rr[)r�rr�r�r�r��
assertFailurer�)rr}r�rrr
�testWrongDomainLookup�s
z'RegistrationTests.testWrongDomainLookupcCs4|��tjddd�}|jj�|�}|�|t�|S)NZjanezbell.example.com)rr[)r�rr�r�r�r�r�r�)rr}r�rrr
�testNoContactLookup�s
z%RegistrationTests.testNoContactLookupN)rrrrr�r�r�r�r�r�r�r�r�r�r�rrrr
r�;s	
	
		r�c@seZdZdd�Zdd�ZdS)�ClientcCs tj�|�g|_t��|_dS)N)r�Base�__init__rwrZDeferred�deferred)rrrr
r��szClient.__init__cCs|j�|�|j�|j�dS)N)rwrr��callback)r�responser�rrr
�handle_response�szClient.handle_responseN)rrrr�r�rrrr
r��sr�c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�	LiveTestscCsztjdd�|_t�d�|_|j|j_|j_tjd|jdd�|_t	�|_
tjd|j
dd�|_|j��j
|j��jf|_dS)Nz	127.0.0.1)r[zbell.example.comr)Z	interface)rr�r�r�r�r�rZ	listenUDP�
serverPortr��client�
clientPort�getHostr[r\�
serverAddress)rrrr
r�s
zLiveTests.setUpcCsLx |jj��D]\}}|��qWt�|jj�}t�|jj�}t�	||g�S)N)
r�r�r�r�rZ
maybeDeferredr�Z
stopListeningr�Z
gatherResults)rr�r!Zd1Zd2rrr
r��s
zLiveTests.tearDowncs��j��j}t�dd�}|�dd�|�dd|�|�dtjd|d	�����j�	tj
d�jd
d�|��jj}�fdd
�}|�
|�|S)Nr�zsip:bell.example.comr-zsip:joe@bell.example.comr�zsip:joe@127.0.0.1:%drGz	127.0.0.1)r\r)r[r\cs*��t|�d�|d}��|jd�dS)NrrrA)rr0rD)rwrP)rrr
�check�sz%LiveTests.testRegister.<locals>.check)r�r�r\rrNrOrlr"r�r�r�r�r�r�)rr�rPr�r�r)rr
r��s
zLiveTests.testRegistercs��j��j}t�dd�}|�dd�|�dd|�|�dtjd|d	d
�����j�j	gd�}��
t|�d���
|d
dd���
|d
dt��j
�tjd�jdd�|��j
j}�fdd�}|�|�|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.
        r�zsip:bell.example.comr-zsip:joe@bell.example.comr�zsip:joe@127.0.0.1:%drGz	127.0.0.1T)r\ra)rnrrrz+rport=True is deprecated since Twisted 9.0.ro)r[r\cs*��t|�d�|d}��|jd�dS)NrrrA)rr0rD)rwrP)rrr
r�sz)LiveTests.test_amoralRPort.<locals>.check)r�r�r\rrNrOrlr"rp�test_amoralRPortrr0rrr�r�r�r�r�r�)rr�rPrsr�r�r)rr
r��s*	


zLiveTests.test_amoralRPortN)rrrrr�r�r�rrrr
r��s
r�)(rLZtwisted.credrrZtwisted.internetrrZtwisted.protocolsrZ
twisted.trialrZtwisted.internet.asyncioreactorrZzope.interfacer	�replacer/r4r6r=rCr?Zrequest_nattedrHrZTestCaserrJrMrUr{r�ZILocatorr�r�r�r�r�r�r�rrrr
�<module>s@

	zl|