lynxis lazus has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/32510 )


Change subject: HLR_Tests: add testcase for multiple APNs in subscriber data
......................................................................

HLR_Tests: add testcase for multiple APNs in subscriber data

With a new HLR version there are multiple APN possible in the
Subscriber Data (PDP Info).

Change-Id: I8d0c08272bc239370e800d6014ab9c68087b8989
Signed-off-by: Alexander Couzens <[email protected]>
---
M hlr/HLR_Tests.ttcn
M library/GSUP_Types.ttcn
2 files changed, 130 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks 
refs/changes/10/32510/1

diff --git a/hlr/HLR_Tests.ttcn b/hlr/HLR_Tests.ttcn
index 959c680..a778703 100644
--- a/hlr/HLR_Tests.ttcn
+++ b/hlr/HLR_Tests.ttcn
@@ -535,12 +535,15 @@
        return ret;
 }
 
+/* return_isd -> return the Insert Subscriber Data instead of the Update 
Location Result */
 function f_perform_UL(hexstring imsi, template hexstring msisdn,
                        template (omit) integer exp_err_cause := omit,
                        GSUP_CnDomain dom := OSMO_GSUP_CN_DOMAIN_PS,
-                       template (omit) octetstring source_name := omit)
+                       template (omit) octetstring source_name := omit,
+                       boolean return_isd := false)
 runs on HLR_ConnHdlr return GSUP_PDU {
        var GSUP_PDU ret;
+       var GSUP_PDU isd;
        timer T := 3.0;
        var boolean exp_fail := false;
        var boolean isd_done := false;
@@ -570,7 +573,7 @@
                setverdict(fail, "Unexpected UL ERROR");
                mtc.stop;
                }
-       [not exp_fail and not isd_done] GSUP.receive(tr_GSUP_ISD_REQ(imsi, 
msisdn, destination_name := source_name)) -> value ret {
+       [not exp_fail and not isd_done] GSUP.receive(tr_GSUP_ISD_REQ(imsi, 
msisdn, destination_name := source_name)) -> value isd {
                GSUP.send(ts_GSUP_ISD_RES(imsi, source_name := source_name));
                isd_done := true;
                repeat;
@@ -584,6 +587,10 @@
                mtc.stop;
                }
        }
+       if (return_isd) {
+               return isd;
+       }
+
        return ret;
 }

@@ -994,6 +1001,7 @@
        res := f_perform_UL(g_pars.sub.imsi, g_pars.sub.msisdn, source_name := 
g_pars.source_name);
        setverdict(pass);
 }
+
 testcase TC_gsup_ul() runs on test_CT {
        var HlrSubscriberList sl;
        var GSUP_PDU res;
@@ -1015,6 +1023,70 @@
        setverdict(pass);
 }

+private function f_TC_gsup_ul_subscriber_data() runs on HLR_ConnHdlr {
+       var GSUP_PDU isd;
+       log("GSUP ul subscriber_data", isd);
+       isd := f_perform_UL(g_pars.sub.imsi, g_pars.sub.msisdn, source_name := 
g_pars.source_name, return_isd := true);
+
+       template GSUP_IEs tr_pdp_info_internet := {
+                       tr_GSUP_IE_PDP_CONTEXT_ID('01'O),
+                       tr_GSUP_IE_APN(char2oct("internet"))
+       }
+       template GSUP_IEs tr_pdp_info_wildcard := {
+                       tr_GSUP_IE_PDP_CONTEXT_ID('02'O),
+                       tr_GSUP_IE_APN(char2oct("*"))
+       }
+
+       /* Search for PDP info 'internet', '*' */
+       var boolean found := false;
+       var GSUP_IeValue ievalue;
+       var GSUP_IEs pdp_info;
+       found := f_gsup_find_nested_ie_multiple(isd.ies, OSMO_GSUP_PDP_INFO_IE, 
0, ievalue);
+       if (not found) {
+               setverdict(fail, "Multiple APNs: Coulnd't find first PDP Info 
IE in: ", isd);
+               return;
+       }
+       pdp_info := ievalue.pdp_info;
+       if (not match(pdp_info, tr_pdp_info_internet)) {
+               setverdict(fail, "Multiple APNs: first PDP Info doesn't match: 
", pdp_info, "on Template: ", tr_pdp_info_internet);
+               return;
+       }
+
+       /* wildcard '*' */
+       found := f_gsup_find_nested_ie_multiple(isd.ies, OSMO_GSUP_PDP_INFO_IE, 
1, ievalue);
+       if (not found) {
+               setverdict(fail, "Multiple APNs: Coulnd't find second PDP Info 
IE in: ", isd);
+               return;
+       }
+       pdp_info := ievalue.pdp_info;
+       if (not match(pdp_info, tr_pdp_info_wildcard)) {
+               setverdict(fail, "Multiple APNs: second PDP Info doesn't match: 
", pdp_info, "on Template: ", tr_pdp_info_wildcard);
+               return;
+       }
+
+       setverdict(pass);
+}
+
+testcase TC_gsup_ul_subscriber_data() runs on test_CT {
+       /* Do a GSUP Update Location Request to get a Insert Subscriber Data 
Request (ISD).
+        * Check for multiple APN in the ISD:
+        * SGSN  -> HLR: Update Location Request
+        * SGSN <-  HLR: Insert Subscriber Data Request (Check the TLV)
+        * SGSN  -> HLR: Insert Subscriber Data Result
+        * SGSN <-  HLR: Update Location Result
+        */
+       var HlrSubscriberList sl;
+
+       f_init(false);
+       f_vty_config2(VTY, {"hlr", "ps"} , "no pdp-profiles default");
+       f_vty_config2(VTY, {"hlr", "ps", "pdp-profiles default", "profile 1"}, 
"apn internet");
+       f_vty_config2(VTY, {"hlr", "ps", "pdp-profiles default", "profile 2"}, 
"apn *");
+       sl := f_gen_subs();
+       f_start_handler_per_sub(refers(f_TC_gsup_ul_subscriber_data), sl);
+
+       setverdict(pass);
+}
+
 /* Test only the VTY commands */
 testcase TC_vty() runs on test_CT {
        var HlrSubscriber sub;
@@ -1941,6 +2013,7 @@
        execute( TC_gsup_sai_err_unknown_imsi() );
        execute( TC_gsup_ul() );
        execute( TC_gsup_ul_via_proxy() );
+       execute( TC_gsup_ul_subscriber_data() );
        execute( TC_vty() );
        execute( TC_vty_msisdn_isd() );
        execute( TC_gsup_purge_cs() );
diff --git a/library/GSUP_Types.ttcn b/library/GSUP_Types.ttcn
index 41181e8..032bd26 100644
--- a/library/GSUP_Types.ttcn
+++ b/library/GSUP_Types.ttcn
@@ -216,6 +216,7 @@
                                 pdp_qos, tag = OSMO_GSUP_PDP_QOS_IE;
                                 pdp_type, tag = OSMO_GSUP_PDP_TYPE_IE;
                                 charg_char, tag = OSMO_GSUP_CHARG_CHAR_IE;
+                                pdp_ctx_id, tag = OSMO_GSUP_PDP_CONTEXT_ID_IE;
                                 session_state, tag = 
OSMO_GSUP_SESSION_STATE_IE;
                                 session_id, tag = OSMO_GSUP_SESSION_ID_IE;
                                 ss_info, tag = OSMO_GSUP_SS_INFO_IE;
@@ -272,6 +273,7 @@
        GSUP_CnDomain   cn_domain,
        /* PDP context + nested IEs */
        GSUP_IEs        pdp_info,
+       OCT1            pdp_ctx_id,
        octetstring     apn,
        octetstring     pdp_qos,
        OCT2            pdp_type,
@@ -406,6 +408,23 @@
        }
 }

+template (value) GSUP_IE ts_GSUP_IE_PDP_CONTEXT_ID(OCT1 ctx_id) := {
+       tag := OSMO_GSUP_PDP_CONTEXT_ID_IE,
+       len := 0,
+       val := {
+               pdp_ctx_id := ctx_id
+       }
+}
+
+template GSUP_IE tr_GSUP_IE_PDP_CONTEXT_ID(template OCT1 ctx_id) := {
+       tag := OSMO_GSUP_PDP_CONTEXT_ID_IE,
+       len := ?,
+       val := {
+               pdp_ctx_id := ctx_id
+       }
+}
+
+
 template (value) GSUP_IE ts_GSUP_IE_PDP_TYPE(OCT2 pdp_type) := {
        tag := OSMO_GSUP_PDP_TYPE_IE,
        len := 0,
@@ -764,6 +783,14 @@
        }
 }

+template GSUP_IE tr_GSUP_IE_APN(template octetstring apn) := {
+       tag := OSMO_GSUP_ACCESS_POINT_NAME_IE,
+       len := ?,
+       val := {
+               apn := apn
+       }
+}
+
 template GSUP_IE ts_GSUP_IE_CnDomain(template GSUP_CnDomain dom) := {
        tag := OSMO_GSUP_CN_DOMAIN_IE,
        len := 0, /* overwritten */
@@ -1689,6 +1716,21 @@
        }
 );

+function f_gsup_find_nested_ie_multiple(GSUP_IEs ies, GSUP_IEI iei, integer 
nth,  out GSUP_IeValue ret) return boolean {
+       var integer current := 0;
+       for (var integer i := 0; i < sizeof(ies); i := i+1) {
+               if (ies[i].tag == iei) {
+                       if (current == nth) {
+                               ret := ies[i].val;
+                               return true;
+                       } else {
+                               current := current + 1;
+                       }
+               }
+       }
+       return false;
+}
+
 function f_gsup_find_nested_ie(GSUP_IEs ies, GSUP_IEI iei, out GSUP_IeValue 
ret) return boolean {
        for (var integer i := 0; i < sizeof(ies); i := i+1) {
                if (ies[i].tag == iei) {

--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/32510
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I8d0c08272bc239370e800d6014ab9c68087b8989
Gerrit-Change-Number: 32510
Gerrit-PatchSet: 1
Gerrit-Owner: lynxis lazus <[email protected]>
Gerrit-MessageType: newchange

Reply via email to