Commit 8f7cdd71 authored by YannGarcia's avatar YannGarcia
Browse files

Implementation of first TC

parent b5278366
Loading
Loading
Loading
Loading
+202 −5
Original line number Diff line number Diff line
module ItsMbr_TestCases {
    
  // Libcommon
  import from LibCommon_Time all;
  import from LibCommon_VerdictControl all;
  import from LibCommon_Sync all;
  import from LibCommon_BasicTypesAndValues all;
  import from LibCommon_DataStrings all;
  
  // LibIts
  import from EtsiTs103759Core language "ASN.1:1997" all;
  import from EtsiTs103759BaseTypes language "ASN.1:1997" all;
  import from EtsiTs103759CommonObservations language "ASN.1:1997" all;
  import from EtsiTs103759AsrCam language "ASN.1:1997" all;
  import from Ieee1609Dot2BaseTypes language "ASN.1:1997" all;

  // LibItsCommon
  import from LibItsCommon_TypesAndValues all;
  import from LibItsCommon_Functions all;
  import from LibItsCommon_TypesAndValues all;
  import from LibItsCommon_ASN1_NamedNumbers all;
  
  // LibItsGeoNetworking
  import from LibItsGeoNetworking_TypesAndValues all;
  import from LibItsGeoNetworking_Functions all;
  import from LibItsGeoNetworking_Templates all;
  import from LibItsGeoNetworking_Pics all;
  import from LibItsGeoNetworking_Pixits all;
  import from LibItsGeoNetworking_TestSystem all;

  // LibItsCam
  import from LibItsCam_TypesAndValues all;
  import from LibItsCam_Templates all;
  
  // LibItsSecurity
  import from LibItsSecurity_TypesAndValues all;
  import from LibItsSecurity_TestSystem all;
  import from LibItsSecurity_Templates all;
  import from LibItsSecurity_Functions all;
  import from LibItsSecurity_Pixits all;
  import from LibItsSecurity_Pics all;
  
  // LibHttp
  import from LibHttp_TypesAndValues all;
  import from LibHttp_Templates all;
  import from LibHttp_Functions all;
  import from LibHttp_TestSystem all;
  import from LibHttp_Pics all;
  import from LibHttp_BinaryTemplates all;

  // LibItsMbr
  import from LibItsMbr_TypesAndValues all;
  import from LibItsMbr_Templates all;
  import from LibItsMbr_Functions all;
  import from LibItsMbr_TestSystem all;
  import from LibItsMbr_Pics all;
  import from LibItsMbr_Pixits all;
  //import from LibItsMbr_EncdecDeclarations all;

  group CAM {

    group class1 {

      testcase TC_MRS_ITSS_MESSAGES_CLASS1_CAM_001() runs on ItsMtc system ItsMbrItssSystem {
        // Local variables
        var ItsMbrItss v_itss;
        var ItsMbrHttp v_ea;
        
        // Test control
        if (not PICS_IUT_ITS_S or not PICS_DETECTOR_CAM_SPEED) {
          log("*** " & testcasename() & ": PICS_IUT_ITS_S and PICS_DETECTOR_CAM_SPEED required for executing the TC ***");
          setverdict(inconc);
          stop;
        }
        
        // Test component configuration
        f_cfMtcUp01(v_itss, v_ea);
        
        // Start components
        v_itss.start(f_TC_MRS_ITSS_MESSAGES_CLASS1_CAM_001_itss());
        v_ea.start(f_TC_MRS_ITSS_MESSAGES_CLASS1_CAM_001_mbr());
        
        // Synchronization
        f_serverSync2ClientsAndStop({c_prDone, c_tbDone});
        
        // Cleanup
        f_cfMtcDown01(v_itss, v_ea);
        
      } // End of testcase TC_MRS_ITSS_MESSAGES_CLASS1_CAM_001
      
      group f_TC_MRS_ITSS_MESSAGES_CLASS1_CAM_001 {
        
        function f_TC_MRS_ITSS_MESSAGES_CLASS1_CAM_001_itss() runs on ItsMbrItss system ItsMbrItssSystem {
          // Local variables
          
          // Test component configuration
          vc_hashedId8ToBeUsed := ""; // No certificates //PX_IUT_DEFAULT_CERTIFICATE
          f_cfUp_itss();
          
          // Test adapter configuration
          
          // Preamble
          // Initial state: CAM shall be emitted
          geoNetworkingPort.clear;
          tc_ac.start;
          alt {
            [] geoNetworkingPort.receive(
                                         mw_geoNwInd(
                                                     mw_geoNwSecPdu(
                                                                    mw_etsiTs103097Data_signed(
                                                                                               mw_signedData(
                                                                                                             -, 
                                                                                                             mw_toBeSignedData(
                                                                                                                    mw_signedDataPayload,
                                                                                                                    mw_headerInfo_cam
                                                                                               ))), 
                                                                    mw_geoNwShbPacket
                                         ))) {
              log("*** " & testcasename() & "INFO: CA message received ***");
              f_sendUtMbrTrigger(c_CamTgt_SpeedCommon, c_ObsSpeed_ValueTooLarge_VehicleType);
              f_selfOrClientSyncAndVerdict(c_prDone, e_error);
            }
            [] tc_ac.timeout {
              log("*** " & testcasename() & ": INCONC: No CA message received ***");
              f_selfOrClientSyncAndVerdict(c_prDone, e_success);
            }
          } // End of 'alt' statement
          
          // Test Body
          // TODO Send CAM message with incosistent speed value
          log("*** " & testcasename() & ": PASS: MR triggerd ***");
          f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
          
          // Postamble
          f_cfDown_itss();
        } // End of function f_TC_MRS_ITSS_MESSAGES_CLASS1_CAM_001_itss
        
        function f_TC_MRS_ITSS_MESSAGES_CLASS1_CAM_001_mbr() runs on ItsMbrHttp system ItsMbrItssSystem {
          // Local variable
          var Headers v_headers;
          var HttpMessage v_request;
          
          // Test component configuration
          f_cfHttpUp();
          
          // Test adapter configuration
          
          // Preamble
          f_init_default_headers_list(-, "mbr", v_headers);
          f_selfOrClientSyncAndVerdict(c_prDone, e_success);
          
          // Test Body
          tc_ac.start;
          alt {
            [] httpPort.receive(
                                mw_http_request(
                                                mw_http_request_post(
                                                                     PICS_HTTP_POST_URI_MBR,
                                                                     -,
                                                                     mw_http_message_body_binary(
                                                                                                 mw_binary_body_ieee1609dot2_data(
                                                                                                                                  mw_mrRequestMessage(
                                                                                                                                                      mw_encryptedData(
                                                                                                                                                                       { *, mw_recipientInfo_certRecipInfo(mw_pKRecipientInfo(vc_maHashedId8)), * },
                                                                                                                                                                       mw_symmetricCiphertext_aes128ccm
                                ))))))) -> value v_request {
              var HttpMessage v_response;
              var integer v_result;
              var EtsiTs103759Data v_etsiTs103759_data;
              
              tc_ac.stop;

              // Verify IUT response
              f_verify_http_mbr_request_from_iut_itss(v_request.request, v_headers, v_etsiTs103759_data, v_response, v_result);
              // Send response
              if (isvalue(v_response)) {
                httpPort.send(v_response);
              } else { // Send HTTP error 500
                f_send_500_Internal_Error(v_headers);
              }
              // Set verdict
              if (v_result == 0) {
                log("*** " & testcasename() & ": PASS: MR received ***");
                f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
              } else {
                log("*** " & testcasename() & ": FAIL: Failed to verify MR ***");
                f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
              }
            }
            [] tc_ac.timeout {
              log("*** " & testcasename() & ": INCONC: Expected message not received ***");
              f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
            }
          } // End of 'alt' statement
          
          // Postamble
          f_cfHttpDown();
        } // End of function f_TC_MRS_ITSS_MESSAGES_CLASS1_CAM_001_mbr
        
      } // End of group f_TC_MRS_ITSS_MESSAGES_CLASS1_CAM_001
      
    } // End of group  class1

    // Ats Its
    import from ItsMbr_TpFunctions all;
  } // End of group CAM

} // End of module ItsMbr_TestCases
+18 −0
Original line number Diff line number Diff line
module LibItsMbr_EncdecDeclarations {

  // LibIts
  import from EtsiTs103759Core language "ASN.1:1997" all;
  import from EtsiTs103759CommonObservations language "ASN.1:1997" all;
  import from EtsiTs103759BaseTypes language "ASN.1:1997" all;
  import from Ieee1609Dot2BaseTypes language "ASN.1:1997" all;

  // LibItsSecurity
  import from LibItsSecurity_TypesAndValues all;

  external function fx_enc_EtsiTs103759Data(in EtsiTs103759Data p_etsi_ts_103759_data) return bitstring
  with {extension "prototype(convert) encode(PER)"}

  external function fx_dec_EtsiTs103759Data(inout bitstring b, out EtsiTs103759Data p_etsi_ts_103759_data)return integer
  with {extension "prototype(sliding) decode(PER)"}

} // End of module LibItsMbr_EncdecDeclarations
 No newline at end of file
+6 −0
Original line number Diff line number Diff line
module LibItsMbr_Pics {

  modulepar boolean PICS_IUT_ITS_S := true;

  modulepar boolean PICS_DETECTOR_CAM_SPEED := true;

  modulepar charstring PICS_HTTP_POST_URI_MBR := "/mbr/report";

} // End of module LibItsMbr_Pics
 No newline at end of file
+91 −20
Original line number Diff line number Diff line
@@ -7,18 +7,23 @@ module LibItsMbr_Templates {
  // LibHelpers
  import from LibHelpers_Functions all;

  // LibItsCommon
  import from LibItsCommon_TypesAndValues all;

  // LibMbr
  import from LibItsMbr_TypesAndValues all;

  // LibIts
  import from EtsiTs103759Core language "ASN.1:1997" all;
  import from EtsiTs103759BaseTypes language "ASN.1:1997" all;
  import from EtsiTs103759CommonObservations language "ASN.1:1997" all;
  import from EtsiTs103759AsrCam language "ASN.1:1997" all;
  import from Ieee1609Dot2BaseTypes language "ASN.1:1997" all;
  import from Ieee1609Dot2 language "ASN.1:1997" all;
  import from EtsiTs103097Module language "ASN.1:1997" all;

  // LibItsCommon
  import from LibItsCommon_TypesAndValues all;

  // LibItsSecurity
  import from LibItsSecurity_Templates all;

  // LibMbr
  import from LibItsMbr_TypesAndValues all;

  group mbrPrimitives {

@@ -119,6 +124,20 @@ module LibItsMbr_Templates {
    
  } // End of group mbrPrimitives

  group etsiTs103097Data {

    template (present) EtsiTs103097Data mw_mrRequestMessage(
                                                            template (present) EncryptedData p_encryptedData := ?
                                                            ) modifies mw_etsiTs103097Data_encrypted := {
    } // End of template mw_mrRequestMessage
    
    template (present) EtsiTs103097Data mw_mrResponseMessage(
                                                             template (present) EncryptedData p_encryptedData := ?
                                                             ) modifies mw_etsiTs103097Data_encrypted := {
    } // End of template mw_mrResponseMessage

  } // End of group EtsiTs103097Data

  group etsiTs103759Data {

    template (value) EtsiTs103759Data m_etsiTs103759Data(
@@ -145,24 +164,76 @@ module LibItsMbr_Templates {
      report        := p_report 
    } // End of template mw_etsiTs103759Data

    //template (value) MbSingleObservation
  } // End of group etsiTs103759Data

  group camObservation { // FIXME To be checked

    // template (value) AidSpecificReport m_cam_specific_report(
    //                                                          in template (value) C_ASR_SINGLE_OBS p_content
    //                                                          ) := {
    //   aid   := c_AsrCam,
    //   content := p_content
    // } // End of template m_cam_specific_report

    // template (present) AidSpecificReport mw_cam_specific_report(
    //                                                             template (present) C_ASR_SINGLE_OBS p_content := ?
    //                                                             ) := {
    //   aid   := c_AsrCam,
    //   content := p_content
    // } // End of template mw_cam_specific_report
    template (value) AidSpecificReport m_cam_specific_report(
                                                             in template (value) AidSpecificReport.content p_content
                                                             ) := {
      aid   := c_AsrCam,
      content := p_content
    } // End of template m_cam_specific_report

    template (present) AidSpecificReport mw_cam_specific_report(
                                                                template (present) AidSpecificReport.content p_content := ?
                                                                ) := {
      aid   := c_AsrCam,
      content := p_content
    } // End of template mw_cam_specific_report

    template (value) AsrCam m_asr_cam_report(
                                             in template (value) AsrCam.observations p_observations, 
                                             in template (value) V2xPduStreamList p_v2xPduEvidence,
                                             in template (value) AsrCam.nonV2xPduEvidence p_nonV2xPduEvidence
                                             ) := {
      observations       := p_observations, 
      v2xPduEvidence     := p_v2xPduEvidence,
      nonV2xPduEvidence  := p_nonV2xPduEvidence
    } // End of template m_asr_cam_speed_report

    template (present) AsrCam mw_asr_cam_report(
                                                template (present) AsrCam.observations p_observations := ?, 
                                                template (present) V2xPduStreamList p_v2xPduEvidence := ?,
                                                template (present) AsrCam.nonV2xPduEvidence p_nonV2xPduEvidence := ?
                                                ) := {
      observations       := p_observations, 
      v2xPduEvidence     := p_v2xPduEvidence,
      nonV2xPduEvidence  := p_nonV2xPduEvidence
    } // End of template mw_asr_cam_report

    group speed {

      template (value) ObservationsByTargetSpeed m_obsrvation_speed(
                                                                    in template (value) ObservationsByTargetSpeed.observations p_observations
                                                                    ) := {
        tgtId         := c_CamTgt_SpeedCommon,
        observations  := p_observations
      } // End of template mw_obsrvation_speed

      template (present) ObservationsByTargetSpeed mw_obsrvation_speed(
                                                                       template (present) ObservationsByTargetSpeed.observations p_observations := ?
                                                                       ) := {
        tgtId         := c_CamTgt_SpeedCommon,
        observations  := p_observations
      } // End of template mw_obsrvation_speed

      template (value) MbObsCamSpeed m_mb_obs_cam_speed_vehicle_type := {
        obsId  := c_ObsSpeed_ValueTooLarge_VehicleType,
        obs    := { speed_ValueTooLarge_VehicleType := NULL }
      } // End of template m_mb_obs_cam_speed_vehicle_type

      template (value) MbObsCamSpeed m_mb_obs_cam_speed_drive_direction_reverse := {
        obsId  := c_ObsSpeed_ValueTooLarge_DriveDirectionReverse,
        obs    := { speed_ValueTooLarge_DriveDirectionReverse := NULL }
      } // End of template m_mb_obs_cam_speed_drive_direction_reverse

      template (value) MbObsCamSpeed m_mb_obs_cam_speed_change_too_large := {
        obsId  := c_ObsSpeed_ChangeTooLarge,
        obs    := { speed_ChangeTooLarge := NULL }
      } // End of template m_mb_obs_cam_speed_change_too_large

    } // End of group speed

  } // End of group camObservation

+13 −5
Original line number Diff line number Diff line
@@ -5,9 +5,14 @@ module LibItsMbr_TypesAndValues {
  import from LibCommon_DataStrings all;

  // LibIts
  import from EtsiTs103759BaseTypes language "ASN.1:1997" all;
  import from EtsiTs103759Core language "ASN.1:1997" all;
  import from EtsiTs103759CommonObservations language "ASN.1:1997" all;
  import from Ieee1609Dot2BaseTypes language "ASN.1:1997" all;

  group constants {

    const integer MbrProtocolVersion := 1;

  } // End of group constants

  group utPrimitives {

@@ -21,10 +26,11 @@ module LibItsMbr_TypesAndValues {
      variant "FIELDORDER(msb)"
    }

    type union UtMbrTrigger {
      IdMbObs idMbObs
    type record UtMbrTrigger {
      UInt8 targetId,
      UInt8 cause
    } with {
      variant ""
      variant "FIELDORDER(msb)"
    }

    /**
@@ -96,6 +102,8 @@ module LibItsMbr_TypesAndValues {
    octetstring data
  } // End of type InfoPortData

  type record of V2xPduStream V2xPduStreamList;

} with {
  variant ""
  encode "LibItsMbr"
Loading