Created top-level directory tests and moved test-pjsua there. This will be the placeholder for future developed tests

git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@2392 74dad513-b988-da41-8d7b-12977e46ad98
diff --git a/tests/pjsua/scripts-recvfrom/200_reg_good_enocredentiall.py b/tests/pjsua/scripts-recvfrom/200_reg_good_enocredentiall.py
new file mode 100644
index 0000000..33d12b1
--- /dev/null
+++ b/tests/pjsua/scripts-recvfrom/200_reg_good_enocredentiall.py
@@ -0,0 +1,15 @@
+# $Id$
+import inc_sip as sip
+import inc_sdp as sdp
+
+pjsua = "--null-audio --id=sip:CLIENT --registrar sip:127.0.0.1:$PORT"
+
+req1 = sip.RecvfromTransaction("", 401,
+				include=["REGISTER sip"], 
+				exclude=["Authorization"],
+				resp_hdr=["WWW-Authenticate: Digest realm=\"python\", nonce=\"1234\""],
+				expect="PJSIP_ENOCREDENTIAL"
+			  )
+
+recvfrom_cfg = sip.RecvfromCfg("Failed registration test",
+			       pjsua, [req1])
diff --git a/tests/pjsua/scripts-recvfrom/201_reg_good_ok.py b/tests/pjsua/scripts-recvfrom/201_reg_good_ok.py
new file mode 100644
index 0000000..9b5a9f9
--- /dev/null
+++ b/tests/pjsua/scripts-recvfrom/201_reg_good_ok.py
@@ -0,0 +1,23 @@
+# $Id$
+import inc_sip as sip
+import inc_sdp as sdp
+
+pjsua = "--null-audio --id=sip:CLIENT --registrar sip:127.0.0.1:$PORT " + \
+	"--username user --realm python --password passwd --auto-update-nat=0"
+
+req1 = sip.RecvfromTransaction("Initial registration", 401,
+				include=["REGISTER sip"], 
+				exclude=["Authorization"],
+				resp_hdr=["WWW-Authenticate: Digest realm=\"python\", nonce=\"1234\""],
+				expect="SIP/2.0 401"
+			  )
+
+req2 = sip.RecvfromTransaction("Registration retry with auth", 200,
+				include=["REGISTER sip", "Authorization:", 
+					     "realm=\"python\"", "username=\"user\"", 
+					     "nonce=\"1234\"", "response="],
+				expect="registration success"	     
+			  )
+
+recvfrom_cfg = sip.RecvfromCfg("Successful registration test",
+			       pjsua, [req1, req2])
diff --git a/tests/pjsua/scripts-recvfrom/202_reg_good_ok_wildcard.py b/tests/pjsua/scripts-recvfrom/202_reg_good_ok_wildcard.py
new file mode 100644
index 0000000..66ed19e
--- /dev/null
+++ b/tests/pjsua/scripts-recvfrom/202_reg_good_ok_wildcard.py
@@ -0,0 +1,23 @@
+# $Id$
+import inc_sip as sip
+import inc_sdp as sdp
+
+pjsua = "--null-audio --id=sip:CLIENT --registrar sip:127.0.0.1:$PORT " + \
+	"--username user --realm \"*\" --password passwd --auto-update-nat=0"
+
+req1 = sip.RecvfromTransaction("Initial registration", 401,
+				include=["REGISTER sip"], 
+				exclude=["Authorization"],
+				resp_hdr=["WWW-Authenticate: Digest realm=\"python\", nonce=\"1234\""],
+				expect="SIP/2.0 401"
+			  )
+
+req2 = sip.RecvfromTransaction("Registration retry with auth", 200,
+				include=["REGISTER sip", "Authorization:", 
+					     "realm=\"python\"", "username=\"user\"", 
+					     "nonce=\"1234\"", "response="],
+				expect="registration success"	     
+			  )
+
+recvfrom_cfg = sip.RecvfromCfg("Successful registration with wildcard realm test",
+			       pjsua, [req1, req2])
diff --git a/tests/pjsua/scripts-recvfrom/205_reg_good_no_realm.py b/tests/pjsua/scripts-recvfrom/205_reg_good_no_realm.py
new file mode 100644
index 0000000..199493e
--- /dev/null
+++ b/tests/pjsua/scripts-recvfrom/205_reg_good_no_realm.py
@@ -0,0 +1,16 @@
+# $Id$
+import inc_sip as sip
+import inc_sdp as sdp
+
+pjsua = "--null-audio --id=sip:CLIENT --registrar sip:127.0.0.1:$PORT " + \
+	"--realm=provider --user=username --password=password"
+
+req1 = sip.RecvfromTransaction("", 401,
+				include=["REGISTER sip"], 
+				exclude=["Authorization"],
+				resp_hdr=["WWW-Authenticate: Digest realm=\"python\", nonce=\"1234\""],
+				expect="PJSIP_ENOCREDENTIAL"
+			  )
+
+recvfrom_cfg = sip.RecvfromCfg("Failed registration because of realm test",
+			       pjsua, [req1])
diff --git a/tests/pjsua/scripts-recvfrom/206_reg_good_efailedcredential.py b/tests/pjsua/scripts-recvfrom/206_reg_good_efailedcredential.py
new file mode 100644
index 0000000..dc4a4db
--- /dev/null
+++ b/tests/pjsua/scripts-recvfrom/206_reg_good_efailedcredential.py
@@ -0,0 +1,26 @@
+# $Id$
+import inc_sip as sip
+import inc_sdp as sdp
+
+# Authentication failure test with same nonce
+
+
+pjsua = "--null-audio --id=sip:CLIENT --registrar sip:127.0.0.1:$PORT " + \
+	"--realm=python --user=username --password=password"
+
+req1 = sip.RecvfromTransaction("Initial request", 401,
+				include=["REGISTER sip"], 
+				exclude=["Authorization"],
+				resp_hdr=["WWW-Authenticate: Digest realm=\"python\", nonce=\"1\""]
+			  	)
+
+req2 = sip.RecvfromTransaction("REGISTER retry", 401,
+				include=["REGISTER sip", "Authorization", "nonce=\"1\""], 
+				exclude=["Authorization:[\\s\\S]+Authorization:"],
+				resp_hdr=["WWW-Authenticate: Digest realm=\"python\", nonce=\"1\""],
+				expect="PJSIP_EFAILEDCREDENTIAL"
+			  	)
+
+
+recvfrom_cfg = sip.RecvfromCfg("Authentication failure with same nonce",
+			       pjsua, [req1, req2])
diff --git a/tests/pjsua/scripts-recvfrom/208_reg_good_retry_nonce_ok.py b/tests/pjsua/scripts-recvfrom/208_reg_good_retry_nonce_ok.py
new file mode 100644
index 0000000..46e1728
--- /dev/null
+++ b/tests/pjsua/scripts-recvfrom/208_reg_good_retry_nonce_ok.py
@@ -0,0 +1,29 @@
+# $Id$
+import inc_sip as sip
+import inc_sdp as sdp
+
+pjsua = "--null-audio --id=sip:CLIENT --registrar sip:127.0.0.1:$PORT " + \
+	"--realm=python --user=username --password=password " + \
+	"--auto-update-nat=0"
+
+req1 = sip.RecvfromTransaction("Initial request", 401,
+				include=["REGISTER sip"], 
+				exclude=["Authorization"],
+				resp_hdr=["WWW-Authenticate: Digest realm=\"python\", nonce=\"1\""]
+			  	)
+
+req2 = sip.RecvfromTransaction("REGISTER first retry", 401,
+				include=["REGISTER sip", "Authorization", "nonce=\"1\""], 
+				exclude=["Authorization:[\\s\\S]+Authorization:"],
+				resp_hdr=["WWW-Authenticate: Digest realm=\"python\", nonce=\"2\", stale=true"]
+			  	)
+
+
+req3 = sip.RecvfromTransaction("REGISTER retry with new nonce", 200,
+				include=["REGISTER sip", "Authorization", "nonce=\"2\""], 
+				exclude=["Authorization:[\\s\\S]+Authorization:"],
+				expect="registration success"
+			  	)
+
+recvfrom_cfg = sip.RecvfromCfg("Authentication okay after retry with new nonce",
+			       pjsua, [req1, req2, req3])
diff --git a/tests/pjsua/scripts-recvfrom/215_reg_good_multi_ok.py b/tests/pjsua/scripts-recvfrom/215_reg_good_multi_ok.py
new file mode 100644
index 0000000..61194bd
--- /dev/null
+++ b/tests/pjsua/scripts-recvfrom/215_reg_good_multi_ok.py
@@ -0,0 +1,28 @@
+# $Id$
+import inc_sip as sip
+import inc_sdp as sdp
+
+pjsua = "--null-audio --id=sip:CLIENT --registrar sip:127.0.0.1:$PORT " + \
+	"--username theuser1 --realm python1 --password passwd --next-cred " + \
+	"--username theuser2 --realm python2 --password passwd " + \
+	"--auto-update-nat=0"
+
+req1 = sip.RecvfromTransaction("Initial registration", 401,
+				include=["REGISTER sip"], 
+				resp_hdr=["WWW-Authenticate: Digest realm=\"python1\", nonce=\"1234\"",
+					  "WWW-Authenticate: Digest realm=\"python2\", nonce=\"6789\""],
+				expect="SIP/2.0 401"
+			  )
+
+req2 = sip.RecvfromTransaction("Registration retry with auth", 200,
+				include=["REGISTER sip", 
+					 "Authorization:[\\s\\S]+Authorization:", # Must have 2 Auth hdrs
+					 "realm=\"python1\"", "realm=\"python2\"", 
+					 "username=\"theuser1\"", "username=\"theuser2\"", 
+					 "nonce=\"1234\"", "nonce=\"6789\"", 
+					 "response="],
+				expect="registration success"	     
+			  )
+
+recvfrom_cfg = sip.RecvfromCfg("Multiple authentication challenges",
+			       pjsua, [req1, req2])
diff --git a/tests/pjsua/scripts-recvfrom/220_reg_good_ims_ok.py b/tests/pjsua/scripts-recvfrom/220_reg_good_ims_ok.py
new file mode 100644
index 0000000..d37add1
--- /dev/null
+++ b/tests/pjsua/scripts-recvfrom/220_reg_good_ims_ok.py
@@ -0,0 +1,26 @@
+# $Id$
+import inc_sip as sip
+import inc_sdp as sdp
+
+pjsua = "--null-audio --id=sip:CLIENT --registrar sip:127.0.0.1:$PORT " + \
+	"--username user@ims-domain --realm python --password passwd --use-ims --auto-update-nat=0"
+
+req1 = sip.RecvfromTransaction("Initial registration", 401,
+				include=["REGISTER sip", "Authorization", 
+					 "username=\"user@ims-domain\"",
+					 "realm=\"python\""], 
+				resp_hdr=["WWW-Authenticate: Digest realm=\"python\", nonce=\"1234\""],
+				expect="SIP/2.0 401"
+			  )
+
+req2 = sip.RecvfromTransaction("Registration retry with auth", 200,
+				include=["REGISTER sip", "Authorization:", 
+					     "realm=\"python\"", "username=\"user@ims-domain\"", 
+					     "nonce=\"1234\"", "response="],
+				# Must not have double Authorization header:
+				exclude=["Authorization:[\\s\\S]+Authorization:"],
+				expect="registration success"	     
+			  )
+
+recvfrom_cfg = sip.RecvfromCfg("Successful IMS registration test",
+			       pjsua, [req1, req2])
diff --git a/tests/pjsua/scripts-recvfrom/230_reg_bad_fail_stale_true.py b/tests/pjsua/scripts-recvfrom/230_reg_bad_fail_stale_true.py
new file mode 100644
index 0000000..4bceaf4
--- /dev/null
+++ b/tests/pjsua/scripts-recvfrom/230_reg_bad_fail_stale_true.py
@@ -0,0 +1,41 @@
+# $Id$
+import inc_sip as sip
+import inc_sdp as sdp
+
+# In this test we simulate broken server, where it always sends
+# stale=true with all 401 responses. We should expect pjsip to
+# retry the authentication until PJSIP_MAX_STALE_COUNT is
+# exceeded. When pjsip retries the authentication, it should
+# use the new nonce from server
+
+
+pjsua = "--null-audio --id=sip:CLIENT --registrar sip:127.0.0.1:$PORT " + \
+	"--realm=python --user=username --password=password"
+
+req1 = sip.RecvfromTransaction("Initial request", 401,
+				include=["REGISTER sip"], 
+				exclude=["Authorization"],
+				resp_hdr=["WWW-Authenticate: Digest realm=\"python\", nonce=\"1\""]
+			  	)
+
+req2 = sip.RecvfromTransaction("First retry", 401,
+				include=["REGISTER sip", "Authorization", "nonce=\"1\""], 
+				exclude=["Authorization:[\\s\\S]+Authorization:"],
+				resp_hdr=["WWW-Authenticate: Digest realm=\"python\", nonce=\"2\", stale=true"]
+			  	)
+
+req3 = sip.RecvfromTransaction("Second retry retry", 401,
+				include=["REGISTER sip", "Authorization", "nonce=\"2\""], 
+				exclude=["Authorization:[\\s\\S]+Authorization:"],
+				resp_hdr=["WWW-Authenticate: Digest realm=\"python\", nonce=\"3\", stale=true"]
+				)
+
+req4 = sip.RecvfromTransaction("Third retry", 401,
+				include=["REGISTER sip", "Authorization", "nonce=\"3\""], 
+				exclude=["Authorization:[\\s\\S]+Authorization:"],
+				resp_hdr=["WWW-Authenticate: Digest realm=\"python\", nonce=\"4\", stale=true"],
+				expect="PJSIP_EAUTHSTALECOUNT"
+			  	)
+
+recvfrom_cfg = sip.RecvfromCfg("Failed registration retry (server rejects with stale=true) ",
+			       pjsua, [req1, req2, req3, req4])
diff --git a/tests/pjsua/scripts-recvfrom/231_reg_bad_fail_stale_false_nonce_changed.py b/tests/pjsua/scripts-recvfrom/231_reg_bad_fail_stale_false_nonce_changed.py
new file mode 100644
index 0000000..443b91b
--- /dev/null
+++ b/tests/pjsua/scripts-recvfrom/231_reg_bad_fail_stale_false_nonce_changed.py
@@ -0,0 +1,41 @@
+# $Id$
+import inc_sip as sip
+import inc_sdp as sdp
+
+# In this test we simulate broken server, where:
+#	- it wants to signal that NONCE has change
+#	- but it sets stale=false
+# For this case pjsip will retry authentication until
+# PJSIP_MAX_STALE_COUNT is exceeded.
+# 
+
+pjsua = "--null-audio --id=sip:CLIENT --registrar sip:127.0.0.1:$PORT " + \
+	"--realm=python --user=username --password=password"
+
+req1 = sip.RecvfromTransaction("Initial request", 401,
+				include=["REGISTER sip"], 
+				exclude=["Authorization"],
+				resp_hdr=["WWW-Authenticate: Digest realm=\"python\", nonce=\"1\""]
+			  	)
+
+req2 = sip.RecvfromTransaction("First retry", 401,
+				include=["REGISTER sip", "Authorization", "nonce=\"1\""], 
+				exclude=["Authorization:[\\s\\S]+Authorization:"],
+				resp_hdr=["WWW-Authenticate: Digest realm=\"python\", nonce=\"2\", stale=true"]
+			  	)
+
+req3 = sip.RecvfromTransaction("Second retry retry", 401,
+				include=["REGISTER sip", "Authorization", "nonce=\"2\""], 
+				exclude=["Authorization:[\\s\\S]+Authorization:"],
+				resp_hdr=["WWW-Authenticate: Digest realm=\"python\", nonce=\"3\", stale=true"]
+				)
+
+req4 = sip.RecvfromTransaction("Third retry", 401,
+				include=["REGISTER sip", "Authorization", "nonce=\"3\""], 
+				exclude=["Authorization:[\\s\\S]+Authorization:"],
+				resp_hdr=["WWW-Authenticate: Digest realm=\"python\", nonce=\"4\", stale=true"],
+				expect="PJSIP_EAUTHSTALECOUNT"
+			  	)
+
+recvfrom_cfg = sip.RecvfromCfg("Failed registration retry (server rejects with stale=true) ",
+			       pjsua, [req1, req2, req3, req4])
diff --git a/tests/pjsua/scripts-recvfrom/234_reg_bad_stale_ok.py b/tests/pjsua/scripts-recvfrom/234_reg_bad_stale_ok.py
new file mode 100644
index 0000000..cfa9403
--- /dev/null
+++ b/tests/pjsua/scripts-recvfrom/234_reg_bad_stale_ok.py
@@ -0,0 +1,41 @@
+# $Id$
+import inc_sip as sip
+import inc_sdp as sdp
+
+# In this test we simulate broken server, where it wants to
+# change the nonce, but it fails to set stale to true. In this
+# case, we should expect pjsip to retry the authentication until
+# PJSIP_MAX_STALE_COUNT is exceeded as it should have detected
+# that that nonce has changed
+
+
+pjsua = "--null-audio --id=sip:CLIENT --registrar sip:127.0.0.1:$PORT " + \
+	"--realm=python --user=username --password=password " + \
+	"--auto-update-nat=0"
+
+req1 = sip.RecvfromTransaction("Initial request", 401,
+				include=["REGISTER sip"], 
+				exclude=["Authorization"],
+				resp_hdr=["WWW-Authenticate: Digest realm=\"python\", nonce=\"1\""]
+			  	)
+
+req2 = sip.RecvfromTransaction("First retry", 401,
+				include=["REGISTER sip", "Authorization", "nonce=\"1\""], 
+				exclude=["Authorization:[\\s\\S]+Authorization:"],
+				resp_hdr=["WWW-Authenticate: Digest realm=\"python\", nonce=\"2\""]
+			  	)
+
+req3 = sip.RecvfromTransaction("Second retry retry", 401,
+				include=["REGISTER sip", "Authorization", "nonce=\"2\""], 
+				exclude=["Authorization:[\\s\\S]+Authorization:"],
+				resp_hdr=["WWW-Authenticate: Digest realm=\"python\", nonce=\"3\""]
+				)
+
+req4 = sip.RecvfromTransaction("Third retry", 200,
+				include=["REGISTER sip", "Authorization", "nonce=\"3\""], 
+				exclude=["Authorization:[\\s\\S]+Authorization:"],
+				expect="registration success"
+			  	)
+
+recvfrom_cfg = sip.RecvfromCfg("Successful auth server changes nonce but with stale=false",
+			       pjsua, [req1, req2, req3, req4])