Răsfoiți Sursa

- extend test 21 to INVITEs, add more tests for uri_db
- fix test 7.cfg after uri_db changes
- several cleanups


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

Henning Westerholt 17 ani în urmă
părinte
comite
7611536475
6 a modificat fișierele cu 90 adăugiri și 47 ștergeri
  1. 30 22
      test/unit/21.cfg
  2. 17 14
      test/unit/21.sh
  3. 0 3
      test/unit/26.sh
  4. 1 7
      test/unit/7.cfg
  5. 41 0
      test/unit/inv_auth.xml
  6. 1 1
      test/unit/reg_auth.xml

+ 30 - 22
test/unit/21.cfg

@@ -8,7 +8,7 @@
 
 # ----------- global configuration parameters ------------------------
 
-debug=3      # debug level (cmd line: -dddddddddd)
+debug=4      # debug level (cmd line: -dddddddddd)
 fork=yes
 log_stderror=no    # (cmd line: -E)
 children=4
@@ -28,7 +28,6 @@ mpath="../modules/"
 loadmodule "db_mysql/db_mysql.so"
 
 loadmodule "sl/sl.so"
-loadmodule "tm/tm.so"
 loadmodule "rr/rr.so"
 loadmodule "maxfwd/maxfwd.so"
 loadmodule "usrloc/usrloc.so"
@@ -36,6 +35,8 @@ loadmodule "registrar/registrar.so"
 loadmodule "textops/textops.so"
 loadmodule "auth/auth.so"
 loadmodule "auth_db/auth_db.so"
+loadmodule "uri_db/uri_db.so"
+loadmodule "xlog/xlog.so"
 
 # ----------------- setting module-specific parameters ---------------
 # -- usrloc params --
@@ -66,28 +67,35 @@ modparam("rr", "enable_full_lr", 1)
 
 route{
 
-#--------Main sainity checks----------------
-
-#look if msg bounces
-if (!mf_process_maxfwd_header("10")) {
-sl_send_reply("483", "Too Many Hops");
-exit;
-};
+	if (!mf_process_maxfwd_header("10")) {
+		sl_send_reply("483", "Too Many Hops");
+		exit;
+	}
 
-#-----------------------------------------
+	if (is_method("ACK")) {
+		xlog("ACK");
+		sl_send_reply("200","OK");
+		exit;
+	}
 
-if (uri == myself) {
-	
-	if(method==REGISTER){
-		if (!proxy_authorize("localhost", "subscriber")) {
-			proxy_challenge("localhost", "0");
-		}
-		else{
-			sl_send_reply("200","OK");
+	if (uri == myself) {
+		if(method==REGISTER) {
+			if (!www_authorize("localhost", "subscriber")) {
+				www_challenge("localhost", "0");
+			} else {
+				if(check_to() && check_from()) {
+					sl_send_reply("200","OK");
+				}
+			}
+		} else {
+			if (!proxy_authorize("localhost", "subscriber")) {
+				proxy_challenge("localhost", "0");
+			} else {
+				if(check_to() && check_from() && does_uri_exist()) {
+					sl_send_reply("200","OK");
+				}
+			}
 		}
+		exit;
 	}
-
-exit();
-}
 }
-

+ 17 - 14
test/unit/21.sh

@@ -1,5 +1,5 @@
 #!/bin/bash
-# tests the authentification via auth_db
+# tests the authentification via auth_db and uri_db
 
 # Copyright (C) 2007 1&1 Internet AG
 #
@@ -30,26 +30,29 @@ fi ;
 
 CFG=21.cfg
 
-#insert a test user into log db
-if [ ! -e $SIPP ] ; then 
-	echo "404 - sipp not found"
-	exit 0
-fi;
+MYSQL="mysql openser -u openser --password=openserrw -e"
 
 # add an registrar entry to the db;
-
-#username domain password email-adreess
-mysql --show-warnings -B -u openser --password=openserrw -D openser -e "INSERT INTO subscriber (username, domain, password, email_address) VALUES (\"alice\",\"localhost\",\"alice\",\"alice@localhost\");"
+$MYSQL "INSERT INTO subscriber (username, domain, password, email_address) VALUES (\"alice\",\"localhost\",\"alice\",\"alice@localhost\");"
 
 ../openser -w . -f $CFG &> /dev/null;
-sipp -s alice 127.0.0.1:5059 -i 127.0.0.1 -m 1 -f 1 -auth_uri alice@localhost -p 5061 -sf auth_test.xml -ap alice &> /dev/null;
-
 ret=$?
+sleep 1
 
-#cleanup:
-killall -9 openser &> /dev/null;
+if [ "$ret" -eq 0 ] ; then
+	sipp -s alice 127.0.0.1:5059 -i 127.0.0.1 -m 1 -f 1 -auth_uri alice@localhost -p 5061 -sf reg_auth.xml -ap alice &> /dev/null;
+	ret=$?
+fi;
+
+if [ "$ret" -eq 0 ] ; then
+	sipp -s alice 127.0.0.1:5059 -i 127.0.0.1 -m 1 -f 1 -auth_uri alice@localhost -p 5061 -sf inv_auth.xml -ap alice &> /dev/null;
+	ret=$?
+fi;
 
-mysql  --show-warnings -B -u openser --password=openserrw -D openser -e "DELETE FROM subscriber WHERE((username = \"alice\") and (domain = \"localhost\"));"
 
+#cleanup:
+killall -9 openser &> /dev/null;
+killall -9 sipp &> /dev/null;
+$MYSQL "DELETE FROM subscriber WHERE((username = \"alice\") and (domain = \"localhost\"));"
 
 exit $ret;

+ 0 - 3
test/unit/26.sh

@@ -77,14 +77,12 @@ if [ "$ret" -eq 0 ] ; then
 	sipp -sn uac -s 49721123456787 127.0.0.1:5060 -i 127.0.0.1 -m 20 -p 5061 &> /dev/null
 	ret=$?
 fi;
-killall -9 sipp
 
 if [ "$ret" -eq 0 ] ; then
 	sipp -sn uas -bg -i localhost -m 10 -p 9000 &> /dev/null
 	sipp -sn uac -s 49721123456786 127.0.0.1:5060 -i 127.0.0.1 -m 10 -p 5061 &> /dev/null
 	ret=$?
 fi;
-killall -9 sipp
 
 if [ "$ret" -eq 0 ] ; then
 	sipp -sn uas -bg -i localhost -m 10 -p 10000 &> /dev/null
@@ -92,7 +90,6 @@ if [ "$ret" -eq 0 ] ; then
 	ret=$?
 fi;
 
-killall -9 sipp
 if [ "$ret" -eq 0 ] ; then
 	sipp -sf failure_route.xml -bg -i localhost -m 10 -p 10000 &> /dev/null
 	sipp -sn uac -s 49721123456785 127.0.0.1:5060 -i 127.0.0.1 -m 10 -p 5061 &> /dev/null

+ 1 - 7
test/unit/7.cfg

@@ -241,13 +241,7 @@ modparam("auth_db", "load_credentials", "$avp(s:caller_uuid)=uuid")
 
 loadmodule "uri_db/uri_db.so"
 modparam("uri_db", "db_url", "mysql://openser:openserrw@localhost/openser")
-modparam("uri_db", "uri_table", "uri")
-modparam("uri_db", "uri_user_column", "username")
-modparam("uri_db", "uri_domain_column", "domain")
-modparam("uri_db", "uri_uriuser_column", "uri_user")
-modparam("uri_db", "subscriber_table", "subscriber")
-modparam("uri_db", "subscriber_user_column", "username")
-modparam("uri_db", "subscriber_domain_column", "domain")
+modparam("uri_db", "db_table", "subscriber")
 modparam("uri_db", "use_uri_table", 0)
 modparam("uri_db", "use_domain", 0)
 

+ 41 - 0
test/unit/inv_auth.xml

@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<scenario name="invite_client">
+  <send retrans="500">
+      <![CDATA[
+
+      INVITE sip:alice@localhost:5059 SIP/2.0
+      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+      From: <sip:alice@localhost>;tag=[call_number]
+      To: <sip:alice@localhost>
+      Call-ID: [call_id]
+      CSeq: 1 INVITE
+      Contact: sip:alice@[local_ip]:[local_port]
+      Max-Forwards: 5
+      Expires: 1800
+      User-Agent: SIPp/Linux
+      Content-Length: 0
+      ]]>
+   </send>
+   <recv response="407" auth="true">
+   </recv>
+
+   <send retrans="500">
+      <![CDATA[
+
+      INVITE sip:alice@localhost:5059 SIP/2.0
+      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+      From: <sip:alice@localhost>;tag=[call_number]
+      To: <sip:alice@localhost>
+      Call-ID: [call_id]
+      CSeq: 2 INVITE
+      Contact: sip:alice@[local_ip]:[local_port]
+      [authentication username=alice password=alice realm=localhost];
+      Max-Forwards: 5
+      Expires: 1800
+      User-Agent: SIPp/Linux
+      Content-Length: 0
+    ]]>
+   </send>
+   <recv response="200">
+  </recv>
+   </scenario>

+ 1 - 1
test/unit/auth_test.xml → test/unit/reg_auth.xml

@@ -16,7 +16,7 @@
       Content-Length: 0
       ]]>
    </send>
-   <recv response="407" auth="true">
+   <recv response="401" auth="true">
    </recv>
 
    <send retrans="500">