From 6f204c13ce8519524eb4da79359ac9b2aea08252 Mon Sep 17 00:00:00 2001 From: Nanang Izzuddin Date: Tue, 11 Aug 2009 12:42:38 +0000 Subject: Ticket #833: - Initial version of Session Timers (RFC 4028). - Added new options in pjsua app to configure Session Timers settings. - Added python tests for Session Timers. git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2858 74dad513-b988-da41-8d7b-12977e46ad98 --- tests/pjsua/scripts-recvfrom/300_timer_good.py | 17 ++++++++++ .../301_timer_good_retry_after_422.py | 28 +++++++++++++++++ tests/pjsua/scripts-sendto/170_timer_required.py | 27 ++++++++++++++++ .../scripts-sendto/171_timer_initiated_by_uas.py | 36 ++++++++++++++++++++++ .../172_timer_supported_but_not_used.py | 26 ++++++++++++++++ .../scripts-sendto/173_timer_offer_no_refresher.py | 26 ++++++++++++++++ .../173_timer_offer_refresher_uac.py | 26 ++++++++++++++++ .../173_timer_offer_refresher_uas.py | 26 ++++++++++++++++ .../pjsua/scripts-sendto/174_timer_se_too_small.py | 26 ++++++++++++++++ 9 files changed, 238 insertions(+) create mode 100644 tests/pjsua/scripts-recvfrom/300_timer_good.py create mode 100644 tests/pjsua/scripts-recvfrom/301_timer_good_retry_after_422.py create mode 100644 tests/pjsua/scripts-sendto/170_timer_required.py create mode 100644 tests/pjsua/scripts-sendto/171_timer_initiated_by_uas.py create mode 100644 tests/pjsua/scripts-sendto/172_timer_supported_but_not_used.py create mode 100644 tests/pjsua/scripts-sendto/173_timer_offer_no_refresher.py create mode 100644 tests/pjsua/scripts-sendto/173_timer_offer_refresher_uac.py create mode 100644 tests/pjsua/scripts-sendto/173_timer_offer_refresher_uas.py create mode 100644 tests/pjsua/scripts-sendto/174_timer_se_too_small.py (limited to 'tests') 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 00000000..75dd1bd8 --- /dev/null +++ b/tests/pjsua/scripts-recvfrom/300_timer_good.py @@ -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 --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 00000000..c3bbac7e --- /dev/null +++ b/tests/pjsua/scripts-recvfrom/301_timer_good_retry_after_422.py @@ -0,0 +1,28 @@ +# $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" + +# 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"], + expect="ACK sip" + ) + +# New INVITE with SE >= Min-SE +req2 = 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]) + diff --git a/tests/pjsua/scripts-sendto/170_timer_required.py b/tests/pjsua/scripts-sendto/170_timer_required.py new file mode 100644 index 00000000..b9bea968 --- /dev/null +++ b/tests/pjsua/scripts-sendto/170_timer_required.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 --use-timer --timer-min-se 90 --timer-se 1800" +extra_headers = "Require: timer\nSupported: timer\nSession-Expires: 1800\n" +include = ["Session-Expires: .*;refresher=.*"] +exclude = [] +sendto_cfg = sip.SendtoCfg("Session Timer required", pjsua_args, sdp, 200, + extra_headers=extra_headers, + resp_inc=include, resp_exc=exclude) + + diff --git a/tests/pjsua/scripts-sendto/171_timer_initiated_by_uas.py b/tests/pjsua/scripts-sendto/171_timer_initiated_by_uas.py new file mode 100644 index 00000000..393a0012 --- /dev/null +++ b/tests/pjsua/scripts-sendto/171_timer_initiated_by_uas.py @@ -0,0 +1,36 @@ +# $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 +""" + +# RFC 4028 Section 9: +# If the incoming request contains a Supported header field with a +# value 'timer' but does not contain a Session-Expires header, it means +# that the UAS is indicating support for timers but is not requesting +# one. The UAS may request a session timer in the 2XX response by +# including a Session-Expires header field. The value MUST NOT be set +# to a duration lower than the value in the Min-SE header field in the +# request, if it is present. + +pjsua_args = "--null-audio --auto-answer 200 --use-timer --timer-min-se 90 --timer-se 1800" +extra_headers = "Supported: timer\n" +include = ["Session-Expires: .*;refresher=.*"] +exclude = [] +sendto_cfg = sip.SendtoCfg("Session Timer initiated by UAS", pjsua_args, sdp, 200, + extra_headers=extra_headers, + resp_inc=include, resp_exc=exclude) + + diff --git a/tests/pjsua/scripts-sendto/172_timer_supported_but_not_used.py b/tests/pjsua/scripts-sendto/172_timer_supported_but_not_used.py new file mode 100644 index 00000000..69b0c900 --- /dev/null +++ b/tests/pjsua/scripts-sendto/172_timer_supported_but_not_used.py @@ -0,0 +1,26 @@ +# $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 = "Supported: timer\n" +include = [] +exclude = ["Session-Expires:"] +sendto_cfg = sip.SendtoCfg("Session Timer supported but not used", pjsua_args, sdp, 200, + extra_headers=extra_headers, + resp_inc=include, resp_exc=exclude) + diff --git a/tests/pjsua/scripts-sendto/173_timer_offer_no_refresher.py b/tests/pjsua/scripts-sendto/173_timer_offer_no_refresher.py new file mode 100644 index 00000000..a0005d3e --- /dev/null +++ b/tests/pjsua/scripts-sendto/173_timer_offer_no_refresher.py @@ -0,0 +1,26 @@ +# $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 --timer-min-se 90" +extra_headers = "Supported: timer\nSession-Expires: 1800\n" +include = ["Session-Expires:.*;refresher=ua[cs]"] +exclude = [] +sendto_cfg = sip.SendtoCfg("Session Timer without specifying refresher", pjsua_args, sdp, 200, + extra_headers=extra_headers, + resp_inc=include, resp_exc=exclude) + diff --git a/tests/pjsua/scripts-sendto/173_timer_offer_refresher_uac.py b/tests/pjsua/scripts-sendto/173_timer_offer_refresher_uac.py new file mode 100644 index 00000000..13c24498 --- /dev/null +++ b/tests/pjsua/scripts-sendto/173_timer_offer_refresher_uac.py @@ -0,0 +1,26 @@ +# $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 --timer-min-se 90" +extra_headers = "Supported: timer\nSession-Expires: 1800;refresher=uac\n" +include = ["Session-Expires:.*;refresher=ua[cs]"] +exclude = [] +sendto_cfg = sip.SendtoCfg("Session Timer offer refresher uac", pjsua_args, sdp, 200, + extra_headers=extra_headers, + resp_inc=include, resp_exc=exclude) + diff --git a/tests/pjsua/scripts-sendto/173_timer_offer_refresher_uas.py b/tests/pjsua/scripts-sendto/173_timer_offer_refresher_uas.py new file mode 100644 index 00000000..2c270e1f --- /dev/null +++ b/tests/pjsua/scripts-sendto/173_timer_offer_refresher_uas.py @@ -0,0 +1,26 @@ +# $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 --timer-min-se 90" +extra_headers = "Supported: timer\nSession-Expires: 1800;refresher=uas\n" +include = ["Session-Expires:.*;refresher=ua[cs]"] +exclude = [] +sendto_cfg = sip.SendtoCfg("Session Timer offer refresher uas", pjsua_args, sdp, 200, + extra_headers=extra_headers, + resp_inc=include, resp_exc=exclude) + diff --git a/tests/pjsua/scripts-sendto/174_timer_se_too_small.py b/tests/pjsua/scripts-sendto/174_timer_se_too_small.py new file mode 100644 index 00000000..c607de6c --- /dev/null +++ b/tests/pjsua/scripts-sendto/174_timer_se_too_small.py @@ -0,0 +1,26 @@ +# $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 --timer-min-se 2000 --timer-se 2000" +extra_headers = "Supported: timer\nSession-Expires: 1800\n" +include = ["Min-SE:\s*2000"] +exclude = [] +sendto_cfg = sip.SendtoCfg("Session Timer SE too small", pjsua_args, sdp, 422, + extra_headers=extra_headers, + resp_inc=include, resp_exc=exclude) + -- cgit v1.2.3