Skip to content

Commit

Permalink
pjsip: identify: transport tests for bind address, network, port and …
Browse files Browse the repository at this point in the history
…protocol.
  • Loading branch information
viktike authored and network committed Apr 3, 2024
1 parent 91e3a64 commit 6f85628
Show file tree
Hide file tree
Showing 6 changed files with 274 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/channels/pjsip/identify/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ tests:
- test: 'header'
- test: 'header_or_ip'
- test: 'request_uri'
- test: 'transport'
- test: 'header_ordering_header_ip'
- test: 'header_ordering_ip_header'
- test: 'ordering'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[default]

exten => echo,1,Log(NOTICE,PJSIP matched endpoint: ${CUT(CHANNEL,-,1)})
same => n,Answer()
same => n,Echo()
same => n,Hangup()
83 changes: 83 additions & 0 deletions tests/channels/pjsip/identify/transport/configs/ast1/pjsip.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
[global]
type=global
debug=yes

[system]
type=system
timer_t1=100
timer_b=6400

[unused-local-transport]
type=transport
bind=127.0.0.1
protocol=udp

[local-transport-template](!)
type=transport
bind=127.0.0.2:5060

[another-local-transport-template](!)
type=transport
bind=127.0.0.3:5061

[local-transport-udp](local-transport-template)
protocol=udp

[local-transport-tcp](local-transport-template)
protocol=tcp

[another-local-transport-udp](another-local-transport-template)
protocol=udp

[another-local-transport-tcp](another-local-transport-template)
protocol=tcp

[endpoint-template-ipv4](!)
type=endpoint
context=default
allow=!all,ulaw,alaw
media_address=127.0.0.2
identify_by=transport

[another-endpoint-template-ipv4](!)
type=endpoint
context=default
allow=!all,ulaw,alaw
media_address=127.0.0.3
identify_by=transport

[alice](endpoint-template-ipv4)
transport=local-transport-udp

[bob](endpoint-template-ipv4)
transport=local-transport-tcp

[carol](another-endpoint-template-ipv4)
transport=another-local-transport-udp

[dave](another-endpoint-template-ipv4)
transport=another-local-transport-tcp

[identify-template](!)
type=identify

[alice](identify-template)
endpoint=alice
match=127.0.0.2 ; match bind IP only
transport=udp ; match transport protocol

[bob](identify-template)
endpoint=bob
match=127.0.0.2/32 ; match bind IP in a CIDR network range
transport=tcp

[carol](identify-template)
endpoint=carol
match=127.0.0.3
transport=udp ; don't match the transport protocol

[dave](identify-template)
endpoint=dave
match=127.0.0.3:5061 ; match bind IP and bind port
;transport=tcp ; don't match the transport protocol

85 changes: 85 additions & 0 deletions tests/channels/pjsip/identify/transport/sipp/nominal.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE scenario SYSTEM "sipp.dtd">

<scenario name="INVITE to echo with SDP in initial INVITE">
<send retrans="500">
<![CDATA[
INVITE sip:echo@[remote_ip]:[remote_port] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: test1 <sip:[service]@[local_ip]:[local_port]>;tag=[call_number]
To: test <sip:test@[remote_ip]:[remote_port]>
Call-ID: [call_id]
CSeq: 1 INVITE
Contact: <sip:test@[local_ip]:[local_port];transport=[transport]>
Max-Forwards: 70
Subject: Test
User-Agent: Test
Content-Type: application/sdp
Content-Length: [len]
v=0
o=phoneA 53655765 2353687637 IN IP[local_ip_type] [local_ip]
s=-
c=IN IP[media_ip_type] [media_ip]
t=0 0
m=audio 6000 RTP/AVP 0
a=rtpmap:0 PCMU/8000
]]>
</send>

<recv response="100"
optional="true">
</recv>

<recv response="200" rtd="true">
</recv>

<send>
<![CDATA[
ACK sip:echo@[remote_ip]:[remote_port] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: test1 <sip:[service]@[local_ip]:[local_port]>;tag=[call_number]
To: test <sip:test@[remote_ip]:[remote_port]>[peer_tag_param]
Call-ID: [call_id]
CSeq: 1 ACK
Contact: <sip:test@[local_ip]:[local_port];transport=[transport]>
Max-Forwards: 70
Subject: Test
Content-Length: 0
]]>
</send>

<pause/>

<send retrans="500">
<![CDATA[
BYE sip:echo@[remote_ip]:[remote_port] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: test1 <sip:[service]@[local_ip]:[local_port]>;tag=[call_number]
To: test <sip:test@[remote_ip]:[remote_port]>[peer_tag_param]
Call-ID: [call_id]
CSeq: 2 BYE
Contact: <sip:test@[local_ip]:[local_port];transport=[transport]>
Max-Forwards: 70
Subject: Test
Content-Length: 0
]]>
</send>

<recv response="200" crlf="true">
</recv>

<!-- definition of the response time repartition table (unit is ms) -->
<ResponseTimeRepartition value="10, 20, 30, 40, 50, 100, 150, 200"/>

<!-- definition of the call length repartition table (unit is ms) -->
<CallLengthRepartition value="10, 50, 100, 500, 1000, 5000, 10000"/>

</scenario>

59 changes: 59 additions & 0 deletions tests/channels/pjsip/identify/transport/sipp/off-nominal.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE scenario SYSTEM "sipp.dtd">

<scenario name="INVITE to echo with SDP in initial INVITE">
<send retrans="500">
<![CDATA[
INVITE sip:echo@[remote_ip]:[remote_port] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: test1 <sip:[service]@[local_ip]:[local_port]>;tag=[call_number]
To: test <sip:test@[remote_ip]:[remote_port]>
Call-ID: [call_id]
CSeq: 1 INVITE
Contact: <sip:test@[local_ip]:[local_port];transport=[transport]>
Max-Forwards: 70
Subject: Test
User-Agent: Test
Content-Type: application/sdp
Content-Length: [len]
v=0
o=phoneA 53655765 2353687637 IN IP[local_ip_type] [local_ip]
s=-
c=IN IP[media_ip_type] [media_ip]
t=0 0
m=audio 6000 RTP/AVP 0
a=rtpmap:0 PCMU/8000
]]>
</send>

<recv response="401" rtd="true">
</recv>

<send>
<![CDATA[
ACK sip:echo@[remote_ip]:[remote_port] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: test1 <sip:[service]@[local_ip]:[local_port]>;tag=[call_number]
To: test <sip:test@[remote_ip]:[remote_port]>[peer_tag_param]
Call-ID: [call_id]
CSeq: 1 ACK
Contact: <sip:test@[local_ip]:[local_port];transport=[transport]>
Max-Forwards: 70
Subject: Test
Content-Length: 0
]]>
</send>

<!-- definition of the response time repartition table (unit is ms) -->
<ResponseTimeRepartition value="10, 20, 30, 40, 50, 100, 150, 200"/>

<!-- definition of the call length repartition table (unit is ms) -->
<CallLengthRepartition value="10, 50, 100, 500, 1000, 5000, 10000"/>

</scenario>

40 changes: 40 additions & 0 deletions tests/channels/pjsip/identify/transport/test-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
testinfo:
summary: 'Tests incoming calls identified by header'
description: |
This test covers sending calls to an Asterisk instance
identified by a custom header. If the custom header
matches, the call is accepted; if not, Asterisk responds
with a 401 (as we 401 any non-matching call for security
reasons).
test-modules:
test-object:
config-section: test-object-config
typename: 'sipp.SIPpTestCase'

test-object-config:
memcheck-delay-stop: 7
fail-on-any: True
test-iterations:
# IPv4 & TCP / UDP
-
scenarios:
- { 'key-args': {'scenario': 'nominal.xml', '-i': '127.0.0.1', '-p': '5061', '-s': 's', '-t': 'u1' },
'ordered-args': ['127.0.0.2:5060'] }
- { 'key-args': {'scenario': 'nominal.xml', '-i': '127.0.0.1', '-p': '5062', '-s': 's', '-t': 't1'},
'ordered-args': ['127.0.0.2:5060'] }
- { 'key-args': {'scenario': 'nominal.xml', '-i': '127.0.0.1', '-p': '5063', '-s': 's', '-t': 'u1' },
'ordered-args': ['127.0.0.3:5061'] }
- { 'key-args': {'scenario': 'nominal.xml', '-i': '127.0.0.1', '-p': '5064', '-s': 's', '-t': 't1' },
'ordered-args': ['127.0.0.3:5061'] }
- { 'key-args': {'scenario': 'off-nominal.xml', '-i': '127.0.0.1', '-p': '5065', '-s': 's' } }

properties:
dependencies:
- sipp :
version : 'v3.0'
- asterisk : 'app_echo'
- asterisk : 'res_pjsip'
- asterisk : 'res_pjsip_endpoint_identifier_ip'
tags:
- pjsip

0 comments on commit 6f85628

Please sign in to comment.