Commit 67ddd7c2 authored by YannGarcia's avatar YannGarcia
Browse files

Validate second AtsMBR test case

parent 9bcf30d5
Loading
Loading
Loading
Loading
+367 −28
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@ module ItsMbr_TestCases {
  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;

  // LibItsCommon
  import from LibItsCommon_TypesAndValues all;
@@ -57,8 +58,334 @@ module ItsMbr_TestCases {
  import from LibItsMbr_Pixits all;
  //import from LibItsMbr_EncdecDeclarations all;

  group CAM {
  // Clause 5.2 Security
  group security {

    /**
     * @desc Check that the IUT generates an encrypted MBR message
     */
    testcase TC_MRS_ITSS_SEC_BV_001() runs on ItsMtc system ItsMbrItssSystem {
      // Local variables
      var ItsMbrItss v_itss;
      var ItsMbrHttp v_ma;
      
      // Test control
      if (not PICS_IUT_ITS_S) {
        log("*** " & testcasename() & ": PICS_IUT_ITS_S required for executing the TC ***");
        setverdict(inconc);
        stop;
      }
      
      // Test component configuration
      f_cfMtcUp01(v_itss, v_ma);
      
      // Start components
      v_itss.start(f_TC_MRS_ITSS_SEC_BV_001_itss());
      v_ma.start(f_TC_MRS_ITSS_SEC_BV_001_ma());
      
      // Synchronization
      f_serverSync2ClientsAndStop({c_prDone, c_tbDone});
      
      // Cleanup
      f_cfMtcDown01(v_itss, v_ma);
      
    } // End of testcase TC_MRS_ITSS_SEC_BV_001
    
    group f_TC_MRS_ITSS_SEC_BV_001 {
      
      function f_TC_MRS_ITSS_SEC_BV_001_itss() runs on ItsMbrItss system ItsMbrItssSystem {
        // Local variables
        var LongPosVector v_longPosVectorIut;
        
        // Test component configuration
        f_cfUp_itss();
        v_longPosVectorIut := f_getPosition(c_compIut);
        
        // Test adapter configuration
        
        // Preamble
        // Initial state: CAM shall be emitted
        f_prNeighbour();
        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_success);
          }
          [] tc_ac.timeout {
            log("*** " & testcasename() & ": INCONC: No CA message received ***");
            f_selfOrClientSyncAndVerdict(c_prDone, e_error);
          }
        } // End of 'alt' statement
        
        // Test Body
        // Send CAM message with inconsistent speed value
        for (var integer i := 0; i < PX_REPEAT_INCONSISTENT_MESSAGE; i := i + 1) {
          f_sendGeoNetMessage(valueof(m_geoNwReq_linkLayerBroadcast(f_prepare_inconsistent_cam(-, true))));
          f_sleepIgnoreDef(PX_REPEAT_INCONSISTENT_MESSAGE_TIMEOUT);
        } // End of 'for' statement
        log("*** " & testcasename() & ": PASS: MR triggered ***");
        f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
        
        // Postamble
        f_poNeighbour();
        f_cfDown_itss();
      } // End of function f_TC_MRS_ITSS_SEC_BV_001_itss
      
      function f_TC_MRS_ITSS_SEC_BV_001_ma() runs on ItsMbrHttp system ItsMbrItssSystem {
        // Local variable
        var HttpMessage  v_request;
        
        // Test component configuration
        f_cfHttpUp(cc_taCert_A, PICS_IUT_MA_CERTIFICATE_ID);
        
        // Test adapter configuration
        
        // Preamble
        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_request.request.header, 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_request.request.header);
            }
            if (v_result != 0) {
              log("*** " & testcasename() & ": FAIL: Failed to verify MR ***");
              f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
            } else {
              log("*** " & testcasename() & ": PASS: MR verified successfully ***");
              f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
            }
          }
          [] 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_SEC_BV_001_mbr
      
    } // End of group f_TC_MRS_ITSS_SEC_BV_001
    
  } // End of group security

  // Clause 5.3.1	CA messages
  group ca_messagess1 {

    // Clause 5.3.1.1	General
    group general {

      /**
       * @desc Check that the IUT provides the certificate of the reported ITS-S when the invalid secured geonetworking packet does not contain the AT certificate
       */
      testcase TC_MRS_ITSS_MESSAGES_001() runs on ItsMtc system ItsMbrItssSystem {
        // Local variables
        var ItsMbrItss v_itss;
        var ItsMbrHttp v_ma;
        
        // 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_ma);
        
        // Start components
        v_itss.start(f_TC_MRS_ITSS_MESSAGES_001_itss());
        v_ma.start(f_TC_MRS_ITSS_MESSAGES_001_ma());
        
        // Synchronization
        f_serverSync2ClientsAndStop({c_prDone, c_tbDone});
        
        // Cleanup
        f_cfMtcDown01(v_itss, v_ma);
        
      } // End of testcase TC_MRS_ITSS_MESSAGES_001
      
      group f_TC_MRS_ITSS_MESSAGES_001 {
        
        function f_TC_MRS_ITSS_MESSAGES_001_itss() runs on ItsMbrItss system ItsMbrItssSystem {
          // Local variables
          var LongPosVector v_longPosVectorIut;
          
          // Test component configuration
          f_cfUp_itss();
          v_longPosVectorIut := f_getPosition(c_compIut);
          
          // Test adapter configuration
          
          // Preamble
          // Initial state: CAM shall be emitted
          f_prNeighbour();
          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_success);
            }
            [] tc_ac.timeout {
              log("*** " & testcasename() & ": INCONC: No CA message received ***");
              f_selfOrClientSyncAndVerdict(c_prDone, e_error);
            }
          } // End of 'alt' statement
          
          // Test Body
          // Send CAM message with inconsistent speed value
          for (var integer i := 0; i < PX_REPEAT_INCONSISTENT_MESSAGE; i := i + 1) {
            f_sendGeoNetMessage(valueof(m_geoNwReq_linkLayerBroadcast(f_prepare_inconsistent_cam(false, true))));
            f_sleepIgnoreDef(PX_REPEAT_INCONSISTENT_MESSAGE_TIMEOUT);
          } // End of 'for' statement
          log("*** " & testcasename() & ": PASS: MR triggered ***");
          f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
          
          // Postamble
          f_poNeighbour();
          f_cfDown_itss();
        } // End of function f_TC_MRS_ITSS_MESSAGES_001_itss
        
        function f_TC_MRS_ITSS_MESSAGES_001_ma() runs on ItsMbrHttp system ItsMbrItssSystem {
          // Local variable
          var InfoPortData v_info_port_data;
          var HttpMessage  v_request;
          
          // Test component configuration
          f_cfHttpUp(cc_taCert_A, PICS_IUT_MA_CERTIFICATE_ID);
          
          // Test adapter configuration
          
          // Preamble
          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;
              var Certificate      v_at_certificate, v_aa_certificate;
              
              tc_ac.stop;

              // Verify IUT response
              f_verify_http_mbr_request_from_iut_itss(v_request.request, v_request.request.header, 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_request.request.header);
              }
              if (v_result != 0) {
                log("*** " & testcasename() & ": FAIL: Failed to verify MR ***");
                f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
              }
              // Validate MR content
              f_prepareCertificates(cc_iutCert_A, v_aa_certificate, v_at_certificate); // cc_iutCert_A is the default value of vc_hashedId8ToBeUsed
              log("Validate MR content: ", match(
                                                 v_etsiTs103759_data.report, 
                                                 mw_cam_specific_report(
                                                                        mw_asr_cam_report_speed(
                                                                                                m_mb_obs_cam_speed_change_too_large, 
                                                                                                { 
                                                                                                  mw_v2x_pdu_stream(
                                                                                                                    1, 
                                                                                                                    -, 
                                                                                                                    PX_REPEAT_INCONSISTENT_MESSAGE - 1,
                                                                                                                    v_at_certificate
                                                                                                                    ) 
                                                                                                  }, 
                                                                                                  {}
                                                ))));
              if (not(match(v_etsiTs103759_data.report, mw_cam_specific_report(mw_asr_cam_report_speed(m_mb_obs_cam_speed_change_too_large, { mw_v2x_pdu_stream(1, -, PX_REPEAT_INCONSISTENT_MESSAGE - 1, v_at_certificate) }, {}))))) {
                log("*** " & testcasename() & ": FAIL: MR content mismatch ***");
                f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
              } else {
                log("*** " & testcasename() & ": PASS: MR received ***");
                f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
              }
            }
            [] 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_001_mbr

      } // End of group f_TC_MRS_ITSS_MESSAGES_001

    } // End of group general

    // Clause 5.3.1.2	Class1
    group class1 {

      /**
@@ -135,9 +462,14 @@ module ItsMbr_TestCases {
          // Test Body
          // Send CAM message with inconsistent speed value
          for (var integer i := 0; i < PX_REPEAT_INCONSISTENT_MESSAGE; i := i + 1) {
            v_inconsistantMessages[lengthof(v_inconsistantMessages)] := f_send_inconsistent_cam(true);
            v_inconsistantMessages[lengthof(v_inconsistantMessages)] := f_prepare_inconsistent_cam(-, true);
          } // End of 'for' statement
          log("InfoPort: ", InfoPortData: { data := v_inconsistantMessages });
          infoPort.send(InfoPortData: { data := v_inconsistantMessages });
          for (var integer i := 0; i < PX_REPEAT_INCONSISTENT_MESSAGE; i := i + 1) {
            f_sendGeoNetMessage(valueof(m_geoNwReq_linkLayerBroadcast(v_inconsistantMessages[i])));
            f_sleepIgnoreDef(PX_REPEAT_INCONSISTENT_MESSAGE_TIMEOUT);
          }
          } // End of 'for' statement
          log("*** " & testcasename() & ": PASS: MR triggered ***");
          f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
          
@@ -148,6 +480,8 @@ module ItsMbr_TestCases {
        
        function f_TC_MRS_ITSS_MESSAGES_CLASS1_CAM_001_ma() runs on ItsMbrHttp system ItsMbrItssSystem {
          // Local variable
          var InfoPortData v_info_port_data;
          var boolean      v_start_awaiting := false;
          var HttpMessage  v_request;
          
          // Test component configuration
@@ -161,7 +495,8 @@ module ItsMbr_TestCases {
          // Test Body
          tc_ac.start;
          alt {
            [] httpPort.receive(
            [v_start_awaiting == true] 
              httpPort.receive(
                               mw_http_request(
                                               mw_http_request_post(
                                                                    PICS_HTTP_POST_URI_MBR,
@@ -187,21 +522,25 @@ module ItsMbr_TestCases {
              } else { // Send HTTP error 500
                f_send_500_Internal_Error(v_request.request.header);
              }
              if (v_result != 0) {
                log("*** " & testcasename() & ": FAIL: Failed to verify MR ***");
                f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
              }
              // Validate MR content
              log("Validate MR content :", match(v_etsiTs103759_data.report, (mw_cam_specific_report(mw_asr_cam_report_speed(m_mb_obs_cam_speed_change_too_large, {mw_v2x_pdu_stream}, {})))));
              if (not(match(v_etsiTs103759_data.report, mw_cam_specific_report(mw_asr_cam_report_speed(m_mb_obs_cam_speed_change_too_large, {mw_v2x_pdu_stream(1, -, PX_REPEAT_INCONSISTENT_MESSAGE - 1)}, {}))))) {
              log("Validate MR content: ", match(v_etsiTs103759_data.report, mw_cam_specific_report(mw_asr_cam_report_speed(m_mb_obs_cam_speed_change_too_large, { mw_v2x_pdu_stream(1, substr(v_info_port_data.data[0].gnPacket.packet.payload, 4/*BTP layer*/, lengthof(v_info_port_data.data[0].gnPacket.packet.payload) - 4), PX_REPEAT_INCONSISTENT_MESSAGE - 1) }, {}))));
              if (not(match(v_etsiTs103759_data.report, mw_cam_specific_report(mw_asr_cam_report_speed(m_mb_obs_cam_speed_change_too_large, { mw_v2x_pdu_stream(1, substr(v_info_port_data.data[0].gnPacket.packet.payload, 4/*BTP layer*/, lengthof(v_info_port_data.data[0].gnPacket.packet.payload) - 4), PX_REPEAT_INCONSISTENT_MESSAGE - 1) }, {}))))) {
                log("*** " & testcasename() & ": FAIL: MR content mismatch ***");
                f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
              }
              // Set verdict
              if (v_result == 0) {
              } else {
                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);
              }
            }
            [] infoPort.receive(InfoPortData:?) -> value v_info_port_data {
              log("*** " & testcasename() & ": INFO: Received inconsistent messages sent ***");
              v_start_awaiting := true;
              repeat;
            }
            [] tc_ac.timeout {
              log("*** " & testcasename() & ": INCONC: Expected message not received ***");
              f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
@@ -216,6 +555,6 @@ module ItsMbr_TestCases {

    } // End of group class1

  } // End of group CAM
  } // End of group ca_messages

} // End of module ItsMbr_TestCases
+15 −12
Original line number Diff line number Diff line
@@ -10,7 +10,10 @@ module ItsMbr_TestControl {

    if (PICS_IUT_ITS_S) {

      execute(TC_MRS_ITSS_SEC_BV_001());

      if (PICS_DETECTOR_CAM_SPEED) {
        execute(TC_MRS_ITSS_MESSAGES_001());
        execute(TC_MRS_ITSS_MESSAGES_CLASS1_CAM_001());
      } // PICS_DETECTOR_CAM_SPEED

+12 −4
Original line number Diff line number Diff line
module LibItsMbr_Pixits {

  /**
   * @desc Number of inconsistent message to send to the IUT
   * @see ETSI TS 103 868-3 Table B.7
   */
  modulepar integer PX_REPEAT_INCONSISTENT_MESSAGE       := 1;

  /**
   * @desc requestTime (in second) between two inconsistent messages
   * @see ETSI TS 103 868-3 Table B.7
   */
  modulepar float PX_REPEAT_INCONSISTENT_MESSAGE_TIMEOUT := 1.0;

  /**
@@ -17,15 +25,15 @@ module LibItsMbr_Pixits {
  modulepar integer PX_MBR_PASSENGER_CAR_SPEED_THRESHOLD := 14000;

  /**
   * @desc Speed threshold value for roadSideUnit(15)
   * @desc Position threshold value for short range communication
   * @see ASN.1 Type definition for SetMbObsTgtsCam
   */
  modulepar integer PX_MBR_RSU_SPEED_THRESHOLD := 0;
  modulepar float PX_MBR_PASSENGER_CAR_POSITION_THRESHOLD := 200.0;

  /**
   * @desc Position threshold value for short range communication
   * @desc Speed threshold value for roadSideUnit(15)
   * @see ASN.1 Type definition for SetMbObsTgtsCam
   */
  modulepar float PX_MBR_PASSENGER_CAR_POSITION_THRESHOLD := 200.0;
  modulepar integer PX_MBR_RSU_SPEED_THRESHOLD := 0;

} // End of module LibItsMbr_Pixits
 No newline at end of file
+60 −36

File changed.

Preview size limit exceeded, changes collapsed.

+9 −4
Original line number Diff line number Diff line
@@ -143,18 +143,23 @@ Package its_mrs_commons {
            SUT component IUT of type ItsHttpComponent
            connection between MA.g and IUT.g;

        Test Configuration CFG_ITS_MRS_02 containing // ETSI TS 103 759 [3], Clause 5.2 Communication assumptions and requirements - Short Range
            Tester component MA of type ItsComponent
            SUT component IUT of type ItsComponent
        Test Configuration CFG_ITS_MRS_02 containing // ETSI TS 103 759 [3], Clause 5.2 Communication assumptions and requirements - Long Range
            Tester component MA of type ItsHttpComponent
            SUT component IUT of type ItsHttpComponent
            connection between MA.g and IUT.g;

        Test Configuration CFG_ITS_MRS_03 containing 
        Test Configuration CFG_ITS_MRS_03 containing  // ETSI TS 103 759 [3], Clause 5.2 Communication assumptions and requirements - Short Range
            Tester component MA of type ItsHttpComponent
            Tester component ITS_S of type ItsComponent
            SUT component IUT of type ItsHttpComponent
            connection between MA.g and IUT.g
            connection between ITS_S.g and IUT.g;

        Test Configuration CFG_ITS_MRS_04 containing // ETSI TS 103 759 [3], Clause 5.2 Communication assumptions and requirements - Long Range
            Tester component ITS_S of type ItsHttpComponent
            SUT component IUT of type ItsHttpComponent
            connection between ITS_S.g and IUT.g;

    } // End of 'Configuration' statement

} // End of Package its_mrs_commons
Loading