Added various tests with invalid SDP and other SIP parameters

git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@2066 74dad513-b988-da41-8d7b-12977e46ad98
diff --git a/pjsip-apps/src/test-pjsua/inc_cfg.py b/pjsip-apps/src/test-pjsua/inc_cfg.py
index 5b7514a..f20a934 100644
--- a/pjsip-apps/src/test-pjsua/inc_cfg.py
+++ b/pjsip-apps/src/test-pjsua/inc_cfg.py
@@ -79,8 +79,8 @@
 	def __init__(	self, 
 			title, 		# Test title
 			inst_params, 	# InstanceParam's as list
-			skip=False,
 			func=None,
+			skip=False,
 			post_func=None,
 			user_data=None):
 		self.title = title
diff --git a/pjsip-apps/src/test-pjsua/inc_sip.py b/pjsip-apps/src/test-pjsua/inc_sip.py
index 04b5a96..a4eb15a 100644
--- a/pjsip-apps/src/test-pjsua/inc_sip.py
+++ b/pjsip-apps/src/test-pjsua/inc_sip.py
@@ -1,4 +1,4 @@
-# $Id:$
+# $Id$
 #
 from socket import *
 import re
@@ -207,6 +207,8 @@
 	inst_param = None
 	# Initial SDP
 	sdp = ""
+	# Extra headers to add to request
+	extra_headers = ""
 	# Expected code
 	resp_code = 0
 	# Use TCP?
@@ -216,11 +218,14 @@
 	# List of RE patterns that must NOT exist in response
 	resp_exclude = []
 	# Constructor
-	def __init__(self, name, pjsua_args, sdp, resp_code, resp_inc=[], resp_exc=[], use_tcp=False):
+	def __init__(self, name, pjsua_args, sdp, resp_code, 
+		     resp_inc=[], resp_exc=[], use_tcp=False,
+		     extra_headers=""):
 		self.sdp = sdp
 		self.resp_code = resp_code
 		self.resp_include = resp_inc
 		self.resp_exclude = resp_exc
 		self.use_tcp = use_tcp
+		self.extra_headers = extra_headers
 		self.inst_param = cfg.InstanceParam("pjsua", pjsua_args)
 
diff --git a/pjsip-apps/src/test-pjsua/mod_sendto.py b/pjsip-apps/src/test-pjsua/mod_sendto.py
index 92437e9..7b1f482 100644
--- a/pjsip-apps/src/test-pjsua/mod_sendto.py
+++ b/pjsip-apps/src/test-pjsua/mod_sendto.py
@@ -1,4 +1,4 @@
-# $Id:$
+# $Id$
 import imp
 import sys
 import inc_sip as sip
@@ -18,7 +18,7 @@
 	#dlg = sip.Dialog("127.0.0.1", 5060, tcp=cfg_file.sendto_cfg.use_tcp)
 	cfg = cfg_file.sendto_cfg
 	
-	req = dlg.create_invite(cfg.sdp)
+	req = dlg.create_invite(cfg.sdp, cfg.extra_headers)
 	resp = dlg.send_request_wait(req, 10)
 	if resp=="":
 		raise TestError("Timed-out waiting for response")
diff --git a/pjsip-apps/src/test-pjsua/scripts-sendto/150_err_extension.py b/pjsip-apps/src/test-pjsua/scripts-sendto/150_err_extension.py
new file mode 100644
index 0000000..cb46d1f
--- /dev/null
+++ b/pjsip-apps/src/test-pjsua/scripts-sendto/150_err_extension.py
@@ -0,0 +1,27 @@
+# $Id$
+import inc_sip as sip
+import inc_sdp as sdp
+
+sdp = \
+"""
+v=0
+o=- 0 0 IN IP4 127.0.0.1
+s=pjmedia
+c=IN IP4 127.0.0.1
+t=0 0
+m=audio 4000 RTP/AVP 0 101
+a=rtpmap:0 PCMU/8000
+a=sendrecv
+a=rtpmap:101 telephone-event/8000
+a=fmtp:101 0-15
+"""
+
+pjsua_args = "--null-audio --auto-answer 200"
+extra_headers = "Require: xxx-my-extension\n"
+include = ["Unsupported: xxx-my-extension"]
+exclude = []
+sendto_cfg = sip.SendtoCfg("Bad extension", pjsua_args, sdp, 420, 
+			   extra_headers=extra_headers,
+			   resp_inc=include, resp_exc=exclude) 
+			   
+
diff --git a/pjsip-apps/src/test-pjsua/scripts-sendto/151_err_sdp_video.py b/pjsip-apps/src/test-pjsua/scripts-sendto/151_err_sdp_video.py
new file mode 100644
index 0000000..6294484
--- /dev/null
+++ b/pjsip-apps/src/test-pjsua/scripts-sendto/151_err_sdp_video.py
@@ -0,0 +1,24 @@
+# $Id$
+import inc_sip as sip
+import inc_sdp as sdp
+
+sdp = \
+"""
+v=0
+o=- 0 0 IN IP4 127.0.0.1
+s=pjmedia
+c=IN IP4 127.0.0.1
+t=0 0
+m=video 4000 RTP/AVP 0
+"""
+
+pjsua_args = "--null-audio --auto-answer 200"
+extra_headers = ""
+include = ["Content-Type: application/sdp",	# response must include SDP
+	   "m=audio"]
+exclude = []
+
+sendto_cfg = sip.SendtoCfg("Video not acceptable", pjsua_args, sdp, 488,
+			   extra_headers=extra_headers,
+			   resp_inc=include, resp_exc=exclude) 
+
diff --git a/pjsip-apps/src/test-pjsua/scripts-sendto/152_err_sdp_no_media.py b/pjsip-apps/src/test-pjsua/scripts-sendto/152_err_sdp_no_media.py
new file mode 100644
index 0000000..4e7465a
--- /dev/null
+++ b/pjsip-apps/src/test-pjsua/scripts-sendto/152_err_sdp_no_media.py
@@ -0,0 +1,22 @@
+# $Id$
+import inc_sip as sip
+import inc_sdp as sdp
+
+sdp = \
+"""
+v=0
+o=- 0 0 IN IP4 127.0.0.1
+s=pjmedia
+c=IN IP4 127.0.0.1
+t=0 0
+"""
+
+pjsua_args = "--null-audio --auto-answer 200"
+extra_headers = ""
+include = []
+exclude = []
+
+sendto_cfg = sip.SendtoCfg("No media in SDP", pjsua_args, sdp, 400,
+			   extra_headers=extra_headers,
+			   resp_inc=include, resp_exc=exclude) 
+
diff --git a/pjsip-apps/src/test-pjsua/scripts-sendto/153_err_sdp_unsupported_codec.py b/pjsip-apps/src/test-pjsua/scripts-sendto/153_err_sdp_unsupported_codec.py
new file mode 100644
index 0000000..173a6b8
--- /dev/null
+++ b/pjsip-apps/src/test-pjsua/scripts-sendto/153_err_sdp_unsupported_codec.py
@@ -0,0 +1,25 @@
+# $Id$
+import inc_sip as sip
+import inc_sdp as sdp
+
+sdp = \
+"""
+v=0
+o=- 0 0 IN IP4 127.0.0.1
+s=pjmedia
+c=IN IP4 127.0.0.1
+t=0 0
+m=video 4000 RTP/AVP 101
+a=rtpmap:101 my-proprietary-codec
+"""
+
+pjsua_args = "--null-audio --auto-answer 200"
+extra_headers = ""
+include = ["Content-Type: application/sdp",	# response must include SDP
+	   "m=audio"]
+exclude = []
+
+sendto_cfg = sip.SendtoCfg("Unsupported codec", pjsua_args, sdp, 488,
+			   extra_headers=extra_headers,
+			   resp_inc=include, resp_exc=exclude) 
+
diff --git a/pjsip-apps/src/test-pjsua/scripts-sendto/155_err_sdp_bad_syntax.py b/pjsip-apps/src/test-pjsua/scripts-sendto/155_err_sdp_bad_syntax.py
new file mode 100644
index 0000000..d32ef3d
--- /dev/null
+++ b/pjsip-apps/src/test-pjsua/scripts-sendto/155_err_sdp_bad_syntax.py
@@ -0,0 +1,23 @@
+# $Id$
+import inc_sip as sip
+import inc_sdp as sdp
+
+sdp = \
+"""
+v=
+o=
+s=
+c=
+t=
+a=
+"""
+
+pjsua_args = "--null-audio --auto-answer 200"
+extra_headers = ""
+include = [ "Warning: " ]	# better have Warning header
+exclude = []
+
+sendto_cfg = sip.SendtoCfg("Bad SDP syntax", pjsua_args, sdp, 400,
+			   extra_headers=extra_headers,
+			   resp_inc=include, resp_exc=exclude) 
+
diff --git a/pjsip-apps/src/test-pjsua/scripts-sendto/156_err_sdp_bad_net_type.py b/pjsip-apps/src/test-pjsua/scripts-sendto/156_err_sdp_bad_net_type.py
new file mode 100644
index 0000000..7c1536b
--- /dev/null
+++ b/pjsip-apps/src/test-pjsua/scripts-sendto/156_err_sdp_bad_net_type.py
@@ -0,0 +1,27 @@
+# $Id$
+import inc_sip as sip
+import inc_sdp as sdp
+
+sdp = \
+"""
+v=0
+o=- 0 0 IN IP4 127.0.0.1
+s=pjmedia
+c=AF IP4 127.0.0.1
+t=0 0
+m=audio 4000 RTP/AVP 0 101
+a=rtpmap:0 PCMU/8000
+a=sendrecv
+a=rtpmap:101 telephone-event/8000
+a=fmtp:101 0-15
+"""
+
+pjsua_args = "--null-audio --auto-answer 200"
+extra_headers = ""
+include = [ "Warning: " ]	# better have Warning header
+exclude = []
+sendto_cfg = sip.SendtoCfg("Bad SDP network type", pjsua_args, sdp, 400, 
+			   extra_headers=extra_headers,
+			   resp_inc=include, resp_exc=exclude) 
+			   
+
diff --git a/pjsip-apps/src/test-pjsua/scripts-sendto/157_err_sdp_bad_addr_type.py b/pjsip-apps/src/test-pjsua/scripts-sendto/157_err_sdp_bad_addr_type.py
new file mode 100644
index 0000000..cac5c98
--- /dev/null
+++ b/pjsip-apps/src/test-pjsua/scripts-sendto/157_err_sdp_bad_addr_type.py
@@ -0,0 +1,27 @@
+# $Id$
+import inc_sip as sip
+import inc_sdp as sdp
+
+sdp = \
+"""
+v=0
+o=- 0 0 IN IP4 127.0.0.1
+s=pjmedia
+c=IN IP7 127.0.0.1
+t=0 0
+m=audio 4000 RTP/AVP 0 101
+a=rtpmap:0 PCMU/8000
+a=sendrecv
+a=rtpmap:101 telephone-event/8000
+a=fmtp:101 0-15
+"""
+
+pjsua_args = "--null-audio --auto-answer 200"
+extra_headers = ""
+include = [ "Warning: " ]	# better have Warning header
+exclude = []
+sendto_cfg = sip.SendtoCfg("Bad SDP address type", pjsua_args, sdp, 400, 
+			   extra_headers=extra_headers,
+			   resp_inc=include, resp_exc=exclude) 
+			   
+
diff --git a/pjsip-apps/src/test-pjsua/scripts-sendto/158_err_sdp_bad_transport_type.py b/pjsip-apps/src/test-pjsua/scripts-sendto/158_err_sdp_bad_transport_type.py
new file mode 100644
index 0000000..28f4998
--- /dev/null
+++ b/pjsip-apps/src/test-pjsua/scripts-sendto/158_err_sdp_bad_transport_type.py
@@ -0,0 +1,27 @@
+# $Id$
+import inc_sip as sip
+import inc_sdp as sdp
+
+sdp = \
+"""
+v=0
+o=- 0 0 IN IP4 127.0.0.1
+s=pjmedia
+c=IN IP4 127.0.0.1
+t=0 0
+m=audio 4000 RTP/XAVP 0 101
+a=rtpmap:0 PCMU/8000
+a=sendrecv
+a=rtpmap:101 telephone-event/8000
+a=fmtp:101 0-15
+"""
+
+pjsua_args = "--null-audio --auto-answer 200"
+extra_headers = ""
+include = []
+exclude = []
+sendto_cfg = sip.SendtoCfg("Unsupported transport type", pjsua_args, sdp, 406, 
+			   extra_headers=extra_headers,
+			   resp_inc=include, resp_exc=exclude) 
+			   
+
diff --git a/pjsip-apps/src/test-pjsua/scripts-sendto/160_err_duplicate_replaces.py b/pjsip-apps/src/test-pjsua/scripts-sendto/160_err_duplicate_replaces.py
new file mode 100644
index 0000000..ec4b0fd
--- /dev/null
+++ b/pjsip-apps/src/test-pjsua/scripts-sendto/160_err_duplicate_replaces.py
@@ -0,0 +1,23 @@
+# $Id$
+import inc_sip as sip
+import inc_sdp as sdp
+
+sdp = \
+"""
+v=0
+o=- 0 0 IN IP4 127.0.0.1
+s=pjmedia
+c=IN IP4 127.0.0.1
+t=0 0
+m=audio 4000 RTP/AVP 0
+"""
+
+pjsua_args = "--null-audio --auto-answer 200"
+extra_headers = "Replaces: abcd;from_tag=1\r\nReplaces: efgh;from_tag=2\r\n"
+include = []
+exclude = []
+
+sendto_cfg = sip.SendtoCfg("Duplicate replaces header", pjsua_args, sdp, 400,
+			   extra_headers=extra_headers,
+			   resp_inc=include, resp_exc=exclude) 
+
diff --git a/pjsip-apps/src/test-pjsua/scripts-sendto/161_err_replaces_dlg_not_found.py b/pjsip-apps/src/test-pjsua/scripts-sendto/161_err_replaces_dlg_not_found.py
new file mode 100644
index 0000000..863a1a5
--- /dev/null
+++ b/pjsip-apps/src/test-pjsua/scripts-sendto/161_err_replaces_dlg_not_found.py
@@ -0,0 +1,23 @@
+# $Id$
+import inc_sip as sip
+import inc_sdp as sdp
+
+sdp = \
+"""
+v=0
+o=- 0 0 IN IP4 127.0.0.1
+s=pjmedia
+c=IN IP4 127.0.0.1
+t=0 0
+m=audio 4000 RTP/AVP 0
+"""
+
+pjsua_args = "--null-audio --auto-answer 200"
+extra_headers = "Replaces: abcd;from_tag=1\r\n"
+include = []
+exclude = []
+
+sendto_cfg = sip.SendtoCfg("Replaced dialog not found", pjsua_args, sdp, 481,
+			   extra_headers=extra_headers,
+			   resp_inc=include, resp_exc=exclude) 
+