Jelajahi Sumber

- added tests for presence

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@3989 689a6050-402a-0410-94f2-e92a70836424
Anca Vamanu 17 tahun lalu
induk
melakukan
8ce632822b

+ 93 - 0
test/unit/presence.cfg

@@ -0,0 +1,93 @@
+#
+# $Id$
+#
+# simple quick-start config script - Stand-alone presence server
+#
+ 
+# ----------- global configuration parameters ------------------------
+ 
+debug=4      # debug level (cmd line: -dddddddddd)
+fork=yes
+log_stderror=no    # (cmd line: -E)
+children=4
+
+listen=127.0.0.1 
+port=5059
+
+dns=no
+rev_dns=no
+
+# ------------------ module loading ----------------------------------
+
+#set module path
+mpath="../modules/"
+
+loadmodule "db_mysql/db_mysql.so"
+loadmodule "sl/sl.so"
+loadmodule "maxfwd/maxfwd.so"
+loadmodule "textops/textops.so"
+loadmodule "tm/tm.so"
+loadmodule "rr/rr.so"
+loadmodule "presence/presence.so"
+loadmodule "presence_xml/presence_xml.so"
+loadmodule "avpops/avpops.so"
+loadmodule "mi_fifo/mi_fifo.so"
+ 
+# ----------------- setting module-specific parameters ---------------
+ 
+# -- rr params --
+# add value to ;lr param to make some broken UAs happy
+modparam("rr", "enable_full_lr", 1)
+ 
+# -- presence params --
+modparam("presence|presence_xml", "db_url", "mysql://openser:openserrw@localhost/openser")
+ 
+modparam("presence_xml", "force_active", 1)
+ 
+modparam("presence", "server_address", "sip:10.10.10.10:5060")
+
+modparam("mi_fifo", "fifo_name", "/tmp/openser_fifo_presence")
+ 
+# -------------------------  request routing logic -------------------
+ 
+# main routing logic
+ 
+route{
+    # initial sanity checks -- messages with
+    # max_forwards==0, or excessively long requests
+    if (!mf_process_maxfwd_header("10")) {
+        sl_send_reply("483","Too Many Hops");
+        exit;
+    };
+ 
+    if (msg:len >=  2048 ) {
+        sl_send_reply("513", "Message too big");
+        exit;
+    };
+ 
+    if (!is_method("SUBSCRIBE|PUBLISH")) {
+        sl_send_reply("488", "Not Acceptable Here");
+        exit;
+    }
+ 
+    # presence handling
+    if (! t_newtran())
+    {
+        sl_reply_error();
+        exit;
+     };
+ 
+    if(is_method("PUBLISH"))
+    {
+        handle_publish();
+        t_release();
+    }
+    else
+    if( is_method("SUBSCRIBE"))
+    {
+        handle_subscribe();
+        t_release();
+    };
+ 
+    exit;
+}

+ 53 - 0
test/unit/presence.sh

@@ -0,0 +1,53 @@
+#!/bin/bash
+# tests the authentification via auth_db and uri_db
+
+# Copyright (C) 2008 Voice System
+#
+# This file is part of openser, a free SIP server.
+#
+# openser is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version
+#
+# openser is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+
+# needs the sipp utility to run
+which sipp > /dev/null
+ret=$?
+
+if [ ! $? -eq 0 ] ; then
+	echo "sipp not found, not run"
+	exit 0
+fi ;
+
+CFG=presence.cfg
+
+../openser -w . -f $CFG &> /dev/null;
+ret=$?
+sleep 1
+
+if [ "$ret" -eq 0 ] ; then
+    sipp -sf publish_scenario.xml -i 127.0.0.1 -p 5061 -inf publish.csv 127.0.0.1:5059 -recv_timeout 500000 -m 1 &> /dev/null;
+    ret=$?
+fi;
+
+
+if [ "$ret" -eq 0 ] ; then
+    sipp -sf subscribe_notify_scenario.xml -i 127.0.0.1 -p 5061 -inf subscribe_notify.csv 127.0.0.1:5059 -recv_timeout 500000 -m 1 &> /dev/null;
+    ret=$?
+fi;
+
+
+#cleanup:
+killall -9 openser &> /dev/null;
+killall -9 sipp &> /dev/null;
+
+exit $ret;

+ 4 - 0
test/unit/publish.csv

@@ -0,0 +1,4 @@
+SEQUENTIAL
+user1;127.0.0.1:5059
+user2;127.0.0.1:5059
+

+ 86 - 0
test/unit/publish_scenario.xml

@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="publish_scenario">
+
+  <!--  First PUBLISH without Etag -->
+  <!--  Then another publish with status 'busy'
+  -->
+    <send retrans="1000">
+    <![CDATA[
+
+
+PUBLISH sip:[field0]@[field1] SIP/2.0
+Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+Max-Forwards: 70
+Contact: sip:[field0]@[local_ip]:[local_port]
+To: <sip:[field0]@[field1]>
+From: <sip:[field0]@[field1]>;tag=[call_number]
+Call-ID: [call_id]
+CSeq: 1 PUBLISH
+Expires: 60
+Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO
+Content-Type: application/pidf+xml
+User-Agent: sipp
+Event: presence
+Content-Length: [len]
+
+<?xml version='1.0' encoding='UTF-8'?><presence xmlns='urn:ietf:params:xml:ns:pidf' xmlns:dm='urn:ietf:params:xml:ns:pidf:data-model' xmlns:rpid='urn:ietf:params:xml:ns:pidf:rpid' xmlns:c='urn:ietf:params:xml:ns:pidf:cipid' entity='sip:[field0]@[field1]'><tuple id='t532d494f'><status><basic>open</basic></status></tuple><dm:person id='p98169736'><rpid:activities><rpid:unknown/></rpid:activities></dm:person></presence>
+]]>
+  </send>
+
+  <recv response="200" rtd="true">
+    <action>
+        <!-- Save the ETag value in [$3] -->
+        <ereg regexp=".*"
+              search_in="hdr"
+              header="SIP-ETag:"
+              check_it="true"
+              assign_to="3"/>	
+        <!-- Save the To-tag value in [$4] -->
+        <ereg regexp=".*;tag=(.*)"
+              search_in="hdr"
+              header=To:"
+              check_it="true"
+              assign_to="19,4"/>	
+    </action>
+  </recv>
+
+  <pause min="500" max="1000"/>
+
+  <send retrans="1000">
+    <![CDATA[
+
+PUBLISH sip:[field0]@[field1] SIP/2.0
+Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]---[$4]
+Max-Forwards: 70
+Contact: sip:[field0]@[local_ip]:[local_port]
+To: "[field0]"<sip:[field0]@[field1]>
+From: "[field0]"<sip:[field0]@[field1]>;tag=[call_number]
+Call-ID: [$4]///[call_id]
+CSeq: 1 PUBLISH
+Expires: 60
+Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO
+Content-Type: application/pidf+xml
+User-Agent: sipp
+Event: presence
+SIP-If-Match:[$3]
+Content-Length: [len]
+
+<?xml version='1.0' encoding='UTF-8'?><presence xmlns='urn:ietf:params:xml:ns:pidf' xmlns:dm='urn:ietf:params:xml:ns:pidf:data-model' xmlns:rpid='urn:ietf:params:xml:ns:pidf:rpid' xmlns:c='urn:ietf:params:xml:ns:pidf:cipid' entity='sip:[field0]@[field1]'><tuple id='t532d494f'><status><basic>open</basic></status></tuple><dm:person id='p98169736'><rpid:activities><rpid:busy/></rpid:activities><dm:note>Busy</dm:note></dm:person></presence>
+]]>
+  </send>
+
+  <recv response="200" rtd="true">
+      <action>
+        <!-- Save the To-tag value in [$4] -->
+        <ereg regexp=".*;tag=(.*)"
+              search_in="hdr"
+              header=To:"
+              check_it="true"
+              assign_to="19,4"/>	
+    </action>
+  </recv>
+
+</scenario>
+

+ 4 - 0
test/unit/subscribe_notify.csv

@@ -0,0 +1,4 @@
+SEQUENTIAL
+user1;127.0.0.1:5059;user2
+user2;127.0.0.1:5059;user1
+user2;127.0.0.1:5059;user3

+ 58 - 0
test/unit/subscribe_notify_scenario.xml

@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="subscribe_notify__presence_scenario">
+
+    <!-- Send SUBSCRIBE for presence  and receive NOTIFY message -->
+
+    <send retrans="1000">
+    <![CDATA[
+
+
+SUBSCRIBE sip:[field2]@[field1] SIP/2.0
+Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+Max-Forwards: 70
+Contact: sip:[field0]@[local_ip]:[local_port]
+To: <sip:[field2]@[field1]>
+From: "[field0]"<sip:[field0]@[field1]>;tag=[call_number]
+Call-ID: [call_id]
+CSeq: 1 SUBSCRIBE
+Expires: 3600
+Accept: multipart/related, application/rlmi+xml, application/pidf+xml
+Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO
+User-Agent: sipp
+Event: presence
+Content-Length: 0
+
+    ]]>
+  </send>
+
+  <recv response="202" rtd="true">
+  </recv>
+
+  <recv request="NOTIFY">
+  </recv>
+
+  <send crlf="true">
+    <![CDATA[
+
+      SIP/2.0 200 OK
+      [last_Via:]
+      [last_From:]
+      [last_To:]
+      [last_Call-ID:]
+      [last_CSeq:]
+      User-Agent: sipp
+      Content-Length: 0
+
+    ]]>
+  </send>
+
+  <!-- definition of the response time repartition table (unit is ms)   -->
+  <ResponseTimeRepartition value="10, 20, 30, 40, 50, 100, 150, 200"/>
+
+  <!-- definition of the call length repartition table (unit is ms)     -->
+  <CallLengthRepartition value="10, 50, 100, 500, 1000, 5000, 10000"/>
+
+</scenario>
+