Commit 493d2b37 authored by YannGarcia's avatar YannGarcia
Browse files

Add RnisNotifications support

parent 97948a1e
Loading
Loading
Loading
Loading
+108 −108
Original line number Diff line number Diff line
@@ -99,123 +99,123 @@ int json_codec::decode (const OCTETSTRING& p_data, LibItsHttp__JsonMessageBodyTy
    traffic_rule.decode(AppEnablementAPI__TypesAndValues::TrafficRule_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
    msg.trafficRule() = traffic_rule;
  } else if (it->second.find("\"CellChangeSubscription\"") != std::string::npos) {
    // Replace "type": "1" by type": "EU_IPV4_ADDRESS", "type": "2"...
    // TODO Create a method instead of copy/past
    //loggers::get_instance().log("json_codec::decode: Before, str=%s", str.c_str());
    std::size_t it_start = str.find("\"type\"");
    loggers::get_instance().log("json_codec::decode: id_start=%d", it_start);
    if (it_start != std::string::npos) {
      std::size_t it_stop = str.find(",", it_start);
      //loggers::get_instance().log("json_codec::decode: id_stop=%d", it_stop);
      //loggers::get_instance().log("json_codec::decode: segment=%s", str.substr(it_start, it_stop - it_start).c_str());
      std::size_t it = str.find("1", it_start, 1);
      //loggers::get_instance().log("json_codec::decode: it=%d", it);
      if ((it != std::string::npos) && (it < it_stop)) {
        str = str.substr(0, it) + "UE_IPV4_ADDRESS" + str.substr(it + 1);
      } else {
        it = str.find("2", it_start, 1);
        //loggers::get_instance().log("json_codec::decode: it=%d", it);
        if ((it != std::string::npos) && (it < it_stop)) {
          str = str.substr(0, it) + "UE_IPV6_ADDRESS" + str.substr(it + 1);
        } else {
          it = str.find("3", it_start, 1);
          //loggers::get_instance().log("json_codec::decode: it=%d", it);
          if ((it != std::string::npos) && (it < it_stop)) {
            str = str.substr(0, it) + "NATED_IP_ADDRESS" + str.substr(it + 1);
          } else {
            it = str.find("4", it_start, 1);
            //loggers::get_instance().log("json_codec::decode: it=%d", it);
            if ((it != std::string::npos) && (it < it_stop)) {
              str = str.substr(0, it) + "GTP_TEID" + str.substr(it + 1);
            }
          }
        }
      }
    }
    //loggers::get_instance().log("json_codec::decode: After, str=%s", str.c_str());
    decoding_buffer.clear();
    decoding_buffer.put_os(OCTETSTRING(str.length(), (const unsigned char*)str.c_str()));
//    // Replace "type": "1" by type": "EU_IPV4_ADDRESS", "type": "2"...
//    // TODO Create a method instead of copy/past
//    //loggers::get_instance().log("json_codec::decode: Before, str=%s", str.c_str());
//    std::size_t it_start = str.find("\"type\"");
//    loggers::get_instance().log("json_codec::decode: id_start=%d", it_start);
//    if (it_start != std::string::npos) {
//      std::size_t it_stop = str.find(",", it_start);
//      //loggers::get_instance().log("json_codec::decode: id_stop=%d", it_stop);
//      //loggers::get_instance().log("json_codec::decode: segment=%s", str.substr(it_start, it_stop - it_start).c_str());
//      std::size_t it = str.find("1", it_start, 1);
//      //loggers::get_instance().log("json_codec::decode: it=%d", it);
//      if ((it != std::string::npos) && (it < it_stop)) {
//        str = str.substr(0, it) + "UE_IPV4_ADDRESS" + str.substr(it + 1);
//      } else {
//        it = str.find("2", it_start, 1);
//        //loggers::get_instance().log("json_codec::decode: it=%d", it);
//        if ((it != std::string::npos) && (it < it_stop)) {
//          str = str.substr(0, it) + "UE_IPV6_ADDRESS" + str.substr(it + 1);
//        } else {
//          it = str.find("3", it_start, 1);
//          //loggers::get_instance().log("json_codec::decode: it=%d", it);
//          if ((it != std::string::npos) && (it < it_stop)) {
//            str = str.substr(0, it) + "NATED_IP_ADDRESS" + str.substr(it + 1);
//          } else {
//            it = str.find("4", it_start, 1);
//            //loggers::get_instance().log("json_codec::decode: it=%d", it);
//            if ((it != std::string::npos) && (it < it_stop)) {
//              str = str.substr(0, it) + "GTP_TEID" + str.substr(it + 1);
//            }
//          }
//        }
//      }
//    }
//    //loggers::get_instance().log("json_codec::decode: After, str=%s", str.c_str());
//    decoding_buffer.clear();
//    decoding_buffer.put_os(OCTETSTRING(str.length(), (const unsigned char*)str.c_str()));
    RnisAPI__TypesAndValues::CellChangeSubscription cell_change_subscription;
    cell_change_subscription.decode(RnisAPI__TypesAndValues::CellChangeSubscription_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
    msg.cellChangeSubscription() = cell_change_subscription;
    //TODO Continue with other ChangeSubscription
  } else if (it->second.find("\"RabInfo\"") != std::string::npos) {
    // Replace "type": "1" by type": "EU_IPV4_ADDRESS", "type": "2"...
    // TODO Create a method instead of copy/past
    // loggers::get_instance().log("json_codec::decode: Before, str=%s", str.c_str());
    std::size_t it_start = str.find("\"type\"");
    loggers::get_instance().log("json_codec::decode: id_start=%d", it_start);
    if (it_start != std::string::npos) {
      std::size_t it_stop = str.find(",", it_start);
      //loggers::get_instance().log("json_codec::decode: id_stop=%d", it_stop);
      //loggers::get_instance().log("json_codec::decode: segment=%s", str.substr(it_start, it_stop - it_start).c_str());
      std::size_t it = str.find("1", it_start, 1);
      //loggers::get_instance().log("json_codec::decode: it=%d", it);
      if ((it != std::string::npos) && (it < it_stop)) {
        str = str.substr(0, it) + "UE_IPV4_ADDRESS" + str.substr(it + 1);
      } else {
        it = str.find("2", it_start, 1);
        //loggers::get_instance().log("json_codec::decode: it=%d", it);
        if ((it != std::string::npos) && (it < it_stop)) {
          str = str.substr(0, it) + "UE_IPV6_ADDRESS" + str.substr(it + 1);
        } else {
          it = str.find("3", it_start, 1);
          //loggers::get_instance().log("json_codec::decode: it=%d", it);
          if ((it != std::string::npos) && (it < it_stop)) {
            str = str.substr(0, it) + "NATED_IP_ADDRESS" + str.substr(it + 1);
          } else {
            it = str.find("4", it_start, 1);
            //loggers::get_instance().log("json_codec::decode: it=%d", it);
            if ((it != std::string::npos) && (it < it_stop)) {
              str = str.substr(0, it) + "GTP_TEID" + str.substr(it + 1);
            }
          }
        }
      }
    }
    //loggers::get_instance().log("json_codec::decode: After, str=%s", str.c_str());
    decoding_buffer.clear();
    decoding_buffer.put_os(OCTETSTRING(str.length(), (const unsigned char*)str.c_str()));
//    // Replace "type": "1" by type": "EU_IPV4_ADDRESS", "type": "2"...
//    // TODO Create a method instead of copy/past
//    // loggers::get_instance().log("json_codec::decode: Before, str=%s", str.c_str());
//    std::size_t it_start = str.find("\"type\"");
//    loggers::get_instance().log("json_codec::decode: id_start=%d", it_start);
//    if (it_start != std::string::npos) {
//      std::size_t it_stop = str.find(",", it_start);
//      //loggers::get_instance().log("json_codec::decode: id_stop=%d", it_stop);
//      //loggers::get_instance().log("json_codec::decode: segment=%s", str.substr(it_start, it_stop - it_start).c_str());
//      std::size_t it = str.find("1", it_start, 1);
//      //loggers::get_instance().log("json_codec::decode: it=%d", it);
//      if ((it != std::string::npos) && (it < it_stop)) {
//        str = str.substr(0, it) + "UE_IPV4_ADDRESS" + str.substr(it + 1);
//      } else {
//        it = str.find("2", it_start, 1);
//        //loggers::get_instance().log("json_codec::decode: it=%d", it);
//        if ((it != std::string::npos) && (it < it_stop)) {
//          str = str.substr(0, it) + "UE_IPV6_ADDRESS" + str.substr(it + 1);
//        } else {
//          it = str.find("3", it_start, 1);
//          //loggers::get_instance().log("json_codec::decode: it=%d", it);
//          if ((it != std::string::npos) && (it < it_stop)) {
//            str = str.substr(0, it) + "NATED_IP_ADDRESS" + str.substr(it + 1);
//          } else {
//            it = str.find("4", it_start, 1);
//            //loggers::get_instance().log("json_codec::decode: it=%d", it);
//            if ((it != std::string::npos) && (it < it_stop)) {
//              str = str.substr(0, it) + "GTP_TEID" + str.substr(it + 1);
//            }
//          }
//        }
//      }
//    }
//    //loggers::get_instance().log("json_codec::decode: After, str=%s", str.c_str());
//    decoding_buffer.clear();
//    decoding_buffer.put_os(OCTETSTRING(str.length(), (const unsigned char*)str.c_str()));
    RnisAPI__TypesAndValues::RabInfo rab_info;
    rab_info.decode(RnisAPI__TypesAndValues::RabInfo_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
    msg.rabInfo() = rab_info;
  } else if (it->second.find("\"S1BearerInfo\"") != std::string::npos) {
    // Replace "type": "1" by type": "EU_IPV4_ADDRESS", "type": "2"...
    // TODO Create a method instead of copy/past
    // loggers::get_instance().log("json_codec::decode: Before, str=%s", str.c_str());
    std::size_t it_start = str.find("\"type\"");
    loggers::get_instance().log("json_codec::decode: id_start=%d", it_start);
    if (it_start != std::string::npos) {
      std::size_t it_stop = str.find(",", it_start);
      //loggers::get_instance().log("json_codec::decode: id_stop=%d", it_stop);
      //loggers::get_instance().log("json_codec::decode: segment=%s", str.substr(it_start, it_stop - it_start).c_str());
      std::size_t it = str.find("1", it_start, 1);
      //loggers::get_instance().log("json_codec::decode: it=%d", it);
      if ((it != std::string::npos) && (it < it_stop)) {
        str = str.substr(0, it) + "UE_IPV4_ADDRESS" + str.substr(it + 1);
      } else {
        it = str.find("2", it_start, 1);
        //loggers::get_instance().log("json_codec::decode: it=%d", it);
        if ((it != std::string::npos) && (it < it_stop)) {
          str = str.substr(0, it) + "UE_IPV6_ADDRESS" + str.substr(it + 1);
        } else {
          it = str.find("3", it_start, 1);
          //loggers::get_instance().log("json_codec::decode: it=%d", it);
          if ((it != std::string::npos) && (it < it_stop)) {
            str = str.substr(0, it) + "NATED_IP_ADDRESS" + str.substr(it + 1);
          } else {
            it = str.find("4", it_start, 1);
            //loggers::get_instance().log("json_codec::decode: it=%d", it);
            if ((it != std::string::npos) && (it < it_stop)) {
              str = str.substr(0, it) + "GTP_TEID" + str.substr(it + 1);
            }
          }
        }
      }
    }
    //loggers::get_instance().log("json_codec::decode: After, str=%s", str.c_str());
    decoding_buffer.clear();
    decoding_buffer.put_os(OCTETSTRING(str.length(), (const unsigned char*)str.c_str()));
//    // Replace "type": "1" by type": "EU_IPV4_ADDRESS", "type": "2"...
//    // TODO Create a method instead of copy/past
//    // loggers::get_instance().log("json_codec::decode: Before, str=%s", str.c_str());
//    std::size_t it_start = str.find("\"type\"");
//    loggers::get_instance().log("json_codec::decode: id_start=%d", it_start);
//    if (it_start != std::string::npos) {
//      std::size_t it_stop = str.find(",", it_start);
//      //loggers::get_instance().log("json_codec::decode: id_stop=%d", it_stop);
//      //loggers::get_instance().log("json_codec::decode: segment=%s", str.substr(it_start, it_stop - it_start).c_str());
//      std::size_t it = str.find("1", it_start, 1);
//      //loggers::get_instance().log("json_codec::decode: it=%d", it);
//      if ((it != std::string::npos) && (it < it_stop)) {
//        str = str.substr(0, it) + "UE_IPV4_ADDRESS" + str.substr(it + 1);
//      } else {
//        it = str.find("2", it_start, 1);
//        //loggers::get_instance().log("json_codec::decode: it=%d", it);
//        if ((it != std::string::npos) && (it < it_stop)) {
//          str = str.substr(0, it) + "UE_IPV6_ADDRESS" + str.substr(it + 1);
//        } else {
//          it = str.find("3", it_start, 1);
//          //loggers::get_instance().log("json_codec::decode: it=%d", it);
//          if ((it != std::string::npos) && (it < it_stop)) {
//            str = str.substr(0, it) + "NATED_IP_ADDRESS" + str.substr(it + 1);
//          } else {
//            it = str.find("4", it_start, 1);
//            //loggers::get_instance().log("json_codec::decode: it=%d", it);
//            if ((it != std::string::npos) && (it < it_stop)) {
//              str = str.substr(0, it) + "GTP_TEID" + str.substr(it + 1);
//            }
//          }
//        }
//      }
//    }
//    //loggers::get_instance().log("json_codec::decode: After, str=%s", str.c_str());
//    decoding_buffer.clear();
//    decoding_buffer.put_os(OCTETSTRING(str.length(), (const unsigned char*)str.c_str()));
    RnisAPI__TypesAndValues::S1BearerInfo s1_nearer_info;
    s1_nearer_info.decode(RnisAPI__TypesAndValues::S1BearerInfo_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
    msg.s1BearerInfo() = s1_nearer_info;
+3 −3
Original line number Diff line number Diff line
@@ -77,7 +77,7 @@ tcp_layer::tcp_layer(const std::string & p_type, const std::string & param) : la

  map_user();

  if (!_reconnect_on_send) {
  if (!_reconnect_on_send && !server_mode) {
    open_client_connection(_params[params::server].c_str(), _params[params::port].c_str(), NULL, NULL);
  }
}
+17 −11
Original line number Diff line number Diff line
@@ -4,12 +4,13 @@
# IUT roles

LibCommon_Time.PX_TAC := 30.0
#LibCommon_Time.PX_TWAIT := 30.0
LibCommon_Sync.PX_TSYNC_TIME_LIMIT := 30.0;
LibCommon_Sync.PX_TSHUT_DOWN_TIME_LIMIT := 30.0;

LibItsHttp_Pics.PICS_HEADER_HOST := "192.168.56.1"
#LibItsHttp_Pics.PICS_HEADER_HOST := "192.168.56.1"
#LibItsHttp_Pics.PICS_HEADER_HOST := "172.28.4.87"
#LibItsHttp_Pics.PICS_HEADER_HOST := "192.168.0.17"
LibItsHttp_Pics.PICS_HEADER_HOST := "192.168.1.34"

LibItsHttp_Pics.PICS_HEADER_CONTENT_TYPE := "application/json"

@@ -18,6 +19,7 @@ LibMec_Pics.PICS_SERVICES := true
LibMec_Pics.PICS_RNIS                   := true
LibMec_Pics.PICS_RNIS_QUERY             := true
LibMec_Pics.PICS_RNIS_ALL_SUBSCRIPTIONS := true
LibMec_Pics.PICS_RNIS_NOTIFICATIONS     := true

LocationAPI_Pics.PICS_LOCATION_API_SUPPORTED         := false

@@ -44,7 +46,8 @@ LogEventTypes:= Yes

[TESTPORT_PARAMETERS]
# In this section you can specify parameters that are passed to Test Ports.
system.httpPort.params := "HTTP(codecs=json:json_codec)/TCP(debug=1,server=192.168.56.1,port=8081,use_ssl=0)"
system.httpPort.params := "HTTP(codecs=json:json_codec)/TCP(debug=1,server=192.168.1.34,port=8081,use_ssl=0)"
system.httpPort_notif.params := "HTTP(codecs=json:json_codec)/TCP(debug=1,server_mode=1,local_port=8081,use_ssl=0)"

[DEFINE]
# In this section you can create macro definitions,
@@ -108,14 +111,17 @@ system.httpPort.params := "HTTP(codecs=json:json_codec)/TCP(debug=1,server=192.1
#AtsMec_RnisAPI_TestCases.TC_MEC_SRV_RNIS_017_OK
#AtsMec_RnisAPI_TestCases.TC_MEC_SRV_RNIS_018_OK
#AtsMec_RnisAPI_TestCases.TC_MEC_SRV_RNIS_019_OK
AtsMec_RnisAPI_TestCases.TC_MEC_SRV_RNIS_016_BR
AtsMec_RnisAPI_TestCases.TC_MEC_SRV_RNIS_016_NF
AtsMec_RnisAPI_TestCases.TC_MEC_SRV_RNIS_017_BR
AtsMec_RnisAPI_TestCases.TC_MEC_SRV_RNIS_017_NF
AtsMec_RnisAPI_TestCases.TC_MEC_SRV_RNIS_018_BR
AtsMec_RnisAPI_TestCases.TC_MEC_SRV_RNIS_018_NF
AtsMec_RnisAPI_TestCases.TC_MEC_SRV_RNIS_019_BR
AtsMec_RnisAPI_TestCases.TC_MEC_SRV_RNIS_019_NF
#AtsMec_RnisAPI_TestCases.TC_MEC_SRV_RNIS_016_BR
#AtsMec_RnisAPI_TestCases.TC_MEC_SRV_RNIS_016_NF
#AtsMec_RnisAPI_TestCases.TC_MEC_SRV_RNIS_017_BR
#AtsMec_RnisAPI_TestCases.TC_MEC_SRV_RNIS_017_NF
#AtsMec_RnisAPI_TestCases.TC_MEC_SRV_RNIS_018_BR
#AtsMec_RnisAPI_TestCases.TC_MEC_SRV_RNIS_018_NF
#AtsMec_RnisAPI_TestCases.TC_MEC_SRV_RNIS_019_BR
#AtsMec_RnisAPI_TestCases.TC_MEC_SRV_RNIS_019_NF

AtsMec_RnisAPI_TestCases.TC_MEC_SRV_RNIS_001_OK


#AtsMec_AppEnablementAPI_TestCases.TC_MEC_SRV_TRANS_001_OK
#AtsMec_AppEnablementAPI_TestCases.TC_MEC_SRV_TRAF_001_OK
+64 −1
Original line number Diff line number Diff line
@@ -503,7 +503,7 @@ module AtsMec_RnisAPI_TestCases {
                                                                                                                                           {
                                                                                                                                             mw_s1_ue_info(
                                                                                                                                                           { mw_temp_ue_id },
                                                                                                                                                           { mw_associate_id },
                                                                                                                                                           -, // TODO use superset instead of { mw_associate_id },
                                                                                                                                                           { *, mw_ecgi(mw_plmn, PX_CELL_ID), * },
                                                                                                                                                           { 
                                                                                                                                                             mw_s1_bearer_info_detailed
@@ -1025,5 +1025,68 @@ module AtsMec_RnisAPI_TestCases {
    
  } // End of group rnis_query_bi_bo
  
  group rnis_notifications {
    
    /**
     * @desc Check that the RNIS service sends an RNIS notification  about cell change if the RNIS service has an associated subscription and the event is generated
.
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/RNIS/RnisQuery_BV.tplan2
     */
    testcase TC_MEC_SRV_RNIS_001_OK() runs on HttpComponent system HttpTestAdapter {
        // Local variables
        var HeaderLines v_headers;
        
        // Test control
        if (not(PICS_RNIS) or not(PICS_RNIS_NOTIFICATIONS)) {
            log("*** " & testcasename() & ": PICS_RNIS and PICS_RNIS_NOTIFICATIONS required for executing the TC ***");
            setverdict(inconc);
            stop;
        }
        
        // Test component configuration
        f_cf_01_http_notif_up();
        
        // Test adapter configuration
        
        // Preamble
        f_init_default_headers_list(-, -, v_headers);
        action("Trigger a cell change event");
        f_selfOrClientSyncAndVerdict(c_prDone, e_success);
        
        // Test Body
        tc_wait.start;
        alt {
          [] httpPort_notif.receive(
                                    mw_http_request(
                                                    mw_http_request_post(
                                                                         -,
                                                                         -,
                                                                         mw_http_message_body_json(
                                                                                                   mw_body_json_cell_change_subscription(
                                                                                                                                         mw_cell_change_subscription(
                                                                                                                                                                     PX_CALLBACK_REFERENCE
                                                                                                                                                                     )))))) {
            tc_wait.stop;
            log("*** " & testcasename() & ": INFO: IUT successfully sends cell-change notification ***");
            
            // Send 204 No Content
            httpPort_notif.send(m_http_response(m_http_response_204_no_content(v_headers)));
            
            log("*** " & testcasename() & ": PASS: IUT successfully sends cell-change notification ***");
            f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
          }
          [] tc_wait.timeout {
            log("*** " & testcasename() & ": INCONC: Expected message not received ***");
            f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
          }
        } // End of 'alt' statement
        
        // Postamble
        f_cf_01_http_notif_down();
    } // End of testcase TC_MEC_SRV_RNIS_001_OK
    
    
  } // End of group rnis_notifications 
  
} // End of module AtsMec_RnisAPI_TestCases
+3 −0
Original line number Diff line number Diff line
@@ -90,6 +90,9 @@ module AtsMec_TestControl {
        execute(TC_MEC_SRV_RNIS_019_BR());
        execute(TC_MEC_SRV_RNIS_019_NF());
      }
      if (PICS_RNIS_NOTIFICATIONS) {
        execute(TC_MEC_SRV_RNIS_001_OK());
      }
    }

    if (PICS_BWMANAGEMENT_API_SUPPORTED) {
Loading