Browse Source

test/unit: updates to unit 22

Daniel-Constantin Mierla 11 years ago
parent
commit
6f476de8d0
2 changed files with 80 additions and 11 deletions
  1. 74 0
      test/unit/22.cfg
  2. 6 11
      test/unit/22.sh

+ 74 - 0
test/unit/22.cfg

@@ -0,0 +1,74 @@
+# ----------- global configuration parameters ------------------------
+debug=2
+fork=yes
+log_stderror=no
+children=1
+disable_tcp=yes
+
+alias=localhost
+
+# ------------------ module loading ----------------------------------
+loadpath "../../modules/"
+loadmodule "db_postgres"
+loadmodule "tm"
+loadmodule "sl"
+loadmodule "rr"
+loadmodule "maxfwd"
+loadmodule "textops"
+loadmodule "xlog"
+loadmodule "pv"
+loadmodule "mi_fifo"
+modparam("mi_fifo", "fifo_name", "/tmp/kamailio_fifo")
+
+loadmodule "usrloc"
+modparam("usrloc", "db_mode", 1)
+
+loadmodule "registrar"
+modparam("registrar", "min_expires", 5)
+modparam("usrloc", "timer_interval", 1)
+modparam("usrloc", "db_url", "postgres://kamailio:kamailiorw@localhost/kamailio")
+
+#-------------------------  request routing logic -------------------
+request_route {
+
+	if (!mf_process_maxfwd_header("10")) {
+		sl_send_reply("483","Too Many Hops");
+		exit;
+	}
+
+	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;
+}
+

+ 6 - 11
test/unit/22.sh

@@ -27,18 +27,15 @@ if ! (check_sipsak && check_kamailio && check_module "db_postgres" && check_post
 	exit 0
 fi ;
 
-CFG=11.cfg
-
-cp $CFG $CFG.tmp
-echo "loadmodule \"$SRC_DIR/modules/db_postgres/db_postgres.so\"" >> $CFG
-echo "modparam(\"usrloc\", \"db_url\", \"postgres://kamailio:kamailiorw@localhost/kamailio\")" >> $CFG
+SIPDOMAIN=127.0.0.1
+CFG=22.cfg
 
 $BIN -w . -f $CFG > /dev/null
 ret=$?
 
 sleep 1
 # register a user
-sipsak -U -C sip:foobar@localhost -s sip:49721123456789@localhost -H localhost &> /dev/null
+sipsak -U -C sip:foobar@127.0.0.1 -s sip:49721123456789@$SIPDOMAIN -H $SIPDOMAIN &> /dev/null
 ret=$?
 
 if [ "$ret" -eq 0 ]; then
@@ -55,7 +52,7 @@ fi;
 
 if [ "$ret" -eq 0 ]; then
 	# unregister the user
-	sipsak -U -C "*" -s sip:49721123456789@127.0.0.1 -H localhost -x 0 &> /dev/null
+	sipsak -U -C "*" -s sip:49721123456789@$SIPDOMAIN -H $SIPDOMAIN -x 0 &> /dev/null
 fi;
 
 if [ "$ret" -eq 0 ]; then
@@ -76,7 +73,7 @@ $PSQL "delete from location where username like '49721123456789%';"
 
 if [ "$ret" -eq 0 ]; then
 	# register again
-	sipsak -U -C sip:foobar@localhost -s sip:49721123456789@localhost -H localhost &> /dev/null
+	sipsak -U -C sip:foobar@127.0.0.1 -s sip:49721123456789@$SIPDOMAIN -H $SIPDOMAIN &> /dev/null
 	ret=$?
 fi;
 
@@ -90,7 +87,7 @@ sleep 1
 
 if [ "$ret" -eq 0 ]; then
 	# check if the contact is still registered
-	sipsak -U -C empty -s sip:49721123456789@127.0.0.1 -H localhost -q "Contact: <sip:foobar@localhost>" &> /dev/null
+	sipsak -U -C empty -s sip:49721123456789@$SIPDOMAIN -H $SIPDOMAIN -q "Contact: <sip:[email protected]>" &> /dev/null
 	ret=$?
 fi;
 
@@ -104,6 +101,4 @@ $KILL
 
 $PSQL "delete from location where username like '49721123456789%';"
 
-mv $CFG.tmp $CFG
-
 exit $ret