Change in ...osmo-ttcn3-hacks[master]: hlr: add Check IMEI tests

laforge gerrit-no-reply at lists.osmocom.org
Thu Jun 13 09:35:17 UTC 2019


laforge has submitted this change and it was merged. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/14402 )

Change subject: hlr: add Check IMEI tests
......................................................................

hlr: add Check IMEI tests

Create tests for most code paths of rx_check_imei_req() in hlr.c (except
for subscriber create on demand, this will be in an upcoming patch).

Add missing message types to GSUP_Types.ttcn, and adjust the IMEI and
IMEI_Result IEs for consistency with the existing IEs, and to make the
tests compile.

Related: OS#2541
Change-Id: I97c8462f0817149feadd0c4865e3df6c2af92a80
---
M hlr/HLR_Tests.ttcn
M library/GSUP_Types.ttcn
2 files changed, 139 insertions(+), 6 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 e58515b..4c158fd 100644
--- a/hlr/HLR_Tests.ttcn
+++ b/hlr/HLR_Tests.ttcn
@@ -574,6 +574,47 @@
 	return ret;
 }
 
+function f_perform_CHECK_IMEI(hexstring imsi, hexstring imei,
+			      template (omit) integer exp_err_cause := omit,
+			      template (omit) GSUP_IMEIResult result := omit)
+runs on HLR_ConnHdlr {
+	var GSUP_PDU pdu;
+	timer T := 3.0;
+	var boolean exp_fail := false;
+	if (not istemplatekind(exp_err_cause, "omit")) {
+		exp_fail := true;
+	}
+
+	GSUP.send(valueof(ts_GSUP_CHECK_IMEI_REQ(imsi, imei)));
+	T.start;
+	alt {
+	[exp_fail] GSUP.receive(tr_GSUP_CHECK_IMEI_ERR(imsi, exp_err_cause)) -> value pdu {
+		setverdict(pass);
+		}
+	[exp_fail] GSUP.receive(tr_GSUP_CHECK_IMEI_ERR(imsi, ?)) -> value pdu {
+		setverdict(fail, "Unexpected CHECK IMEI ERROR Cause: ", pdu);
+		}
+	[exp_fail] GSUP.receive(tr_GSUP_CHECK_IMEI_RES(imsi, ?)) -> value pdu {
+		setverdict(fail, "Unexpected CHECK IMEI RES instead of ERR");
+		}
+	[not exp_fail] GSUP.receive(tr_GSUP_CHECK_IMEI_ERR(imsi, ?)) -> value pdu {
+		setverdict(fail, "Unexpected CHECK IMEI ERROR");
+		}
+	[not exp_fail] GSUP.receive(tr_GSUP_CHECK_IMEI_RES(imsi, result)) -> value pdu {
+		setverdict(pass);
+		}
+	[not exp_fail] GSUP.receive(tr_GSUP_CHECK_IMEI_RES(imsi, ?)) -> value pdu {
+		setverdict(fail, "Unexpected CHECK IMEI RES");
+		}
+	[] GSUP.receive { repeat; }
+	[] T.timeout {
+		setverdict(fail, "Timeout waiting for CHECK IMEI response");
+		mtc.stop;
+		}
+	}
+}
+
+
 
 
 /***********************************************************************
@@ -1090,6 +1131,71 @@
    * timeout cases
  */
 
+
+/* Test Check IMEI */
+private function f_TC_gsup_check_imei() runs on HLR_ConnHdlr {
+	/* store-imei disabled */
+	f_vty_config(VTY, "hlr", "no store-imei");
+	f_perform_CHECK_IMEI(g_pars.sub.imsi, '12345678901234'H, result := OSMO_GSUP_IMEI_RESULT_ACK);
+	f_vty_subscr_show_nomatch(VTY, g_pars.sub, pattern "*IMEI: *12345678901234*");
+
+	/* store-imei enabled */
+	f_vty_config(VTY, "hlr", "store-imei");
+	f_perform_CHECK_IMEI(g_pars.sub.imsi, '12345678901234'H, result := OSMO_GSUP_IMEI_RESULT_ACK);
+	f_vty_subscr_show(VTY, g_pars.sub, pattern "*IMEI: *12345678901234*");
+}
+testcase TC_gsup_check_imei() runs on test_CT {
+	var HlrSubscriberList sl;
+
+	f_init(false);
+	sl := f_gen_subs();
+	f_start_handler_per_sub(refers(f_TC_gsup_check_imei), sl);
+
+	setverdict(pass);
+}
+
+/* Test Check IMEI with invalid IMEI length */
+private function f_TC_gsup_check_imei_invalid_len() runs on HLR_ConnHdlr {
+	/* IMEI too long */
+	f_perform_CHECK_IMEI(g_pars.sub.imsi, '111456789012345F'H, 96 /* Invalid Mandatory Information */);
+	f_perform_CHECK_IMEI(g_pars.sub.imsi, '2224567890123456'H, 96 /* Invalid Mandatory Information */);
+
+	/* IMEI too short */
+	f_perform_CHECK_IMEI(g_pars.sub.imsi, '3334567890123F'H, 96 /* Invalid Mandatory Information */);
+	f_perform_CHECK_IMEI(g_pars.sub.imsi, '444456789012'H, 96 /* Invalid Mandatory Information */);
+	f_perform_CHECK_IMEI(g_pars.sub.imsi, ''H, 96 /* Invalid Mandatory Information */);
+}
+testcase TC_gsup_check_imei_invalid_len() runs on test_CT {
+	var HlrSubscriberList sl;
+
+	f_init(false);
+	sl := f_gen_subs();
+	f_start_handler_per_sub(refers(f_TC_gsup_check_imei_invalid_len), sl);
+
+	setverdict(pass);
+}
+
+/* Test Check IMEI with unknown IMSI */
+private function f_TC_gsup_check_imei_unknown_imsi() runs on HLR_ConnHdlr {
+	f_vty_config(VTY, "hlr", "no store-imei");
+	f_perform_CHECK_IMEI(g_pars.sub.imsi, '22245678901234'H, 96 /* Invalid Mandatory Information */);
+
+	/* Check again with store-imei set (different code path) */
+	f_vty_config(VTY, "hlr", "store-imei");
+	f_perform_CHECK_IMEI(g_pars.sub.imsi, '22245678901234'H, 96 /* Invalid Mandatory Information */);
+
+	setverdict(pass);
+}
+testcase TC_gsup_check_imei_unknown_imsi() runs on test_CT {
+	var hexstring imsi := f_rnd_imsi('26242'H);
+	var HLR_ConnHdlrPars pars := valueof(t_Pars(imsi));
+	var HLR_ConnHdlr vc_conn;
+
+	f_init(false);
+	vc_conn := f_start_handler(refers(f_TC_gsup_check_imei_unknown_imsi), pars);
+	vc_conn.done;
+}
+
 /* TODO:
   * UL with ISD error
   * UL with ISD timeout
@@ -1126,6 +1232,10 @@
 
 	/* "Structured" Supplementary Services */
 	execute( TC_mo_sss_reject() );
+
+	execute( TC_gsup_check_imei() );
+	execute( TC_gsup_check_imei_invalid_len() );
+	execute( TC_gsup_check_imei_unknown_imsi() );
 };
 
 };
diff --git a/library/GSUP_Types.ttcn b/library/GSUP_Types.ttcn
index 10cf1b8..8081347 100644
--- a/library/GSUP_Types.ttcn
+++ b/library/GSUP_Types.ttcn
@@ -419,6 +419,17 @@
 	ies := ies
 }
 
+template (value) GSUP_IMEI ts_GSUP_IMEI(hexstring digits) := {
+	len := 0, /* overwritten */
+	digits := digits
+}
+
+template GSUP_IMEI tr_GSUP_IMEI(template hexstring digits) := {
+	len := ?,
+	digits := digits
+}
+
+
 template (value) GSUP_PDU ts_GSUP_SAI_REQ(hexstring imsi) :=
 	ts_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST, { valueof(ts_GSUP_IE_IMSI(imsi)) });
 
@@ -523,6 +534,18 @@
 	tr_GSUP(OSMO_GSUP_MSGT_PURGE_MS_ERROR, {
 		tr_GSUP_IE_IMSI(imsi), tr_GSUP_IE_Cause(cause) });
 
+template (value) GSUP_PDU ts_GSUP_CHECK_IMEI_REQ(hexstring imsi, hexstring imei) :=
+	ts_GSUP(OSMO_GSUP_MSGT_CHECK_IMEI_REQUEST, {
+			valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_IMEI(imei)) });
+
+template GSUP_PDU tr_GSUP_CHECK_IMEI_RES(template hexstring imsi, template GSUP_IMEIResult result) :=
+	tr_GSUP(OSMO_GSUP_MSGT_CHECK_IMEI_RESULT, {
+		tr_GSUP_IE_IMSI(imsi), tr_GSUP_IE_IMEI_Result(result) });
+
+template GSUP_PDU tr_GSUP_CHECK_IMEI_ERR(template hexstring imsi, template integer cause) :=
+	tr_GSUP(OSMO_GSUP_MSGT_CHECK_IMEI_ERROR, {
+		tr_GSUP_IE_IMSI(imsi), tr_GSUP_IE_Cause(cause) });
+
 
 template (value) GSUP_IE ts_GSUP_IE_CancelType(GSUP_CancelType ctype) := {
 	tag := OSMO_GSUP_CANCEL_TYPE_IE,
@@ -764,29 +787,29 @@
 	}
 }
 
-template (value) GSUP_IE ts_GSUP_IE_IMEI_IE(GSUP_IMEI imei) := {
+template (value) GSUP_IE ts_GSUP_IE_IMEI(hexstring imei) := {
 	tag := OSMO_GSUP_IMEI_IE,
 	len := 0, /* overwritten */
 	val := {
-		imei := imei
+		imei := ts_GSUP_IMEI(imei)
 	}
 }
-template GSUP_IE tr_GSUP_IE_IMEI_IE(template GSUP_IMEI imei) := {
+template GSUP_IE tr_GSUP_IE_IMEI(template hexstring imei) := {
 	tag := OSMO_GSUP_IMEI_IE,
 	len := ?,
 	val := {
-		imei := imei
+		imei := tr_GSUP_IMEI(imei)
 	}
 }
 
-template (value) GSUP_IE ts_GSUP_IE_IMEI_RESULT_IE(GSUP_IMEIResult result) := {
+template (value) GSUP_IE ts_GSUP_IE_IMEI_Result(GSUP_IMEIResult result) := {
 	tag := OSMO_GSUP_IMEI_RESULT_IE,
 	len := 0, /* overwritten */
 	val := {
 		imei_result := result
 	}
 }
-template GSUP_IE tr_GSUP_IE_IMEI_RESULT_IE(template GSUP_IMEIResult result) := {
+template GSUP_IE tr_GSUP_IE_IMEI_Result(template GSUP_IMEIResult result) := {
 	tag := OSMO_GSUP_IMEI_RESULT_IE,
 	len := ?,
 	val := {

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/14402
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: I97c8462f0817149feadd0c4865e3df6c2af92a80
Gerrit-Change-Number: 14402
Gerrit-PatchSet: 5
Gerrit-Owner: osmith <osmith at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <axilirator at gmail.com>
Gerrit-Reviewer: laforge <laforge at gnumonks.org>
Gerrit-Reviewer: osmith <osmith at sysmocom.de>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190613/6d6d82d1/attachment.html>


More information about the gerrit-log mailing list