aboutsummaryrefslogtreecommitdiffstats
path: root/hlr
diff options
context:
space:
mode:
authorAlexander Couzens <lynxis@fe80.eu>2020-01-10 07:57:16 +0100
committerlaforge <laforge@osmocom.org>2020-01-15 15:57:46 +0000
commit9269644b70fa191beafd4c1395d5893906ffe40e (patch)
tree3d8589c9d1ccc6ab0e836c32982f099452a479e3 /hlr
parent5ef90a033ecabe8182258664836621bbe56c62cd (diff)
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
Diffstat (limited to 'hlr')
-rw-r--r--hlr/HLR_Tests.ttcn65
1 files changed, 61 insertions, 4 deletions
diff --git a/hlr/HLR_Tests.ttcn b/hlr/HLR_Tests.ttcn
index 50109a6f..4caa88e0 100644
--- a/hlr/HLR_Tests.ttcn
+++ b/hlr/HLR_Tests.ttcn
@@ -50,6 +50,9 @@ modulepar {
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 @@ function f_vty_subscr_show_nomatch(TELNETasp_PT VTY, HlrSubscriber sub, template
/* 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 @@ runs on HLR_ConnHdlr return GSUP_PDU {
}
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 @@ private function f_TC_gsup_sai() runs on HLR_ConnHdlr {
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 @@ testcase TC_gsup_sai() runs on test_CT {
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_ensure_amf_separation_bit(GSUP_PDU res, BIT1 sep_bit)
}
}
+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 @@ testcase TC_subscr_create_on_demand_sai() runs on test_CT {
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() );