msc: TC_lu_auth_2G_fail: Test auth failure in 2G auth

Change-Id: I54ef4137c0b95658b1e844ac1bb13729f27fd0d1
diff --git a/msc_tests/MSC_Tests.ttcn b/msc_tests/MSC_Tests.ttcn
index b1a7d1b..367cd79 100644
--- a/msc_tests/MSC_Tests.ttcn
+++ b/msc_tests/MSC_Tests.ttcn
@@ -1043,6 +1043,50 @@
 	vc_conn.done;
 }
 
+/* Test LU (with authentication enabled), with wrong response from MS */
+private function f_tc_lu_auth_2G_fail(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr {
+	g_pars := pars;
+
+	var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi)
+
+	/* tell GSUP dispatcher to send this IMSI to us */
+	f_create_gsup_expect(hex2str(g_pars.imsi));
+
+	/* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */
+	f_bssap_compl_l3(l3_lu);
+
+	/* Send Early Classmark, just for the fun of it */
+	BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3));
+
+	var AuthVector vec := f_gen_auth_vec_2g();
+	var GSUP_IE auth_tuple := valueof(ts_GSUP_IE_AuthTuple2G(vec.rand, vec.sres, vec.kc));
+	GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi));
+	GSUP.send(ts_GSUP_SAI_RES(g_pars.imsi, auth_tuple));
+
+	BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_AUTH_REQ(vec.rand)));
+	/* Send back wrong auth response */
+	BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MT_MM_AUTH_RESP_2G('00000000'O)));
+
+	/* Expect GSUP AUTH FAIL REP to HLR */
+	GSUP.receive(tr_GSUP_AUTH_FAIL_IND(g_pars.imsi));
+
+	/* Expect LU REJECT with Cause == Illegal MS */
+	BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej('03'O)));
+	BSSAP.receive(tr_BSSMAP_ClearCommand);
+	BSSAP.send(ts_BSSMAP_ClearComplete);
+	BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND);
+	setverdict(pass);
+}
+testcase TC_lu_auth_2G_fail() runs on MTC_CT {
+	var BSC_ConnHdlr vc_conn;
+	f_init();
+	f_vty_config(MSCVTY, "network", "authentication required");
+	f_vty_config(MSCVTY, "msc", "assign-tmsi");
+
+	vc_conn := f_start_handler(refers(f_tc_lu_auth_2G_fail), testcasename(), 23);
+	vc_conn.done;
+}
+
 
 /* TODO:
    * continue to send repeated MO signalling messages to keep channel open: does MSC tmeout?