From d4d66f28bac82c87fe563c50ce6f201cdb307cd3 Mon Sep 17 00:00:00 2001 From: YannGarcia Date: Thu, 20 Jun 2019 02:27:39 -0700 Subject: [PATCH] Add support of userTracking --- ccsrc/Protocols/Json/json_codec.cc | 10 +- etc/AtsMec/AtsMec.cfg | 2 +- ttcn/AtsMec/AtsMec_LocationAPI_TestCases.ttcn | 136 +++++++++++++++++- ...AtsMec_RadioNodeLocationAPI_TestCases.ttcn | 4 +- ttcn/AtsMec/AtsMec_TestControl.ttcn | 12 +- ttcn/LibCommon | 1 + ttcn/LibIts | 1 + .../LocationAPI/ttcn/LocationAPI_Pixits.ttcn | 6 + .../ttcn/LocationAPI_Templates.ttcn | 27 ++++ ttcn/LibMec/ttcn/LibMec_Pixits.ttcn | 2 + .../LibItsHttp_JsonMessageBodyTypes.ttcn | 1 + .../LibItsHttp_JsonTemplates.ttcn | 12 ++ 12 files changed, 198 insertions(+), 16 deletions(-) create mode 160000 ttcn/LibCommon create mode 160000 ttcn/LibIts diff --git a/ccsrc/Protocols/Json/json_codec.cc b/ccsrc/Protocols/Json/json_codec.cc index 1017b3d..fad5c14 100644 --- a/ccsrc/Protocols/Json/json_codec.cc +++ b/ccsrc/Protocols/Json/json_codec.cc @@ -20,6 +20,10 @@ int json_codec::encode (const LibItsHttp__JsonMessageBodyTypes::JsonBody& msg, O const UEidentityAPI__TypesAndValues::UeIdentityTagInfo& ue_identity_tag_info = msg.ueIdentityTagInfo(); ue_identity_tag_info.encode(UEidentityAPI__TypesAndValues::UeIdentityTagInfo_descr_, encoding_buffer, TTCN_EncDec::CT_JSON); data = OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data()); + } else if (msg.ischosen(LibItsHttp__JsonMessageBodyTypes::JsonBody::ALT_userTrackingSubscription)) { + const LocationAPI__TypesAndValues::UserTrackingSubscription& user_tracking_subscription = msg.userTrackingSubscription(); + user_tracking_subscription.encode(LocationAPI__TypesAndValues::UserTrackingSubscription_descr_, encoding_buffer, TTCN_EncDec::CT_JSON); + data = char2oct(CHARSTRING("{\"userTrackingSubscription\": ")) + OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data()) + char2oct(CHARSTRING("}")); } else { loggers::get_instance().error("json_codec::encode: Not supported"); } @@ -64,11 +68,15 @@ int json_codec::decode (const OCTETSTRING& p_data, LibItsHttp__JsonMessageBodyTy LocationAPI__TypesAndValues::AccessPointList access_point_list; access_point_list.decode(LocationAPI__TypesAndValues::AccessPointList_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.accessPointList() = access_point_list; - } else if (it->second.find("\"SubscriptionLinkList\"") != std::string::npos) { // Be carefull to the order + } else if (it->second.find("\"SubscriptionLinkList\"") != std::string::npos) { // Be carefull to the order // TODO To be refined, find("\"accessPointList\"") is not optimal RnisAPI__TypesAndValues::SubscriptionLinkList subscription_link_list; subscription_link_list.decode(RnisAPI__TypesAndValues::SubscriptionLinkList_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.subscriptionLinkList() = subscription_link_list; + } else if (it->second.find("\"userTrackingSubscription\"") != std::string::npos) { + LocationAPI__TypesAndValues::UserTrackingSubscription user_tracking_subscription; + user_tracking_subscription.decode(LocationAPI__TypesAndValues::UserTrackingSubscription_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); + msg.userTrackingSubscription() = user_tracking_subscription; } else if (it->second.find("\"userInfo\"") != std::string::npos) { LocationAPI__TypesAndValues::UserInfo user_info; user_info.decode(LocationAPI__TypesAndValues::UserInfo_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); diff --git a/etc/AtsMec/AtsMec.cfg b/etc/AtsMec/AtsMec.cfg index c759158..a9b416c 100644 --- a/etc/AtsMec/AtsMec.cfg +++ b/etc/AtsMec/AtsMec.cfg @@ -19,7 +19,7 @@ LocationAPI_Pics.PICS_LOCATION_API_SUPPORTED := true UEidentityAPI_Pics.PICS_UE_IDENTITY_API_SUPPORTED := true -BwManagementAPI_Pics.PICS_BWMANAGEMENT_API_SUPPORTED := false +BwManagementAPI_Pics.PICS_BWMANAGEMENT_API_SUPPORTED := true [LOGGING] # In this section you can specify the name of the log file and the classes of events diff --git a/ttcn/AtsMec/AtsMec_LocationAPI_TestCases.ttcn b/ttcn/AtsMec/AtsMec_LocationAPI_TestCases.ttcn index 59a1b9b..b7e255b 100644 --- a/ttcn/AtsMec/AtsMec_LocationAPI_TestCases.ttcn +++ b/ttcn/AtsMec/AtsMec_LocationAPI_TestCases.ttcn @@ -34,14 +34,14 @@ module AtsMec_LocationAPI_TestCases { import from LibMec_Pics all; import from LibMec_Pixits all; - group me_app_role { + group location { /** * @desc Check that the IUT responds with a list for the location of User Equipments when queried by a MEC Application * @see https://forge.etsi.org/gitlab/mec/MEC-tests/blob/master/Test%20Purposes/Plat/Mp1/UeLocation/PlatUeLocation.tplan2 - * @see https://forge.etsi.org/gitlab/mec/gs013-location-api/blob/master/LocationAPI.yaml + * @see https://forge.etsi.org/gitlab/mec/gs013-location-api/blob/master/LocationAPI.yaml#/definitions/UserInfo */ - testcase TC_MEC_PLAT_MP1_LOC_BV_001() runs on HttpComponent system HttpTestAdapter { + testcase TC_MEC_PLAT_LOC_001_OK() runs on HttpComponent system HttpTestAdapter { // Local variables var HeaderLines v_headers; var HttpMessage v_response; @@ -96,8 +96,134 @@ module AtsMec_LocationAPI_TestCases { // Postamble f_cf_01_http_down(); - } // End of testcase TC_MEC_PLAT_MP1_LOC_BV_001 + } // End of testcase TC_MEC_PLAT_LOC_001_OK - } // End of group me_app_role + } // End of group location + + group subscription { + + /** + * @desc Check that the IUT acknowledges the UE location change subscription request when commanded by a MEC Application and notifies it when the location changes + * @see https://forge.etsi.org/gitlab/mec/MEC-tests/blob/master/Test%20Purposes/Plat/Mp1/UeLocation/PlatUeLocation.tplan2 + * @see https://forge.etsi.org/gitlab/mec/gs013-location-api/blob/master/LocationAPI.yaml#/definitions/UserTrackingSubscription + */ + testcase TC_MEC_PLAT_LOCSUB_001_OK() runs on HttpComponent system HttpTestAdapter { + // Local variables + var HeaderLines v_headers; + var HttpMessage v_response; + + // Test control + if (not(PICS_MEC_PLAT) or not(PICS_LOCATION_API_SUPPORTED)) { + log("*** " & testcasename() & ": PICS_MEC_PLAT and PICS_LOCATION_API_SUPPORTED required for executing the TC ***"); + setverdict(inconc); + stop; + } + + // Test component configuration + f_cf_01_http_up(); + + // Test adapter configuration + + // Preamble + f_init_default_headers_list(-, -, v_headers); + httpPort.send( + m_http_request( + m_http_request_post( + PX_ME_APP_Q_USERS_SUB_URI, + v_headers, + m_http_message_body_json( + m_body_json_user_tracking_subscription( + m_user_tracking_subscription( + PX_CLIENT_ID, + PX_CALLBACK_REF_URL, + PX_USER + ) + ) + ) + ) + ) + ); + f_selfOrClientSyncAndVerdict(c_prDone, e_success); + + // Test Body + tc_ac.start; + alt { + [] httpPort.receive( + mw_http_response( + mw_http_response_201_created( + mw_http_message_body_json( + mw_body_json_user_tracking_subscription( + mw_user_tracking_subscription_response( + PX_CLIENT_ID, + PX_CALLBACK_REF_URL, + PX_USER + )))))) -> value v_response { + log("*** " & testcasename() & ": PASS: IUT successfully responds with a ressourceURL ***"); + f_selfOrClientSyncAndVerdict(c_tbDone, e_success); + } + [] tc_ac.timeout { + log("*** " & testcasename() & ": INCONC: Expected message not received ***"); + f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout); + } + } // End of 'alt' statement + + // Postamble + f_cf_01_http_down(); + } // End of testcase TC_MEC_PLAT_LOCSUB_001_OK + + /** + * @desc Check that the IUT acknowledges the cancellation of UE location change notifications when commanded by a MEC Application + * @see https://forge.etsi.org/gitlab/mec/MEC-tests/blob/master/Test%20Purposes/Plat/Mp1/UeLocation/PlatUeLocation.tplan2 + */ + testcase TC_MEC_PLAT_LOCSUB_002_OK() runs on HttpComponent system HttpTestAdapter { + // Local variables + var HeaderLines v_headers; + var HttpMessage v_response; + + // Test control + if (not(PICS_MEC_PLAT) or not(PICS_LOCATION_API_SUPPORTED)) { + log("*** " & testcasename() & ": PICS_MEC_PLAT and PICS_LOCATION_API_SUPPORTED required for executing the TC ***"); + setverdict(inconc); + stop; + } + + // Test component configuration + f_cf_01_http_up(); + + // Test adapter configuration + + // Preamble + f_init_default_headers_list(-, -, v_headers); + httpPort.send( + m_http_request( + m_http_request_get( + PX_ME_APP_Q_USERS_SUB_URI & "/" & PX_SUBSCRIPTION_ID, // TODO Shall be extract from Subscription request + v_headers + ) + ) + ); + f_selfOrClientSyncAndVerdict(c_prDone, e_success); + + // Test Body + tc_ac.start; + alt { + [] httpPort.receive( + mw_http_response( + mw_http_response_ok + )) -> value v_response { + log("*** " & testcasename() & ": PASS: IUT successfully cancel subscription ***"); + f_selfOrClientSyncAndVerdict(c_tbDone, e_success); + } + [] tc_ac.timeout { + log("*** " & testcasename() & ": INCONC: Expected message not received ***"); + f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout); + } + } // End of 'alt' statement + + // Postamble + f_cf_01_http_down(); + } // End of testcase TC_MEC_PLAT_LOCSUB_002_OK + + } // End of group subscription } // End of module AtsMec_LocationAPI_TestCases diff --git a/ttcn/AtsMec/AtsMec_RadioNodeLocationAPI_TestCases.ttcn b/ttcn/AtsMec/AtsMec_RadioNodeLocationAPI_TestCases.ttcn index da3c238..45872e6 100644 --- a/ttcn/AtsMec/AtsMec_RadioNodeLocationAPI_TestCases.ttcn +++ b/ttcn/AtsMec/AtsMec_RadioNodeLocationAPI_TestCases.ttcn @@ -41,7 +41,7 @@ module AtsMec_RadioNodeLocationAPI_TestCases { * @see https://forge.etsi.org/gitlab/mec/MEC-tests/blob/master/Test%20Purposes/Plat/Mp1/RadioNode/PlatRadioNodeLocation.tplan2 * @see https://forge.etsi.org/gitlab/mec/gs013-location-api/blob/master/LocationAPI.yaml#/definitions/AccessPointList */ - testcase TC_MEC_PLAT_MP1_RLOC_BV_001() runs on HttpComponent system HttpTestAdapter { + testcase TC_MEC_PLAT_RLOC_001_OK() runs on HttpComponent system HttpTestAdapter { // Local variables var HeaderLines v_headers; var HttpMessage v_response; @@ -92,7 +92,7 @@ module AtsMec_RadioNodeLocationAPI_TestCases { // Postamble f_cf_01_http_down(); - } // End of testcase TC_MEC_PLAT_MP1_RLOC_BV_001 + } // End of testcase TC_MEC_PLAT_RLOC_001_OK } // End of group me_app_role diff --git a/ttcn/AtsMec/AtsMec_TestControl.ttcn b/ttcn/AtsMec/AtsMec_TestControl.ttcn index c92cead..5aad9fc 100644 --- a/ttcn/AtsMec/AtsMec_TestControl.ttcn +++ b/ttcn/AtsMec/AtsMec_TestControl.ttcn @@ -24,7 +24,11 @@ module AtsMec_TestControl { if (PICS_MEC_PLAT) { if (PICS_LOCATION_API_SUPPORTED) { - execute(TC_MEC_PLAT_MP1_LOC_BV_001()); + execute(TC_MEC_PLAT_LOC_001_OK()); + execute(TC_MEC_PLAT_INFLOOK_001_OK()); + execute(TC_MEC_PLAT_LOCSUB_001_OK()); + execute(TC_MEC_PLAT_LOCSUB_002_OK()); + execute(TC_MEC_PLAT_RLOC_001_OK()); } if (PICS_UE_IDENTITY_API_SUPPORTED) { execute(TC_MEC_PLAT_UETAG_001_OK()); @@ -35,12 +39,6 @@ module AtsMec_TestControl { execute(TP_MEC_PLAT_UETAG_003_BI()); execute(TP_MEC_PLAT_UETAG_004_BI()); } - if (PICS_LOCATION_API_SUPPORTED) { - execute(TC_MEC_PLAT_INFLOOK_001_OK()); - } - if (PICS_LOCATION_API_SUPPORTED) { - execute(TC_MEC_PLAT_MP1_RLOC_BV_001()); - } } if (PICS_RNIS) { diff --git a/ttcn/LibCommon b/ttcn/LibCommon new file mode 160000 index 0000000..8f0b628 --- /dev/null +++ b/ttcn/LibCommon @@ -0,0 +1 @@ +Subproject commit 8f0b6280029f2b786f289ee6cf671553a4806b17 diff --git a/ttcn/LibIts b/ttcn/LibIts new file mode 160000 index 0000000..903d7d1 --- /dev/null +++ b/ttcn/LibIts @@ -0,0 +1 @@ +Subproject commit 903d7d1c3b8273c13bddb07568a4c038072e2b94 diff --git a/ttcn/LibMec/LocationAPI/ttcn/LocationAPI_Pixits.ttcn b/ttcn/LibMec/LocationAPI/ttcn/LocationAPI_Pixits.ttcn index 54f15a2..64d3854 100644 --- a/ttcn/LibMec/LocationAPI/ttcn/LocationAPI_Pixits.ttcn +++ b/ttcn/LibMec/LocationAPI/ttcn/LocationAPI_Pixits.ttcn @@ -8,6 +8,10 @@ module LocationAPI_Pixits { modulepar Address PX_USER := "acr:192.0.0.1"; + modulepar ClientCorrelator PX_CLIENT_ID := "0123"; + + modulepar charstring PX_SUBSCRIPTION_ID := "subscription0123"; + modulepar AccessPointId PX_ACCESS_POINT_ID := "001010000000000000000000000000001"; modulepar ZoneId PX_ZONE_ID := "zone01"; @@ -22,4 +26,6 @@ module LocationAPI_Pixits { modulepar UInt32 PX_NB_USERS := 10; + modulepar CallbackReference PX_CALLBACK_REF_URL := { "http://clientApp.example.com/location_notifications/123456" }; + } // End of module LocationAPI_Pixits diff --git a/ttcn/LibMec/LocationAPI/ttcn/LocationAPI_Templates.ttcn b/ttcn/LibMec/LocationAPI/ttcn/LocationAPI_Templates.ttcn index 9a0fd08..b5690ae 100644 --- a/ttcn/LibMec/LocationAPI/ttcn/LocationAPI_Templates.ttcn +++ b/ttcn/LibMec/LocationAPI/ttcn/LocationAPI_Templates.ttcn @@ -126,4 +126,31 @@ module LocationAPI_Templates { resourceURL := p_resourceURL } // End of template mw_access_point_list + template (value) UserTrackingSubscription m_user_tracking_subscription( + in ClientCorrelator p_clientCorrelator, + in CallbackReference p_callbackReference, + in Address p_address := PX_USER, + in UserEventCriteria p_userEventCriteria := { Transferring } + ) := { + clientCorrelator := p_clientCorrelator, + callbackReference := p_callbackReference, + address_ := p_address, + userEventCriteria := p_userEventCriteria, + resourceURL := omit + } // End of template m_user_tracking_subscription + + template (present) UserTrackingSubscription mw_user_tracking_subscription_response( + template (present) ClientCorrelator p_clientCorrelator := ?, + template (present) CallbackReference p_callbackReference := ?, + template (present) Address p_address := PX_USER, + template (present) UserEventCriteria p_userEventCriteria := { Transferring }, + template (present) ResourceURL p_resourceURL := ? + ) := { + clientCorrelator := p_clientCorrelator, + callbackReference := p_callbackReference, + address_ := p_address, + userEventCriteria := p_userEventCriteria, + resourceURL := p_resourceURL + } // End of template mw_user_tracking_subscription + } // End of module LocationAPI_Templates diff --git a/ttcn/LibMec/ttcn/LibMec_Pixits.ttcn b/ttcn/LibMec/ttcn/LibMec_Pixits.ttcn index e834582..b356064 100644 --- a/ttcn/LibMec/ttcn/LibMec_Pixits.ttcn +++ b/ttcn/LibMec/ttcn/LibMec_Pixits.ttcn @@ -6,6 +6,8 @@ module LibMec_Pixits { modulepar charstring PX_ME_APP_Q_DIST_URI := "/exampleAPI/location/v2/subscriptions/distance"; + modulepar charstring PX_ME_APP_Q_USERS_SUB_URI := "/exampleAPI/location/v2/subscriptions/userTracking"; + modulepar charstring PX_ME_APP_Q_UE_IDENTITY_ID_URI := "/exampleAPI/ui/v2/"; modulepar charstring PX_RNIS_SUBSCRITIONS_URI := "/exampleAPI/rni/v2/subscriptions/"; diff --git a/ttcn/patch_lib_http/LibItsHttp_JsonMessageBodyTypes.ttcn b/ttcn/patch_lib_http/LibItsHttp_JsonMessageBodyTypes.ttcn index 37546d2..c225b64 100644 --- a/ttcn/patch_lib_http/LibItsHttp_JsonMessageBodyTypes.ttcn +++ b/ttcn/patch_lib_http/LibItsHttp_JsonMessageBodyTypes.ttcn @@ -21,6 +21,7 @@ module LibItsHttp_JsonMessageBodyTypes { UserList userList, ZoneInfo zoneInfo, AccessPointList accessPointList, + UserTrackingSubscription userTrackingSubscription, UEidentityAPI_TypesAndValues.ProblemDetails problemDetails_ue_identity, UeIdentityTagInfo ueIdentityTagInfo, SubscriptionLinkList subscriptionLinkList, diff --git a/ttcn/patch_lib_http/LibItsHttp_JsonTemplates.ttcn b/ttcn/patch_lib_http/LibItsHttp_JsonTemplates.ttcn index d366bce..8ce0ad2 100644 --- a/ttcn/patch_lib_http/LibItsHttp_JsonTemplates.ttcn +++ b/ttcn/patch_lib_http/LibItsHttp_JsonTemplates.ttcn @@ -91,6 +91,18 @@ module LibItsHttp_JsonTemplates { accessPointList := p_access_point_list } // End of template mw_body_json_access_point_list + template (value) JsonBody m_body_json_user_tracking_subscription( + in template (value) UserTrackingSubscription p_user_tracking_subscription + ) := { + userTrackingSubscription := p_user_tracking_subscription + } // End of template m_body_json_user_tracking_subscription + + template (present) JsonBody mw_body_json_user_tracking_subscription( + template (present) UserTrackingSubscription p_user_tracking_subscription := ? + ) := { + userTrackingSubscription := p_user_tracking_subscription + } // End of template mw_body_json_user_rtracking_subscription + } // End of group locarion_api group ue_identity_api { -- GitLab