dia2gsup: Introduce new error scenario tests
Related: OS#5757
Change-Id: Ic870a2c1de74bee3f7d8e26874635d58469ccbea
diff --git a/dia2gsup/DIA2GSUP_Tests.ttcn b/dia2gsup/DIA2GSUP_Tests.ttcn
index 6a3f85c..673038c 100644
--- a/dia2gsup/DIA2GSUP_Tests.ttcn
+++ b/dia2gsup/DIA2GSUP_Tests.ttcn
@@ -214,8 +214,145 @@
setverdict(pass);
}
+private function f_DIA_AI_gsup_error(integer gsup_cause, template (present) GenericAVP err_avp) runs on D2G_ConnHdlr {
+ var PDU_DIAMETER rx_dia;
+ var UINT32 hbh_id := f_rnd_octstring(4);
+ var UINT32 ete_id := f_rnd_octstring(4);
+ var octetstring sess_id := char2oct("foobar");
+ var OCT3 vplmn := '00F110'O;
+
+ /* Unlike AIR, AIA contains no IMSI. Register ete_id in DIAMETER_Emulation,
+ * so AIA is forwarded back to us in DIAMETER port instead of MTC_CT.DIAMETER_UNIT.
+ */
+ f_diameter_expect_eteid(ete_id);
+
+ /* Send AIR to translator; expect it to show up on GSUP side */
+ DIAMETER.send(ts_DIA_AIR(g_pars.imsi, vplmn, sess_id, hbh_id := hbh_id, ete_id := ete_id));
+ GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi));
+
+ /* Send an error response back to the translator; expect AIA */
+ GSUP.send(ts_GSUP_SAI_ERR(g_pars.imsi, gsup_cause));
+
+ alt {
+ /* Unlike AIR, AIA contains no IMSI, hence it is received in DIAMETER_UNIT: */
+ [] DIAMETER.receive(tr_DIA_AIA_ERR(err_avp)) {
+ setverdict(pass);
+ }
+ [] DIAMETER.receive(PDU_DIAMETER:?) -> value rx_dia {
+ Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Unexpected Diameter msg rx: ", rx_dia));
+ }
+ }
+}
+
+private function f_TC_authinfo_gsup_err_imsi_unknown(charstring id) runs on D2G_ConnHdlr {
+ var DIAMETER_ExperimentalResultcode res_code := DIAMETER_ERROR_USER_UNKNOWN;
+ f_DIA_AI_gsup_error(2, tr_AVP_ExperimentalResult(vendor_id_3GPP, int2oct(enum2int(res_code), 4)));
+}
+testcase TC_authinfo_gsup_err_imsi_unknown() runs on MTC_CT {
+ var D2G_ConnHdlrPars pars := f_init_pars();
+ var D2G_ConnHdlr vc_conn;
+ f_init();
+ vc_conn := f_start_handler(refers(f_TC_authinfo_gsup_err_imsi_unknown), pars);
+ vc_conn.done;
+ setverdict(pass);
+}
+
+private function f_TC_authinfo_gsup_err_illegal_ms(charstring id) runs on D2G_ConnHdlr {
+ var DIAMETER_ExperimentalResultcode res_code := DIAMETER_ERROR_USER_UNKNOWN;
+ f_DIA_AI_gsup_error(3, tr_AVP_ExperimentalResult(vendor_id_3GPP, int2oct(enum2int(res_code), 4)));
+}
+testcase TC_authinfo_gsup_err_illegal_ms() runs on MTC_CT {
+ var D2G_ConnHdlrPars pars := f_init_pars();
+ var D2G_ConnHdlr vc_conn;
+ f_init();
+ vc_conn := f_start_handler(refers(f_TC_authinfo_gsup_err_illegal_ms), pars);
+ vc_conn.done;
+ setverdict(pass);
+}
+
+private function f_TC_authinfo_gsup_err_plmn_not_allowed(charstring id) runs on D2G_ConnHdlr {
+ f_DIA_AI_gsup_error(11, tr_AVP_ResultCode(DIAMETER_UNABLE_TO_COMPLY));
+}
+testcase TC_authinfo_gsup_err_plmn_not_allowed() runs on MTC_CT {
+ var D2G_ConnHdlrPars pars := f_init_pars();
+ var D2G_ConnHdlr vc_conn;
+ f_init();
+ vc_conn := f_start_handler(refers(f_TC_authinfo_gsup_err_plmn_not_allowed), pars);
+ vc_conn.done;
+ setverdict(pass);
+}
+
+private function f_TC_authinfo_gsup_err_romaning_not_allowed(charstring id) runs on D2G_ConnHdlr {
+ var DIAMETER_ExperimentalResultcode res_code := DIAMETER_ERROR_ROAMING_NOT_ALLOWED;
+ f_DIA_AI_gsup_error(12, tr_AVP_ExperimentalResult(vendor_id_3GPP, int2oct(enum2int(res_code), 4)));
+}
+testcase TC_authinfo_gsup_err_romaning_not_allowed() runs on MTC_CT {
+ var D2G_ConnHdlrPars pars := f_init_pars();
+ var D2G_ConnHdlr vc_conn;
+ f_init();
+ vc_conn := f_start_handler(refers(f_TC_authinfo_gsup_err_romaning_not_allowed), pars);
+ vc_conn.done;
+ setverdict(pass);
+}
+
+private function f_TC_authinfo_gsup_err_net_fail(charstring id) runs on D2G_ConnHdlr {
+ f_DIA_AI_gsup_error(17, tr_AVP_ResultCode(DIAMETER_UNABLE_TO_COMPLY));
+}
+testcase TC_authinfo_gsup_err_net_fail() runs on MTC_CT {
+ var D2G_ConnHdlrPars pars := f_init_pars();
+ var D2G_ConnHdlr vc_conn;
+ f_init();
+ vc_conn := f_start_handler(refers(f_TC_authinfo_gsup_err_net_fail), pars);
+ vc_conn.done;
+ setverdict(pass);
+}
+
+private function f_TC_authinfo_gsup_err_congestion(charstring id) runs on D2G_ConnHdlr {
+ f_DIA_AI_gsup_error(22, tr_AVP_ResultCode(DIAMETER_UNABLE_TO_COMPLY));
+}
+testcase TC_authinfo_gsup_err_congestion() runs on MTC_CT {
+ var D2G_ConnHdlrPars pars := f_init_pars();
+ var D2G_ConnHdlr vc_conn;
+ f_init();
+ vc_conn := f_start_handler(refers(f_TC_authinfo_gsup_err_congestion), pars);
+ vc_conn.done;
+ setverdict(pass);
+}
+
+private function f_TC_authinfo_gsup_err_auth_unacceptable(charstring id) runs on D2G_ConnHdlr {
+ f_DIA_AI_gsup_error(23, tr_AVP_ResultCode(DIAMETER_UNABLE_TO_COMPLY));
+}
+testcase TC_authinfo_gsup_err_auth_unacceptable() runs on MTC_CT {
+ var D2G_ConnHdlrPars pars := f_init_pars();
+ var D2G_ConnHdlr vc_conn;
+ f_init();
+ vc_conn := f_start_handler(refers(f_TC_authinfo_gsup_err_auth_unacceptable), pars);
+ vc_conn.done;
+ setverdict(pass);
+}
+
+private function f_TC_authinfo_gsup_err_proto_unspec(charstring id) runs on D2G_ConnHdlr {
+ f_DIA_AI_gsup_error(23, tr_AVP_ResultCode(DIAMETER_UNABLE_TO_COMPLY));
+}
+testcase TC_authinfo_gsup_err_proto_unspec() runs on MTC_CT {
+ var D2G_ConnHdlrPars pars := f_init_pars();
+ var D2G_ConnHdlr vc_conn;
+ f_init();
+ vc_conn := f_start_handler(refers(f_TC_authinfo_gsup_err_proto_unspec), pars);
+ vc_conn.done;
+ setverdict(pass);
+}
+
control {
execute ( TC_authinfo_normal() );
+ execute ( TC_authinfo_gsup_err_imsi_unknown() );
+ execute ( TC_authinfo_gsup_err_illegal_ms() );
+ execute ( TC_authinfo_gsup_err_plmn_not_allowed() );
+ execute ( TC_authinfo_gsup_err_romaning_not_allowed() );
+ execute ( TC_authinfo_gsup_err_net_fail() );
+ execute ( TC_authinfo_gsup_err_congestion() );
+ execute ( TC_authinfo_gsup_err_auth_unacceptable() );
+ execute ( TC_authinfo_gsup_err_proto_unspec() );
}
}
diff --git a/library/DIAMETER_Templates.ttcn b/library/DIAMETER_Templates.ttcn
index 63db7fc..8bb53e0 100644
--- a/library/DIAMETER_Templates.ttcn
+++ b/library/DIAMETER_Templates.ttcn
@@ -101,6 +101,22 @@
DIAMETER_ERROR_EAP_CODE_UNKNOWN (5048)
};
+/* 3GPP TS 29.272 section 7.4. Errors in Experimental-Result-Code */
+type enumerated DIAMETER_ExperimentalResultcode {
+ /* transient */
+ DIAMETER_AUTHENTICATION_DATA_UNAVAILABLE (4181),
+ DIAMETER_ERROR_CAMEL_SUBSCRIPTION_PRESENT (4182),
+ /* permanent */
+ DIAMETER_ERROR_USER_UNKNOWN (5001),
+ DIAMETER_AUTHORIZATION_REJECTED (5003),
+ DIAMETER_ERROR_ROAMING_NOT_ALLOWED (5004),
+ DIAMETER_MISSING_AVP (5005),
+ DIAMETER_ERROR_UNKNOWN_EPS_SUBSCRIPTION (5420),
+ DIAMETER_ERROR_RAT_NOT_ALLOWED (5421),
+ DIAMETER_ERROR_EQUIPMENT_UNKNOWN (5422),
+ DIAMETER_ERROR_UNKOWN_SERVING_NODE (5423)
+}
+
/* Gy : 3GPP TS 32.299 7.1.6, RFC4006 3.1 */
const uint32_t c_DIAMETER_CREDIT_CONTROL_AID := 4;
/* 3GPP TS 29.272 Section 7.1.8 */
@@ -338,6 +354,24 @@
}
}
}
+private function f_tr_AVP_VendorId(template (present) Vendor_Id vendor_id)
+return template (present) BASE_NONE_Vendor_Id {
+ if (istemplatekind(vendor_id, "?")) {
+ return ?;
+ } else {
+ var template (present) BASE_NONE_Vendor_Id c;
+ c := int2oct(enum2int(valueof(vendor_id)), 4);
+ return c;
+ }
+}
+template (present) GenericAVP tr_AVP_VendorId(template (present) Vendor_Id vendor_id) := {
+ avp := {
+ avp_header := tr_DIA_Hdr(c_AVP_Code_BASE_NONE_Vendor_Id),
+ avp_data := {
+ avp_BASE_NONE_Vendor_Id := f_tr_AVP_VendorId(vendor_id)
+ }
+ }
+}
template (value) GenericAVP ts_AVP_ProductName(charstring name) := {
avp := {
@@ -451,6 +485,28 @@
}
}
+template (present) GenericAVP tr_AVP_ExperimentalResultCode(template (present) AVP_Unsigned32 n := ?) := {
+ avp := {
+ avp_header := tr_DIA_Hdr(c_AVP_Code_BASE_NONE_Experimental_Result_Code),
+ avp_data := {
+ avp_BASE_NONE_Experimental_Result_Code := n
+ }
+ }
+}
+
+template (present) GenericAVP tr_AVP_ExperimentalResult(template (present) Vendor_Id vendor_id := ?,
+ template (present) AVP_Unsigned32 err_code := ?
+ ) := {
+ avp := {
+ avp_header := tr_DIA_Hdr(c_AVP_Code_BASE_NONE_Experimental_Result),
+ avp_data := {
+ avp_BASE_NONE_Experimental_Result := {
+ tr_AVP_VendorId(vendor_id),
+ tr_AVP_ExperimentalResultCode(err_code)
+ }
+ }
+ }
+}
template (value) GenericAVP ts_AVP_SuppVendorIdRaw(uint32_t vendor_id) := {
avp := {
@@ -471,11 +527,21 @@
}
}
}
-template (present) GenericAVP tr_AVP_ResultCode(DIAMETER_Resultcode res_code) := {
+private function f_tr_DIAMETER_Resultcode(template (present) DIAMETER_Resultcode res_code)
+return template (present) BASE_NONE_Result_Code {
+ if (istemplatekind(res_code, "?")) {
+ return ?;
+ } else {
+ var template (present) BASE_NONE_Result_Code c;
+ c := int2oct(enum2int(valueof(res_code)), 4);
+ return c;
+ }
+}
+template (present) GenericAVP tr_AVP_ResultCode(template (present) DIAMETER_Resultcode res_code) := {
avp := {
avp_header := tr_DIA_Hdr(c_AVP_Code_BASE_NONE_Result_Code),
avp_data := {
- avp_BASE_NONE_Result_Code := int2oct(enum2int(res_code), 4)
+ avp_BASE_NONE_Result_Code := f_tr_DIAMETER_Resultcode(res_code)
}
}
}
@@ -1414,6 +1480,25 @@
tr_AVP_ResultCode(DIAMETER_SUCCESS),
tr_AVP_3GPP_AuthInfo(auth_info_contents)
));
+template (present) PDU_DIAMETER
+tr_DIA_AIA_ERR(template (present) GenericAVP err_avp := ?,
+ template (present) octetstring sess_id := ?,
+ template (present) charstring orig_host := ?,
+ template (present) charstring orig_realm := ?,
+ template (present) UINT32 hbh_id := ?,
+ template (present) UINT32 ete_id := ?) :=
+ tr_DIAMETER(flags := '0???????'B,
+ cmd_code := Authentication_Information,
+ app_id := int2oct(c_DIAMETER_3GPP_S6_AID, 4),
+ hbh_id := hbh_id,
+ ete_id := ete_id,
+ avps := superset(
+ tr_AVP_SessionId(sess_id),
+ tr_AVP_AuthSessionState(NO_STATE_MAINTAINED),
+ tr_AVP_OriginHost(orig_host),
+ tr_AVP_OriginRealm(orig_realm),
+ err_avp
+ ));
/* TS 29.272 7.2.3 Update Location Request */