diff options
author | David M. Lee <dlee@digium.com> | 2013-01-07 14:24:28 -0600 |
---|---|---|
committer | David M. Lee <dlee@digium.com> | 2013-01-07 14:24:28 -0600 |
commit | f3ab456a17af1c89a6e3be4d20c5944853df1cb0 (patch) | |
tree | d00e1a332cd038a6d906a1ea0ac91e1a4458e617 /tests/pjsua/scripts-recvfrom |
Import pjproject-2.0.1
Diffstat (limited to 'tests/pjsua/scripts-recvfrom')
21 files changed, 577 insertions, 0 deletions
diff --git a/tests/pjsua/scripts-recvfrom/100_simple.py b/tests/pjsua/scripts-recvfrom/100_simple.py new file mode 100644 index 0000000..7f65ee1 --- /dev/null +++ b/tests/pjsua/scripts-recvfrom/100_simple.py @@ -0,0 +1,16 @@ +# $Id: 100_simple.py 3284 2010-08-18 07:38:48Z bennylp $ +import inc_sip as sip +import inc_sdp as sdp + +pjsua = "--null-audio --id=sip:CLIENT --registrar sip:127.0.0.1:$PORT " + \ + "--auto-update-nat=0" + +req1 = sip.RecvfromTransaction("Registration", 200, + include=["REGISTER sip"], + exclude=["Authorization"], + resp_hdr=["Server: Snake Registrar", "Expires: 221", "Contact: sip:localhost"], + expect="registration success" + ) + +recvfrom_cfg = sip.RecvfromCfg("Simple registration test", + pjsua, [req1]) 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..3df45db --- /dev/null +++ b/tests/pjsua/scripts-recvfrom/200_reg_good_enocredentiall.py @@ -0,0 +1,15 @@ +# $Id: 200_reg_good_enocredentiall.py 2392 2008-12-22 18:54:58Z bennylp $ +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..c6f524a --- /dev/null +++ b/tests/pjsua/scripts-recvfrom/201_reg_good_ok.py @@ -0,0 +1,23 @@ +# $Id: 201_reg_good_ok.py 2392 2008-12-22 18:54:58Z bennylp $ +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..524d4cd --- /dev/null +++ b/tests/pjsua/scripts-recvfrom/202_reg_good_ok_wildcard.py @@ -0,0 +1,23 @@ +# $Id: 202_reg_good_ok_wildcard.py 2392 2008-12-22 18:54:58Z bennylp $ +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/203_reg_good_empty_realm.py b/tests/pjsua/scripts-recvfrom/203_reg_good_empty_realm.py new file mode 100644 index 0000000..e936438 --- /dev/null +++ b/tests/pjsua/scripts-recvfrom/203_reg_good_empty_realm.py @@ -0,0 +1,31 @@ +# $Id: 203_reg_good_empty_realm.py 3150 2010-04-29 00:23:43Z bennylp $ +import inc_sip as sip +import inc_sdp as sdp + +pjsua = "--null-audio --id=sip:CLIENT --registrar sip:127.0.0.1:$PORT " + \ + "--realm=* --user=username --password=password " + \ + "--auto-update-nat=0" + +# 401 Response, missing realm value +req1 = sip.RecvfromTransaction("Initial request", 401, + include=["REGISTER sip"], + exclude=[], + resp_hdr=['WWW-Authenticate: Digest'] + ) + +# Client should retry, we giving it another 401 with empty realm +req2 = sip.RecvfromTransaction("REGISTER retry #1 of 2", 407, + include=["REGISTER sip"], + exclude=[], + resp_hdr=['Proxy-Authenticate: Digest realm=""'] + ) + +# Client should retry +req3 = sip.RecvfromTransaction("REGISTER retry #2 of 2", 200, + include=[], + exclude=[], + expect="registration success" + ) + +recvfrom_cfg = sip.RecvfromCfg("Registration with empty realm", + pjsua, [req1, req2, req3]) 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..5343854 --- /dev/null +++ b/tests/pjsua/scripts-recvfrom/205_reg_good_no_realm.py @@ -0,0 +1,16 @@ +# $Id: 205_reg_good_no_realm.py 2392 2008-12-22 18:54:58Z bennylp $ +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..9cd5ecb --- /dev/null +++ b/tests/pjsua/scripts-recvfrom/206_reg_good_efailedcredential.py @@ -0,0 +1,26 @@ +# $Id: 206_reg_good_efailedcredential.py 2392 2008-12-22 18:54:58Z bennylp $ +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..ef862d0 --- /dev/null +++ b/tests/pjsua/scripts-recvfrom/208_reg_good_retry_nonce_ok.py @@ -0,0 +1,29 @@ +# $Id: 208_reg_good_retry_nonce_ok.py 2392 2008-12-22 18:54:58Z bennylp $ +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/209a_reg_handle_423_ok.py b/tests/pjsua/scripts-recvfrom/209a_reg_handle_423_ok.py new file mode 100644 index 0000000..2b57342 --- /dev/null +++ b/tests/pjsua/scripts-recvfrom/209a_reg_handle_423_ok.py @@ -0,0 +1,31 @@ +# $Id: 209a_reg_handle_423_ok.py 3105 2010-02-23 11:03:07Z bennylp $ +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" + +# 423 Response without Min-Expires header +req1 = sip.RecvfromTransaction("Initial request", 423, + include=["REGISTER sip"], + exclude=[], + resp_hdr=[] + ) + +# Client should retry with Expires header containing special value (pjsip specific) +req2 = sip.RecvfromTransaction("REGISTER retry after 423 response without Min-Expires header", 423, + include=["REGISTER sip", "Expires: 3601"], + exclude=[], + resp_hdr=["Min-Expires: 3612"] + ) + +# Client should retry with proper Expires header now +req3 = sip.RecvfromTransaction("REGISTER retry after proper 423", 200, + include=["Expires: 3612"], + exclude=[], + expect="registration success" + ) + +recvfrom_cfg = sip.RecvfromCfg("Reregistration after 423 response", + pjsua, [req1, req2, req3]) diff --git a/tests/pjsua/scripts-recvfrom/209b_reg_handle_423_bad_min_expires1.py b/tests/pjsua/scripts-recvfrom/209b_reg_handle_423_bad_min_expires1.py new file mode 100644 index 0000000..3c22109 --- /dev/null +++ b/tests/pjsua/scripts-recvfrom/209b_reg_handle_423_bad_min_expires1.py @@ -0,0 +1,20 @@ +# $Id: 209b_reg_handle_423_bad_min_expires1.py 3105 2010-02-23 11:03:07Z bennylp $ +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 --reg-timeout 300" + +# 423 Response with Min-Expires header that is lower than what the client +# had requested +req1 = sip.RecvfromTransaction("Initial request", 423, + include=["REGISTER sip"], + exclude=[], + resp_hdr=["Min-Expires: 250"], + expect="invalid Min-Expires" + + ) + +recvfrom_cfg = sip.RecvfromCfg("Invalid 423 response to REGISTER", + pjsua, [req1]) diff --git a/tests/pjsua/scripts-recvfrom/209c_reg_handle_423_bad_min_expires2.py b/tests/pjsua/scripts-recvfrom/209c_reg_handle_423_bad_min_expires2.py new file mode 100644 index 0000000..68fda46 --- /dev/null +++ b/tests/pjsua/scripts-recvfrom/209c_reg_handle_423_bad_min_expires2.py @@ -0,0 +1,25 @@ +# $Id: 209c_reg_handle_423_bad_min_expires2.py 3105 2010-02-23 11:03:07Z bennylp $ +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 --reg-timeout 300" + +# 423 without Min-Expires. PJSIP would retry with Expires: 3601 +req1 = sip.RecvfromTransaction("Initial request", 423, + include=["REGISTER sip"], + exclude=[], + resp_hdr=[] + ) + +# Another 423, still without Min-Expires +req2 = sip.RecvfromTransaction("Retry with guessed Expires header", 423, + include=["REGISTER sip", "Expires: 3601"], + exclude=[], + resp_hdr=[], + expect="without Min-Expires header is invalid" + ) + +recvfrom_cfg = sip.RecvfromCfg("Invalid 423 response to REGISTER", + pjsua, [req1, req2]) 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..4b63a5e --- /dev/null +++ b/tests/pjsua/scripts-recvfrom/215_reg_good_multi_ok.py @@ -0,0 +1,28 @@ +# $Id: 215_reg_good_multi_ok.py 2392 2008-12-22 18:54:58Z bennylp $ +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..4d1ff16 --- /dev/null +++ b/tests/pjsua/scripts-recvfrom/220_reg_good_ims_ok.py @@ -0,0 +1,26 @@ +# $Id: 220_reg_good_ims_ok.py 2392 2008-12-22 18:54:58Z bennylp $ +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..cfd7d00 --- /dev/null +++ b/tests/pjsua/scripts-recvfrom/230_reg_bad_fail_stale_true.py @@ -0,0 +1,41 @@ +# $Id: 230_reg_bad_fail_stale_true.py 2392 2008-12-22 18:54:58Z bennylp $ +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..ed47d29 --- /dev/null +++ b/tests/pjsua/scripts-recvfrom/231_reg_bad_fail_stale_false_nonce_changed.py @@ -0,0 +1,41 @@ +# $Id: 231_reg_bad_fail_stale_false_nonce_changed.py 2392 2008-12-22 18:54:58Z bennylp $ +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..e50da60 --- /dev/null +++ b/tests/pjsua/scripts-recvfrom/234_reg_bad_stale_ok.py @@ -0,0 +1,41 @@ +# $Id: 234_reg_bad_stale_ok.py 2392 2008-12-22 18:54:58Z bennylp $ +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]) diff --git a/tests/pjsua/scripts-recvfrom/235_reg_good_tel_uri_enocredential.py b/tests/pjsua/scripts-recvfrom/235_reg_good_tel_uri_enocredential.py new file mode 100644 index 0000000..c15a77b --- /dev/null +++ b/tests/pjsua/scripts-recvfrom/235_reg_good_tel_uri_enocredential.py @@ -0,0 +1,15 @@ +# $Id: 235_reg_good_tel_uri_enocredential.py 3323 2010-09-28 07:43:18Z bennylp $ +import inc_sip as sip +import inc_sdp as sdp + +pjsua = "--null-audio --id=tel:+12345 --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 with tel: URI test", + pjsua, [req1]) diff --git a/tests/pjsua/scripts-recvfrom/240_publish_scenarios.py b/tests/pjsua/scripts-recvfrom/240_publish_scenarios.py new file mode 100644 index 0000000..bd9a51d --- /dev/null +++ b/tests/pjsua/scripts-recvfrom/240_publish_scenarios.py @@ -0,0 +1,51 @@ +# $Id: 240_publish_scenarios.py 2661 2009-04-28 22:19:49Z bennylp $ +import inc_sip as sip +import inc_sdp as sdp + +# Several PUBLISH failure scenarios that should be handled automatically + + +pjsua = "--null-audio --id=sip:127.0.0.1:$PORT --registrar sip:127.0.0.1:$PORT " + \ + "--realm=python --user=username --password=password " + \ + "--auto-update-nat=0 --publish" +#pjsua = "--null-audio --local-port 0 --rtp-port 0" + +# Handle REGISTER first +req1 = sip.RecvfromTransaction("Initial REGISTER", 200, + include=["REGISTER sip"], + exclude=[], + resp_hdr=["Expires: 1800"] + ) + +# First PUBLISH, reply with 412 +req2 = sip.RecvfromTransaction("Initial PUBLISH, will be replied with 412", 412, + include=["PUBLISH sip"], + exclude=["Expires:"] + ) + +# Second PUBLISH +req3 = sip.RecvfromTransaction("Second PUBLISH, will be replied with 200", 200, + include=["PUBLISH sip"], + exclude=["Expires:"], + resp_hdr=["Expires: 60", "SIP-ETag: dx200xyz"] + ) + +# PUBLISH refresh, respond with 408 +req4 = sip.RecvfromTransaction("PUBLISH refresh, will be replied with 408", 408, + include=["PUBLISH sip", "SIP-If-Match: dx200xyz"], + exclude=["Expires:"], + resp_hdr=["Expires: 60", "SIP-ETag: dx200xyz"] + ) + +# After 5 minutes, pjsua should retry again +req5 = sip.RecvfromTransaction("PUBLISH retry", 200, + include=["PUBLISH sip"], + exclude=["Expires:", "SIP-If-Match:"], + resp_hdr=["Expires: 60", "SIP-ETag: abc"] + ) + + + +recvfrom_cfg = sip.RecvfromCfg("PUBLISH scenarios", + pjsua, [req1, req2, req3]) + diff --git a/tests/pjsua/scripts-recvfrom/300_timer_good.py b/tests/pjsua/scripts-recvfrom/300_timer_good.py new file mode 100644 index 0000000..4281141 --- /dev/null +++ b/tests/pjsua/scripts-recvfrom/300_timer_good.py @@ -0,0 +1,17 @@ +# $Id: 300_timer_good.py 3307 2010-09-08 05:38:49Z nanang $ +import inc_sip as sip +import inc_sdp as sdp + +# INVITE session using session timer + +pjsua = "--null-audio sip:127.0.0.1:$PORT --use-timer 2 --timer-min-se 100 --timer-se 2000" + +req = sip.RecvfromTransaction("INVITE with session timer", 200, + include=["Session-Expires:\s*2000", "Min-SE:\s*100"], + exclude=[], + resp_hdr=["Session-Expires: 1000;refresher=uac"] + ) + +recvfrom_cfg = sip.RecvfromCfg("INVITE session using session timer", + pjsua, [req]) + diff --git a/tests/pjsua/scripts-recvfrom/301_timer_good_retry_after_422.py b/tests/pjsua/scripts-recvfrom/301_timer_good_retry_after_422.py new file mode 100644 index 0000000..3bd8a57 --- /dev/null +++ b/tests/pjsua/scripts-recvfrom/301_timer_good_retry_after_422.py @@ -0,0 +1,30 @@ +# $Id: 301_timer_good_retry_after_422.py 3287 2010-08-18 14:30:17Z nanang $ +import inc_sip as sip +import inc_sdp as sdp + +# Session timers retry after 422 + + +pjsua = "--null-audio sip:127.0.0.1:$PORT --timer-min-se 100 --timer-se 1000" + +# First INVITE with timer rejected with 422 +req1 = sip.RecvfromTransaction("INVITE with SE too small", 422, + include=["Session-Expires:\s*1000"], + exclude=[], + resp_hdr=["Min-SE: 2000"] + ) + +# Wait for ACK +req2 = sip.RecvfromTransaction("Wait ACK", 0, include=["ACK sip"]) + +# New INVITE with SE >= Min-SE +req3 = sip.RecvfromTransaction("Retrying with acceptable SE", 200, + include=["Session-Expires:\s*2000", "Min-SE:\s*2000"], + exclude=[], + resp_hdr=["Session-Expires: 2000;refresher=uac"] + ) + + +recvfrom_cfg = sip.RecvfromCfg("Session timers retry after 422", + pjsua, [req1, req2, req3]) + diff --git a/tests/pjsua/scripts-recvfrom/400_inv_answered_with_less_media.py b/tests/pjsua/scripts-recvfrom/400_inv_answered_with_less_media.py new file mode 100644 index 0000000..2fd8c7f --- /dev/null +++ b/tests/pjsua/scripts-recvfrom/400_inv_answered_with_less_media.py @@ -0,0 +1,32 @@ +# $Id: 400_inv_answered_with_less_media.py 3716 2011-08-19 12:24:48Z nanang $ +import inc_sip as sip +import inc_sdp as sdp + +# Offer with 2 media lines answered with only 1 media line + +pjsua = "--null-audio sip:127.0.0.1:$PORT --id=sip:1000@localhost --extra-audio --use-srtp=0" + +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 +""" + +req = sip.RecvfromTransaction("Receiving 2 media lines, answer with 1 media line", 200, + include=["m=audio \d+ RTP/AVP", "m=audio \d+ RTP/AVP"], + exclude=[], + resp_hdr=["Content-type: application/sdp"], + resp_body=sdp, + ) + +recvfrom_cfg = sip.RecvfromCfg("Receiving answer with less media lines", + pjsua, [req]) + |