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
This commit is contained in:
parent
141620d343
commit
936dbe64ee
|
@ -574,6 +574,47 @@ runs on HLR_ConnHdlr return GSUP_PDU {
|
||||||
return ret;
|
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 @@ testcase TC_mo_sss_reject() runs on test_CT {
|
||||||
* timeout cases
|
* 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:
|
/* TODO:
|
||||||
* UL with ISD error
|
* UL with ISD error
|
||||||
* UL with ISD timeout
|
* UL with ISD timeout
|
||||||
|
@ -1126,6 +1232,10 @@ control {
|
||||||
|
|
||||||
/* "Structured" Supplementary Services */
|
/* "Structured" Supplementary Services */
|
||||||
execute( TC_mo_sss_reject() );
|
execute( TC_mo_sss_reject() );
|
||||||
|
|
||||||
|
execute( TC_gsup_check_imei() );
|
||||||
|
execute( TC_gsup_check_imei_invalid_len() );
|
||||||
|
execute( TC_gsup_check_imei_unknown_imsi() );
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -419,6 +419,17 @@ template GSUP_PDU ts_GSUP(GSUP_MessageType msgt, GSUP_IEs ies := {}) := {
|
||||||
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) :=
|
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)) });
|
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(OSMO_GSUP_MSGT_PURGE_MS_ERROR, {
|
||||||
tr_GSUP_IE_IMSI(imsi), tr_GSUP_IE_Cause(cause) });
|
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) := {
|
template (value) GSUP_IE ts_GSUP_IE_CancelType(GSUP_CancelType ctype) := {
|
||||||
tag := OSMO_GSUP_CANCEL_TYPE_IE,
|
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,
|
tag := OSMO_GSUP_IMEI_IE,
|
||||||
len := 0, /* overwritten */
|
len := 0, /* overwritten */
|
||||||
val := {
|
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,
|
tag := OSMO_GSUP_IMEI_IE,
|
||||||
len := ?,
|
len := ?,
|
||||||
val := {
|
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,
|
tag := OSMO_GSUP_IMEI_RESULT_IE,
|
||||||
len := 0, /* overwritten */
|
len := 0, /* overwritten */
|
||||||
val := {
|
val := {
|
||||||
imei_result := result
|
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,
|
tag := OSMO_GSUP_IMEI_RESULT_IE,
|
||||||
len := ?,
|
len := ?,
|
||||||
val := {
|
val := {
|
||||||
|
|
Loading…
Reference in New Issue