Commit e6ac183b authored by garciay's avatar garciay
Browse files

Add new ECRF tets

parent 4f9920d5
Loading
Loading
Loading
Loading
+9 −26
Original line number Diff line number Diff line
@@ -82,7 +82,7 @@ int http_codec::decode (const OCTETSTRING& data, LibItsHttp__TypesAndValues::Htt
      response.header() = headers;
      loggers::get_instance().log_to_hexa("Before decoding Body: ", decoding_buffer);
      LibItsHttp__MessageBodyTypes::HttpMessageBody body;
      if (decode_body(decoding_buffer, body, std::string("application/x-its-request"/*TODO Add Content-Type*/)) == -1) {
      if (decode_body(decoding_buffer, body) == -1) {
        response.body().set_to_omit();
      } else {
        response.body() = OPTIONAL<LibItsHttp__MessageBodyTypes::HttpMessageBody>(body);
@@ -106,7 +106,7 @@ int http_codec::decode (const OCTETSTRING& data, LibItsHttp__TypesAndValues::Htt
      request.header() = headers;
      OPTIONAL<LibItsHttp__MessageBodyTypes::HttpMessageBody> body;
      body.set_to_omit();
      if (decode_body(decoding_buffer, body, std::string("application/x-its-request"/*TODO Add Content-Type*/)) == -1) {
      if (decode_body(decoding_buffer, body) == -1) {
        request.body().set_to_omit();
      } else {
        request.body() = body;
@@ -389,13 +389,11 @@ int http_codec::encode_body(const LibItsHttp__MessageBodyTypes::HttpMessageBody&
    } 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: # of codecs=%d - %p", _codecs.size(), this);
      if (p_content_type.find("x-its") != std::string::npos) {
        loggers::get_instance().log("http_codec::encode_body: Find x-its");
        it = _codecs.find("http_its"); // TODO Use params
        if (it != _codecs.cend()) {
          loggers::get_instance().log("http_codec::encode_body: Call 'http_etsi_ieee1609dot2_codec'");
          _codecs["http_its"]->encode((Record_Type&)binary_body.ieee1609dot2__data(), p_encoding_buffer); // TODO Use params
          _codecs["http_its"]->encode((Record_Type&)binary_body, p_encoding_buffer); // TODO Use params
          processed = true;
        }
      } // TODO Add new HTTP message codec here
@@ -448,10 +446,10 @@ int http_codec::encode_body(const LibItsHttp__MessageBodyTypes::HttpMessageBody&
  return 0;
}

int http_codec::decode_body(TTCN_Buffer& decoding_buffer, LibItsHttp__MessageBodyTypes::HttpMessageBody& message_body, const std::string& p_content_type) {
int http_codec::decode_body(TTCN_Buffer& decoding_buffer, LibItsHttp__MessageBodyTypes::HttpMessageBody& message_body) {
  loggers::get_instance().log(">>> http_codec::decode_body");
  loggers::get_instance().log_to_hexa("http_codec::decode_body", decoding_buffer);
  loggers::get_instance().log("http_codec::decode_body: Content-Type=%s", p_content_type.c_str());
  loggers::get_instance().log("http_codec::decode_body: # of codecs=%d", _codecs.size());

  // Sanity check
  if (decoding_buffer.get_len() - decoding_buffer.get_pos() <= 0) {
@@ -498,24 +496,9 @@ int http_codec::decode_body(TTCN_Buffer& decoding_buffer, LibItsHttp__MessageBod
  loggers::get_instance().log("http_codec::decode_body: Binary mode: %x", _dc.is_binary);
  LibItsHttp__MessageBodyTypes::HttpMessageBody v;
  if (_dc.is_binary == 0x01) {
    LibItsHttp__BinaryMessageBodyTypes::BinaryBody binary_body;
    bool processed = false;
    // TODO To be refined adding a string identifier to check which codec to use. E.g. held_code.id() returns "xmlns=\"urn:ietf:params:xml:ns:geopriv:held\">"
    if (p_content_type.find("x-its") != std::string::npos) {
      loggers::get_instance().log("http_codec::decode_body: Find 'x-its'");
      if (_codecs["http_its"].get() != nullptr) {
        loggers::get_instance().log("http_codec::decode_body: Call 'http_etsi_ieee1609dot2_codec'");
        if (_codecs["http_its"]->decode(body, binary_body.ieee1609dot2__data()) == 0) {
        message_body.binary__body() = binary_body;
        processed = true;
      }
      delete codec;
    } // TODO Add new HTTP message codec here
    if (!processed) {
      loggers::get_instance().warning("http_codec::decode_body: Unsupported HTTP codec, use raw field as default");
      binary_body.raw() = body;
      message_body.binary__body() = binary_body;
    }
    LibItsHttp__BinaryMessageBodyTypes::BinaryBody bb;
    bb.raw() = body;
    message_body.binary__body() = bb;
  } else {
    // Convert into string
    params p;
@@ -542,7 +525,7 @@ int http_codec::decode_body(TTCN_Buffer& decoding_buffer, LibItsHttp__MessageBod
         }
         message_body.xml__body() = xml_body;
       } else if (p["decode_str"].find("xmlns=\"urn:ietf:params:xml:ns:lost1\">") != std::string::npos) {
         loggers::get_instance().log("http_codec::decode_body: Find 'urn:ietf:params:xml:ns:loat1'");
         loggers::get_instance().log("http_codec::decode_body: Find 'urn:ietf:params:xml:ns:lost1'");
         if (_codecs["lost"].get() != nullptr) {
           loggers::get_instance().log("http_codec::decode_body: Call 'lost_codec'");
           if (_codecs["lost"]->decode(body, (Record_Type&)xml_body, &p) == -1) {
+144 −0
Original line number Diff line number Diff line
@@ -1850,6 +1850,150 @@ module AtsNg112_TestCases {
        f_cf_01_http_down();
    } // End of testcase TC_ECRF_HTTP_POST_BV_11
    
    /**
     * @desc "IUT successfully responds with configured service types for a ListServices request without service element"
     */
    testcase TC_ECRF_HTTP_POST_BV_12() runs on HttpComponent system TestAdapter {
        // Local variables
        var HeaderLines v_headers;
        var HttpMessage v_response;
        
        // Test control
        if (not(PICS_ECRF_IUT) or (not PICS_HTTP_POST_REQUEST) or (not PICS_SERVICE_LOST) or not(PICS_L_LST_ALL1)) {
          log("*** " & testcasename() & ": PICS_ECRF_IUT and PICS_HTTP_POST_REQUEST and PICS_SERVICE_LOST and PICS_L_LST_ALL1 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_ECRF_URI,
                                                         v_headers,
                                                         m_http_message_body_xml(
                                                                                 m_body_xml_list_services_by_location_request(
                                                                                                                              m_list_services_by_location(
                                                                                                                                                          {
                                                                                                                                                            m_location(
                                                                                                                                                                       PX_LOST_ID,
                                                                                                                                                                       { m_extension_point(encvalue_unichar(valueof(m_point(PX_POINT_IN_E_POLICE_SERVICE_BOUNDARY, PX_SRS_NAME, "point1")))) },
                                                                                                                                                                       "geodetic-2d" // TODO Use a Pixit
                                                                                                                                                                       )
                                                                                                                                                            }
                                                                                                                                                          )
                                                                                                                              )
                                                                                 )
                                                         )));
        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_xml(
                                                                                            mw_body_xml_list_services_by_location_response(
                                                                                                                                           mw_list_services_by_location_response(
                                                                                                                                                                                 { "urn:service:sos.fire", "urn:service:sos.police" },
                                                                                                                                                                                 mw_path({ mw_via }),
                                                                                                                                                                                 -,
                                                                                                                                                                                 mw_location_used(PX_LOST_ID)
                                                                                                                                                                                 )))))) -> value v_response {
            tc_ac.stop;
            
            log("*** " & testcasename() & ": PASS: IUT successfully responds with ListServicesByLocationResponse ***");
            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_ECRF_HTTP_POST_BV_12
    
    /**
     * @desc "IUT successfully responds with configured service types for a ListServicesByLocation request without service element"
     */
    testcase TC_ECRF_HTTP_POST_BV_13() runs on HttpComponent system TestAdapter {
        // Local variables
        var HeaderLines v_headers;
        var HttpMessage v_response;
        
        // Test control
        if (not(PICS_ECRF_IUT) or (not PICS_HTTP_POST_REQUEST) or (not PICS_SERVICE_LOST) or not(PICS_L_LST_GEO1)) {
          log("*** " & testcasename() & ": PICS_ECRF_IUT and PICS_HTTP_POST_REQUEST and PICS_SERVICE_LOST and PICS_L_LST_GEO1 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_ECRF_URI,
                                                         v_headers,
                                                         m_http_message_body_xml(
                                                                                 m_body_xml_list_services_by_location_request(
                                                                                                                              m_list_services_by_location(
                                                                                                                                                          {
                                                                                                                                                            m_location(
                                                                                                                                                                       PX_LOST_ID,
                                                                                                                                                                       { m_extension_point(encvalue_unichar(valueof(m_point(PX_POINT_IN_E_POLICE_SERVICE_BOUNDARY, PX_SRS_NAME, "point1")))) },
                                                                                                                                                                       "geodetic-2d" // TODO Use a Pixit
                                                                                                                                                                       )
                                                                                                                                                            }
                                                                                                                                                          )
                                                                                                                              )
                                                                                 )
                                                         )));
        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_xml(
                                                                                            mw_body_xml_list_services_by_location_response(
                                                                                                                                           mw_list_services_by_location_response(
                                                                                                                                                                                 { "urn:service:sos.police" },
                                                                                                                                                                                 mw_path({ mw_via }),
                                                                                                                                                                                 -,
                                                                                                                                                                                 mw_location_used(PX_LOST_ID)
                                                                                                                                                                                 )))))) -> value v_response {
            tc_ac.stop;
            
            log("*** " & testcasename() & ": PASS: IUT successfully responds with ListServicesByLocationResponse ***");
            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_ECRF_HTTP_POST_BV_13
    
  } // End of group ecrf_role
  
  group esrp_role {
+9 −3
Original line number Diff line number Diff line
@@ -37,9 +37,15 @@ module AtsNg112_TestControl {
            execute(TC_ECRF_HTTP_POST_BV_07());
            execute(TC_ECRF_HTTP_POST_BV_08());
          }
          if (PICS_L_FIS_GEO1) { execute(TC_ECRF_HTTP_POST_BV_09()); }
          if (PICS_L_LST_ALL1) { execute(TC_ECRF_HTTP_POST_BV_10()); }
          if (PICS_L_FIS_GEO1) { execute(TC_ECRF_HTTP_POST_BV_11()); }
          if (PICS_L_FIS_GEO1) {
            execute(TC_ECRF_HTTP_POST_BV_09());
            execute(TC_ECRF_HTTP_POST_BV_11());
            execute(TC_ECRF_HTTP_POST_BV_13());
          }
          if (PICS_L_LST_ALL1) {
            execute(TC_ECRF_HTTP_POST_BV_10());
            execute(TC_ECRF_HTTP_POST_BV_12());
          }
        }
      }
      if (PICS_ESRP_IUT) {
+1624 −0

File added.

Preview size limit exceeded, changes collapsed.

+1601 −0

File added.

Preview size limit exceeded, changes collapsed.