Change in osmo-ttcn3-hacks[master]: hlr: add TC_gsup_sai_num_auth_vectors

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

lynxis lazus gerrit-no-reply at lists.osmocom.org
Fri Jan 10 06:59:13 UTC 2020


lynxis lazus has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/16790 )


Change subject: hlr: add TC_gsup_sai_num_auth_vectors
......................................................................

hlr: add TC_gsup_sai_num_auth_vectors

TC_gsup_sai_num_auth_vectors tests the GSUP IE
GSUP_IE_NUM_VECTORS_REQ which allows the client to
ask for a specific amount of auth tuples in a
Send Auth Info request.

Change-Id: I10a523cbaf08fe42924ffd0dc498496fdc76395f
---
M hlr/HLR_Tests.ttcn
1 file changed, 54 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/90/16790/1

diff --git a/hlr/HLR_Tests.ttcn b/hlr/HLR_Tests.ttcn
index 50109a6..729fc03 100644
--- a/hlr/HLR_Tests.ttcn
+++ b/hlr/HLR_Tests.ttcn
@@ -50,6 +50,9 @@
 	charstring mp_hlr_ip := "127.0.0.1";
 	integer mp_hlr_gsup_port := 4222;
 	integer mp_hlr_ctrl_port := 4259;
+	/* how many auth tuples are expected
+	   when IE ts_GSUP_IE_NUM_VECTORS_REQ is absent */
+	integer mp_default_num_auth_tuples := 5;
 };
 
 type record HlrSubscrAud2G {
@@ -395,7 +398,7 @@
 
 /* perform SendAuthInfo for given imsi, return the GSUP response/error */
 function f_perform_SAI(hexstring imsi, template (omit) integer exp_err_cause := omit,
-		       boolean is_eps := false)
+		       boolean is_eps := false, template (omit) integer num_auth_tuple := omit)
 runs on HLR_ConnHdlr return GSUP_PDU {
 	var GSUP_PDU ret;
 	timer T := 3.0;
@@ -406,6 +409,8 @@
 
 	if (is_eps) {
 		GSUP.send(ts_GSUP_SAI_REQ_EPS(imsi));
+	} else if (not istemplatekind(num_auth_tuple, "omit")) {
+		GSUP.send(valueof(ts_GSUP_SAI_REQ_NUM_AUTH(imsi, int2oct(valueof(num_auth_tuple), 1))));
 	} else {
 		GSUP.send(valueof(ts_GSUP_SAI_REQ(imsi)));
 	}
@@ -710,11 +715,13 @@
 /* test SAI for a number of different subscriber cases (algo, 2g/3g, ...) */
 private function f_TC_gsup_sai() runs on HLR_ConnHdlr {
 	var GSUP_PDU res;
+	var integer num_auth_tuples;
 	res := f_perform_SAI(g_pars.sub.imsi);
 	if (ispresent(g_pars.sub.aud3g)) {
 		f_ensure_amf_separation_bit(res, '0'B);
 	}
-	/* TODO: match if tuple[s] matches expectation */
+
+	f_count_auth_tuples(res, mp_default_num_auth_tuples);
 	setverdict(pass);
 }
 testcase TC_gsup_sai() runs on test_CT {
@@ -729,6 +736,31 @@
 	setverdict(pass);
 }
 
+/* test SAI for a number of different subscriber cases (algo, 2g/3g, ...) */
+private function f_TC_gsup_sai_num_auth_vectors() runs on HLR_ConnHdlr {
+	var GSUP_PDU res;
+	res := f_perform_SAI(g_pars.sub.imsi, num_auth_tuple := 1);
+	f_count_auth_tuples(res, 1);
+	res := f_perform_SAI(g_pars.sub.imsi, num_auth_tuple := 4);
+	f_count_auth_tuples(res, 4);
+	// res := f_perform_SAI(g_pars.sub.imsi, num_auth_tuple := 5);
+	// f_count_auth_tuples(res, 5);
+	// res := f_perform_SAI(g_pars.sub.imsi, exp_err_cause :=,  num_auth_tuple := 254);
+	// f_count_auth_tuples(res, 5);
+	setverdict(pass);
+}
+testcase TC_gsup_sai_num_auth_vectors() runs on test_CT {
+	var HlrSubscriberList sl;
+	var GSUP_PDU res;
+
+	f_init(false);
+
+	sl := f_gen_subs();
+	f_start_handler_per_sub(refers(f_TC_gsup_sai_num_auth_vectors), sl);
+
+	setverdict(pass);
+}
+
 private function f_ensure_amf_separation_bit(GSUP_PDU res, BIT1 sep_bit)
 {
 	for (var integer i := 0; i < lengthof(res.ies); i := i+1) {
@@ -749,6 +781,25 @@
 	}
 }
 
+private function f_count_auth_tuples(GSUP_PDU res, template (omit) integer expected_auth_tuples := omit)
+{
+	var integer auth_tuples := 0;
+	for (var integer i := 0; i < lengthof(res.ies); i := i+1) {
+		var GSUP_IE tuple := res.ies[i];
+		if (tuple.tag == OSMO_GSUP_AUTH_TUPLE_IE) {
+			auth_tuples := auth_tuples + 1;
+		}
+	}
+
+	if ((not istemplatekind(expected_auth_tuples, "omit")) and
+			(auth_tuples != valueof(expected_auth_tuples))) {
+		setverdict(fail,
+			"Did not received expected number of auth tuples. Expected ",
+			mp_default_num_auth_tuples,
+			" but received ", auth_tuples);
+	}
+}
+
 /* test SAI for a number of different subscriber cases (algo, 2g/3g, ...) */
 private function f_TC_gsup_sai_eps() runs on HLR_ConnHdlr {
 	var GSUP_PDU res;
@@ -1471,6 +1522,7 @@
 control {
 	execute( TC_gsup_sai_err_invalid_imsi() );
 	execute( TC_gsup_sai() );
+	execute( TC_gsup_sai_num_auth_vectors() );
 	execute( TC_gsup_sai_eps() );
 	execute( TC_gsup_ul_unknown_imsi() );
 	execute( TC_gsup_sai_err_unknown_imsi() );

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/16790
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I10a523cbaf08fe42924ffd0dc498496fdc76395f
Gerrit-Change-Number: 16790
Gerrit-PatchSet: 1
Gerrit-Owner: lynxis lazus <lynxis at fe80.eu>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200110/1cbf5562/attachment.htm>


More information about the gerrit-log mailing list