initial commit

This commit is contained in:
Dan Bastone committed 2021-10-29 14:41:03 -04:00
commit 636959b37b
2474 files changed
+1343178

No files matched your search

@@ -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 " + \
"--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])
@@ -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])
@@ -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])
@@ -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])
@@ -0,0 +1,31 @@
# $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=* --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])
@@ -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])
@@ -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])
@@ -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])
@@ -0,0 +1,31 @@
# $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"
# 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])
@@ -0,0 +1,20 @@
# $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 --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])
@@ -0,0 +1,25 @@
# $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 --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])
@@ -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])
@@ -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])
@@ -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])
@@ -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])
@@ -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])
@@ -0,0 +1,15 @@
# $Id$
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])
@@ -0,0 +1,51 @@
# $Id$
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])
@@ -0,0 +1,17 @@
# $Id$
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 --no-tcp"
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])
@@ -0,0 +1,30 @@
# $Id$
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 --no-tcp"
# 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])
@@ -0,0 +1,32 @@
# $Id$
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])