Loading ccsrc/Protocols/Json/json_codec_factory_mec048.hh 0 → 100644 +46 −0 Viewed Changes for ccsrc/Protocols/Json/json_codec_factory_mec048.hh: 46 added lines, 0 removed lines. Original line number Diff line number Diff line /*! * \file json_codec_factory_mec048.hh * \brief Header file for ITS JSON/IP protocol codec factory. * \author ETSI STF569 / TTF T027 // TTF T043 * \copyright ETSI Copyright Notification * No part may be reproduced except as authorized by written permission. * The copyright and the foregoing restriction extend to reproduction in all media. * All rights reserved. * \version 0.1 */ #pragma once #include "codec_stack_builder.hh" #include "json_codec_mec048.hh" class Record_Type; //! TITAN forward declaration /*! * \class json_codec_factory_mec048 * \brief This class provides a factory class to create an json_codec class instance */ class json_codec_factory_mec048: public codec_factory { static json_codec_factory_mec048 _f; //! Reference to the unique instance of this class public: //! \publicsection /*! * \brief Default constructor * Create a new instance of the json_codec_factory_mec048 class * \remark The HELD/IP codec identifier is HELD */ json_codec_factory_mec048() { // register factory codec_stack_builder::register_codec_factory("json_codec_mec048", this); }; /*! * \fn codec* create_codec(const std::string & type, const std::string & param); * \brief Create the codecs stack based on the provided codecs stack description * \param[in] p_type The provided codecs stack description * \param[in] p_params Optional parameters * \return 0 on success, -1 otherwise * \inline */ inline virtual codec_gen<Record_Type, Record_Type>* create_codec() { return (codec_gen<Record_Type, Record_Type>*)new json_codec_mec048(); }; }; // End of class json_codec_factory_mec048 ccsrc/Protocols/Json/json_codec_mec048.cc 0 → 100644 +104 −0 Viewed Changes for ccsrc/Protocols/Json/json_codec_mec048.cc: 104 added lines, 0 removed lines. Original line number Diff line number Diff line #include <stdexcept> #include <regex> #include <string> #include "json_codec_factory_mec048.hh" #include "loggers.hh" #include "LibHttp_JsonMessageBodyTypes.hh" int json_codec_mec048::encode (const LibHttp__JsonMessageBodyTypes::JsonBody& msg, OCTETSTRING& data) { loggers::get_instance().log_msg(">>> json_codec_mec048::encode: ", (const Base_Type&)msg); TTCN_EncDec::clear_error(); TTCN_EncDec::set_error_behavior(TTCN_EncDec::ET_ALL, TTCN_EncDec::EB_DEFAULT); TTCN_Buffer encoding_buffer; if (msg.ischosen(LibHttp__JsonMessageBodyTypes::JsonBody::ALT_tenantInfo)) { const SelfServiceEnablementAPI__TypesAndValues::TenantInfo& tenant_info = msg.tenantInfo(); tenant_info.encode(SelfServiceEnablementAPI__TypesAndValues::TenantInfo_descr_, encoding_buffer, TTCN_EncDec::CT_JSON); data = /*char2oct(CHARSTRING("{\"TenantInfo\": ")) + */OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data())/* + char2oct(CHARSTRING("}"))*/; } else if (msg.ischosen(LibHttp__JsonMessageBodyTypes::JsonBody::ALT_resourceUsageSubscription)) { const SelfServiceEnablementAPI__TypesAndValues::ResourceUsageSubscription& resource_usage_subscription = msg.resourceUsageSubscription(); resource_usage_subscription.encode(SelfServiceEnablementAPI__TypesAndValues::ResourceUsageSubscription_descr_, encoding_buffer, TTCN_EncDec::CT_JSON); data = /*char2oct(CHARSTRING("{\"ResourceUsageSubscription\": ")) + */OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data())/* + char2oct(CHARSTRING("}"))*/; } else if (msg.ischosen(LibHttp__JsonMessageBodyTypes::JsonBody::ALT_siteResourceUsageSubscription)) { const SelfServiceEnablementAPI__TypesAndValues::SiteResourceUsageSubscription& site_resource_usage_subscription = msg.siteResourceUsageSubscription(); site_resource_usage_subscription.encode(SelfServiceEnablementAPI__TypesAndValues::SiteResourceUsageSubscription_descr_, encoding_buffer, TTCN_EncDec::CT_JSON); data = /*char2oct(CHARSTRING("{\"SiteResourceUsageSubscription\": ")) + */OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data())/* + char2oct(CHARSTRING("}"))*/; } else { return json_codec::encode(msg, data); } loggers::get_instance().log("<<< json_codec_mec048::encode"); return 0; } int json_codec_mec048::decode (const OCTETSTRING& p_data, LibHttp__JsonMessageBodyTypes::JsonBody& msg, params* p_params) { loggers::get_instance().log_msg(">>> json_codec_mec048::decode: p_data=", p_data); // Sanity checks params::const_iterator it; if (p_params == nullptr) { loggers::get_instance().warning("json_codec_mec048::decode: Failed to access p_params (null pointer)"); return -1; // TODO Use p_data instead of return -1 } else { it = p_params->find("decode_str"); if (it == p_params->cend()) { loggers::get_instance().warning("json_codec_mec048::decode: Failed to access p_params item (decode_str)"); return -1; // TODO Use p_data instead of return -1 } loggers::get_instance().log("json_codec_mec048::decode: it->second='%c' / '%s'", it->second.c_str()[0], it->second.c_str()); } // Remove data structure name (if present) ... std::string str; if ((it->second[0] != '[') && (it->second[0] != '{')) { int idx_begin = it->second.find(":"); int idx_end = it->second.rfind("}") - 1; // Remove the last '}' str = it->second.substr(idx_begin + 1, idx_end - idx_begin); } else { str = it->second; } // ..and create the decoding buffer TTCN_EncDec::set_error_behavior(TTCN_EncDec::ET_ALL, TTCN_EncDec::EB_DEFAULT); TTCN_EncDec::clear_error(); loggers::get_instance().log("json_codec_mec048::decode: decoding_buffer='%c' / '%s'", str[0], str.c_str()); TTCN_Buffer decoding_buffer(OCTETSTRING(str.length(), (const unsigned char*)str.c_str())); if (it->second.find("\"tenantId\"") != std::string::npos) { // Be careful to the order if (it->second[0] == '[') { SelfServiceEnablementAPI__TypesAndValues::TenantInfoList tenant_info_list; tenant_info_list.decode(SelfServiceEnablementAPI__TypesAndValues::TenantInfoList_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.tenantInfoList() = tenant_info_list; } else { SelfServiceEnablementAPI__TypesAndValues::TenantInfo tenant_info; tenant_info.decode(SelfServiceEnablementAPI__TypesAndValues::TenantInfo_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.tenantInfo() = tenant_info; } } else if ( (it->second.find("\"_links\"") != std::string::npos) && ((it->second.find("\"subscriptions\"") != std::string::npos) || (it->second.find("\"subscriptionType\"") == std::string::npos)) ) { SelfServiceEnablementAPI__TypesAndValues::SubscriptionLinkList subscription_link_list; subscription_link_list.decode(SelfServiceEnablementAPI__TypesAndValues::SubscriptionLinkList_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.subscriptionLinkList__cse() = subscription_link_list; } else if ((it->second.find("\"subscriptionType\"") != std::string::npos) && (it->second.find("\"ResourceUsageSubscription\"") != std::string::npos)) { SelfServiceEnablementAPI__TypesAndValues::ResourceUsageSubscription resource_usage_subscription; resource_usage_subscription.decode(SelfServiceEnablementAPI__TypesAndValues::ResourceUsageSubscription_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.resourceUsageSubscription() = resource_usage_subscription; } else if ((it->second.find("\"subscriptionType\"") != std::string::npos) && (it->second.find("\"SiteResourceUsageSubscription\"") != std::string::npos)) { SelfServiceEnablementAPI__TypesAndValues::SiteResourceUsageSubscription site_resource_usage_subscription; site_resource_usage_subscription.decode(SelfServiceEnablementAPI__TypesAndValues::SiteResourceUsageSubscription_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.siteResourceUsageSubscription() = site_resource_usage_subscription; } else { return json_codec::decode(p_data, msg, p_params); } loggers::get_instance().log_msg("<<< json_codec_mec048::decode: ", (const Base_Type&)msg); return 0; } json_codec_factory_mec048 json_codec_factory_mec048::_f; ccsrc/Protocols/Json/json_codec_mec048.hh 0 → 100644 +25 −0 Viewed Changes for ccsrc/Protocols/Json/json_codec_mec048.hh: 25 added lines, 0 removed lines. Original line number Diff line number Diff line #pragma once #include "codec_gen.hh" #include "params.hh" #include "json_codec.hh" class Base_Type; class TTCN_Typedescriptor_t; class TTCN_Buffer; namespace LibHttp__JsonMessageBodyTypes { class JsonBody; } class json_codec_mec048: public json_codec { public: explicit json_codec_mec048() : json_codec() { }; virtual ~json_codec_mec048() { }; int encode (const LibHttp__JsonMessageBodyTypes::JsonBody&, OCTETSTRING& data); int decode (const OCTETSTRING& p_data, LibHttp__JsonMessageBodyTypes::JsonBody&, params* p_params = NULL); }; // End of class json_codec_mec048 etc/AtsMec_SelfServiceEnablement/AtsMec_SelfServiceEnablementAPI.cf_ 0 → 100644 +165 −0 Viewed Changes for etc/AtsMec_SelfServiceEnablement/AtsMec_SelfServiceEnablementAPI.cf_: 165 added lines, 0 removed lines. Original line number Diff line number Diff line [MODULE_PARAMETERS] # This section shall contain the values of all parameters that are defined in your TTCN-3 modules. # 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; LibHttp_Pics.PICS_HEADER_HOST := "192.168.1.21" #"192.168.1.39" LibHttp_Pics.PICS_HEADER_CONTENT_TYPE := "application/json" LibHttp_Pics.PICS_USE_TOKEN_HEADER := true #LibHttp_Pics.PICS_TOKEN_HEADER := "Basic WrongToken" # LibMec_Pixits LibMec_Pics.PICS_ROOT_API := "/sbxykqjr17/mep1/" # Need to sign in on https://mec-platform.etsi.org/, section 'Try-it from your MEC application' [LOGGING] # In this section you can specify the name of the log file and the classes of events # you want to log into the file or display on console (standard error). LogFile := "../logs/AtsMec_FederationEnablement/%e.%h-%r.%s" FileMask := LOG_ALL | USER | DEBUG | MATCHING ConsoleMask := LOG_ALL | USER | DEBUG | MATCHING #FileMask := ERROR | WARNING | USER | MATCHING | EXECUTOR_RUNTIME | VERDICTOP | PORTEVENT | TESTCASE #ConsoleMask := ERROR | WARNING | USER | MATCHING | EXECUTOR_RUNTIME | VERDICTOP | PORTEVENT | TESTCASE LogSourceInfo := Stack LogEntityName:= Yes LogEventTypes:= Yes #TimeStampFormat := DateTime [TESTPORT_PARAMETERS] # In this section you can specify parameters that are passed to Test Ports. #system.httpPort.params := "HTTP(codecs=json:json_codec_mec015)/TCP(debug=1,server=172.26.214.231,port=3001,use_ssl=0)" #system.httpPort.params := "HTTP(codecs=json:json_codec)/TCP(debug=1,server=try-mec.etsi.org,port=443,use_ssl=1)" #system.httpPort_notif.params := "HTTP(codecs=json:json_codec_mec015)/TCP(debug=1,server_mode=1,use_ssl=0)" [DEFINE] # In this section you can create macro definitions, # that can be used in other configuration file sections except [INCLUDE] and [ORDERED_INCLUDE]. [INCLUDE] # To use configuration settings given in other configuration files, # the configuration files just need to be listed in this section, with their full or relative pathnames. [ORDERED_INCLUDE] # To use configuration settings given in other configuration files, # the configuration files just need to be listed in this section, with their full or relative pathnames. [EXTERNAL_COMMANDS] # This section can define external commands (shell scripts) to be executed by the ETS # whenever a control part or test case is started or terminated. #BeginTestCase := "" #EndTestCase := "" #BeginControlPart := "" #EndControlPart := "" [EXECUTE] # In this section you can specify what parts of your test suite you want to execute. #AtsMec_TestControl.control # Check that the IUT responds with a list of all available tenantInfo when requested to a CSE - No query parameters #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_001_OK # Check that the IUT responds with a list of all available tenantInfo when requested to a CSE - customerId attribute as query parameter #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_001_OK_02 # Check that the IUT responds with a list of all available tenantInfo when requested to a CSE - customerName as query parameter #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_001_OK_03 # Check that the IUT creates a new tenantInfo when requested to a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_002_OK # Check that the IUT responds with an error on creating a tenantInfo with resourceUseInfo and siteList #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_002_BR # Check that the IUT responds with a specific tenantInfo when requested to a MEC Consumer #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_003_OK # Check that the IUT returns an error when requesting a not existing tenantInfo to a MEC Consumer #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_003_NF # Check that the IUT updates an existing tenantInfo when requested to a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_004_OK # Check that the IUT returns an error on updating a not existing tenantInfo requested to a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_004_NF # Check that the IUT returns an error on updating with invalid values tenantInfo requested to a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_004_BR # Check that the IUT removes a tenantInfo when requested to a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_005_OK # Check that the IUT returns an error on deleting a not existing tenantInfo when requested to a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_005_NF # Check that the IUT returns a resourceQuotaInfo for a specific tenant when requested to a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_006_OK # Check that the IUT returns an error on retrieving resourceQuotaInfo for a not existing tenant when requested to a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_006_NF # Check that the IUT updates the resourceQuotaInfo for an existing tenant when requested to a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_007_OK # Check that the IUT returns an error on updating the resourceQuotaInfo for a not existing tenant when requested to a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_007_NF # Check that the IUT creates the resourceQuotaInfo for an existing tenant when requested to a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_008_OK # Check that the IUT returns an error on creating the resourceQuotaInfo for a not existing tenant when requested to a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_008_NF # Check that the IUT returns the list of per site resource quota for a specific tenant when requested to a CSE - No filter #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_009_OK # Check that the IUT returns the list of per site resource quota for a specific tenant when requested to a CSE - siteId filter" AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_009_OK_01 # Check that the IUT returns an error on requesting site resource quota info on a not existing tenant when requested to a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_009_NF # Check that the IUT creates a site resource quota info for a existing tenant when requested to a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_010_OK # Check that the IUT returns an error on creating a site resource quota with wrong parameters #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_010_BR # Check that the IUT returns the site resource quota for a specific tenant and site identifier when requested to a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_011_OK # Check that the IUT returns an error on requesting site resource quota info on a not existing tenant when requested to a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_011_NF # Check that the IUT updates a site resource quota info for a existing tenant when requested to a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_012_OK # Check that the IUT returns an error updating a site resource quota info for a existing tenant when requested to a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_012_BR # Check that the IUT returns an error updating a site resource quota info for a not existing tenant when requested to a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_012_NF # Check that the IUT returns the list of subscriptions when requested to a CSE - no filter #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_013_OK # Check that the IUT returns the list of subscriptions when requested to a CSE - subscription_type filter #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_013_OK_02 # Check that the IUT creates a new subscription when requested to a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_014_OK # Check that the IUT creates a new subscription when requested to a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_014_OK_02 # Check that the IUT returns an error on creating a new subscription when requested to a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_014_BR # Check that the IUT returns a subscription when requested by a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_015_OK # Check that the IUT returns an error on requesting a not existing subscription when requested by a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_015_NF # Check that the IUT updates an existing subscription when requested by a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_016_OK # Check that the IUT returns an error updating an not existing subscription when requested by a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_016_NF # Check that the IUT returns an error updating an existing subscription with wrong parameters when requested by a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_016_BR # Check that the IUT deletes an existing subscription when requested by a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_017_OK # Check that the IUT returns an error on a deletion of a not existing subscription when requested by a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_017_NF # Check that the CSE sends a site resource usage notification if the CSE has an associated subscription and the event is generated #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_018_OK # Check that the CSE sends a resource usage notification if the CSE has an associated subscription and the event is generated #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_019_OK # Check that the CSE sends a notification on subscription expiration if the CSE has an associated subscription and the event is generated #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_020_OK [GROUPS] # In this section you can specify groups of hosts. These groups can be used inside the # [COMPONENTS] section to restrict the creation of certain PTCs to a given set of hosts. [COMPONENTS] # This section consists of rules restricting the location of created PTCs. [MAIN_CONTROLLER] # The options herein control the behavior of MC. KillTimer := 10.0 LocalAddress := 127.0.0.1 TCPPort := 12000 NumHCs := 1 ttcn/AtsMec_SelfServiceEnablement/AtsMec_SelfServiceEnablementAPI_TestCases.ttcn 0 → 100644 +2989 −0 Viewed File added.Preview size limit exceeded, changes collapsed. Show changes Loading
ccsrc/Protocols/Json/json_codec_factory_mec048.hh 0 → 100644 +46 −0 Viewed Changes for ccsrc/Protocols/Json/json_codec_factory_mec048.hh: 46 added lines, 0 removed lines. Original line number Diff line number Diff line /*! * \file json_codec_factory_mec048.hh * \brief Header file for ITS JSON/IP protocol codec factory. * \author ETSI STF569 / TTF T027 // TTF T043 * \copyright ETSI Copyright Notification * No part may be reproduced except as authorized by written permission. * The copyright and the foregoing restriction extend to reproduction in all media. * All rights reserved. * \version 0.1 */ #pragma once #include "codec_stack_builder.hh" #include "json_codec_mec048.hh" class Record_Type; //! TITAN forward declaration /*! * \class json_codec_factory_mec048 * \brief This class provides a factory class to create an json_codec class instance */ class json_codec_factory_mec048: public codec_factory { static json_codec_factory_mec048 _f; //! Reference to the unique instance of this class public: //! \publicsection /*! * \brief Default constructor * Create a new instance of the json_codec_factory_mec048 class * \remark The HELD/IP codec identifier is HELD */ json_codec_factory_mec048() { // register factory codec_stack_builder::register_codec_factory("json_codec_mec048", this); }; /*! * \fn codec* create_codec(const std::string & type, const std::string & param); * \brief Create the codecs stack based on the provided codecs stack description * \param[in] p_type The provided codecs stack description * \param[in] p_params Optional parameters * \return 0 on success, -1 otherwise * \inline */ inline virtual codec_gen<Record_Type, Record_Type>* create_codec() { return (codec_gen<Record_Type, Record_Type>*)new json_codec_mec048(); }; }; // End of class json_codec_factory_mec048
ccsrc/Protocols/Json/json_codec_mec048.cc 0 → 100644 +104 −0 Viewed Changes for ccsrc/Protocols/Json/json_codec_mec048.cc: 104 added lines, 0 removed lines. Original line number Diff line number Diff line #include <stdexcept> #include <regex> #include <string> #include "json_codec_factory_mec048.hh" #include "loggers.hh" #include "LibHttp_JsonMessageBodyTypes.hh" int json_codec_mec048::encode (const LibHttp__JsonMessageBodyTypes::JsonBody& msg, OCTETSTRING& data) { loggers::get_instance().log_msg(">>> json_codec_mec048::encode: ", (const Base_Type&)msg); TTCN_EncDec::clear_error(); TTCN_EncDec::set_error_behavior(TTCN_EncDec::ET_ALL, TTCN_EncDec::EB_DEFAULT); TTCN_Buffer encoding_buffer; if (msg.ischosen(LibHttp__JsonMessageBodyTypes::JsonBody::ALT_tenantInfo)) { const SelfServiceEnablementAPI__TypesAndValues::TenantInfo& tenant_info = msg.tenantInfo(); tenant_info.encode(SelfServiceEnablementAPI__TypesAndValues::TenantInfo_descr_, encoding_buffer, TTCN_EncDec::CT_JSON); data = /*char2oct(CHARSTRING("{\"TenantInfo\": ")) + */OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data())/* + char2oct(CHARSTRING("}"))*/; } else if (msg.ischosen(LibHttp__JsonMessageBodyTypes::JsonBody::ALT_resourceUsageSubscription)) { const SelfServiceEnablementAPI__TypesAndValues::ResourceUsageSubscription& resource_usage_subscription = msg.resourceUsageSubscription(); resource_usage_subscription.encode(SelfServiceEnablementAPI__TypesAndValues::ResourceUsageSubscription_descr_, encoding_buffer, TTCN_EncDec::CT_JSON); data = /*char2oct(CHARSTRING("{\"ResourceUsageSubscription\": ")) + */OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data())/* + char2oct(CHARSTRING("}"))*/; } else if (msg.ischosen(LibHttp__JsonMessageBodyTypes::JsonBody::ALT_siteResourceUsageSubscription)) { const SelfServiceEnablementAPI__TypesAndValues::SiteResourceUsageSubscription& site_resource_usage_subscription = msg.siteResourceUsageSubscription(); site_resource_usage_subscription.encode(SelfServiceEnablementAPI__TypesAndValues::SiteResourceUsageSubscription_descr_, encoding_buffer, TTCN_EncDec::CT_JSON); data = /*char2oct(CHARSTRING("{\"SiteResourceUsageSubscription\": ")) + */OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data())/* + char2oct(CHARSTRING("}"))*/; } else { return json_codec::encode(msg, data); } loggers::get_instance().log("<<< json_codec_mec048::encode"); return 0; } int json_codec_mec048::decode (const OCTETSTRING& p_data, LibHttp__JsonMessageBodyTypes::JsonBody& msg, params* p_params) { loggers::get_instance().log_msg(">>> json_codec_mec048::decode: p_data=", p_data); // Sanity checks params::const_iterator it; if (p_params == nullptr) { loggers::get_instance().warning("json_codec_mec048::decode: Failed to access p_params (null pointer)"); return -1; // TODO Use p_data instead of return -1 } else { it = p_params->find("decode_str"); if (it == p_params->cend()) { loggers::get_instance().warning("json_codec_mec048::decode: Failed to access p_params item (decode_str)"); return -1; // TODO Use p_data instead of return -1 } loggers::get_instance().log("json_codec_mec048::decode: it->second='%c' / '%s'", it->second.c_str()[0], it->second.c_str()); } // Remove data structure name (if present) ... std::string str; if ((it->second[0] != '[') && (it->second[0] != '{')) { int idx_begin = it->second.find(":"); int idx_end = it->second.rfind("}") - 1; // Remove the last '}' str = it->second.substr(idx_begin + 1, idx_end - idx_begin); } else { str = it->second; } // ..and create the decoding buffer TTCN_EncDec::set_error_behavior(TTCN_EncDec::ET_ALL, TTCN_EncDec::EB_DEFAULT); TTCN_EncDec::clear_error(); loggers::get_instance().log("json_codec_mec048::decode: decoding_buffer='%c' / '%s'", str[0], str.c_str()); TTCN_Buffer decoding_buffer(OCTETSTRING(str.length(), (const unsigned char*)str.c_str())); if (it->second.find("\"tenantId\"") != std::string::npos) { // Be careful to the order if (it->second[0] == '[') { SelfServiceEnablementAPI__TypesAndValues::TenantInfoList tenant_info_list; tenant_info_list.decode(SelfServiceEnablementAPI__TypesAndValues::TenantInfoList_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.tenantInfoList() = tenant_info_list; } else { SelfServiceEnablementAPI__TypesAndValues::TenantInfo tenant_info; tenant_info.decode(SelfServiceEnablementAPI__TypesAndValues::TenantInfo_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.tenantInfo() = tenant_info; } } else if ( (it->second.find("\"_links\"") != std::string::npos) && ((it->second.find("\"subscriptions\"") != std::string::npos) || (it->second.find("\"subscriptionType\"") == std::string::npos)) ) { SelfServiceEnablementAPI__TypesAndValues::SubscriptionLinkList subscription_link_list; subscription_link_list.decode(SelfServiceEnablementAPI__TypesAndValues::SubscriptionLinkList_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.subscriptionLinkList__cse() = subscription_link_list; } else if ((it->second.find("\"subscriptionType\"") != std::string::npos) && (it->second.find("\"ResourceUsageSubscription\"") != std::string::npos)) { SelfServiceEnablementAPI__TypesAndValues::ResourceUsageSubscription resource_usage_subscription; resource_usage_subscription.decode(SelfServiceEnablementAPI__TypesAndValues::ResourceUsageSubscription_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.resourceUsageSubscription() = resource_usage_subscription; } else if ((it->second.find("\"subscriptionType\"") != std::string::npos) && (it->second.find("\"SiteResourceUsageSubscription\"") != std::string::npos)) { SelfServiceEnablementAPI__TypesAndValues::SiteResourceUsageSubscription site_resource_usage_subscription; site_resource_usage_subscription.decode(SelfServiceEnablementAPI__TypesAndValues::SiteResourceUsageSubscription_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.siteResourceUsageSubscription() = site_resource_usage_subscription; } else { return json_codec::decode(p_data, msg, p_params); } loggers::get_instance().log_msg("<<< json_codec_mec048::decode: ", (const Base_Type&)msg); return 0; } json_codec_factory_mec048 json_codec_factory_mec048::_f;
ccsrc/Protocols/Json/json_codec_mec048.hh 0 → 100644 +25 −0 Viewed Changes for ccsrc/Protocols/Json/json_codec_mec048.hh: 25 added lines, 0 removed lines. Original line number Diff line number Diff line #pragma once #include "codec_gen.hh" #include "params.hh" #include "json_codec.hh" class Base_Type; class TTCN_Typedescriptor_t; class TTCN_Buffer; namespace LibHttp__JsonMessageBodyTypes { class JsonBody; } class json_codec_mec048: public json_codec { public: explicit json_codec_mec048() : json_codec() { }; virtual ~json_codec_mec048() { }; int encode (const LibHttp__JsonMessageBodyTypes::JsonBody&, OCTETSTRING& data); int decode (const OCTETSTRING& p_data, LibHttp__JsonMessageBodyTypes::JsonBody&, params* p_params = NULL); }; // End of class json_codec_mec048
etc/AtsMec_SelfServiceEnablement/AtsMec_SelfServiceEnablementAPI.cf_ 0 → 100644 +165 −0 Viewed Changes for etc/AtsMec_SelfServiceEnablement/AtsMec_SelfServiceEnablementAPI.cf_: 165 added lines, 0 removed lines. Original line number Diff line number Diff line [MODULE_PARAMETERS] # This section shall contain the values of all parameters that are defined in your TTCN-3 modules. # 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; LibHttp_Pics.PICS_HEADER_HOST := "192.168.1.21" #"192.168.1.39" LibHttp_Pics.PICS_HEADER_CONTENT_TYPE := "application/json" LibHttp_Pics.PICS_USE_TOKEN_HEADER := true #LibHttp_Pics.PICS_TOKEN_HEADER := "Basic WrongToken" # LibMec_Pixits LibMec_Pics.PICS_ROOT_API := "/sbxykqjr17/mep1/" # Need to sign in on https://mec-platform.etsi.org/, section 'Try-it from your MEC application' [LOGGING] # In this section you can specify the name of the log file and the classes of events # you want to log into the file or display on console (standard error). LogFile := "../logs/AtsMec_FederationEnablement/%e.%h-%r.%s" FileMask := LOG_ALL | USER | DEBUG | MATCHING ConsoleMask := LOG_ALL | USER | DEBUG | MATCHING #FileMask := ERROR | WARNING | USER | MATCHING | EXECUTOR_RUNTIME | VERDICTOP | PORTEVENT | TESTCASE #ConsoleMask := ERROR | WARNING | USER | MATCHING | EXECUTOR_RUNTIME | VERDICTOP | PORTEVENT | TESTCASE LogSourceInfo := Stack LogEntityName:= Yes LogEventTypes:= Yes #TimeStampFormat := DateTime [TESTPORT_PARAMETERS] # In this section you can specify parameters that are passed to Test Ports. #system.httpPort.params := "HTTP(codecs=json:json_codec_mec015)/TCP(debug=1,server=172.26.214.231,port=3001,use_ssl=0)" #system.httpPort.params := "HTTP(codecs=json:json_codec)/TCP(debug=1,server=try-mec.etsi.org,port=443,use_ssl=1)" #system.httpPort_notif.params := "HTTP(codecs=json:json_codec_mec015)/TCP(debug=1,server_mode=1,use_ssl=0)" [DEFINE] # In this section you can create macro definitions, # that can be used in other configuration file sections except [INCLUDE] and [ORDERED_INCLUDE]. [INCLUDE] # To use configuration settings given in other configuration files, # the configuration files just need to be listed in this section, with their full or relative pathnames. [ORDERED_INCLUDE] # To use configuration settings given in other configuration files, # the configuration files just need to be listed in this section, with their full or relative pathnames. [EXTERNAL_COMMANDS] # This section can define external commands (shell scripts) to be executed by the ETS # whenever a control part or test case is started or terminated. #BeginTestCase := "" #EndTestCase := "" #BeginControlPart := "" #EndControlPart := "" [EXECUTE] # In this section you can specify what parts of your test suite you want to execute. #AtsMec_TestControl.control # Check that the IUT responds with a list of all available tenantInfo when requested to a CSE - No query parameters #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_001_OK # Check that the IUT responds with a list of all available tenantInfo when requested to a CSE - customerId attribute as query parameter #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_001_OK_02 # Check that the IUT responds with a list of all available tenantInfo when requested to a CSE - customerName as query parameter #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_001_OK_03 # Check that the IUT creates a new tenantInfo when requested to a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_002_OK # Check that the IUT responds with an error on creating a tenantInfo with resourceUseInfo and siteList #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_002_BR # Check that the IUT responds with a specific tenantInfo when requested to a MEC Consumer #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_003_OK # Check that the IUT returns an error when requesting a not existing tenantInfo to a MEC Consumer #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_003_NF # Check that the IUT updates an existing tenantInfo when requested to a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_004_OK # Check that the IUT returns an error on updating a not existing tenantInfo requested to a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_004_NF # Check that the IUT returns an error on updating with invalid values tenantInfo requested to a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_004_BR # Check that the IUT removes a tenantInfo when requested to a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_005_OK # Check that the IUT returns an error on deleting a not existing tenantInfo when requested to a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_005_NF # Check that the IUT returns a resourceQuotaInfo for a specific tenant when requested to a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_006_OK # Check that the IUT returns an error on retrieving resourceQuotaInfo for a not existing tenant when requested to a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_006_NF # Check that the IUT updates the resourceQuotaInfo for an existing tenant when requested to a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_007_OK # Check that the IUT returns an error on updating the resourceQuotaInfo for a not existing tenant when requested to a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_007_NF # Check that the IUT creates the resourceQuotaInfo for an existing tenant when requested to a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_008_OK # Check that the IUT returns an error on creating the resourceQuotaInfo for a not existing tenant when requested to a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_008_NF # Check that the IUT returns the list of per site resource quota for a specific tenant when requested to a CSE - No filter #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_009_OK # Check that the IUT returns the list of per site resource quota for a specific tenant when requested to a CSE - siteId filter" AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_009_OK_01 # Check that the IUT returns an error on requesting site resource quota info on a not existing tenant when requested to a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_009_NF # Check that the IUT creates a site resource quota info for a existing tenant when requested to a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_010_OK # Check that the IUT returns an error on creating a site resource quota with wrong parameters #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_010_BR # Check that the IUT returns the site resource quota for a specific tenant and site identifier when requested to a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_011_OK # Check that the IUT returns an error on requesting site resource quota info on a not existing tenant when requested to a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_011_NF # Check that the IUT updates a site resource quota info for a existing tenant when requested to a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_012_OK # Check that the IUT returns an error updating a site resource quota info for a existing tenant when requested to a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_012_BR # Check that the IUT returns an error updating a site resource quota info for a not existing tenant when requested to a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_012_NF # Check that the IUT returns the list of subscriptions when requested to a CSE - no filter #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_013_OK # Check that the IUT returns the list of subscriptions when requested to a CSE - subscription_type filter #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_013_OK_02 # Check that the IUT creates a new subscription when requested to a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_014_OK # Check that the IUT creates a new subscription when requested to a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_014_OK_02 # Check that the IUT returns an error on creating a new subscription when requested to a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_014_BR # Check that the IUT returns a subscription when requested by a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_015_OK # Check that the IUT returns an error on requesting a not existing subscription when requested by a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_015_NF # Check that the IUT updates an existing subscription when requested by a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_016_OK # Check that the IUT returns an error updating an not existing subscription when requested by a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_016_NF # Check that the IUT returns an error updating an existing subscription with wrong parameters when requested by a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_016_BR # Check that the IUT deletes an existing subscription when requested by a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_017_OK # Check that the IUT returns an error on a deletion of a not existing subscription when requested by a CSE #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_017_NF # Check that the CSE sends a site resource usage notification if the CSE has an associated subscription and the event is generated #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_018_OK # Check that the CSE sends a resource usage notification if the CSE has an associated subscription and the event is generated #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_019_OK # Check that the CSE sends a notification on subscription expiration if the CSE has an associated subscription and the event is generated #AtsMec_SelfServiceEnablementAPI_TestCases.TC_MEC_MEC048_MEO_CSE_020_OK [GROUPS] # In this section you can specify groups of hosts. These groups can be used inside the # [COMPONENTS] section to restrict the creation of certain PTCs to a given set of hosts. [COMPONENTS] # This section consists of rules restricting the location of created PTCs. [MAIN_CONTROLLER] # The options herein control the behavior of MC. KillTimer := 10.0 LocalAddress := 127.0.0.1 TCPPort := 12000 NumHCs := 1
ttcn/AtsMec_SelfServiceEnablement/AtsMec_SelfServiceEnablementAPI_TestCases.ttcn 0 → 100644 +2989 −0 Viewed File added.Preview size limit exceeded, changes collapsed. Show changes