Module: sip-router Branch: master Commit: 6f476de8d0e658c148328ace7f0f27f0574fb52e URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=6f476de8...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: Mon Oct 13 22:35:07 2014 +0200
test/unit: updates to unit 22
---
test/unit/22.cfg | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ test/unit/22.sh | 17 ++++-------- 2 files changed, 80 insertions(+), 11 deletions(-)
diff --git a/test/unit/22.cfg b/test/unit/22.cfg new file mode 100644 index 0000000..692ca15 --- /dev/null +++ b/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; +} + diff --git a/test/unit/22.sh b/test/unit/22.sh index 3945feb..78014cd 100755 --- a/test/unit/22.sh +++ b/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:foobar@127.0.0.1" &> /dev/null ret=$? fi;
@@ -104,6 +101,4 @@ $KILL
$PSQL "delete from location where username like '49721123456789%';"
-mv $CFG.tmp $CFG - exit $ret