Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[default]
exten => s,1,NoOp()
same => n,Hangup()
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[local]
type=transport
protocol=udp
bind=0.0.0.0

[first_dest]
type=aor
contact=sip:[email protected]:5061
max_contacts=1

[first_dest]
type=endpoint
context=default
aors=first_dest
direct_media=no
disallow=all
allow=ulaw
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE scenario SYSTEM "sipp.dtd">

<scenario name="Verify no MESSAGE received at redirect destination">
<!-- This scenario verifies that NO MESSAGE is received at the redirect destination.

Approach:
1. Send OPTIONS to Asterisk to establish the scenario
2. Receive response to OPTIONS (typically 401 Unauthorized)
3. Pause for 5 seconds
4. If any MESSAGE arrives during this time, SIPp will fail with "unexpected message"
5. If no MESSAGE arrives, test passes -->

<!-- Send OPTIONS to establish the scenario -->
<send>
<![CDATA[

OPTIONS sip:127.0.0.1 SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
To: sip:127.0.0.1
Call-ID: [call_id]
CSeq: 1 OPTIONS
Contact: sip:sipp@[local_ip]:[local_port]
Max-Forwards: 70
Content-Length: 0

]]>
</send>

<!-- Receive response to OPTIONS (typically 401 Unauthorized) -->
<recv response="401">
</recv>

<!-- Wait 5 seconds. If MESSAGE arrives during this pause, SIPp will fail automatically -->
<pause milliseconds="5000" />

</scenario>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE scenario SYSTEM "sipp.dtd">

<scenario name="MESSAGE responds with 305 but should not be redirected">
<recv request="MESSAGE" crlf="true">
</recv>

<send retrans="500">
<![CDATA[

SIP/2.0 305 Use Proxy
[last_Via:]
[last_From:]
[last_To:];tag=[pid]SIPpTag01[call_number]
[last_Call-ID:]
[last_CSeq:]
Contact: <sip:[email protected]:5062>
Content-Length: 0

]]>
</send>

</scenario>
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
testinfo:
summary: 'Test MESSAGE does NOT redirect when redirect_method is not set'
description: |
'This test verifies that when an outgoing SIP MESSAGE receives a 305
redirect response, Asterisk does NOT follow the redirect when the
endpoint is configured without redirect_method (default behavior).

Test flow:
1. AMI MessageSend action triggers MESSAGE to first_dest endpoint
2. SIPp scenario at port 5061 responds with 305 Use Proxy
3. 305 response contains Contact header pointing to port 5062
4. SIPp scenario at port 5062 sends OPTIONS and waits 5 seconds
5. Asterisk should NOT send a MESSAGE to port 5062 (no redirect)
6. If unexpected MESSAGE received on 5062, SIPp fails the test
7. Test passes if both scenarios complete without unexpected messages'

properties:
dependencies:
- app: 'sipp'
- asterisk: 'res_pjsip'
- asterisk: 'res_pjsip_messaging'
tags:
- pjsip

test-modules:
test-object:
config-section: test-object-config
typename: 'sipp.SIPpTestCase'
modules:
-
config-section: ami-config
typename: 'pluggable_modules.EventActionModule'

test-object-config:
reactor-timeout: 15
connect-ami: true
stop-after-scenarios: true
test-iterations:
-
scenarios:
- {'key-args': {'scenario': 'no_redirect_305.xml', '-p': '5061', '-m': '1'}}
- {'key-args': {'scenario': 'no_message_expected.xml', '-p': '5062', '-m': '1', '-default_behaviors': 'abortunexp'}}

ami-config:
-
ami-start:
ami-actions:
delay: 1
action:
Action: 'MessageSend'
To: 'pjsip:first_dest'
From: 'sip:sender@asterisk'
Body: 'Test message that should not be redirected'
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[default]
exten => s,1,NoOp()
same => n,Hangup()
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[local]
type=transport
protocol=udp
bind=0.0.0.0

[first_dest]
type=aor
contact=sip:[email protected]:5061
max_contacts=1

[first_dest]
type=endpoint
context=default
aors=first_dest
direct_media=no
disallow=all
allow=ulaw
redirect_method=uri_pjsip
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE scenario SYSTEM "sipp.dtd">

<scenario name="MESSAGE final destination">
<recv request="MESSAGE" crlf="true">
<action>
<!-- Verify this is the redirected MESSAGE -->
<ereg search_in="msg" regexp="MESSAGE sip:redirected@"
check_it="true" assign_to="junk1"/>
<ereg search_in="body" regexp="My test redirect message"
check_it="true" assign_to="junk2"/>
</action>
</recv>
<Reference variables="junk1"/>
<Reference variables="junk2"/>

<send>
<![CDATA[

SIP/2.0 202 Accepted
[last_Via:]
[last_From:]
[last_To:];tag=[call_number]
[last_Call-ID:]
[last_CSeq:]
Content-Length: 0

]]>
</send>

</scenario>
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE scenario SYSTEM "sipp.dtd">

<scenario name="MESSAGE redirect with 305">
<recv request="MESSAGE" crlf="true">
<action>
<ereg search_in="body" regexp="My test redirect message"
check_it="true" assign_to="junk"/>
</action>
</recv>
<Reference variables="junk"/>

<send retrans="500">
<![CDATA[

SIP/2.0 305 Use Proxy
[last_Via:]
[last_From:]
[last_To:];tag=[pid]SIPpTag01[call_number]
[last_Call-ID:]
[last_CSeq:]
Contact: <sip:[email protected]:5062>
Content-Length: 0

]]>
</send>

<pause milliseconds="1000" />

</scenario>
51 changes: 51 additions & 0 deletions tests/channels/pjsip/message/message_redirect/test-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
testinfo:
summary: 'Test MESSAGE redirect with 305 Use Proxy'
description: |
'This test verifies that when an outgoing SIP MESSAGE receives a 305
redirect response, Asterisk properly follows the redirect to the URI
specified in the Contact header. The endpoint is configured with
redirect_method=uri_pjsip.

Test flow:
1. AMI MessageSend action triggers MESSAGE to first_dest endpoint
2. SIPp scenario at port 5061 responds with 305 Use Proxy
3. 305 response contains Contact header with redirected destination
4. Asterisk sends new MESSAGE to the redirected URI
5. SIPp scenario at port 5062 receives redirected MESSAGE and responds 202'

properties:
dependencies:
- app: 'sipp'
- asterisk: 'res_pjsip'
- asterisk: 'res_pjsip_messaging'
tags:
- pjsip

test-modules:
test-object:
config-section: test-object-config
typename: 'sipp.SIPpTestCase'
modules:
-
config-section: ami-config
typename: 'pluggable_modules.EventActionModule'

test-object-config:
reactor-timeout: 15
connect-ami: true
stop-after-scenarios: true
test-iterations:
-
scenarios:
- {'key-args': {'scenario': 'redirect_305.xml', '-p': '5061'}}
- {'key-args': {'scenario': 'final_destination.xml', '-p': '5062'}}

ami-config:
-
ami-start:
ami-actions:
action:
Action: 'MessageSend'
To: 'pjsip:first_dest'
From: 'sip:sender@asterisk'
Body: 'My test redirect message'
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[default]
exten => s,1,NoOp()
same => n,Hangup()
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[local]
type=transport
protocol=udp
bind=0.0.0.0

[first_dest]
type=aor
contact=sip:[email protected]:5061
max_contacts=1

[first_dest]
type=endpoint
context=default
aors=first_dest
direct_media=no
disallow=all
allow=ulaw
redirect_method=uri_pjsip
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE scenario SYSTEM "sipp.dtd">

<scenario name="MESSAGE contact1 accepts">
<recv request="MESSAGE" crlf="true">
<action>
<!-- Verify this is the redirected MESSAGE to contact1 -->
<ereg search_in="msg" regexp="MESSAGE sip:contact1@"
check_it="true" assign_to="junk1"/>
<ereg search_in="body" regexp="Iteration [0-9]+:"
check_it="true" assign_to="junk2"/>
</action>
</recv>
<Reference variables="junk1"/>
<Reference variables="junk2"/>

<send>
<![CDATA[

SIP/2.0 202 Accepted
[last_Via:]
[last_From:]
[last_To:];tag=[call_number]
[last_Call-ID:]
[last_CSeq:]
Content-Length: 0

]]>
</send>

</scenario>
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE scenario SYSTEM "sipp.dtd">

<scenario name="MESSAGE contact1 redirects to contact2">
<recv request="MESSAGE" crlf="true">
<action>
<ereg search_in="msg" regexp="MESSAGE sip:contact1@"
check_it="true" assign_to="junk1"/>
<ereg search_in="body" regexp="Iteration [0-9]+:"
check_it="true" assign_to="junk2"/>
</action>
</recv>
<Reference variables="junk1"/>
<Reference variables="junk2"/>

<send retrans="500">
<![CDATA[

SIP/2.0 305 Use Proxy
[last_Via:]
[last_From:]
[last_To:];tag=[pid]SIPpTag01[call_number]
[last_Call-ID:]
[last_CSeq:]
Contact: <sip:[email protected]:5063>
Content-Length: 0

]]>
</send>

<pause milliseconds="500" />

</scenario>
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE scenario SYSTEM "sipp.dtd">

<scenario name="MESSAGE contact1 rejects">
<recv request="MESSAGE" crlf="true">
<action>
<!-- Verify this is the redirected MESSAGE to contact1 -->
<ereg search_in="msg" regexp="MESSAGE sip:contact1@"
check_it="true" assign_to="junk1"/>
<ereg search_in="body" regexp="Iteration [0-9]+:"
check_it="true" assign_to="junk2"/>
</action>
</recv>
<Reference variables="junk1"/>
<Reference variables="junk2"/>

<send>
<![CDATA[

SIP/2.0 403 Forbidden
[last_Via:]
[last_From:]
[last_To:];tag=[call_number]
[last_Call-ID:]
[last_CSeq:]
Content-Length: 0

]]>
</send>

<pause milliseconds="500" />

</scenario>
Loading
Loading