Commit 942d14eb authored by garciay's avatar garciay
Browse files

validate TC_LIS_HTTP_GET_BV_01

parent 642d494c
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@
#include "LibItsHttp_XmlMessageBodyTypes.hh"

#include "urn_ietf_params_xml_ns_geopriv_held.hh"
#include "urn_ietf_params_xml_ns_pidf_geopriv10.hh"

int held_codec::encode (const LibItsHttp__XmlMessageBodyTypes::XmlBody& msg, OCTETSTRING& data)
{
@@ -79,6 +80,10 @@ int held_codec::decode (const OCTETSTRING& p_data, LibItsHttp__XmlMessageBodyTyp
    urn__ietf__params__xml__ns__geopriv__held::LocationResponseType location_response;
    location_response.decode(urn__ietf__params__xml__ns__geopriv__held::LocationResponse_descr_, decoding_buffer, TTCN_EncDec::CT_XER, XER_EXTENDED);
    msg.locationResponse() = location_response;
  } else if (it->second.find("<presence") != std::string::npos) {
    urn__ietf__params__xml__ns__pidf::Presence presence;
    presence.decode(urn__ietf__params__xml__ns__pidf::Presence_descr_, decoding_buffer, TTCN_EncDec::CT_XER, XER_EXTENDED);
    msg.presence() = presence;
  } else if (it->second.find("<error") != std::string::npos) {
    urn__ietf__params__xml__ns__geopriv__held::Error error;
    error.decode(urn__ietf__params__xml__ns__geopriv__held::Error_descr_, decoding_buffer, TTCN_EncDec::CT_XER, XER_EXTENDED);
+9 −3
Original line number Diff line number Diff line
@@ -439,8 +439,11 @@ int http_codec::decode_body(TTCN_Buffer& decoding_buffer, LibItsHttp__MessageBod
       loggers::get_instance().log("http_codec::decode_body: Find xml message");
       LibItsHttp__XmlMessageBodyTypes::XmlBody xml_body;
       // 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["decode_str"].find("xmlns=\"urn:ietf:params:xml:ns:geopriv:held\">") != std::string::npos) {
         loggers::get_instance().log("http_codec::decode_body: Find 'urn:ietf:params:xml:ns:geopriv:held'");
       if (
           (p["decode_str"].find("xmlns=\"urn:ietf:params:xml:ns:geopriv:held\">") != std::string::npos) ||
           (p["decode_str"].find("xmlns=\"urn:ietf:params:xml:ns:pidf\">") != std::string::npos)
           ) {
         loggers::get_instance().log("http_codec::decode_body: Identified Held'");
         if (_codecs["held"].get() != nullptr) {
           loggers::get_instance().log("http_codec::decode_body: Call 'held_codec'");
           if (_codecs["held"]->decode(body, (Record_Type&)xml_body, &p) == -1) {
@@ -471,6 +474,9 @@ int http_codec::decode_body(TTCN_Buffer& decoding_buffer, LibItsHttp__MessageBod
           xml_body.raw() = CHARSTRING(body.lengthof(), (char*)static_cast<const unsigned char*>(body));
         }
         message_body.xml__body() = xml_body;
       } else {
         loggers::get_instance().warning("http_codec::decode_body: No codec found");
         xml_body.raw() = CHARSTRING(body.lengthof(), (char*)static_cast<const unsigned char*>(body));
       }
    } else if (p["decode_str"].find("<html>") != std::string::npos) { // Try to identify HTML
      loggers::get_instance().log("http_codec::decode_body: Find html message");
+41 −50
Original line number Diff line number Diff line
@@ -21,6 +21,11 @@ module AtsNg112_TestCases {
    with {
        extension "File:../xsd/RFC6155_held_id.xsd";
    }
  // RFC3863 PIDF
  import from urn_ietf_params_xml_ns_pidf language "XSD" all
  with {
    extension "File:../xsd/urn_ietf_params_xml_ns_pidf.ttcn"
  }
  import from urn_ietf_params_xml_ns_pidf_geopriv10 language "XSD" all
    with {
        extension "File:../xsd/RFC4119_geopriv10.xsd";
@@ -781,7 +786,7 @@ module AtsNg112_TestCases {
    testcase TC_LIS_HTTP_GET_BV_01() runs on HttpComponent system TestAdapter {
        // Local variables
        var HeaderLines v_headers;
        var HttpMessage v_response, v_response1;
        var HttpMessage v_response;
        
        // Test control
        if (not(PICS_LIS_IUT) or (not PICS_HTTP_GET_REQUEST) or (not PICS_LOCATION_HELD)) {
@@ -824,24 +829,26 @@ module AtsNg112_TestCases {
                                                                                                                          mw_locationResponse(
                                                                                                                                              mw_locationUriSet
                                                                                                                                              )
                                                                                                                          ))))) -> value v_response1 {
                                                                                                                          ))))) -> value v_response {
            var template charstring v_uri_pattern := "(http[s]#(0,1))://([^:/\\s]+)/(?+)";
            var charstring v_uri;
            var charstring v_scheme;
            var charstring v_host;
            var charstring v_params;

            tc_ac.stop;
            f_sleep(1.0);

            // Extract link details
            v_uri := oct2char(unichar2oct(v_response.response.body.xml_body.locationResponse.locationUriSet.locationURI_list[0]));
            v_scheme := regexp(v_uri, v_uri_pattern, 0);
          v_host := regexp(v_uri, v_uri_pattern, 1); // FIXME Add support of a different host
            v_params := "/" & regexp(v_uri, v_uri_pattern, 2);
            // Send the GET request
            httpPort.send(
                          m_http_request(
                                         m_http_request_get(
                                                            PICS_LIS_URI,
                                                            v_headers,
                                                            m_http_message_body_xml(m_body_xml_location_request(
                                                                                                                m_locationRequest(
                                                                                                                                  { encvalue_unichar(valueof(m_device({ "<uri>" & v_response1.response.body.xml_body.locationResponse.locationUriSet.locationURI_list[0] & "</uri>" }))) },
                                                                                                                                  m_locationTypeType(
                                                                                                                                                     m_locationTypeBase_locationUri,
                                                                                                                                                     true
                                                                                                                                                     )
                                                                                                                                  )
                                                                                                                )
                                                                                     )
                                                            v_params,
                                                            v_headers
                                                            )
                                         )
                          );
@@ -866,10 +873,9 @@ module AtsNg112_TestCases {
                              mw_http_response(
                                               mw_http_response_ok(
                                                                   mw_http_message_body_xml(
                                                                                            mw_body_xml_location_response(
                                                                                                                          mw_locationResponse(-, ?)
                                                                                            mw_body_xml_presence(
                                                                                                                 mw_presence(-, { mw_tuple })
                                                                                                                 ))))) -> value v_response {
            var Presence v_presence;
            var Tuple v_tuple;
            var Geopriv v_geopriv;
            var Circle v_circle;
@@ -877,15 +883,8 @@ module AtsNg112_TestCases {
            var integer v_result;
            
            tc_ac.stop;
            log("##################################### ", v_response);
            // Extract presence element from Location-Response
            v_temp := v_response.response.body.xml_body.locationResponse.elem_list[0];
            v_result := decvalue_unichar(v_temp, v_presence);
            if (v_result == 0) {
              log(match(v_presence, mw_presence)); // FIXME Required by TITAN to get details in case of mismatch
              if (match(v_presence, mw_presence)) {
            // Extract first Tuple element from Presence
                v_tuple := v_presence.tuple_list[0];
            v_tuple := v_response.response.body.xml_body.presence.tuple_list[0];
            v_temp := v_tuple.status.elem_list[0];
            // Extract Geopriv element from Tuple
            v_result := decvalue_unichar(v_temp, v_geopriv);
@@ -911,14 +910,6 @@ module AtsNg112_TestCases {
              log("*** " & testcasename() & ": FAIL: Unexpected response ***");
              f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
            }
              } else {
                log("*** " & testcasename() & ": FAIL: Unexpected response ***");
                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
              }
            } else {
              log("*** " & testcasename() & ": FAIL: Unexpected response ***");
              f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
            }
          }
          [] tc_ac.timeout {
            log("*** " & testcasename() & ": INCONC: Expected message not received ***");
+8 −1
Original line number Diff line number Diff line
@@ -11,6 +11,12 @@ module LibItsHttp_XmlMessageBodyTypes {
    extension "File:../xsd/RFC5985_held.xsd";
  }

  // RFC3863 PIDF
  import from urn_ietf_params_xml_ns_pidf language "XSD" all
  with {
    extension "File:../xsd/urn_ietf_params_xml_ns_pidf.ttcn"
  }
  
  // RFC5222
  import from urn_ietf_params_xml_ns_lost1 language "XSD" all
  with {
@@ -18,7 +24,7 @@ module LibItsHttp_XmlMessageBodyTypes {
  }
  
  /**
   * This file volontary contains a trivial declaration of the type XmlBodu. 
   * This file volontary contains a trivial declaration of the type XmlBody. 
   * In accordance with your TTCN-3 module LibItsHttp_XMLTypes, you have to change the XmlBody typing.
   */
  // TODO Add here your custom RFCs import
@@ -27,6 +33,7 @@ module LibItsHttp_XmlMessageBodyTypes {
    // TODO Add here your custom variants
    LocationRequest     locationRequest,
    LocationResponse    locationResponse,
    Presence            presence,
    ErrorType           errorType,
    FindService         findServiceRequest,
    FindServiceResponse findServiceResponse,
+17 −7
Original line number Diff line number Diff line
@@ -22,6 +22,11 @@ module LibItsHttp_XmlTemplates {
    with {
        extension "File:../xsd/RFC6155_held_id.xsd";
    }
  // RFC3863 PIDF
  import from urn_ietf_params_xml_ns_pidf language "XSD" all
  with {
    extension "File:../xsd/urn_ietf_params_xml_ns_pidf.ttcn"
  }
  import from urn_ietf_params_xml_ns_pidf_geopriv10 language "XSD" all
    with {
        extension "File:../xsd/RFC4119_geopriv10.xsd";
@@ -95,6 +100,12 @@ module LibItsHttp_XmlTemplates {
        locationResponse := p_locationResponse
      } // End of template mw_body_xml_location_response

      template (present) XmlBody mw_body_xml_presence(
                                                      in template (present) Presence p_presence := ?
      ) := {
        presence := p_presence
      } // End of template mw_body_xml_presence

      template (present) XmlBody mw_body_xml_location_response_error(
                                                                     in template (present) ErrorType p_error_type := ?
      ) := {
@@ -219,13 +230,12 @@ module LibItsHttp_XmlTemplates {
      elem_list  := {}
    } // End of template mw_presence
    
    template (present) Tuple mw_tuple(
                                      template (present) universal charstring p_id,
    template Tuple mw_tuple(
                            template (present) universal charstring p_id := ?,
                            template (present) Status p_status := ?,
                            template (present) Tuple.elem_list p_elem_list := {},
                            template (present) Tuple.note_list p_note_list := {},
                            template Contact p_contact := *
                                      // TODO To be completed
    ) := {
      id        := p_id,
      status    := p_status,
Loading