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/.

laforge gerrit-no-reply at lists.osmocom.org
Wed Jan 15 15:57:46 UTC 2020


laforge has submitted this change. ( 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, 61 insertions(+), 4 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  fixeria: Looks good to me, but someone else must approve
  Jenkins Builder: Verified



diff --git a/hlr/HLR_Tests.ttcn b/hlr/HLR_Tests.ttcn
index 50109a6..4caa88e 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,8 +398,9 @@
 
 /* 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 template GSUP_PDU sai_msg;
 	var GSUP_PDU ret;
 	timer T := 3.0;
 	var boolean exp_fail := false;
@@ -405,10 +409,17 @@
 	}
 
 	if (is_eps) {
-		GSUP.send(ts_GSUP_SAI_REQ_EPS(imsi));
+		sai_msg := ts_GSUP_SAI_REQ_EPS(imsi);
 	} else {
-		GSUP.send(valueof(ts_GSUP_SAI_REQ(imsi)));
+		sai_msg := ts_GSUP_SAI_REQ(imsi);
 	}
+	if (not istemplatekind(num_auth_tuple, "omit")) {
+		sai_msg.ies := valueof(sai_msg.ies) & {
+			valueof(ts_GSUP_IE_NUM_VECTORS_REQ(int2oct(valueof(num_auth_tuple), 1)))
+		};
+	}
+	GSUP.send(sai_msg);
+
 	T.start;
 	alt {
 	[exp_fail] GSUP.receive(tr_GSUP_SAI_ERR(imsi, exp_err_cause)) -> value ret {
@@ -714,7 +725,8 @@
 	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 +741,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, 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 +786,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
+			not match(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 +1527,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: 4
Gerrit-Owner: lynxis lazus <lynxis at fe80.eu>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <axilirator at gmail.com>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: lynxis lazus <lynxis at fe80.eu>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200115/aff39101/attachment.htm>


More information about the gerrit-log mailing list