Просмотр исходного кода

- fix output for test 8
- add a test for persistent registrar for mysql


git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@3092 689a6050-402a-0410-94f2-e92a70836424

Henning Westerholt 18 лет назад
Родитель
Сommit
3b396f6910
3 измененных файлов с 118 добавлено и 2 удалено
  1. 61 0
      test/unit/11.cfg
  2. 55 0
      test/unit/11.sh
  3. 2 2
      test/unit/8.sh

+ 61 - 0
test/unit/11.cfg

@@ -0,0 +1,61 @@
+# ----------- global configuration parameters ------------------------
+debug=9            # debug level (cmd line: -dddddddddd)
+fork=yes
+log_stderror=no    # (cmd line: -E)
+children=1
+disable_tcp=yes
+
+# ------------------ module loading ----------------------------------
+mpath="../modules/"
+loadmodule "mysql/mysql.so"
+loadmodule "sl/sl.so"
+loadmodule "tm/tm.so"
+loadmodule "rr/rr.so"
+loadmodule "maxfwd/maxfwd.so"
+loadmodule "textops/textops.so"
+loadmodule "mi_fifo/mi_fifo.so"
+modparam("mi_fifo", "fifo_name", "/tmp/openser_fifo")
+
+loadmodule "usrloc/usrloc.so"
+modparam("usrloc", "db_mode", 1)
+
+loadmodule "registrar/registrar.so"
+#-------------------------  request routing logic -------------------
+route{
+
+        if (!method=="REGISTER")
+                record_route();
+
+        if (loose_route()) {
+                # mark routing logic in request
+                append_hf("P-hint: rr-enforced\r\n");
+                route(1);
+        };
+
+        if (!uri==myself) {
+                append_hf("P-hint: outbound\r\n");
+                route(1);
+        };
+
+        if (uri==myself) {
+                if (method=="REGISTER") {
+                        save("location");
+                        exit;
+                };
+                if (!lookup("location")) {
+                        sl_send_reply("404", "Not Found");
+                        exit;
+                };
+                append_hf("P-hint: usrloc applied\r\n");
+        };
+
+        route(1);
+}
+
+
+route[1] {
+        if (!t_relay()) {
+                sl_reply_error();
+        };
+        exit;
+}

+ 55 - 0
test/unit/11.sh

@@ -0,0 +1,55 @@
+#!/bin/bash
+# database access and persistent storage for registrar on mysql
+
+# needs the netcat utility to run
+
+CFG=11.cfg
+
+which nc > /dev/null
+ret=$?
+
+if [ ! $ret -eq 0 ] ; then
+	echo "netcat not found, not run"
+	exit 0
+fi ;
+
+../openser -f $CFG > /dev/null
+ret=$?
+
+sleep 1
+
+# register a user
+cat register.sip | nc -q 1 -u localhost 5060 > /dev/null
+
+cd ../scripts
+
+if [ "$ret" -eq 0 ] ; then
+	./openserctl ul show | grep "AOR:: 1000" > /dev/null
+	ret=$?
+fi ;
+
+TMP=`mysql -B -u openserro --password=openserro openser -e "select COUNT(*) from location where username="1000";" | tail -n 1`
+if [ "$TMP" -eq 0 ] ; then
+	ret=1
+fi ;
+
+# unregister the user
+cat ../test/unregister.sip | nc -q 1 -u localhost 5060 > /dev/null
+
+if [ "$ret" -eq 0 ] ; then
+	./openserctl ul show | grep "AOR:: 1000" > /dev/null
+	ret=$?
+	if [ "$ret" -eq 0 ] ; then
+		ret=1
+	else
+		ret=0
+	fi ;
+fi ;
+
+ret=`mysql -B -u openserro --password=openserro openser -e "select COUNT(*) from location where username="1000";" | tail -n 1`
+
+cd ../test
+
+killall -9 openser
+
+exit $ret

+ 2 - 2
test/unit/8.sh

@@ -17,11 +17,11 @@ sed -i "s/# INSTALL_SERWEB_TABLES=ask/INSTALL_SERWEB_TABLES=yes/g" openserctlrc
 cp openserdbctl.mysql openserdbctl.mysql.bak
 sed -i "s/#PW=""/PW="$PW"/g" openserdbctl.mysql
 
-./openserdbctl create $tmp_name #> /dev/null
+./openserdbctl create $tmp_name > /dev/null
 ret=$?
 
 if [ "$ret" -eq 0 ] ; then
-	./openserdbctl drop $tmp_name #> /dev/null
+	./openserdbctl drop $tmp_name > /dev/null
 	ret=$?
 fi ;