ItsPki_TestCases.ttcn 10.9 KB
Newer Older
garciay's avatar
garciay committed
/**
 *  @author   ETSI / STF545
 *  @version  $URL$
 *            $Id$
 *  @desc     Testcases  file for Security Protocol
 *  @reference   ETSI TS ITS-00546v006
 *  @copyright   ETSI Copyright Notification
 *               No part may be reproduced except as authorized by written permission.
 *               The copyright and the foregoing restriction extend to reproduction in all media.
 *               All rights reserved.
 */
module ItsPki_TestCases {
  // Libcommon
  import from LibCommon_Time all;
  import from LibCommon_VerdictControl all;
  import from LibCommon_Sync all;
  import from LibCommon_BasicTypesAndValues all;
    
  // LibIts
  import from IEEE1609dot2BaseTypes language "ASN.1:1997" all;
  import from IEEE1609dot2 language "ASN.1:1997" all;
  import from EtsiTs102941BaseTypes language "ASN.1:1997" all;
  import from EtsiTs102941TypesEnrolment language "ASN.1:1997" all;
  import from EtsiTs102941MessagesItss language "ASN.1:1997" all;
  import from EtsiTs103097Module language "ASN.1:1997" all;
  import from ITS_Container language "ASN.1:1997" all;
  import from CAM_PDU_Descriptions language "ASN.1:1997" all;
    
  // LibItsCommon
  import from LibItsCommon_Functions all;
  import from LibItsCommon_ASN1_NamedNumbers all;
    
  /* // LibItsCam */
  /* import from LibItsCam_TestSystem all; */
  /* import from LibItsCam_Functions all; */
  /* import from LibItsCam_Templates all; */
  /* import from LibItsCam_TypesAndValues all; */
  /* import from LibItsCam_Pics 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;
    
  // LibItsHttp
  import from LibItsHttp_TypesAndValues all;
  import from LibItsHttp_Templates all;
  import from LibItsHttp_BinaryTemplates all;
  import from LibItsHttp_Functions all;
    
  // LibItsPki
  import from LibItsPki_Templates all;
  import from LibItsPki_TestSystem all;
    
  // AtsPki
  import from ItsPki_Functions all;

  /**
   * @desc 5.2	ITS-S behaviour
   */
  group itss_behavior {

    group itss_manufacturing {

      /**
       * @desc Check that IUT sends an enrolment request when triggered.
       * <pre>
       * Pics Selection: 
       * Initial conditions: 
       *     with {
       *         the IUT being in the "initial state"
       *     }
       * Expected behaviour:
       *     ensure that {
       *         when {
       *             the IUT is triggered to requested a new Enrolment Certificate (EC)
       *         }
       *         then {
       *             the IUT sends to EA an EnrolmentRequestMessage
       *         }
       *     }
       * </pre>
       * 
       * @see       ETSI TS ITS-00546v006 TP 2
       * @reference ETSI TS 102 941 [2], clause 6.1.3
       */
      testcase TC_SEC_PKI_ITSS_ENR_BV_01() runs on ItsPki system ItsPkiSystem {
        // Local variables
        var EtsiTs103097Certificate v_certificate;
        var HeaderLines v_headers;
        var charstring v_hashedId8ToBeUsed := "CERT_TS_A_AT";
    
        // Test control
    
        // Test component configuration
        f_cfUp();
    
        // Test adapter configuration
    
        // Preamble
        f_readCertificate(v_hashedId8ToBeUsed, v_certificate);
        // TODO Trigger UtPkiEnrollmentRequest
        f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
    
        // Test Body
        tc_ac.start;
        alt {
          [] httpPort.receive(
                              mw_http_response(
                                               mw_http_response_ok(
                                                                   mw_http_message_body_binary(
                                                                                               mw_binary_body_innerEcRequest
                                                                                               )))) {
            tc_ac.stop;
            log("*** " & testcasename() & ": PASS: InnerEcRequest was sent ***");
            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
          }
          [] httpPort.receive(
                              mw_http_response(
                                               mw_http_response_ko
                                               )) {
            tc_ac.stop;
            log("*** " & testcasename() & ": FAIL: HTTP error ***");
            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
          }
          [] httpPort.receive(mw_http_response) {
            tc_ac.stop;
            log("*** " & testcasename() & ": FAIL: Unexpected response received ***");
            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
          }
          [] tc_ac.timeout {
            log("*** " & testcasename() & ": INCONC: Expected message not received ***");
            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
          }
        } // End of 'alt' statement
        
        // Postamble
        f_cfDown();
        
      } // End of testcase TC_SEC_PKI_ITSS_ENR_BV_01
      
    } // End of group itss_manufacturing
    
    
  } // End of group itss_behavior
  group ea_behavior {
    
    /**
     * @desc The EnrolmentResponse message shall be sent by the EA to the 
     *       ITS-S across the interface at reference point S3 in response 
     *       to a received EnrolmentRequest message.
     * <pre>
     * Pics Selection: 
     * Initial conditions: 
     *     with {
     *         the IUT being in the "operational state"
     *     }
     * Expected behaviour:
     *     ensure that {
     *         when {
     *             the IUT receives an EnrolmentRequestMessage across the interface at the reference point S3
     *         }
     *         then {
     *             the IUT answers with an EnrolmentResponseMessage across the interface at reference point S3
     *         }
     *     }
     * </pre>
     * 
     * @see       ETSI TS ITS-00546v006 TP 20
     * @reference ETSI TS 102 941, clause 6.2.3.2.2
     */
    testcase TC_SEC_PKI_SND_EA_BV_01() runs on ItsPki system ItsPkiSystem {
      // Local variables
      var EtsiTs103097Certificate v_certificate;
      var HeaderLines v_headers;
      var charstring v_hashedId8ToBeUsed := "CERT_TS_A_AT";
    
      // Test control
    
      // Test component configuration
      f_cfUp();
    
      // Test adapter configuration
    
      // Preamble
      f_readCertificate(v_hashedId8ToBeUsed, v_certificate);
      f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
    
      // Test Body
      f_init_default_headers_list(v_headers);
      httpPort.send(
                    m_http_request(
                                   m_http_request_post(
                                                       "/", 
                                                       v_headers, 
                                                       m_http_message_body_binary(
                                                                                  m_binary_body_innerEcRequest(
                                                                                                               m_innerEcRequest(
                                                                                                                                "TODO",
                                                                                                                                m_publicKeys(
                                                                                                                                             v_certificate.toBeSigned.verifyKeyIndicator.verificationKey,
                                                                                                                                             v_certificate.toBeSigned.encryptionKey
                                                                                                                                             ),
                                                                                                                                m_certificateSubjectAttributes(
                                                                                                                                                               v_certificate.toBeSigned.appPermissions,
                                                                                                                                                               v_certificate.toBeSigned.validityPeriod,
                                                                                                                                                               v_certificate.toBeSigned.region,
                                                                                                                                                               v_certificate.toBeSigned.assuranceLevel
                                                                                                                                                               )))))));
      tc_ac.start;
      alt {
        [] httpPort.receive(
                            mw_http_response(
                                             mw_http_response_ok(
                                                                 mw_http_message_body_binary(
                                                                                             mw_binary_body_innerEcResponse(
                                                                                                                            mw_innerEcResponse_ok
                                                                                                                            ))))) {
          tc_ac.stop;
          log("*** " & testcasename() & ": PASS: InnerEcReponse received ***");
          f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
        }
        [] httpPort.receive(
                            mw_http_response(
                                             mw_http_response_ko
                                             )) {
          tc_ac.stop;
          log("*** " & testcasename() & ": FAIL: HTTP error ***");
          f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
        }
        [] httpPort.receive(mw_http_response) {
          tc_ac.stop;
          log("*** " & testcasename() & ": FAIL: Unexpected response received ***");
          f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
        }
        [] tc_ac.timeout {
          log("*** " & testcasename() & ": INCONC: Expected message not received ***");
          f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
        }
      } // End of 'alt' statement
    
      // Postamble
      f_cfDown();
    
    } // End of testcase TC_SEC_PKI_SND_EA_BV_01

  } // End of group ea_behavior

  group aa_behavior {

  } // End of group aa_beavior
  
} // End of module ItsPki_TestCases