Forráskód Böngészése

units/tuacxx0001: new unit test for uac module

- uac_req_send() with user authentication
Daniel-Constantin Mierla 6 éve
szülő
commit
7192258f87

+ 7 - 0
units/tuacxx0001/README.md

@@ -0,0 +1,7 @@
+# UAC Module - UAC Request Send Tests #
+
+Summary: uac module - uac_req_send() tests
+
+Following tests are done:
+
+  * send an INFO request and authenticate it

+ 76 - 0
units/tuacxx0001/kamailio-tuacxx0001.cfg

@@ -0,0 +1,76 @@
+#!KAMAILIO
+#
+# Kamailio (OpenSER) SIP Server v5.3 - default configuration script
+#     - web: https://www.kamailio.org
+#     - git: https://github.com/kamailio/kamailio
+#
+debug=3
+log_stderror=yes
+
+memdbg=5
+memlog=5
+
+log_facility=LOG_LOCAL0
+log_prefix="{$mt $hdr(CSeq) $ci} "
+
+/* number of SIP routing processes */
+children=2
+
+loadmodule "jsonrpcs.so"
+loadmodule "kex.so"
+loadmodule "corex.so"
+loadmodule "tm.so"
+loadmodule "tmx.so"
+loadmodule "sl.so"
+loadmodule "rr.so"
+loadmodule "pv.so"
+loadmodule "maxfwd.so"
+loadmodule "textops.so"
+loadmodule "xlog.so"
+
+loadmodule "auth.so"
+loadmodule "uac.so"
+
+# ----- tm params -----
+# auto-discard branches from previous serial forking leg
+modparam("tm", "failure_reply_mode", 3)
+# default retransmission timeout: 30sec
+modparam("tm", "fr_timer", 30000)
+# default invite retransmission timeout after 1xx: 120sec
+modparam("tm", "fr_inv_timer", 120000)
+
+# ----- rr params -----
+# set next param to 1 to add value to ;lr param (helps with some UAs)
+modparam("rr", "enable_full_lr", 0)
+# do not append from tag to the RR (no need for this script)
+modparam("rr", "append_fromtag", 1)
+
+
+####### Routing Logic ########
+
+
+/* Main SIP request routing logic
+ * - processing of any incoming SIP request starts with this route
+ * - note: this is the same as route { ... } */
+request_route {
+
+	if(is_method("OPTIONS")) {
+		sl_send_reply("200", "ok");
+		$uac_req(method)="INFO";
+		$uac_req(ruri)="sip:test@" + $Ri;
+		$uac_req(furi)="sip:test@" + $Ri;
+		$uac_req(turi)="sip:test@" + $Ri;
+		$uac_req(auser)="test";
+		$uac_req(apasswd)="test123";
+		uac_req_send();
+		exit;
+	}
+	if(is_method("INFO")) {
+		if (!pv_auth_check("$fd", "test123", "0", "1")) {
+			auth_challenge("$fd", "0");
+			exit;
+		}
+		xlog("info request authenticated\n");
+	}
+	sl_send_reply("200", "ok");
+}

+ 23 - 0
units/tuacxx0001/tuacxx0001.sh

@@ -0,0 +1,23 @@
+#!/bin/bash
+
+. ../../etc/config
+. ../../libs/utils
+
+echo "--- start kamailio -f ./kamailio-tuacxx0001.cfg"
+${KAMBIN} -P ${KAMPID} -w ${KAMRUN} -Y ${KAMRUN} -f ./kamailio-tuacxx0001.cfg -a no -ddd -E 2>&1 | tee /tmp/kamailio-tuacxx0001.log &
+ret=$?
+sleep 1
+sipsak -s sip:[email protected]
+sleep 1
+kill_pidfile ${KAMPID}
+sleep 1
+echo
+echo "--- grep output"
+echo
+grep "info request authenticated" /tmp/kamailio-tuacxx0001.log
+ret=$?
+rm -f /tmp/kamailio-tuacxx0001.log
+if [ ! "$ret" -eq 0 ] ; then
+    exit 1
+fi
+exit 0