Commit d91c2529 authored by Yann Garcia's avatar Yann Garcia

Finalyze UEidentityAPI support

parent a85ee750
......@@ -13,6 +13,7 @@
#include "LibItsHttp_TypesAndValues.hh"
#include "LibItsHttp_MessageBodyTypes.hh"
#include "LibItsHttp_XmlMessageBodyTypes.hh"
#include "LibItsHttp_JsonMessageBodyTypes.hh"
int http_codec::encode (const LibItsHttp__TypesAndValues::HttpMessage& msg, OCTETSTRING& data)
{
......@@ -413,16 +414,6 @@ int http_codec::encode_body(const LibItsHttp__MessageBodyTypes::HttpMessageBody&
if (it != _codecs.cend()) {
loggers::get_instance().log("http_codec::encode_body: Call '%s'", it->first.c_str());
//_codecs["http_its"]->encode((Record_Type&)binary_body.ieee1609dot2__data(), p_encoding_buffer); // TODO Use params
#if defined(GEMALTO_FIX) // Temporary fix to be removed
// GEMALTO Encode in hex string
CHARSTRING buf = oct2str(p_encoding_buffer);
p_encoding_buffer = OCTETSTRING(buf.lengthof(), (const unsigned char*)(static_cast<const char*>(buf)));
loggers::get_instance().log_msg("http_codec::encode_body: Convert binary to string: ", p_encoding_buffer);
#endif
processed = true;
}
} // TODO Add new HTTP message codec here
......@@ -463,6 +454,27 @@ int http_codec::encode_body(const LibItsHttp__MessageBodyTypes::HttpMessageBody&
p_encoding_buffer = OCTETSTRING(0, nullptr);
}
}
} else if (p_message_body.ischosen(LibItsHttp__MessageBodyTypes::HttpMessageBody::ALT_json__body)) {
const LibItsHttp__JsonMessageBodyTypes::JsonBody& json_body = p_message_body.json__body();
if (json_body.ischosen(LibItsHttp__JsonMessageBodyTypes::JsonBody::ALT_raw)) {
p_encoding_buffer = unichar2oct(json_body.raw());
} else {
std::map<std::string, std::unique_ptr<codec<Record_Type, Record_Type> > >::const_iterator it;
bool processed = false;
loggers::get_instance().log("http_codec::encode_body: Content-Type:'%s'", p_content_type.c_str());
if (p_content_type.find("json") != std::string::npos) {
it = _codecs.find("json"); // TODO Use params
if (it != _codecs.cend()) {
loggers::get_instance().log("http_codec::encode_body: Call 'json_codec'");
_codecs["json"]->encode((Record_Type&)json_body, p_encoding_buffer); // TODO Use params
processed = true;
}
} // TODO Add new HTTP message codec here
if (!processed) {
loggers::get_instance().warning("http_codec::encode_body: Unsupported HTTP codec, use raw field as default");
p_encoding_buffer = OCTETSTRING(0, nullptr);
}
}
} else {
loggers::get_instance().warning("http_codec::encode_body: Failed to encode HTTP message body");
return -1;
......
......@@ -15,8 +15,14 @@ int json_codec::encode (const LibItsHttp__JsonMessageBodyTypes::JsonBody& msg, O
TTCN_EncDec::clear_error();
TTCN_EncDec::set_error_behavior(TTCN_EncDec::ET_ALL, TTCN_EncDec::EB_DEFAULT);
TTCN_Buffer encoding_buffer;
loggers::get_instance().error("json_codec::encode: Not supported: ");
if (msg.ischosen(LibItsHttp__JsonMessageBodyTypes::JsonBody::ALT_ueIdentityTagInfo)) {
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 {
loggers::get_instance().error("json_codec::encode: Not supported");
}
loggers::get_instance().log("<<< json_codec::encode");
return 0;
......@@ -56,6 +62,10 @@ int json_codec::decode (const OCTETSTRING& p_data, LibItsHttp__JsonMessageBodyTy
UEidentityAPI__TypesAndValues::UeIdentityTagInfo ue_identity_tag_info;
ue_identity_tag_info.decode(UEidentityAPI__TypesAndValues::UeIdentityTagInfo_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
msg.ueIdentityTagInfo() = ue_identity_tag_info;
} else if (it->second.find("\"problemDetails\"") != std::string::npos) {
UEidentityAPI__TypesAndValues::ProblemDetails problem_details;
problem_details.decode(UEidentityAPI__TypesAndValues::ProblemDetails_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
msg.problemDetails() = problem_details;
} else {
loggers::get_instance().warning("json_codec::decode: Unsupported variant");
return -1;
......
......@@ -20,6 +20,8 @@ module AtsMec_TestControl {
}
if (PICS_UE_IDENTITY_API_SUPPORTED) {
execute(TC_MEC_PLAT_MP1_UETAG_BV_001());
execute(TC_MEC_PLAT_MP1_UETAG_BV_002());
execute(TC_MEC_PLAT_MP1_UETAG_BV_003());
}
}
}
......
......@@ -37,62 +37,201 @@ module AtsMec_UEidentityAPI_TestCases {
group me_app_role {
/**
* @desc Check that the IUT responds with a list for the location of User Equipments when queried by a MEC Application
* @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/UeIdentity/PlatUeIdentity.tplan2
*/
testcase TC_MEC_PLAT_MP1_UETAG_BV_001() runs on HttpComponent system HttpTestAdapter {
// Local variables
var HeaderLines v_headers;
var HttpMessage v_response;
// Local variables
var HeaderLines v_headers;
var HttpMessage v_response;
// Test control
if (not(PICS_ME_APP_IUT) or not(PICS_UE_IDENTITY_API_SUPPORTED)) {
log("*** " & testcasename() & ": PICS_ME_APP_IUT and PICS_LOCATION_API_SUPPORTED required for executing the TC ***");
setverdict(inconc);
stop;
}
// Test control
if (not(PICS_ME_APP_IUT) or not(PICS_UE_IDENTITY_API_SUPPORTED)) {
log("*** " & testcasename() & ": PICS_ME_APP_IUT and PICS_LOCATION_API_SUPPORTED required for executing the TC ***");
setverdict(inconc);
stop;
}
// Test component configuration
f_cf_01_http_up();
// Test component configuration
f_cf_01_http_up();
// Test adapter configuration
// Test adapter configuration
// Preamble
f_init_default_headers_list(-, -, v_headers);
httpPort.send(
m_http_request(
m_http_request_post(
PICS_ME_APP_Q_UE_IDENTITY_ID_URI & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/ue_identity_tag_info",
v_headers
)
)
);
f_selfOrClientSyncAndVerdictTestBody(c_prDone, e_success);
// Preamble
f_init_default_headers_list(-, -, v_headers);
httpPort.send(
m_http_request(
m_http_request_post(
PICS_ME_APP_Q_UE_IDENTITY_ID_URI & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/ue_identity_tag_info",
v_headers
)
)
);
f_selfOrClientSyncAndVerdictTestBody(c_prDone, e_success);
// Test Body
tc_ac.start;
alt {
[] httpPort.receive(
mw_http_response(
mw_http_response_ok(
mw_http_message_body_json(
mw_body_json_ue_identity_tag_info(
mw_ue_identity_tag_info(
?
)))))) -> value v_response {
log("*** " & testcasename() & ": PASS: IUT successfully responds with a UeIdentityTag ***");
f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
}
[] tc_ac.timeout {
log("*** " & testcasename() & ": INCONC: Expected message not received ***");
f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
}
} // End of 'alt' statement
// Test Body
tc_ac.start;
alt {
[] httpPort.receive(
mw_http_response(
mw_http_response_ok(
mw_http_message_body_json(
mw_body_json_ue_identity_tag_info(
mw_ue_identity_tag_info(
{ *, mw_ue_identity_tag_item(PX_UE_IDENTITY_TAG, REGISTERED), * }
)))))) -> value v_response {
log("*** " & testcasename() & ": PASS: IUT successfully responds with a UeIdentityTag ***");
f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
}
[] tc_ac.timeout {
log("*** " & testcasename() & ": INCONC: Expected message not received ***");
f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
}
} // End of 'alt' statement
// Postamble
f_cf_01_http_down();
// Postamble
f_cf_01_http_down();
} // End of testcase TC_MEC_PLAT_MP1_UETAG_BV_001
/**
* @desc Check that the IUT registers a tag (representing a UE) or a list of tags when commanded by a MEC Application
* @see https://forge.etsi.org/gitlab/mec/MEC-tests/blob/master/Test%20Purposes/Plat/Mp1/UeIdentity/PlatUeIdentity.tplan2
*/
testcase TC_MEC_PLAT_MP1_UETAG_BV_002() runs on HttpComponent system HttpTestAdapter {
// Local variables
var HeaderLines v_headers;
var HttpMessage v_response;
// Test control
if (not(PICS_ME_APP_IUT) or not(PICS_UE_IDENTITY_API_SUPPORTED)) {
log("*** " & testcasename() & ": PICS_ME_APP_IUT 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(
PICS_ME_APP_Q_UE_IDENTITY_ID_URI & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/ue_identity_tag_info",
v_headers,
m_http_message_body_json(
m_body_json_ue_identity_tag_info(
m_ue_identity_tag_info(
{
m_ue_identity_tag_item(
PX_UE_IDENTITY_TAG,
REGISTERED
)
}
)
)
)
)
)
);
f_selfOrClientSyncAndVerdictTestBody(c_prDone, e_success);
// Test Body
tc_ac.start;
alt {
[] httpPort.receive(
mw_http_response(
mw_http_response_ok(
mw_http_message_body_json(
mw_body_json_ue_identity_tag_info(
mw_ue_identity_tag_info(
{ *, mw_ue_identity_tag_item(PX_UE_IDENTITY_TAG, REGISTERED), * }
)))))) -> value v_response {
log("*** " & testcasename() & ": PASS: IUT successfully responds with a UeIdentityTag ***");
f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
}
[] tc_ac.timeout {
log("*** " & testcasename() & ": INCONC: Expected message not received ***");
f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
}
} // End of 'alt' statement
// Postamble
f_cf_01_http_down();
} // End of testcase TC_MEC_PLAT_MP1_UETAG_BV_002
/**
* @desc Check that the IUT deregisters a tag (representing a UE) or a list of tags when commanded by a MEC Application
* @see https://forge.etsi.org/gitlab/mec/MEC-tests/blob/master/Test%20Purposes/Plat/Mp1/UeIdentity/PlatUeIdentity.tplan2
*/
testcase TC_MEC_PLAT_MP1_UETAG_BV_003() runs on HttpComponent system HttpTestAdapter {
// Local variables
var HeaderLines v_headers;
var HttpMessage v_response;
// Test control
if (not(PICS_ME_APP_IUT) or not(PICS_UE_IDENTITY_API_SUPPORTED)) {
log("*** " & testcasename() & ": PICS_ME_APP_IUT 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(
PICS_ME_APP_Q_UE_IDENTITY_ID_URI & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/ue_identity_tag_info",
v_headers,
m_http_message_body_json(
m_body_json_ue_identity_tag_info(
m_ue_identity_tag_info(
{
m_ue_identity_tag_item(
PX_UE_IDENTITY_TAG,
UNREGISTERED
)
}
)
)
)
)
)
);
f_selfOrClientSyncAndVerdictTestBody(c_prDone, e_success);
// Test Body
tc_ac.start;
alt {
[] httpPort.receive(
mw_http_response(
mw_http_response_ok(
mw_http_message_body_json(
mw_body_json_ue_identity_tag_info(
mw_ue_identity_tag_info(
{ *, mw_ue_identity_tag_item(PX_UE_IDENTITY_TAG, UNREGISTERED), * }
)))))) -> value v_response {
log("*** " & testcasename() & ": PASS: IUT successfully responds with a UeIdentityTag ***");
f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
}
[] tc_ac.timeout {
log("*** " & testcasename() & ": INCONC: Expected message not received ***");
f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
}
} // End of 'alt' statement
// Postamble
f_cf_01_http_down();
} // End of testcase TC_MEC_PLAT_MP1_UETAG_BV_003
} // End of group me_app_role
} // End of module AtsMec_TestCases
......@@ -63,47 +63,56 @@ module LibMec_Functions {
group altsteps {
altstep a_default_requests() runs on HttpComponent {
[] httpPort.receive(mw_http_request) {
tc_ac.stop;
log("*** " & testcasename() & ": FAIL: Server error: Receive request istead of response ***");
f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
}
[] httpPort.receive(mw_http_request) {
tc_ac.stop;
log("*** " & testcasename() & ": FAIL: Server error: Receive request istead of response ***");
f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
}
} // End of altstep a_default_requests
altstep a_default_responses() runs on HttpComponent {
var HttpMessage v_response;
[] httpPort.receive(
mw_http_response(
mw_http_response_ok(
mw_http_message_body_xml
))) {
tc_ac.stop;
log("*** " & testcasename() & ": FAIL: Unexpected XML response ***");
f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
}
[] httpPort.receive(
mw_http_response(
mw_http_response_ok(
mw_http_message_body_binary
))) {
tc_ac.stop;
log("*** " & testcasename() & ": FAIL: Unexpected binary response ***");
f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
}
[] httpPort.receive(
mw_http_response(
mw_http_response_ko
)) -> value v_response {
tc_ac.stop;
log("*** " & testcasename() & ": FAIL: Server error: " & int2str(v_response.response.statuscode) & "/" & v_response.response.statustext & " ***");
f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
}
[] httpPort.receive(mw_http_response) -> value v_response {
tc_ac.stop;
log("*** " & testcasename() & ": FAIL: Server error: " & int2str(v_response.response.statuscode) & "/" & v_response.response.statustext & " ***");
f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
}
var HttpMessage v_response;
[] httpPort.receive(
mw_http_response(
mw_http_response_ok(
mw_http_message_body_xml
))) {
tc_ac.stop;
log("*** " & testcasename() & ": FAIL: Unexpected XML response ***");
f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
}
[] httpPort.receive(
mw_http_response(
mw_http_response_ok(
mw_http_message_body_json
))) {
tc_ac.stop;
log("*** " & testcasename() & ": FAIL: Unexpected JSON response ***");
f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
}
[] httpPort.receive(
mw_http_response(
mw_http_response_ok(
mw_http_message_body_binary
))) {
tc_ac.stop;
log("*** " & testcasename() & ": FAIL: Unexpected binary response ***");
f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
}
[] httpPort.receive(
mw_http_response(
mw_http_response_ko
)) -> value v_response {
tc_ac.stop;
log("*** " & testcasename() & ": FAIL: Server error: " & int2str(v_response.response.statuscode) & "/" & v_response.response.statustext & " ***");
f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
}
[] httpPort.receive(mw_http_response) -> value v_response {
tc_ac.stop;
log("*** " & testcasename() & ": FAIL: Server error: " & int2str(v_response.response.statuscode) & "/" & v_response.response.statustext & " ***");
f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
}
} // End of altstep a_default_responses
} // end of group altsteps
......
......@@ -12,21 +12,19 @@ module TestCodec_External {
testcase tc_encode_LocationInfo() runs on TCType system TCType {
var LocationInfo v_location_info := valueof(m_location_info(10.0, 12.0, 9));
var LocationInfo v_location_info_result;
var universal charstring v_result;
var universal charstring v_expected_result := "{\"latitude\":10.000000,\"longitude\":12.000000,\"accuracy\":9}";
var bitstring v_enc_msg;
var universal charstring v_enc_msg;
var integer v_res;
v_enc_msg := encvalue(v_location_info);
v_result := oct2unichar(bit2oct(v_enc_msg), "UTF-8");
log("v_result= ", v_result);
if (match(v_expected_result, v_result)) {
v_enc_msg := encvalue_unichar(v_location_info);
log("v_enc_msg= ", v_enc_msg);
if (match(v_expected_result, v_enc_msg)) {
setverdict(pass, "Encoding succeed");
} else {
setverdict(fail, "Encoding failed");
}
v_res := decvalue(v_enc_msg, v_location_info_result);
v_res := decvalue_unichar(v_enc_msg, v_location_info_result);
if (v_res == 0) {
log("v_location_info_result= ", v_location_info_result);
if (match(v_location_info, v_location_info_result)) {
......@@ -42,21 +40,19 @@ module TestCodec_External {
testcase tc_encode_UserInfo() runs on TCType system TCType {
var UserInfo v_location_info := valueof(m_user_info("acr:10.0.0.1", "001010000000000000000000000000001", "zone01", "http://example.com/exampleAPI/location/v2/users?address=acr%3A10.0.0.1", TimeStamp:{ 1483231138, 0 }));
var UserInfo v_location_info_result;
var universal charstring v_result;
var universal charstring v_expected_result := "{\"address\":\"acr:10.0.0.1\",\"accessPointId\":\"001010000000000000000000000000001\",\"zoneId\":\"zone01\",\"resourceURL\":\"http://example.com/exampleAPI/location/v2/users?address=acr%3A10.0.0.1\",\"timeStamp\":{\"seconds\":1483231138,\"nanoSeconds\":0}}";
var bitstring v_enc_msg;
var universal charstring v_enc_msg;
var integer v_res;
v_enc_msg := encvalue(v_location_info);
v_result := oct2unichar(bit2oct(v_enc_msg), "UTF-8");
log("v_result= ", v_result);
if (match(v_expected_result, v_result)) {
v_enc_msg := encvalue_unichar(v_location_info);
log("v_enc_msg= ", v_enc_msg);
if (match(v_expected_result, v_enc_msg)) {
setverdict(pass, "Encoding succeed");
} else {
setverdict(fail, "Encoding failed");
}
v_res := decvalue(v_enc_msg, v_location_info_result);
v_res := decvalue_unichar(v_enc_msg, v_location_info_result);
if (v_res == 0) {
log("v_location_info_result= ", v_location_info_result);
if (match(v_location_info, v_location_info_result)) {
......@@ -72,21 +68,19 @@ module TestCodec_External {
testcase tc_encode_UeIdentityTags() runs on TCType system TCType {
var UeIdentityTagInfo v_ue_identity_tags_info := valueof(m_ue_identity_tag_info({ m_ue_identity_tag_item("UeTagA", REGISTERED) } ));
var UeIdentityTagInfo v_ue_identity_tags_info_result;
var universal charstring v_result;
var universal charstring v_expected_result := "{\"ueIdentityTags\":[{\"ueIdentityTag\":\"UeTagA\",\"state\":\"REGISTERED\"}]}";
var bitstring v_enc_msg;
var universal charstring v_enc_msg;
var integer v_res;
v_enc_msg := encvalue(v_ue_identity_tags_info);
v_result := oct2unichar(bit2oct(v_enc_msg), "UTF-8");
log("v_result= ", v_result);
if (match(v_expected_result, v_result)) {
v_enc_msg := encvalue_unichar(v_ue_identity_tags_info);
log("v_enc_msg= ", v_enc_msg);
if (match(v_expected_result, v_enc_msg)) {
setverdict(pass, "Encoding succeed");
} else {
setverdict(fail, "Encoding failed");
}
v_res := decvalue(v_enc_msg, v_ue_identity_tags_info_result);
v_res := decvalue_unichar(v_enc_msg, v_ue_identity_tags_info_result);
if (v_res == 0) {
log("v_ue_identity_tags_info_result= ", v_ue_identity_tags_info_result);
if (match(v_ue_identity_tags_info, v_ue_identity_tags_info_result)) {
......@@ -98,8 +92,8 @@ module TestCodec_External {
setverdict(fail, "Decoding operation failed");
}
v_enc_msg := oct2bit(char2oct("{\"ueIdentityTags\": [{ \"ueIdentityTag\": \"UeTagA\",\t\"state\": \"REGISTERED\"}]}"));
v_res := decvalue(v_enc_msg, v_ue_identity_tags_info_result);
v_enc_msg := "{\"ueIdentityTags\": [{ \"ueIdentityTag\": \"UeTagA\",\t\"state\": \"REGISTERED\"}]}";
v_res := decvalue_unichar(v_enc_msg, v_ue_identity_tags_info_result);
if (v_res == 0) {
log("v_ue_identity_tags_info_result (1)= ", v_ue_identity_tags_info_result);
if (match(v_ue_identity_tags_info, v_ue_identity_tags_info_result)) {
......
......@@ -65,12 +65,24 @@ module LibItsHttp_JsonTemplates {
group ue_identity_api {
template (value) JsonBody m_body_json_ue_identity_tag_info(
in template (value) UeIdentityTagInfo p_ueIdentityTagInfo
) := {
ueIdentityTagInfo := p_ueIdentityTagInfo
} // End of template m_body_json_ue_identity_tags
template (present) JsonBody mw_body_json_ue_identity_tag_info(
template (present) UeIdentityTagInfo p_ueIdentityTagInfo := ?
) := {
ueIdentityTagInfo := p_ueIdentityTagInfo
} // End of template mw_body_json_ue_identity_tags
template (value) JsonBody m_body_json_ue_problem_details(
in template (value) ProblemDetails p_problemDetails
) := {
problemDetails := p_problemDetails
} // End of template m_body_json_ue_problem_details
template (present) JsonBody mw_body_json_ue_problem_details(
template (present) ProblemDetails p_problemDetails := ?
) := {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment