summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOliver Smith <osmith@sysmocom.de>2019-06-04 15:54:17 +0200
committerOliver Smith <osmith@sysmocom.de>2019-06-07 12:39:21 +0200
commit01eded1f2948a37d59a57f54ca7efe60549797be (patch)
tree6ee4dcbd64c8f57e552c3894c14bcee04618b255
parent05e8a9676732428aab5f9e39e4ecd48d6d98ca99 (diff)
hlr: add Check IMEI testsosmith/check-imei
-rw-r--r--hlr/HLR_Tests.cfg5
-rw-r--r--hlr/HLR_Tests.ttcn136
-rw-r--r--library/GSUP_Types.ttcn35
3 files changed, 169 insertions, 7 deletions
diff --git a/hlr/HLR_Tests.cfg b/hlr/HLR_Tests.cfg
index 7416362..7e69110 100644
--- a/hlr/HLR_Tests.cfg
+++ b/hlr/HLR_Tests.cfg
@@ -16,4 +16,7 @@
[MAIN_CONTROLLER]
[EXECUTE]
-HLR_Tests.control
+# HLR_Tests.control
+HLR_Tests.TC_gsup_check_imei
+HLR_Tests.TC_gsup_check_imei_invalid_len
+HLR_Tests.TC_gsup_check_imei_unknown_imsi
diff --git a/hlr/HLR_Tests.ttcn b/hlr/HLR_Tests.ttcn
index 21089dd..fd246fd 100644
--- a/hlr/HLR_Tests.ttcn
+++ b/hlr/HLR_Tests.ttcn
@@ -356,6 +356,21 @@ function f_vty_subscr_show(TELNETasp_PT VTY, HlrSubscriber sub, template charstr
f_vty_transceive_match(VTY, prefix & "show", exp, invert);
}
+/***********************************************************************
+ * VTY Configuration
+ ***********************************************************************/
+
+function f_vty_config_store_imei(TELNETasp_PT VTY, boolean enable) {
+ f_vty_transceive(VTY, "configure terminal");
+ f_vty_transceive(VTY, "hlr");
+ if (enable) {
+ f_vty_transceive(VTY, "store-imei");
+ } else {
+ f_vty_transceive(VTY, "no store-imei");
+ }
+ f_vty_transceive(VTY, "exit");
+ f_vty_transceive(VTY, "exit");
+}
/***********************************************************************
* Helper functions for ConnHdlr
@@ -566,6 +581,48 @@ runs on HLR_ConnHdlr return GSUP_PDU {
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 return GSUP_PDU {
+ var GSUP_PDU ret;
+ 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 ret {
+ setverdict(pass);
+ }
+ [exp_fail] GSUP.receive(tr_GSUP_CHECK_IMEI_ERR(imsi, ?)) -> value ret {
+ setverdict(fail, "Unexpected CHECK IMEI ERROR Cause");
+ }
+ [exp_fail] GSUP.receive(tr_GSUP_CHECK_IMEI_RES(imsi, ?)) -> value ret {
+ setverdict(fail, "Unexpected CHECK IMEI RES instead of ERR");
+ }
+ [not exp_fail] GSUP.receive(tr_GSUP_CHECK_IMEI_ERR(imsi, ?)) -> value ret {
+ setverdict(fail, "Unexpected CHECK IMEI ERROR");
+ }
+ [not exp_fail] GSUP.receive(tr_GSUP_CHECK_IMEI_RES(imsi, result)) -> value ret {
+ setverdict(pass);
+ }
+ [not exp_fail] GSUP.receive(tr_GSUP_CHECK_IMEI_RES(imsi, ?)) -> value ret {
+ setverdict(fail, "Unexpected CHECK IMEI RES");
+ }
+ [] GSUP.receive { repeat; }
+ [] T.timeout {
+ setverdict(fail, "Timeout waiting for CHECK IMEI response");
+ mtc.stop;
+ }
+ }
+ return ret;
+}
+
+
/***********************************************************************
@@ -1082,6 +1139,81 @@ testcase TC_mo_sss_reject() runs on test_CT {
* timeout cases
*/
+
+/* Test Check IMEI */
+private function f_TC_gsup_check_imei() runs on HLR_ConnHdlr {
+ var GSUP_PDU res;
+
+ /* store-imei disabled */
+ f_vty_config_store_imei(VTY, false);
+ res := 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*", invert := true);
+
+ /* store-imei enabled */
+ f_vty_config_store_imei(VTY, true);
+ res := 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;
+ var GSUP_PDU res;
+
+ 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 {
+ var GSUP_PDU res;
+
+ /* IMEI too long */
+ res := f_perform_CHECK_IMEI(g_pars.sub.imsi, '111456789012345F'H, 96 /* Invalid Mandatory Information */);
+ res := f_perform_CHECK_IMEI(g_pars.sub.imsi, '2224567890123456'H, 96 /* Invalid Mandatory Information */);
+
+ /* IMEI too short */
+ res := f_perform_CHECK_IMEI(g_pars.sub.imsi, '3334567890123F'H, 96 /* Invalid Mandatory Information */);
+ res := f_perform_CHECK_IMEI(g_pars.sub.imsi, '444456789012'H, 96 /* Invalid Mandatory Information */);
+ res := 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;
+ var GSUP_PDU res;
+
+ 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 {
+ var GSUP_PDU res;
+
+ f_vty_config_store_imei(VTY, false);
+ res := 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_store_imei(VTY, true);
+ res := 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
@@ -1116,6 +1248,10 @@ control {
execute( TC_mo_ussd_euse_continue() );
execute( TC_mo_ussd_euse_defaultroute() );
+ execute( TC_gsup_check_imei() );
+ execute( TC_gsup_check_imei_invalid_len() );
+ execute( TC_gsup_check_imei_unknown_imsi() );
+
/* "Structured" Supplementary Services */
execute( TC_mo_sss_reject() );
};
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 @@ template GSUP_PDU ts_GSUP(GSUP_MessageType msgt, GSUP_IEs ies := {}) := {
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 @@ template GSUP_PDU tr_GSUP_PURGE_MS_ERR(template hexstring imsi, template integer
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 GSUP_IE tr_GSUP_IE_SM_RP_MMS(template OCT1 mms) := {
}
}
-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 := {