Răsfoiți Sursa

tsiput0001: new unit test for siputils module

Daniel-Constantin Mierla 7 ani în urmă
părinte
comite
2f425ff7d1

+ 8 - 0
units/tsiput0001/README.md

@@ -0,0 +1,8 @@
+# SIPUTILS - Basic Tests #
+
+Summary: siputils - basic tests
+
+Following tests are done:
+
+  * run kamailio with `kamailio-tsiput0001.cfg` and do tests with sample SIP
+  traffic

+ 63 - 0
units/tsiput0001/kamailio-tsiput0001.cfg

@@ -0,0 +1,63 @@
+#!KAMAILIO
+
+children=2
+
+loadmodule "jsonrpcs.so"
+loadmodule "kex.so"
+loadmodule "corex.so"
+loadmodule "tm.so"
+loadmodule "tmx.so"
+loadmodule "sl.so"
+loadmodule "pv.so"
+loadmodule "xlog.so"
+loadmodule "siputils.so"
+
+request_route {
+
+	if (is_tel_number("$rU")) {
+		xlog("ruri user $rU is tel number\n");
+	} else {
+		xlog("ruri user $rU is not tel number\n");
+	}
+	if (is_tel_number("+24242424")) {
+		xlog("+24242424 is tel number\n");
+	} else {
+		xlog("+24242424 is not tel number\n");
+	}
+
+	if (is_numeric("$rU")) {
+		xlog("ruri user $rU is numeric\n");
+	} else {
+		xlog("ruri user $rU is not numeric\n");
+	}
+	if (is_numeric("+24242424")) {
+		xlog("+24242424 is numeric\n");
+	} else {
+		xlog("+24242424 is not numeric\n");
+	}
+
+	if (is_alphanum("$rU")) {
+		xlog("ruri user $rU is alpha-numeric\n");
+	} else {
+		xlog("ruri user $rU is not alpha-numeric\n");
+	}
+	if (is_alphanum("+24242424")) {
+		xlog("+24242424 is alpha-numeric\n");
+	} else {
+		xlog("+24242424 is not alpha-numeric\n");
+	}
+
+	if (is_alphanumex("$rU", "+.-_")) {
+		xlog("ruri user $rU is extended alpha-numeric\n");
+	} else {
+		xlog("ruri user $rU is not extended alpha-numeric\n");
+	}
+	if (is_alphanumex("+24242424", "+.-_")) {
+		xlog("+24242424 is extended alpha-numeric\n");
+	} else {
+		xlog("+24242424 is not extended alpha-numeric\n");
+	}
+
+	sl_send_reply("200", "OK");
+	exit;
+}

+ 59 - 0
units/tsiput0001/tsiput0001.sh

@@ -0,0 +1,59 @@
+#!/bin/bash
+
+. ../../etc/config
+. ../../libs/utils
+
+echo "--- start kamailio -f ./kamailio-tsiput0001.cfg"
+${KAMBIN} -P ${KAMPID} -w ${KAMRUN} -Y ${KAMRUN} -f ./kamailio-tsiput0001.cfg -a no -ddd -E 2>&1 | tee /tmp/kamailio-tsiput0001.log &
+ret=$?
+sleep 1
+sipsak -s sip:[email protected]
+sleep 1
+kill_pidfile ${KAMPID}
+sleep 1
+echo
+echo "--- grep output"
+echo
+
+grep "ruri user alice is not tel number" /tmp/kamailio-tsiput0001.log
+ret=$?
+if [ ! "$ret" -eq 0 ] ; then
+    exit 1
+fi
+grep "\+24242424 is tel number" /tmp/kamailio-tsiput0001.log
+ret=$?
+if [ ! "$ret" -eq 0 ] ; then
+    exit 1
+fi
+grep "uri user alice is not numeric" /tmp/kamailio-tsiput0001.log
+ret=$?
+if [ ! "$ret" -eq 0 ] ; then
+    exit 1
+fi
+grep "\+24242424 is not numeric" /tmp/kamailio-tsiput0001.log
+ret=$?
+if [ ! "$ret" -eq 0 ] ; then
+    exit 1
+fi
+grep "ruri user alice is alpha-numeric" /tmp/kamailio-tsiput0001.log
+ret=$?
+if [ ! "$ret" -eq 0 ] ; then
+    exit 1
+fi
+grep "\+24242424 is not alpha-numeric" /tmp/kamailio-tsiput0001.log
+ret=$?
+if [ ! "$ret" -eq 0 ] ; then
+    exit 1
+fi
+grep "ruri user alice is extended alpha-numeric" /tmp/kamailio-tsiput0001.log
+ret=$?
+if [ ! "$ret" -eq 0 ] ; then
+    exit 1
+fi
+grep "\+24242424 is extended alpha-numeric" /tmp/kamailio-tsiput0001.log
+ret=$?
+if [ ! "$ret" -eq 0 ] ; then
+    exit 1
+fi
+
+exit 0