[Asterisk-code-review] testsuite: add validations for 181 and History-Info conversions (testsuite[17])

Friendly Automation asteriskteam at digium.com
Tue Sep 29 07:33:56 CDT 2020


Friendly Automation has submitted this change. ( https://gerrit.asterisk.org/c/testsuite/+/14954 )

Change subject: testsuite: add validations for 181 and History-Info conversions
......................................................................

testsuite: add validations for 181 and History-Info conversions

ASTERISK-29027 #close

Change-Id: I287c78b38f48817ea4547e3ab0370d26d2abf2e3
---
M tests/channels/pjsip/diversion/diversion_basic/sipp/user1.xml
M tests/channels/pjsip/diversion/diversion_caller_id/sipp/user1.xml
M tests/channels/pjsip/diversion/diversion_response/sipp/user1.xml
A tests/channels/pjsip/diversion/diversion_response_181/configs/ast1/extensions.conf
A tests/channels/pjsip/diversion/diversion_response_181/configs/ast1/pjsip.conf
A tests/channels/pjsip/diversion/diversion_response_181/sipp/user1.xml
A tests/channels/pjsip/diversion/diversion_response_181/sipp/user2.xml
A tests/channels/pjsip/diversion/diversion_response_181/test-config.yaml
A tests/channels/pjsip/diversion/history_info_request/configs/ast1/extensions.conf
A tests/channels/pjsip/diversion/history_info_request/configs/ast1/pjsip.conf
A tests/channels/pjsip/diversion/history_info_request/sipp/user1.xml
A tests/channels/pjsip/diversion/history_info_request/sipp/user2.xml
A tests/channels/pjsip/diversion/history_info_request/test-config.yaml
A tests/channels/pjsip/diversion/history_info_response_181/configs/ast1/extensions.conf
A tests/channels/pjsip/diversion/history_info_response_181/configs/ast1/pjsip.conf
A tests/channels/pjsip/diversion/history_info_response_181/sipp/user1.xml
A tests/channels/pjsip/diversion/history_info_response_181/sipp/user2.xml
A tests/channels/pjsip/diversion/history_info_response_181/test-config.yaml
A tests/channels/pjsip/diversion/no_diversion_response_181/configs/ast1/extensions.conf
A tests/channels/pjsip/diversion/no_diversion_response_181/configs/ast1/pjsip.conf
A tests/channels/pjsip/diversion/no_diversion_response_181/sipp/user1.xml
A tests/channels/pjsip/diversion/no_diversion_response_181/sipp/user2.xml
A tests/channels/pjsip/diversion/no_diversion_response_181/test-config.yaml
M tests/channels/pjsip/diversion/tests.yaml
A tests/channels/pjsip/history_info/diversion_request/configs/ast1/extensions.conf
A tests/channels/pjsip/history_info/diversion_request/configs/ast1/pjsip.conf
A tests/channels/pjsip/history_info/diversion_request/sipp/user1.xml
A tests/channels/pjsip/history_info/diversion_request/sipp/user2.xml
A tests/channels/pjsip/history_info/diversion_request/test-config.yaml
A tests/channels/pjsip/history_info/diversion_response_181/configs/ast1/extensions.conf
A tests/channels/pjsip/history_info/diversion_response_181/configs/ast1/pjsip.conf
A tests/channels/pjsip/history_info/diversion_response_181/sipp/user1.xml
A tests/channels/pjsip/history_info/diversion_response_181/sipp/user2.xml
A tests/channels/pjsip/history_info/diversion_response_181/test-config.yaml
A tests/channels/pjsip/history_info/history_info_request/configs/ast1/extensions.conf
A tests/channels/pjsip/history_info/history_info_request/configs/ast1/pjsip.conf
A tests/channels/pjsip/history_info/history_info_request/sipp/user1.xml
A tests/channels/pjsip/history_info/history_info_request/sipp/user2.xml
A tests/channels/pjsip/history_info/history_info_request/test-config.yaml
A tests/channels/pjsip/history_info/history_info_response_181/configs/ast1/extensions.conf
A tests/channels/pjsip/history_info/history_info_response_181/configs/ast1/pjsip.conf
A tests/channels/pjsip/history_info/history_info_response_181/sipp/user1.xml
A tests/channels/pjsip/history_info/history_info_response_181/sipp/user2.xml
A tests/channels/pjsip/history_info/history_info_response_181/test-config.yaml
A tests/channels/pjsip/history_info/no_diversion_response_181/configs/ast1/extensions.conf
A tests/channels/pjsip/history_info/no_diversion_response_181/configs/ast1/pjsip.conf
A tests/channels/pjsip/history_info/no_diversion_response_181/sipp/user1.xml
A tests/channels/pjsip/history_info/no_diversion_response_181/sipp/user2.xml
A tests/channels/pjsip/history_info/no_diversion_response_181/test-config.yaml
A tests/channels/pjsip/history_info/tests.yaml
M tests/channels/pjsip/tests.yaml
51 files changed, 1,843 insertions(+), 3 deletions(-)

Approvals:
  George Joseph: Looks good to me, approved
  Friendly Automation: Approved for Submit



diff --git a/tests/channels/pjsip/diversion/diversion_basic/sipp/user1.xml b/tests/channels/pjsip/diversion/diversion_basic/sipp/user1.xml
index a7c8dda..c21d27a 100644
--- a/tests/channels/pjsip/diversion/diversion_basic/sipp/user1.xml
+++ b/tests/channels/pjsip/diversion/diversion_basic/sipp/user1.xml
@@ -29,7 +29,7 @@
 
 	<recv response="100" optional="true" />
 
-	<recv response="181" optional="true" />
+	<recv response="181" />
 
 	<recv response="180" optional="true" />
 
diff --git a/tests/channels/pjsip/diversion/diversion_caller_id/sipp/user1.xml b/tests/channels/pjsip/diversion/diversion_caller_id/sipp/user1.xml
index cae005c..0151a16 100644
--- a/tests/channels/pjsip/diversion/diversion_caller_id/sipp/user1.xml
+++ b/tests/channels/pjsip/diversion/diversion_caller_id/sipp/user1.xml
@@ -29,7 +29,13 @@
 
 	<recv response="100" optional="true" />
 
-	<recv response="181" optional="true" />
+	<recv response="181">
+                <action>
+                        <!-- Check that the Diversion header is present and contains the correct caller id. -->
+	        	<ereg regexp=".*sip:user3.*" search_in="hdr" header="Diversion:" check_it="true" assign_to="1" />
+		        <log message="Received INVITE with Diversion header: [$1]." />
+		</action>
+	</recv>
 
 	<recv response="180" optional="true" />
 
diff --git a/tests/channels/pjsip/diversion/diversion_response/sipp/user1.xml b/tests/channels/pjsip/diversion/diversion_response/sipp/user1.xml
index cae005c..40d868f 100644
--- a/tests/channels/pjsip/diversion/diversion_response/sipp/user1.xml
+++ b/tests/channels/pjsip/diversion/diversion_response/sipp/user1.xml
@@ -29,7 +29,7 @@
 
 	<recv response="100" optional="true" />
 
-	<recv response="181" optional="true" />
+	<recv response="181" />
 
 	<recv response="180" optional="true" />
 
diff --git a/tests/channels/pjsip/diversion/diversion_response_181/configs/ast1/extensions.conf b/tests/channels/pjsip/diversion/diversion_response_181/configs/ast1/extensions.conf
new file mode 100644
index 0000000..4719251
--- /dev/null
+++ b/tests/channels/pjsip/diversion/diversion_response_181/configs/ast1/extensions.conf
@@ -0,0 +1,7 @@
+[general]
+
+[default]
+
+exten => user1,1,Dial(PJSIP/user1)
+exten => user2,1,Dial(PJSIP/user2)
+exten => user3,1,Dial(PJSIP/user3)
diff --git a/tests/channels/pjsip/diversion/diversion_response_181/configs/ast1/pjsip.conf b/tests/channels/pjsip/diversion/diversion_response_181/configs/ast1/pjsip.conf
new file mode 100644
index 0000000..dcd83e2
--- /dev/null
+++ b/tests/channels/pjsip/diversion/diversion_response_181/configs/ast1/pjsip.conf
@@ -0,0 +1,33 @@
+[system]
+type=system
+timer_t1=100
+timer_b=6400
+
+[local]
+type=transport
+protocol=udp
+bind=0.0.0.0
+
+[user1-aors]
+type=aor
+contact=sip:user1 at 127.0.0.1:5061
+
+[user1]
+type=endpoint
+context=default
+aors=user1-aors
+direct_media=no
+disallow=all
+allow=ulaw
+
+[user2-aors]
+type=aor
+contact=sip:user2 at 127.0.0.1:5062
+
+[user2]
+type=endpoint
+context=default
+aors=user2-aors
+direct_media=no
+disallow=all
+allow=ulaw
diff --git a/tests/channels/pjsip/diversion/diversion_response_181/sipp/user1.xml b/tests/channels/pjsip/diversion/diversion_response_181/sipp/user1.xml
new file mode 100644
index 0000000..9b9a696
--- /dev/null
+++ b/tests/channels/pjsip/diversion/diversion_response_181/sipp/user1.xml
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+
+<scenario name="send an invite to user2">
+	<send retrans="500">
+		<![CDATA[
+			INVITE sip:user2@[remote_ip]:[remote_port] SIP/2.0
+			Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+			From: user1 <sip:user1@[local_ip]:[local_port]>;tag=[call_number]
+			To: user2 <sip:user2@[remote_ip]:[remote_port]>
+			Call-ID: [call_id]
+			CSeq: [cseq] INVITE
+			Contact: sip:user1@[local_ip]:[local_port]
+			Max-Forwards: 70
+			Content-Type: application/sdp
+			Content-Length: [len]
+
+			v=0
+			o=- 1324901698 1324901698 IN IP[local_ip_type] [local_ip]
+			s=-
+			c=IN IP[media_ip_type] [media_ip]
+			t=0 0
+			m=audio [media_port] RTP/AVP 0 101
+			a=sendrecv
+			a=rtpmap:0 PCMU/8000
+			a=rtpmap:101 telephone-event/8000
+
+		]]>
+	</send>
+
+	<recv response="100" optional="true" />
+
+	<recv response="181">
+		<action>
+			<!-- Check that the Diversion header is present and contains the correct name. -->
+			<ereg regexp="amenhotep" search_in="hdr" header="Diversion:" check_it="true" assign_to="1" />
+			<log message="Received 181 with Diversion header: [$1]." />
+		</action>
+	</recv>
+
+	<recv response="180" optional="true" />
+
+	<recv response="183" optional="true" />
+
+	<recv response="200" />
+
+	<send>
+		<![CDATA[
+			ACK sip:user3@[remote_ip]:[remote_port] SIP/2.0
+			Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+			From: <sip:user1@[local_ip]>;tag=[call_number]
+			To: <sip:user3@[remote_ip]:[remote_port]>[peer_tag_param]
+			CSeq: [cseq] ACK
+			Call-ID: [call_id]
+			Max-Forwards: 70
+			Content-Length: 0
+
+		]]>
+	</send>
+
+	<send retrans="500">
+		<![CDATA[
+			BYE sip:user3@[remote_ip]:[remote_port] SIP/2.0
+			Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+			From: <sip:user1@[local_ip]>;tag=[call_number]
+			To: <sip:user3@[remote_ip]:[remote_port]>[peer_tag_param]
+			CSeq: [cseq] BYE
+			Call-ID: [call_id]
+			Max-Forwards: 70
+			Content-Length: 0
+		]]>
+	</send>
+
+	<recv response="200" crlf="true" />
+</scenario>
diff --git a/tests/channels/pjsip/diversion/diversion_response_181/sipp/user2.xml b/tests/channels/pjsip/diversion/diversion_response_181/sipp/user2.xml
new file mode 100644
index 0000000..39fa4cc
--- /dev/null
+++ b/tests/channels/pjsip/diversion/diversion_response_181/sipp/user2.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+
+<scenario name="send forwarding response back with diversion header">
+	<recv request="INVITE" crlf="true" />
+
+	<send>
+		<![CDATA[
+			SIP/2.0 181 Redirected
+			[last_Via:]
+			[last_From:]
+			[last_To:];tag=[call_number]
+			[last_Call-ID:]
+			[last_CSeq:]
+			Contact: <sip:user3@[local_ip]>
+			Diversion: <sip:amenhotep at 127.0.0.1>;reason=unconditional
+			Content-Length: 0
+		]]>
+	</send>
+	<send retrans="500">
+		<![CDATA[
+			SIP/2.0 200 OK
+			[last_Via:]
+			[last_From:]
+			[last_To:];tag=[call_number]
+			[last_Call-ID:]
+			[last_CSeq:]
+			Contact: <sip:user2@[local_ip]:[local_port];transport=[transport]>
+			Content-Type: application/sdp
+			Content-Length: [len]
+
+			v=0
+			o=- 1324901698 1324901698 IN IP[local_ip_type] [local_ip]
+			s=-
+			c=IN IP[media_ip_type] [media_ip]
+			t=0 0
+			m=audio [media_port] RTP/AVP 0 101
+			a=sendrecv
+			a=rtpmap:0 PCMU/8000
+			a=rtpmap:101 telephone-event/8000
+
+		]]>
+	</send>
+
+	<recv request="ACK"/>
+</scenario>
diff --git a/tests/channels/pjsip/diversion/diversion_response_181/test-config.yaml b/tests/channels/pjsip/diversion/diversion_response_181/test-config.yaml
new file mode 100644
index 0000000..269f087
--- /dev/null
+++ b/tests/channels/pjsip/diversion/diversion_response_181/test-config.yaml
@@ -0,0 +1,29 @@
+testinfo:
+    summary: 'Test to make sure a 181 response containing a diversion header gets
+             propagated correctly.'
+
+    description: |
+        'user1 calls user2 which sends a 181 to indicate redirection.
+         Verify the 181 response coming from user2 contains a diversion header.'
+
+properties:
+    dependencies:
+        - app : 'sipp'
+        - asterisk : 'app_dial'
+        - asterisk : 'res_pjsip'
+        - asterisk : 'res_pjsip_diversion'
+    tags:
+        - pjsip
+
+test-modules:
+    test-object:
+        config-section: test-object-config
+        typename: 'sipp.SIPpTestCase'
+
+test-object-config:
+    memcheck-delay-stop: 7
+    test-iterations:
+        -
+             scenarios:
+                - { 'key-args': { 'scenario':'user2.xml', '-p':'5062' } }
+                - { 'key-args': { 'scenario':'user1.xml', '-p':'5061' } }
diff --git a/tests/channels/pjsip/diversion/history_info_request/configs/ast1/extensions.conf b/tests/channels/pjsip/diversion/history_info_request/configs/ast1/extensions.conf
new file mode 100644
index 0000000..4719251
--- /dev/null
+++ b/tests/channels/pjsip/diversion/history_info_request/configs/ast1/extensions.conf
@@ -0,0 +1,7 @@
+[general]
+
+[default]
+
+exten => user1,1,Dial(PJSIP/user1)
+exten => user2,1,Dial(PJSIP/user2)
+exten => user3,1,Dial(PJSIP/user3)
diff --git a/tests/channels/pjsip/diversion/history_info_request/configs/ast1/pjsip.conf b/tests/channels/pjsip/diversion/history_info_request/configs/ast1/pjsip.conf
new file mode 100644
index 0000000..0291c85
--- /dev/null
+++ b/tests/channels/pjsip/diversion/history_info_request/configs/ast1/pjsip.conf
@@ -0,0 +1,45 @@
+[system]
+type=system
+timer_t1=100
+timer_b=6400
+
+[local]
+type=transport
+protocol=udp
+bind=0.0.0.0
+
+[user1-aors]
+type=aor
+contact=sip:user1 at 127.0.0.1:5061
+
+[user1]
+type=endpoint
+context=default
+aors=user1-aors
+direct_media=no
+disallow=all
+allow=ulaw
+
+[user2-aors]
+type=aor
+contact=sip:user2 at 127.0.0.1:5062
+
+[user2]
+type=endpoint
+context=default
+aors=user2-aors
+direct_media=no
+disallow=all
+allow=ulaw
+
+[user3-aors]
+type=aor
+contact=sip:user3 at 127.0.0.1:5063
+
+[user3]
+type=endpoint
+context=default
+aors=user3-aors
+direct_media=no
+disallow=all
+allow=ulaw
diff --git a/tests/channels/pjsip/diversion/history_info_request/sipp/user1.xml b/tests/channels/pjsip/diversion/history_info_request/sipp/user1.xml
new file mode 100644
index 0000000..c38a4c3
--- /dev/null
+++ b/tests/channels/pjsip/diversion/history_info_request/sipp/user1.xml
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+
+<scenario name="send an invite to user2">
+	<send retrans="500">
+		<![CDATA[
+			INVITE sip:user2@[remote_ip]:[remote_port] SIP/2.0
+			Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+			From: user1 <sip:user1@[local_ip]:[local_port]>;tag=[call_number]
+			To: user2 <sip:amenhotep@[remote_ip]:[remote_port]>
+			Call-ID: [call_id]
+			CSeq: [cseq] INVITE
+			Contact: sip:user1@[local_ip]:[local_port]
+			Max-Forwards: 70
+			History-Info: <sip:amenhotep at 127.0.0.1>;index=1
+			History-Info: <sip:user2 at 127.0.0.1;cause=302>;index=1.1
+			Content-Type: application/sdp
+			Content-Length: [len]
+
+			v=0
+			o=- 1324901698 1324901698 IN IP[local_ip_type] [local_ip]
+			s=-
+			c=IN IP[media_ip_type] [media_ip]
+			t=0 0
+			m=audio [media_port] RTP/AVP 0 101
+			a=sendrecv
+			a=rtpmap:0 PCMU/8000
+			a=rtpmap:101 telephone-event/8000
+
+		]]>
+	</send>
+
+	<recv response="100" optional="true" />
+
+	<recv response="181" optional="true" />
+
+	<recv response="180" optional="true" />
+
+	<recv response="183" optional="true" />
+
+	<recv response="200" />
+
+	<send>
+		<![CDATA[
+			ACK sip:user2@[remote_ip]:[remote_port] SIP/2.0
+			Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+			From: <sip:user1@[local_ip]>;tag=[call_number]
+			To: <sip:user2@[remote_ip]:[remote_port]>[peer_tag_param]
+			CSeq: [cseq] ACK
+			Call-ID: [call_id]
+			Max-Forwards: 70
+			Content-Length: 0
+
+		]]>
+	</send>
+
+	<send retrans="500">
+		<![CDATA[
+			BYE sip:user2@[remote_ip]:[remote_port] SIP/2.0
+			Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+			From: <sip:user1@[local_ip]>;tag=[call_number]
+			To: <sip:user2@[remote_ip]:[remote_port]>[peer_tag_param]
+			CSeq: [cseq] BYE
+			Call-ID: [call_id]
+			Max-Forwards: 70
+			Content-Length: 0
+		]]>
+	</send>
+
+	<recv response="200" crlf="true" />
+</scenario>
diff --git a/tests/channels/pjsip/diversion/history_info_request/sipp/user2.xml b/tests/channels/pjsip/diversion/history_info_request/sipp/user2.xml
new file mode 100644
index 0000000..f3f1549
--- /dev/null
+++ b/tests/channels/pjsip/diversion/history_info_request/sipp/user2.xml
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+
+<scenario name="receives invite with diversion info">
+	<recv request="INVITE" crlf="true">
+		<action>
+			<!-- Check that the Diversion header is present and contains the correct name. -->
+			<ereg regexp="amenhotep" search_in="hdr" header="Diversion:" check_it="true" assign_to="1" />
+			<log message="Received INVITE with Diversion header: [$1]." />
+		</action>
+	</recv>
+
+	<send>
+		<![CDATA[
+			SIP/2.0 100 Trying
+			[last_Via:]
+			[last_From:]
+			[last_To:];tag=[call_number]
+			[last_Call-ID:]
+			[last_CSeq:]
+			Contact: <sip:user2@[local_ip]:[local_port];transport=[transport]>
+			Content-Length: 0
+		]]>
+	</send>
+
+	<send>
+		<![CDATA[
+			SIP/2.0 180 Ringing
+			[last_Via:]
+			[last_From:]
+			[last_To:];tag=[call_number]
+			[last_Call-ID:]
+			[last_CSeq:]
+			Contact: <sip:user2@[local_ip]:[local_port];transport=[transport]>
+			Content-Length: 0
+		]]>
+	</send>
+
+	<send retrans="500">
+		<![CDATA[
+			SIP/2.0 200 OK
+			[last_Via:]
+			[last_From:]
+			[last_To:];tag=[call_number]
+			[last_Call-ID:]
+			[last_CSeq:]
+			Contact: <sip:user2@[local_ip]:[local_port];transport=[transport]>
+			Content-Type: application/sdp
+			Content-Length: [len]
+
+			v=0
+			o=- 1324901698 1324901698 IN IP[local_ip_type] [local_ip]
+			s=-
+			c=IN IP[media_ip_type] [media_ip]
+			t=0 0
+			m=audio [media_port] RTP/AVP 0 101
+			a=sendrecv
+			a=rtpmap:0 PCMU/8000
+			a=rtpmap:101 telephone-event/8000
+
+		]]>
+	</send>
+
+	<recv request="ACK"/>
+
+	<recv request="BYE" crlf="true" />
+
+	<send retrans="500">
+		<![CDATA[
+			SIP/2.0 200 OK
+			[last_Via:]
+			[last_From:]
+			[last_To:];tag=[call_number]
+			[last_Call-ID:]
+			[last_CSeq:]
+			Content-Type: application/sdp
+			Content-Length: 0
+
+		]]>
+	</send>
+</scenario>
diff --git a/tests/channels/pjsip/diversion/history_info_request/test-config.yaml b/tests/channels/pjsip/diversion/history_info_request/test-config.yaml
new file mode 100644
index 0000000..43b1a38
--- /dev/null
+++ b/tests/channels/pjsip/diversion/history_info_request/test-config.yaml
@@ -0,0 +1,27 @@
+testinfo:
+    summary: 'Test to make sure the history-info headers on an invite gets
+              propagated as diversion correctly.'
+    description: |
+        'user1 calls user2 with an invite containing a diversion header.'
+
+properties:
+    dependencies:
+        - app : 'sipp'
+        - asterisk : 'app_dial'
+        - asterisk : 'res_pjsip'
+        - asterisk : 'res_pjsip_diversion'
+    tags:
+        - pjsip
+
+test-modules:
+    test-object:
+        config-section: test-object-config
+        typename: 'sipp.SIPpTestCase'
+
+test-object-config:
+    memcheck-delay-stop: 7
+    test-iterations:
+        -
+             scenarios:
+                - { 'key-args': { 'scenario':'user2.xml', '-p':'5062' } }
+                - { 'key-args': { 'scenario':'user1.xml', '-p':'5061' } }
diff --git a/tests/channels/pjsip/diversion/history_info_response_181/configs/ast1/extensions.conf b/tests/channels/pjsip/diversion/history_info_response_181/configs/ast1/extensions.conf
new file mode 100644
index 0000000..4719251
--- /dev/null
+++ b/tests/channels/pjsip/diversion/history_info_response_181/configs/ast1/extensions.conf
@@ -0,0 +1,7 @@
+[general]
+
+[default]
+
+exten => user1,1,Dial(PJSIP/user1)
+exten => user2,1,Dial(PJSIP/user2)
+exten => user3,1,Dial(PJSIP/user3)
diff --git a/tests/channels/pjsip/diversion/history_info_response_181/configs/ast1/pjsip.conf b/tests/channels/pjsip/diversion/history_info_response_181/configs/ast1/pjsip.conf
new file mode 100644
index 0000000..dcd83e2
--- /dev/null
+++ b/tests/channels/pjsip/diversion/history_info_response_181/configs/ast1/pjsip.conf
@@ -0,0 +1,33 @@
+[system]
+type=system
+timer_t1=100
+timer_b=6400
+
+[local]
+type=transport
+protocol=udp
+bind=0.0.0.0
+
+[user1-aors]
+type=aor
+contact=sip:user1 at 127.0.0.1:5061
+
+[user1]
+type=endpoint
+context=default
+aors=user1-aors
+direct_media=no
+disallow=all
+allow=ulaw
+
+[user2-aors]
+type=aor
+contact=sip:user2 at 127.0.0.1:5062
+
+[user2]
+type=endpoint
+context=default
+aors=user2-aors
+direct_media=no
+disallow=all
+allow=ulaw
diff --git a/tests/channels/pjsip/diversion/history_info_response_181/sipp/user1.xml b/tests/channels/pjsip/diversion/history_info_response_181/sipp/user1.xml
new file mode 100644
index 0000000..9b9a696
--- /dev/null
+++ b/tests/channels/pjsip/diversion/history_info_response_181/sipp/user1.xml
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+
+<scenario name="send an invite to user2">
+	<send retrans="500">
+		<![CDATA[
+			INVITE sip:user2@[remote_ip]:[remote_port] SIP/2.0
+			Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+			From: user1 <sip:user1@[local_ip]:[local_port]>;tag=[call_number]
+			To: user2 <sip:user2@[remote_ip]:[remote_port]>
+			Call-ID: [call_id]
+			CSeq: [cseq] INVITE
+			Contact: sip:user1@[local_ip]:[local_port]
+			Max-Forwards: 70
+			Content-Type: application/sdp
+			Content-Length: [len]
+
+			v=0
+			o=- 1324901698 1324901698 IN IP[local_ip_type] [local_ip]
+			s=-
+			c=IN IP[media_ip_type] [media_ip]
+			t=0 0
+			m=audio [media_port] RTP/AVP 0 101
+			a=sendrecv
+			a=rtpmap:0 PCMU/8000
+			a=rtpmap:101 telephone-event/8000
+
+		]]>
+	</send>
+
+	<recv response="100" optional="true" />
+
+	<recv response="181">
+		<action>
+			<!-- Check that the Diversion header is present and contains the correct name. -->
+			<ereg regexp="amenhotep" search_in="hdr" header="Diversion:" check_it="true" assign_to="1" />
+			<log message="Received 181 with Diversion header: [$1]." />
+		</action>
+	</recv>
+
+	<recv response="180" optional="true" />
+
+	<recv response="183" optional="true" />
+
+	<recv response="200" />
+
+	<send>
+		<![CDATA[
+			ACK sip:user3@[remote_ip]:[remote_port] SIP/2.0
+			Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+			From: <sip:user1@[local_ip]>;tag=[call_number]
+			To: <sip:user3@[remote_ip]:[remote_port]>[peer_tag_param]
+			CSeq: [cseq] ACK
+			Call-ID: [call_id]
+			Max-Forwards: 70
+			Content-Length: 0
+
+		]]>
+	</send>
+
+	<send retrans="500">
+		<![CDATA[
+			BYE sip:user3@[remote_ip]:[remote_port] SIP/2.0
+			Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+			From: <sip:user1@[local_ip]>;tag=[call_number]
+			To: <sip:user3@[remote_ip]:[remote_port]>[peer_tag_param]
+			CSeq: [cseq] BYE
+			Call-ID: [call_id]
+			Max-Forwards: 70
+			Content-Length: 0
+		]]>
+	</send>
+
+	<recv response="200" crlf="true" />
+</scenario>
diff --git a/tests/channels/pjsip/diversion/history_info_response_181/sipp/user2.xml b/tests/channels/pjsip/diversion/history_info_response_181/sipp/user2.xml
new file mode 100644
index 0000000..ae98c35
--- /dev/null
+++ b/tests/channels/pjsip/diversion/history_info_response_181/sipp/user2.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+
+<scenario name="send forwarding response back with History-Info headers">
+	<recv request="INVITE" crlf="true" />
+
+	<send>
+		<![CDATA[
+			SIP/2.0 181 Redirected
+			[last_Via:]
+			[last_From:]
+			[last_To:];tag=[call_number]
+			[last_Call-ID:]
+			[last_CSeq:]
+			Contact: <sip:user3@[local_ip]>
+			History-Info: <sip:user2 at 127.0.0.1>;index=1
+			History-Info: <sip:amenhotep at 127.0.0.1;cause=302>;index=1.1
+			Content-Length: 0
+		]]>
+	</send>
+	<send retrans="500">
+		<![CDATA[
+			SIP/2.0 200 OK
+			[last_Via:]
+			[last_From:]
+			[last_To:];tag=[call_number]
+			[last_Call-ID:]
+			[last_CSeq:]
+			Contact: <sip:user2@[local_ip]:[local_port];transport=[transport]>
+			Content-Type: application/sdp
+			Content-Length: [len]
+
+			v=0
+			o=- 1324901698 1324901698 IN IP[local_ip_type] [local_ip]
+			s=-
+			c=IN IP[media_ip_type] [media_ip]
+			t=0 0
+			m=audio [media_port] RTP/AVP 0 101
+			a=sendrecv
+			a=rtpmap:0 PCMU/8000
+			a=rtpmap:101 telephone-event/8000
+
+		]]>
+	</send>
+
+	<recv request="ACK"/>
+</scenario>
diff --git a/tests/channels/pjsip/diversion/history_info_response_181/test-config.yaml b/tests/channels/pjsip/diversion/history_info_response_181/test-config.yaml
new file mode 100644
index 0000000..b8a4153
--- /dev/null
+++ b/tests/channels/pjsip/diversion/history_info_response_181/test-config.yaml
@@ -0,0 +1,29 @@
+testinfo:
+    summary: 'Test to make sure a 181 response containing history-info headers gets
+             propagated as Diversion correctly.'
+
+    description: |
+        'user1 calls user2 which sends a 181 to indicate redirection.
+         Verify the 181 response coming from user2 contains a diversion header.'
+
+properties:
+    dependencies:
+        - app : 'sipp'
+        - asterisk : 'app_dial'
+        - asterisk : 'res_pjsip'
+        - asterisk : 'res_pjsip_diversion'
+    tags:
+        - pjsip
+
+test-modules:
+    test-object:
+        config-section: test-object-config
+        typename: 'sipp.SIPpTestCase'
+
+test-object-config:
+    memcheck-delay-stop: 7
+    test-iterations:
+        -
+             scenarios:
+                - { 'key-args': { 'scenario':'user2.xml', '-p':'5062' } }
+                - { 'key-args': { 'scenario':'user1.xml', '-p':'5061' } }
diff --git a/tests/channels/pjsip/diversion/no_diversion_response_181/configs/ast1/extensions.conf b/tests/channels/pjsip/diversion/no_diversion_response_181/configs/ast1/extensions.conf
new file mode 100644
index 0000000..4719251
--- /dev/null
+++ b/tests/channels/pjsip/diversion/no_diversion_response_181/configs/ast1/extensions.conf
@@ -0,0 +1,7 @@
+[general]
+
+[default]
+
+exten => user1,1,Dial(PJSIP/user1)
+exten => user2,1,Dial(PJSIP/user2)
+exten => user3,1,Dial(PJSIP/user3)
diff --git a/tests/channels/pjsip/diversion/no_diversion_response_181/configs/ast1/pjsip.conf b/tests/channels/pjsip/diversion/no_diversion_response_181/configs/ast1/pjsip.conf
new file mode 100644
index 0000000..dcd83e2
--- /dev/null
+++ b/tests/channels/pjsip/diversion/no_diversion_response_181/configs/ast1/pjsip.conf
@@ -0,0 +1,33 @@
+[system]
+type=system
+timer_t1=100
+timer_b=6400
+
+[local]
+type=transport
+protocol=udp
+bind=0.0.0.0
+
+[user1-aors]
+type=aor
+contact=sip:user1 at 127.0.0.1:5061
+
+[user1]
+type=endpoint
+context=default
+aors=user1-aors
+direct_media=no
+disallow=all
+allow=ulaw
+
+[user2-aors]
+type=aor
+contact=sip:user2 at 127.0.0.1:5062
+
+[user2]
+type=endpoint
+context=default
+aors=user2-aors
+direct_media=no
+disallow=all
+allow=ulaw
diff --git a/tests/channels/pjsip/diversion/no_diversion_response_181/sipp/user1.xml b/tests/channels/pjsip/diversion/no_diversion_response_181/sipp/user1.xml
new file mode 100644
index 0000000..216f8af
--- /dev/null
+++ b/tests/channels/pjsip/diversion/no_diversion_response_181/sipp/user1.xml
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+
+<scenario name="send an invite to user2">
+	<send retrans="500">
+		<![CDATA[
+			INVITE sip:user2@[remote_ip]:[remote_port] SIP/2.0
+			Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+			From: user1 <sip:user1@[local_ip]:[local_port]>;tag=[call_number]
+			To: user2 <sip:user2@[remote_ip]:[remote_port]>
+			Call-ID: [call_id]
+			CSeq: [cseq] INVITE
+			Contact: sip:user1@[local_ip]:[local_port]
+			Max-Forwards: 70
+			Content-Type: application/sdp
+			Content-Length: [len]
+
+			v=0
+			o=- 1324901698 1324901698 IN IP[local_ip_type] [local_ip]
+			s=-
+			c=IN IP[media_ip_type] [media_ip]
+			t=0 0
+			m=audio [media_port] RTP/AVP 0 101
+			a=sendrecv
+			a=rtpmap:0 PCMU/8000
+			a=rtpmap:101 telephone-event/8000
+
+		]]>
+	</send>
+
+	<recv response="100" optional="true" />
+
+	<recv response="181">
+		<action>
+			<!-- Check that the Diversion header is present and contains the correct name. -->
+			<ereg regexp=".+" search_in="hdr" header="Diversion:" check_it_inverse="true" assign_to="1" />
+			<log message="Received 181 with Diversion header: [$1]." />
+		</action>
+	</recv>
+
+	<recv response="180" optional="true" />
+
+	<recv response="183" optional="true" />
+
+	<recv response="200" />
+
+	<send>
+		<![CDATA[
+			ACK sip:user3@[remote_ip]:[remote_port] SIP/2.0
+			Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+			From: <sip:user1@[local_ip]>;tag=[call_number]
+			To: <sip:user3@[remote_ip]:[remote_port]>[peer_tag_param]
+			CSeq: [cseq] ACK
+			Call-ID: [call_id]
+			Max-Forwards: 70
+			Content-Length: 0
+
+		]]>
+	</send>
+
+	<send retrans="500">
+		<![CDATA[
+			BYE sip:user3@[remote_ip]:[remote_port] SIP/2.0
+			Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+			From: <sip:user1@[local_ip]>;tag=[call_number]
+			To: <sip:user3@[remote_ip]:[remote_port]>[peer_tag_param]
+			CSeq: [cseq] BYE
+			Call-ID: [call_id]
+			Max-Forwards: 70
+			Content-Length: 0
+		]]>
+	</send>
+
+	<recv response="200" crlf="true" />
+</scenario>
diff --git a/tests/channels/pjsip/diversion/no_diversion_response_181/sipp/user2.xml b/tests/channels/pjsip/diversion/no_diversion_response_181/sipp/user2.xml
new file mode 100644
index 0000000..dbc6508
--- /dev/null
+++ b/tests/channels/pjsip/diversion/no_diversion_response_181/sipp/user2.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+
+<scenario name="send forwarding response back with diversion header">
+	<recv request="INVITE" crlf="true" />
+
+	<send>
+		<![CDATA[
+			SIP/2.0 181 Redirected
+			[last_Via:]
+			[last_From:]
+			[last_To:];tag=[call_number]
+			[last_Call-ID:]
+			[last_CSeq:]
+			Contact: <sip:user3@[local_ip]>
+			Content-Length: 0
+		]]>
+	</send>
+	<send retrans="500">
+		<![CDATA[
+			SIP/2.0 200 OK
+			[last_Via:]
+			[last_From:]
+			[last_To:];tag=[call_number]
+			[last_Call-ID:]
+			[last_CSeq:]
+			Contact: <sip:user2@[local_ip]:[local_port];transport=[transport]>
+			Content-Type: application/sdp
+			Content-Length: [len]
+
+			v=0
+			o=- 1324901698 1324901698 IN IP[local_ip_type] [local_ip]
+			s=-
+			c=IN IP[media_ip_type] [media_ip]
+			t=0 0
+			m=audio [media_port] RTP/AVP 0 101
+			a=sendrecv
+			a=rtpmap:0 PCMU/8000
+			a=rtpmap:101 telephone-event/8000
+
+		]]>
+	</send>
+
+	<recv request="ACK"/>
+</scenario>
diff --git a/tests/channels/pjsip/diversion/no_diversion_response_181/test-config.yaml b/tests/channels/pjsip/diversion/no_diversion_response_181/test-config.yaml
new file mode 100644
index 0000000..4882cff
--- /dev/null
+++ b/tests/channels/pjsip/diversion/no_diversion_response_181/test-config.yaml
@@ -0,0 +1,29 @@
+testinfo:
+    summary: 'Test to make sure a 181 response containing a no redirection info gets
+             propagated correctly.'
+
+    description: |
+        'user1 calls user2 which sends a 181 to indicate redirection.
+         Verify the 181 response coming from user2 contains no header.'
+
+properties:
+    dependencies:
+        - app : 'sipp'
+        - asterisk : 'app_dial'
+        - asterisk : 'res_pjsip'
+        - asterisk : 'res_pjsip_diversion'
+    tags:
+        - pjsip
+
+test-modules:
+    test-object:
+        config-section: test-object-config
+        typename: 'sipp.SIPpTestCase'
+
+test-object-config:
+    memcheck-delay-stop: 7
+    test-iterations:
+        -
+             scenarios:
+                - { 'key-args': { 'scenario':'user2.xml', '-p':'5062' } }
+                - { 'key-args': { 'scenario':'user1.xml', '-p':'5061' } }
diff --git a/tests/channels/pjsip/diversion/tests.yaml b/tests/channels/pjsip/diversion/tests.yaml
index ea60a32..34f8add 100644
--- a/tests/channels/pjsip/diversion/tests.yaml
+++ b/tests/channels/pjsip/diversion/tests.yaml
@@ -4,6 +4,10 @@
     - test: 'diversion_basic_drop_options'
     - test: 'diversion_caller_id'
     - test: 'diversion_request'
+    - test: 'history_info_request'
     - test: 'diversion_request_drop_options'
     - test: 'diversion_response'
+    - test: 'diversion_response_181'
+    - test: 'no_diversion_response_181'
+    - test: 'history_info_response_181'
     - test: 'diversion_response_drop_options'
diff --git a/tests/channels/pjsip/history_info/diversion_request/configs/ast1/extensions.conf b/tests/channels/pjsip/history_info/diversion_request/configs/ast1/extensions.conf
new file mode 100644
index 0000000..4719251
--- /dev/null
+++ b/tests/channels/pjsip/history_info/diversion_request/configs/ast1/extensions.conf
@@ -0,0 +1,7 @@
+[general]
+
+[default]
+
+exten => user1,1,Dial(PJSIP/user1)
+exten => user2,1,Dial(PJSIP/user2)
+exten => user3,1,Dial(PJSIP/user3)
diff --git a/tests/channels/pjsip/history_info/diversion_request/configs/ast1/pjsip.conf b/tests/channels/pjsip/history_info/diversion_request/configs/ast1/pjsip.conf
new file mode 100644
index 0000000..e274b94
--- /dev/null
+++ b/tests/channels/pjsip/history_info/diversion_request/configs/ast1/pjsip.conf
@@ -0,0 +1,47 @@
+[system]
+type=system
+timer_t1=100
+timer_b=6400
+
+[local]
+type=transport
+protocol=udp
+bind=0.0.0.0
+
+[user1-aors]
+type=aor
+contact=sip:user1 at 127.0.0.1:5061
+
+[user1]
+type=endpoint
+context=default
+aors=user1-aors
+direct_media=no
+disallow=all
+allow=ulaw
+
+[user2-aors]
+type=aor
+contact=sip:user2 at 127.0.0.1:5062
+
+[user2]
+type=endpoint
+context=default
+aors=user2-aors
+direct_media=no
+disallow=all
+allow=ulaw
+send_diversion=no
+send_history_info=yes
+
+[user3-aors]
+type=aor
+contact=sip:user3 at 127.0.0.1:5063
+
+[user3]
+type=endpoint
+context=default
+aors=user3-aors
+direct_media=no
+disallow=all
+allow=ulaw
diff --git a/tests/channels/pjsip/history_info/diversion_request/sipp/user1.xml b/tests/channels/pjsip/history_info/diversion_request/sipp/user1.xml
new file mode 100644
index 0000000..df48d10
--- /dev/null
+++ b/tests/channels/pjsip/history_info/diversion_request/sipp/user1.xml
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+
+<scenario name="send an invite to user2">
+	<send retrans="500">
+		<![CDATA[
+			INVITE sip:user2@[remote_ip]:[remote_port] SIP/2.0
+			Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+			From: user1 <sip:user1@[local_ip]:[local_port]>;tag=[call_number]
+			To: user2 <sip:user2@[remote_ip]:[remote_port]>
+			Call-ID: [call_id]
+			CSeq: [cseq] INVITE
+			Contact: sip:user1@[local_ip]:[local_port]
+			Max-Forwards: 70
+			Diversion: <sip:amenhotep at 127.0.0.1>;reason=unconditional
+			Content-Type: application/sdp
+			Content-Length: [len]
+
+			v=0
+			o=- 1324901698 1324901698 IN IP[local_ip_type] [local_ip]
+			s=-
+			c=IN IP[media_ip_type] [media_ip]
+			t=0 0
+			m=audio [media_port] RTP/AVP 0 101
+			a=sendrecv
+			a=rtpmap:0 PCMU/8000
+			a=rtpmap:101 telephone-event/8000
+
+		]]>
+	</send>
+
+	<recv response="100" optional="true" />
+
+	<recv response="181" optional="true" />
+
+	<recv response="180" optional="true" />
+
+	<recv response="183" optional="true" />
+
+	<recv response="200" />
+
+	<send>
+		<![CDATA[
+			ACK sip:user2@[remote_ip]:[remote_port] SIP/2.0
+			Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+			From: <sip:user1@[local_ip]>;tag=[call_number]
+			To: <sip:user2@[remote_ip]:[remote_port]>[peer_tag_param]
+			CSeq: [cseq] ACK
+			Call-ID: [call_id]
+			Max-Forwards: 70
+			Content-Length: 0
+
+		]]>
+	</send>
+
+	<send retrans="500">
+		<![CDATA[
+			BYE sip:user2@[remote_ip]:[remote_port] SIP/2.0
+			Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+			From: <sip:user1@[local_ip]>;tag=[call_number]
+			To: <sip:user2@[remote_ip]:[remote_port]>[peer_tag_param]
+			CSeq: [cseq] BYE
+			Call-ID: [call_id]
+			Max-Forwards: 70
+			Content-Length: 0
+		]]>
+	</send>
+
+	<recv response="200" crlf="true" />
+</scenario>
diff --git a/tests/channels/pjsip/history_info/diversion_request/sipp/user2.xml b/tests/channels/pjsip/history_info/diversion_request/sipp/user2.xml
new file mode 100644
index 0000000..5d44b30
--- /dev/null
+++ b/tests/channels/pjsip/history_info/diversion_request/sipp/user2.xml
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+
+<scenario name="receives invite with diversion info">
+	<recv request="INVITE" crlf="true">
+		<action>
+			<!-- Check that the Diversion header is present and contains the correct name. -->
+			<ereg regexp="amenhotep" search_in="hdr" header="History-Info:" occurence="1" check_it="true" assign_to="1" />
+			<log message="Received INVITE with History-Info header: [$1]." />
+			<ereg regexp="user2" search_in="hdr" header="History-Info:" occurence="2" check_it="true" assign_to="2" />
+			<log message="Received INVITE with History-Info header: [$2]." />
+		</action>
+	</recv>
+
+	<send>
+		<![CDATA[
+			SIP/2.0 100 Trying
+			[last_Via:]
+			[last_From:]
+			[last_To:];tag=[call_number]
+			[last_Call-ID:]
+			[last_CSeq:]
+			Contact: <sip:user2@[local_ip]:[local_port];transport=[transport]>
+			Content-Length: 0
+		]]>
+	</send>
+
+	<send>
+		<![CDATA[
+			SIP/2.0 180 Ringing
+			[last_Via:]
+			[last_From:]
+			[last_To:];tag=[call_number]
+			[last_Call-ID:]
+			[last_CSeq:]
+			Contact: <sip:user2@[local_ip]:[local_port];transport=[transport]>
+			Content-Length: 0
+		]]>
+	</send>
+
+	<send retrans="500">
+		<![CDATA[
+			SIP/2.0 200 OK
+			[last_Via:]
+			[last_From:]
+			[last_To:];tag=[call_number]
+			[last_Call-ID:]
+			[last_CSeq:]
+			Contact: <sip:user2@[local_ip]:[local_port];transport=[transport]>
+			Content-Type: application/sdp
+			Content-Length: [len]
+
+			v=0
+			o=- 1324901698 1324901698 IN IP[local_ip_type] [local_ip]
+			s=-
+			c=IN IP[media_ip_type] [media_ip]
+			t=0 0
+			m=audio [media_port] RTP/AVP 0 101
+			a=sendrecv
+			a=rtpmap:0 PCMU/8000
+			a=rtpmap:101 telephone-event/8000
+
+		]]>
+	</send>
+
+	<recv request="ACK"/>
+
+	<recv request="BYE" crlf="true" />
+
+	<send retrans="500">
+		<![CDATA[
+			SIP/2.0 200 OK
+			[last_Via:]
+			[last_From:]
+			[last_To:];tag=[call_number]
+			[last_Call-ID:]
+			[last_CSeq:]
+			Content-Type: application/sdp
+			Content-Length: 0
+
+		]]>
+	</send>
+</scenario>
diff --git a/tests/channels/pjsip/history_info/diversion_request/test-config.yaml b/tests/channels/pjsip/history_info/diversion_request/test-config.yaml
new file mode 100644
index 0000000..db7cd54
--- /dev/null
+++ b/tests/channels/pjsip/history_info/diversion_request/test-config.yaml
@@ -0,0 +1,27 @@
+testinfo:
+    summary: 'Test to make sure the diversion header on an invite gets
+              propagated correctly as a history info.'
+    description: |
+        'user1 calls user2 with an invite containing a diversion header.'
+
+properties:
+    dependencies:
+        - app : 'sipp'
+        - asterisk : 'app_dial'
+        - asterisk : 'res_pjsip'
+        - asterisk : 'res_pjsip_diversion'
+    tags:
+        - pjsip
+
+test-modules:
+    test-object:
+        config-section: test-object-config
+        typename: 'sipp.SIPpTestCase'
+
+test-object-config:
+    memcheck-delay-stop: 7
+    test-iterations:
+        -
+             scenarios:
+                - { 'key-args': { 'scenario':'user2.xml', '-p':'5062' } }
+                - { 'key-args': { 'scenario':'user1.xml', '-p':'5061' } }
diff --git a/tests/channels/pjsip/history_info/diversion_response_181/configs/ast1/extensions.conf b/tests/channels/pjsip/history_info/diversion_response_181/configs/ast1/extensions.conf
new file mode 100644
index 0000000..4719251
--- /dev/null
+++ b/tests/channels/pjsip/history_info/diversion_response_181/configs/ast1/extensions.conf
@@ -0,0 +1,7 @@
+[general]
+
+[default]
+
+exten => user1,1,Dial(PJSIP/user1)
+exten => user2,1,Dial(PJSIP/user2)
+exten => user3,1,Dial(PJSIP/user3)
diff --git a/tests/channels/pjsip/history_info/diversion_response_181/configs/ast1/pjsip.conf b/tests/channels/pjsip/history_info/diversion_response_181/configs/ast1/pjsip.conf
new file mode 100644
index 0000000..4ab6741
--- /dev/null
+++ b/tests/channels/pjsip/history_info/diversion_response_181/configs/ast1/pjsip.conf
@@ -0,0 +1,35 @@
+[system]
+type=system
+timer_t1=100
+timer_b=6400
+
+[local]
+type=transport
+protocol=udp
+bind=0.0.0.0
+
+[user1-aors]
+type=aor
+contact=sip:user1 at 127.0.0.1:5061
+
+[user1]
+type=endpoint
+context=default
+aors=user1-aors
+direct_media=no
+disallow=all
+allow=ulaw
+send_diversion=no
+send_history_info=yes
+
+[user2-aors]
+type=aor
+contact=sip:user2 at 127.0.0.1:5062
+
+[user2]
+type=endpoint
+context=default
+aors=user2-aors
+direct_media=no
+disallow=all
+allow=ulaw
diff --git a/tests/channels/pjsip/history_info/diversion_response_181/sipp/user1.xml b/tests/channels/pjsip/history_info/diversion_response_181/sipp/user1.xml
new file mode 100644
index 0000000..129c5b9
--- /dev/null
+++ b/tests/channels/pjsip/history_info/diversion_response_181/sipp/user1.xml
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+
+<scenario name="send an invite to user2">
+	<send retrans="500">
+		<![CDATA[
+                        INVITE sip:user2@[remote_ip]:[remote_port] SIP/2.0
+                        Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+                        From: user1 <sip:user1@[local_ip]:[local_port]>;tag=[call_number]
+                        To: user2 <sip:user2@[remote_ip]:[remote_port]>
+                        Call-ID: [call_id]
+                        CSeq: [cseq] INVITE
+                        Contact: sip:user1@[local_ip]:[local_port]
+                        Max-Forwards: 70
+                        Content-Type: application/sdp
+                        Content-Length: [len]
+
+			v=0
+			o=- 1324901698 1324901698 IN IP[local_ip_type] [local_ip]
+			s=-
+			c=IN IP[media_ip_type] [media_ip]
+			t=0 0
+			m=audio [media_port] RTP/AVP 0 101
+			a=sendrecv
+			a=rtpmap:0 PCMU/8000
+			a=rtpmap:101 telephone-event/8000
+
+		]]>
+	</send>
+
+	<recv response="100" optional="true" />
+
+	<recv response="181">
+                <action>
+                        <!-- Check that the Diversion header is present and contains the correct name. -->
+	        	<ereg regexp="user2" search_in="hdr" header="History-Info:" occurence="1" check_it="true" assign_to="1" />
+		        <log message="Received 181 with History-Info header: [$1]." />
+	        	<ereg regexp="amenhotep" search_in="hdr" header="History-Info:" occurence="2" check_it="true" assign_to="2" />
+		        <log message="Received 181 with History-Info header: [$2]." />
+		</action>
+	</recv>
+
+	<recv response="180" optional="true" />
+
+	<recv response="183" optional="true" />
+
+	<recv response="200" />
+
+	<send>
+		<![CDATA[
+			ACK sip:user3@[remote_ip]:[remote_port] SIP/2.0
+			Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+			From: <sip:user1@[local_ip]>;tag=[call_number]
+			To: <sip:user3@[remote_ip]:[remote_port]>[peer_tag_param]
+			CSeq: [cseq] ACK
+			Call-ID: [call_id]
+			Max-Forwards: 70
+			Content-Length: 0
+
+		]]>
+	</send>
+
+	<send retrans="500">
+		<![CDATA[
+			BYE sip:user3@[remote_ip]:[remote_port] SIP/2.0
+			Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+			From: <sip:user1@[local_ip]>;tag=[call_number]
+			To: <sip:user3@[remote_ip]:[remote_port]>[peer_tag_param]
+			CSeq: [cseq] BYE
+			Call-ID: [call_id]
+			Max-Forwards: 70
+			Content-Length: 0
+		]]>
+	</send>
+
+	<recv response="200" crlf="true" />
+</scenario>
diff --git a/tests/channels/pjsip/history_info/diversion_response_181/sipp/user2.xml b/tests/channels/pjsip/history_info/diversion_response_181/sipp/user2.xml
new file mode 100644
index 0000000..5272697
--- /dev/null
+++ b/tests/channels/pjsip/history_info/diversion_response_181/sipp/user2.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+
+<scenario name="send forwarding response back with history-info header">
+	<recv request="INVITE" crlf="true" />
+
+	<send>
+		<![CDATA[
+			SIP/2.0 181 Redirected
+			[last_Via:]
+			[last_From:]
+			[last_To:];tag=[call_number]
+			[last_Call-ID:]
+			[last_CSeq:]
+			Contact: <sip:user3@[local_ip]>
+			Diversion: <sip:amenhotep at 127.0.0.1>;reason=unconditional
+			Content-Length: 0
+		]]>
+	</send>
+	<send retrans="500">
+		<![CDATA[
+			SIP/2.0 200 OK
+			[last_Via:]
+			[last_From:]
+			[last_To:];tag=[call_number]
+			[last_Call-ID:]
+			[last_CSeq:]
+			Contact: <sip:user2@[local_ip]:[local_port];transport=[transport]>
+			Content-Type: application/sdp
+			Content-Length: [len]
+
+			v=0
+			o=- 1324901698 1324901698 IN IP[local_ip_type] [local_ip]
+			s=-
+			c=IN IP[media_ip_type] [media_ip]
+			t=0 0
+			m=audio [media_port] RTP/AVP 0 101
+			a=sendrecv
+			a=rtpmap:0 PCMU/8000
+			a=rtpmap:101 telephone-event/8000
+
+		]]>
+	</send>
+
+	<recv request="ACK"/>
+</scenario>
diff --git a/tests/channels/pjsip/history_info/diversion_response_181/test-config.yaml b/tests/channels/pjsip/history_info/diversion_response_181/test-config.yaml
new file mode 100644
index 0000000..9126551
--- /dev/null
+++ b/tests/channels/pjsip/history_info/diversion_response_181/test-config.yaml
@@ -0,0 +1,29 @@
+testinfo:
+    summary: 'Test to make sure a 181 response containing a Diversion header gets
+             propagated as History-Info correctly.'
+
+    description: |
+        'user1 calls user2 which sends a 181 to indicate redirection.
+         Verify the 181 response coming from user2 contains a diversion header.'
+
+properties:
+    dependencies:
+        - app : 'sipp'
+        - asterisk : 'app_dial'
+        - asterisk : 'res_pjsip'
+        - asterisk : 'res_pjsip_diversion'
+    tags:
+        - pjsip
+
+test-modules:
+    test-object:
+        config-section: test-object-config
+        typename: 'sipp.SIPpTestCase'
+
+test-object-config:
+    memcheck-delay-stop: 7
+    test-iterations:
+        -
+             scenarios:
+                - { 'key-args': { 'scenario':'user2.xml', '-p':'5062' } }
+                - { 'key-args': { 'scenario':'user1.xml', '-p':'5061' } }
diff --git a/tests/channels/pjsip/history_info/history_info_request/configs/ast1/extensions.conf b/tests/channels/pjsip/history_info/history_info_request/configs/ast1/extensions.conf
new file mode 100644
index 0000000..4719251
--- /dev/null
+++ b/tests/channels/pjsip/history_info/history_info_request/configs/ast1/extensions.conf
@@ -0,0 +1,7 @@
+[general]
+
+[default]
+
+exten => user1,1,Dial(PJSIP/user1)
+exten => user2,1,Dial(PJSIP/user2)
+exten => user3,1,Dial(PJSIP/user3)
diff --git a/tests/channels/pjsip/history_info/history_info_request/configs/ast1/pjsip.conf b/tests/channels/pjsip/history_info/history_info_request/configs/ast1/pjsip.conf
new file mode 100644
index 0000000..425e05f
--- /dev/null
+++ b/tests/channels/pjsip/history_info/history_info_request/configs/ast1/pjsip.conf
@@ -0,0 +1,35 @@
+[system]
+type=system
+timer_t1=100
+timer_b=6400
+
+[local]
+type=transport
+protocol=udp
+bind=0.0.0.0
+
+[user1-aors]
+type=aor
+contact=sip:user1 at 127.0.0.1:5061
+
+[user1]
+type=endpoint
+context=default
+aors=user1-aors
+direct_media=no
+disallow=all
+allow=ulaw
+
+[user2-aors]
+type=aor
+contact=sip:user2 at 127.0.0.1:5062
+
+[user2]
+type=endpoint
+context=default
+aors=user2-aors
+direct_media=no
+disallow=all
+allow=ulaw
+send_diversion=no
+send_history_info=yes
diff --git a/tests/channels/pjsip/history_info/history_info_request/sipp/user1.xml b/tests/channels/pjsip/history_info/history_info_request/sipp/user1.xml
new file mode 100644
index 0000000..c38a4c3
--- /dev/null
+++ b/tests/channels/pjsip/history_info/history_info_request/sipp/user1.xml
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+
+<scenario name="send an invite to user2">
+	<send retrans="500">
+		<![CDATA[
+			INVITE sip:user2@[remote_ip]:[remote_port] SIP/2.0
+			Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+			From: user1 <sip:user1@[local_ip]:[local_port]>;tag=[call_number]
+			To: user2 <sip:amenhotep@[remote_ip]:[remote_port]>
+			Call-ID: [call_id]
+			CSeq: [cseq] INVITE
+			Contact: sip:user1@[local_ip]:[local_port]
+			Max-Forwards: 70
+			History-Info: <sip:amenhotep at 127.0.0.1>;index=1
+			History-Info: <sip:user2 at 127.0.0.1;cause=302>;index=1.1
+			Content-Type: application/sdp
+			Content-Length: [len]
+
+			v=0
+			o=- 1324901698 1324901698 IN IP[local_ip_type] [local_ip]
+			s=-
+			c=IN IP[media_ip_type] [media_ip]
+			t=0 0
+			m=audio [media_port] RTP/AVP 0 101
+			a=sendrecv
+			a=rtpmap:0 PCMU/8000
+			a=rtpmap:101 telephone-event/8000
+
+		]]>
+	</send>
+
+	<recv response="100" optional="true" />
+
+	<recv response="181" optional="true" />
+
+	<recv response="180" optional="true" />
+
+	<recv response="183" optional="true" />
+
+	<recv response="200" />
+
+	<send>
+		<![CDATA[
+			ACK sip:user2@[remote_ip]:[remote_port] SIP/2.0
+			Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+			From: <sip:user1@[local_ip]>;tag=[call_number]
+			To: <sip:user2@[remote_ip]:[remote_port]>[peer_tag_param]
+			CSeq: [cseq] ACK
+			Call-ID: [call_id]
+			Max-Forwards: 70
+			Content-Length: 0
+
+		]]>
+	</send>
+
+	<send retrans="500">
+		<![CDATA[
+			BYE sip:user2@[remote_ip]:[remote_port] SIP/2.0
+			Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+			From: <sip:user1@[local_ip]>;tag=[call_number]
+			To: <sip:user2@[remote_ip]:[remote_port]>[peer_tag_param]
+			CSeq: [cseq] BYE
+			Call-ID: [call_id]
+			Max-Forwards: 70
+			Content-Length: 0
+		]]>
+	</send>
+
+	<recv response="200" crlf="true" />
+</scenario>
diff --git a/tests/channels/pjsip/history_info/history_info_request/sipp/user2.xml b/tests/channels/pjsip/history_info/history_info_request/sipp/user2.xml
new file mode 100644
index 0000000..5d44b30
--- /dev/null
+++ b/tests/channels/pjsip/history_info/history_info_request/sipp/user2.xml
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+
+<scenario name="receives invite with diversion info">
+	<recv request="INVITE" crlf="true">
+		<action>
+			<!-- Check that the Diversion header is present and contains the correct name. -->
+			<ereg regexp="amenhotep" search_in="hdr" header="History-Info:" occurence="1" check_it="true" assign_to="1" />
+			<log message="Received INVITE with History-Info header: [$1]." />
+			<ereg regexp="user2" search_in="hdr" header="History-Info:" occurence="2" check_it="true" assign_to="2" />
+			<log message="Received INVITE with History-Info header: [$2]." />
+		</action>
+	</recv>
+
+	<send>
+		<![CDATA[
+			SIP/2.0 100 Trying
+			[last_Via:]
+			[last_From:]
+			[last_To:];tag=[call_number]
+			[last_Call-ID:]
+			[last_CSeq:]
+			Contact: <sip:user2@[local_ip]:[local_port];transport=[transport]>
+			Content-Length: 0
+		]]>
+	</send>
+
+	<send>
+		<![CDATA[
+			SIP/2.0 180 Ringing
+			[last_Via:]
+			[last_From:]
+			[last_To:];tag=[call_number]
+			[last_Call-ID:]
+			[last_CSeq:]
+			Contact: <sip:user2@[local_ip]:[local_port];transport=[transport]>
+			Content-Length: 0
+		]]>
+	</send>
+
+	<send retrans="500">
+		<![CDATA[
+			SIP/2.0 200 OK
+			[last_Via:]
+			[last_From:]
+			[last_To:];tag=[call_number]
+			[last_Call-ID:]
+			[last_CSeq:]
+			Contact: <sip:user2@[local_ip]:[local_port];transport=[transport]>
+			Content-Type: application/sdp
+			Content-Length: [len]
+
+			v=0
+			o=- 1324901698 1324901698 IN IP[local_ip_type] [local_ip]
+			s=-
+			c=IN IP[media_ip_type] [media_ip]
+			t=0 0
+			m=audio [media_port] RTP/AVP 0 101
+			a=sendrecv
+			a=rtpmap:0 PCMU/8000
+			a=rtpmap:101 telephone-event/8000
+
+		]]>
+	</send>
+
+	<recv request="ACK"/>
+
+	<recv request="BYE" crlf="true" />
+
+	<send retrans="500">
+		<![CDATA[
+			SIP/2.0 200 OK
+			[last_Via:]
+			[last_From:]
+			[last_To:];tag=[call_number]
+			[last_Call-ID:]
+			[last_CSeq:]
+			Content-Type: application/sdp
+			Content-Length: 0
+
+		]]>
+	</send>
+</scenario>
diff --git a/tests/channels/pjsip/history_info/history_info_request/test-config.yaml b/tests/channels/pjsip/history_info/history_info_request/test-config.yaml
new file mode 100644
index 0000000..8fd4c76
--- /dev/null
+++ b/tests/channels/pjsip/history_info/history_info_request/test-config.yaml
@@ -0,0 +1,27 @@
+testinfo:
+    summary: 'Test to make sure the history-info headers on an invite gets
+              propagated as history-info correctly.'
+    description: |
+        'user1 calls user2 with an invite containing a diversion header.'
+
+properties:
+    dependencies:
+        - app : 'sipp'
+        - asterisk : 'app_dial'
+        - asterisk : 'res_pjsip'
+        - asterisk : 'res_pjsip_diversion'
+    tags:
+        - pjsip
+
+test-modules:
+    test-object:
+        config-section: test-object-config
+        typename: 'sipp.SIPpTestCase'
+
+test-object-config:
+    memcheck-delay-stop: 7
+    test-iterations:
+        -
+             scenarios:
+                - { 'key-args': { 'scenario':'user2.xml', '-p':'5062' } }
+                - { 'key-args': { 'scenario':'user1.xml', '-p':'5061' } }
diff --git a/tests/channels/pjsip/history_info/history_info_response_181/configs/ast1/extensions.conf b/tests/channels/pjsip/history_info/history_info_response_181/configs/ast1/extensions.conf
new file mode 100644
index 0000000..4719251
--- /dev/null
+++ b/tests/channels/pjsip/history_info/history_info_response_181/configs/ast1/extensions.conf
@@ -0,0 +1,7 @@
+[general]
+
+[default]
+
+exten => user1,1,Dial(PJSIP/user1)
+exten => user2,1,Dial(PJSIP/user2)
+exten => user3,1,Dial(PJSIP/user3)
diff --git a/tests/channels/pjsip/history_info/history_info_response_181/configs/ast1/pjsip.conf b/tests/channels/pjsip/history_info/history_info_response_181/configs/ast1/pjsip.conf
new file mode 100644
index 0000000..4ab6741
--- /dev/null
+++ b/tests/channels/pjsip/history_info/history_info_response_181/configs/ast1/pjsip.conf
@@ -0,0 +1,35 @@
+[system]
+type=system
+timer_t1=100
+timer_b=6400
+
+[local]
+type=transport
+protocol=udp
+bind=0.0.0.0
+
+[user1-aors]
+type=aor
+contact=sip:user1 at 127.0.0.1:5061
+
+[user1]
+type=endpoint
+context=default
+aors=user1-aors
+direct_media=no
+disallow=all
+allow=ulaw
+send_diversion=no
+send_history_info=yes
+
+[user2-aors]
+type=aor
+contact=sip:user2 at 127.0.0.1:5062
+
+[user2]
+type=endpoint
+context=default
+aors=user2-aors
+direct_media=no
+disallow=all
+allow=ulaw
diff --git a/tests/channels/pjsip/history_info/history_info_response_181/sipp/user1.xml b/tests/channels/pjsip/history_info/history_info_response_181/sipp/user1.xml
new file mode 100644
index 0000000..7431e32
--- /dev/null
+++ b/tests/channels/pjsip/history_info/history_info_response_181/sipp/user1.xml
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+
+<scenario name="send an invite to user2">
+	<send retrans="500">
+		<![CDATA[
+			INVITE sip:user2@[remote_ip]:[remote_port] SIP/2.0
+			Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+			From: user1 <sip:user1@[local_ip]:[local_port]>;tag=[call_number]
+			To: user2 <sip:user2@[remote_ip]:[remote_port]>
+			Call-ID: [call_id]
+			CSeq: [cseq] INVITE
+			Contact: sip:user1@[local_ip]:[local_port]
+			Max-Forwards: 70
+			Content-Type: application/sdp
+			Content-Length: [len]
+
+			v=0
+			o=- 1324901698 1324901698 IN IP[local_ip_type] [local_ip]
+			s=-
+			c=IN IP[media_ip_type] [media_ip]
+			t=0 0
+			m=audio [media_port] RTP/AVP 0 101
+			a=sendrecv
+			a=rtpmap:0 PCMU/8000
+			a=rtpmap:101 telephone-event/8000
+
+		]]>
+	</send>
+
+	<recv response="100" optional="true" />
+
+	<recv response="181">
+		<action>
+			<!-- Check that the Diversion header is present and contains the correct name. -->
+			<ereg regexp="user2" search_in="hdr" header="History-Info:" occurence="1" check_it="true" assign_to="1" />
+			<log message="Received 181 with History-Info header: [$1]." />
+			<ereg regexp="amenhotep" search_in="hdr" header="History-Info:" occurence="2" check_it="true" assign_to="2" />
+			<log message="Received 181 with History-Info header: [$2]." />
+		</action>
+	</recv>
+
+	<recv response="180" optional="true" />
+
+	<recv response="183" optional="true" />
+
+	<recv response="200" />
+
+	<send>
+		<![CDATA[
+			ACK sip:user3@[remote_ip]:[remote_port] SIP/2.0
+			Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+			From: <sip:user1@[local_ip]>;tag=[call_number]
+			To: <sip:user3@[remote_ip]:[remote_port]>[peer_tag_param]
+			CSeq: [cseq] ACK
+			Call-ID: [call_id]
+			Max-Forwards: 70
+			Content-Length: 0
+
+		]]>
+	</send>
+
+	<send retrans="500">
+		<![CDATA[
+			BYE sip:user3@[remote_ip]:[remote_port] SIP/2.0
+			Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+			From: <sip:user1@[local_ip]>;tag=[call_number]
+			To: <sip:user3@[remote_ip]:[remote_port]>[peer_tag_param]
+			CSeq: [cseq] BYE
+			Call-ID: [call_id]
+			Max-Forwards: 70
+			Content-Length: 0
+		]]>
+	</send>
+
+	<recv response="200" crlf="true" />
+</scenario>
diff --git a/tests/channels/pjsip/history_info/history_info_response_181/sipp/user2.xml b/tests/channels/pjsip/history_info/history_info_response_181/sipp/user2.xml
new file mode 100644
index 0000000..2c2d77a
--- /dev/null
+++ b/tests/channels/pjsip/history_info/history_info_response_181/sipp/user2.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+
+<scenario name="send forwarding response back with diversion header">
+	<recv request="INVITE" crlf="true" />
+
+	<send>
+		<![CDATA[
+			SIP/2.0 181 Redirected
+			[last_Via:]
+			[last_From:]
+			[last_To:];tag=[call_number]
+			[last_Call-ID:]
+			[last_CSeq:]
+			Contact: <sip:user3@[local_ip]>
+			History-Info: <sip:user2 at 127.0.0.1>;index=1
+			History-Info: <sip:amenhotep at 127.0.0.1;cause=302>;index=1.1
+			Content-Length: 0
+		]]>
+	</send>
+	<send retrans="500">
+		<![CDATA[
+			SIP/2.0 200 OK
+			[last_Via:]
+			[last_From:]
+			[last_To:];tag=[call_number]
+			[last_Call-ID:]
+			[last_CSeq:]
+			Contact: <sip:user2@[local_ip]:[local_port];transport=[transport]>
+			Content-Type: application/sdp
+			Content-Length: [len]
+
+			v=0
+			o=- 1324901698 1324901698 IN IP[local_ip_type] [local_ip]
+			s=-
+			c=IN IP[media_ip_type] [media_ip]
+			t=0 0
+			m=audio [media_port] RTP/AVP 0 101
+			a=sendrecv
+			a=rtpmap:0 PCMU/8000
+			a=rtpmap:101 telephone-event/8000
+
+		]]>
+	</send>
+
+	<recv request="ACK"/>
+</scenario>
diff --git a/tests/channels/pjsip/history_info/history_info_response_181/test-config.yaml b/tests/channels/pjsip/history_info/history_info_response_181/test-config.yaml
new file mode 100644
index 0000000..e10e01f
--- /dev/null
+++ b/tests/channels/pjsip/history_info/history_info_response_181/test-config.yaml
@@ -0,0 +1,29 @@
+testinfo:
+    summary: 'Test to make sure a 181 response containing history-info headers gets
+             propagated as History-Info correctly.'
+
+    description: |
+        'user1 calls user2 which sends a 181 to indicate redirection.
+         Verify the 181 response coming from user2 contains History-Info headers.'
+
+properties:
+    dependencies:
+        - app : 'sipp'
+        - asterisk : 'app_dial'
+        - asterisk : 'res_pjsip'
+        - asterisk : 'res_pjsip_diversion'
+    tags:
+        - pjsip
+
+test-modules:
+    test-object:
+        config-section: test-object-config
+        typename: 'sipp.SIPpTestCase'
+
+test-object-config:
+    memcheck-delay-stop: 7
+    test-iterations:
+        -
+             scenarios:
+                - { 'key-args': { 'scenario':'user2.xml', '-p':'5062' } }
+                - { 'key-args': { 'scenario':'user1.xml', '-p':'5061' } }
diff --git a/tests/channels/pjsip/history_info/no_diversion_response_181/configs/ast1/extensions.conf b/tests/channels/pjsip/history_info/no_diversion_response_181/configs/ast1/extensions.conf
new file mode 100644
index 0000000..4719251
--- /dev/null
+++ b/tests/channels/pjsip/history_info/no_diversion_response_181/configs/ast1/extensions.conf
@@ -0,0 +1,7 @@
+[general]
+
+[default]
+
+exten => user1,1,Dial(PJSIP/user1)
+exten => user2,1,Dial(PJSIP/user2)
+exten => user3,1,Dial(PJSIP/user3)
diff --git a/tests/channels/pjsip/history_info/no_diversion_response_181/configs/ast1/pjsip.conf b/tests/channels/pjsip/history_info/no_diversion_response_181/configs/ast1/pjsip.conf
new file mode 100644
index 0000000..4ab6741
--- /dev/null
+++ b/tests/channels/pjsip/history_info/no_diversion_response_181/configs/ast1/pjsip.conf
@@ -0,0 +1,35 @@
+[system]
+type=system
+timer_t1=100
+timer_b=6400
+
+[local]
+type=transport
+protocol=udp
+bind=0.0.0.0
+
+[user1-aors]
+type=aor
+contact=sip:user1 at 127.0.0.1:5061
+
+[user1]
+type=endpoint
+context=default
+aors=user1-aors
+direct_media=no
+disallow=all
+allow=ulaw
+send_diversion=no
+send_history_info=yes
+
+[user2-aors]
+type=aor
+contact=sip:user2 at 127.0.0.1:5062
+
+[user2]
+type=endpoint
+context=default
+aors=user2-aors
+direct_media=no
+disallow=all
+allow=ulaw
diff --git a/tests/channels/pjsip/history_info/no_diversion_response_181/sipp/user1.xml b/tests/channels/pjsip/history_info/no_diversion_response_181/sipp/user1.xml
new file mode 100644
index 0000000..55cb5e1
--- /dev/null
+++ b/tests/channels/pjsip/history_info/no_diversion_response_181/sipp/user1.xml
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+
+<scenario name="send an invite to user2">
+	<send retrans="500">
+		<![CDATA[
+			INVITE sip:user2@[remote_ip]:[remote_port] SIP/2.0
+			Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+			From: user1 <sip:user1@[local_ip]:[local_port]>;tag=[call_number]
+			To: user2 <sip:user2@[remote_ip]:[remote_port]>
+			Call-ID: [call_id]
+			CSeq: [cseq] INVITE
+			Contact: sip:user1@[local_ip]:[local_port]
+			Max-Forwards: 70
+			Content-Type: application/sdp
+			Content-Length: [len]
+
+			v=0
+			o=- 1324901698 1324901698 IN IP[local_ip_type] [local_ip]
+			s=-
+			c=IN IP[media_ip_type] [media_ip]
+			t=0 0
+			m=audio [media_port] RTP/AVP 0 101
+			a=sendrecv
+			a=rtpmap:0 PCMU/8000
+			a=rtpmap:101 telephone-event/8000
+
+		]]>
+	</send>
+
+	<recv response="100" optional="true" />
+
+	<recv response="181">
+		<action>
+			<!-- Check that the Diversion header is present and contains the correct name. -->
+			<ereg regexp="user2" search_in="hdr" header="History-Info:" occurence="1" check_it="true" assign_to="1" />
+			<log message="Received 181 with History-Info header: [$1]." />
+			<ereg regexp=".+" search_in="hdr" header="History-Info:" occurence="2" check_it_inverse="true" assign_to="2" />
+			<log message="Received 181 with History-Info header: [$2]." />
+		</action>
+	</recv>
+
+	<recv response="180" optional="true" />
+
+	<recv response="183" optional="true" />
+
+	<recv response="200" />
+
+	<send>
+		<![CDATA[
+			ACK sip:user3@[remote_ip]:[remote_port] SIP/2.0
+			Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+			From: <sip:user1@[local_ip]>;tag=[call_number]
+			To: <sip:user3@[remote_ip]:[remote_port]>[peer_tag_param]
+			CSeq: [cseq] ACK
+			Call-ID: [call_id]
+			Max-Forwards: 70
+			Content-Length: 0
+
+		]]>
+	</send>
+
+	<send retrans="500">
+		<![CDATA[
+			BYE sip:user3@[remote_ip]:[remote_port] SIP/2.0
+			Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+			From: <sip:user1@[local_ip]>;tag=[call_number]
+			To: <sip:user3@[remote_ip]:[remote_port]>[peer_tag_param]
+			CSeq: [cseq] BYE
+			Call-ID: [call_id]
+			Max-Forwards: 70
+			Content-Length: 0
+		]]>
+	</send>
+
+	<recv response="200" crlf="true" />
+</scenario>
diff --git a/tests/channels/pjsip/history_info/no_diversion_response_181/sipp/user2.xml b/tests/channels/pjsip/history_info/no_diversion_response_181/sipp/user2.xml
new file mode 100644
index 0000000..64ac1e5
--- /dev/null
+++ b/tests/channels/pjsip/history_info/no_diversion_response_181/sipp/user2.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+
+<scenario name="send forwarding response back with history-info header">
+	<recv request="INVITE" crlf="true" />
+
+	<send>
+		<![CDATA[
+			SIP/2.0 181 Redirected
+			[last_Via:]
+			[last_From:]
+			[last_To:];tag=[call_number]
+			[last_Call-ID:]
+			[last_CSeq:]
+			Contact: <sip:user3@[local_ip]>
+			Content-Length: 0
+		]]>
+	</send>
+	<send retrans="500">
+		<![CDATA[
+			SIP/2.0 200 OK
+			[last_Via:]
+			[last_From:]
+			[last_To:];tag=[call_number]
+			[last_Call-ID:]
+			[last_CSeq:]
+			Contact: <sip:user2@[local_ip]:[local_port];transport=[transport]>
+			Content-Type: application/sdp
+			Content-Length: [len]
+
+			v=0
+			o=- 1324901698 1324901698 IN IP[local_ip_type] [local_ip]
+			s=-
+			c=IN IP[media_ip_type] [media_ip]
+			t=0 0
+			m=audio [media_port] RTP/AVP 0 101
+			a=sendrecv
+			a=rtpmap:0 PCMU/8000
+			a=rtpmap:101 telephone-event/8000
+
+		]]>
+	</send>
+
+	<recv request="ACK"/>
+</scenario>
diff --git a/tests/channels/pjsip/history_info/no_diversion_response_181/test-config.yaml b/tests/channels/pjsip/history_info/no_diversion_response_181/test-config.yaml
new file mode 100644
index 0000000..90b24e3
--- /dev/null
+++ b/tests/channels/pjsip/history_info/no_diversion_response_181/test-config.yaml
@@ -0,0 +1,29 @@
+testinfo:
+    summary: 'Test to make sure a 181 response containing no redirection gets
+             propagated as History-Info correctly.'
+
+    description: |
+        'user1 calls user2 which sends a 181 to indicate redirection.
+         Verify the 181 response coming from user2 contains a history-info header.'
+
+properties:
+    dependencies:
+        - app : 'sipp'
+        - asterisk : 'app_dial'
+        - asterisk : 'res_pjsip'
+        - asterisk : 'res_pjsip_diversion'
+    tags:
+        - pjsip
+
+test-modules:
+    test-object:
+        config-section: test-object-config
+        typename: 'sipp.SIPpTestCase'
+
+test-object-config:
+    memcheck-delay-stop: 7
+    test-iterations:
+        -
+             scenarios:
+                - { 'key-args': { 'scenario':'user2.xml', '-p':'5062' } }
+                - { 'key-args': { 'scenario':'user1.xml', '-p':'5061' } }
diff --git a/tests/channels/pjsip/history_info/tests.yaml b/tests/channels/pjsip/history_info/tests.yaml
new file mode 100644
index 0000000..12cab26
--- /dev/null
+++ b/tests/channels/pjsip/history_info/tests.yaml
@@ -0,0 +1,7 @@
+# Enter tests here in the order they should be considered for execution:
+tests:
+    - test: 'diversion_request'
+    - test: 'history_info_request'
+    - test: 'history_info_response_181'
+    - test: 'diversion_response_181'
+    - test: 'no_diversion_response_181'
diff --git a/tests/channels/pjsip/tests.yaml b/tests/channels/pjsip/tests.yaml
index 564432b..276fe3e 100644
--- a/tests/channels/pjsip/tests.yaml
+++ b/tests/channels/pjsip/tests.yaml
@@ -6,6 +6,7 @@
     - dir: 'configuration'
     - dir: 'dialplan_functions'
     - dir: 'diversion'
+    - dir: 'history_info'
     - dir: 'headers'
     - dir: 'identify'
     - dir: 'message'

-- 
To view, visit https://gerrit.asterisk.org/c/testsuite/+/14954
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: testsuite
Gerrit-Branch: 17
Gerrit-Change-Id: I287c78b38f48817ea4547e3ab0370d26d2abf2e3
Gerrit-Change-Number: 14954
Gerrit-PatchSet: 1
Gerrit-Owner: Torrey Searle <tsearle at gmail.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20200929/ef873721/attachment-0001.html>


More information about the asterisk-code-review mailing list