ItsPki_TestCases.ttcn 538 KB
Newer Older
ASN.1 Documenter's avatar
ASN.1 Documenter committed
9001 9002 9003 9004 9005 9006 9007 9008 9009 9010 9011 9012 9013 9014 9015 9016 9017 9018 9019 9020 9021 9022 9023 9024 9025 9026 9027 9028 9029 9030 9031 9032 9033 9034 9035 9036 9037 9038 9039 9040 9041 9042 9043 9044 9045 9046 9047 9048 9049 9050 9051 9052 9053 9054 9055 9056 9057 9058 9059 9060 9061 9062 9063 9064 9065 9066 9067 9068 9069 9070 9071 9072 9073 9074 9075 9076 9077 9078 9079 9080 9081 9082 9083 9084 9085 9086 9087 9088 9089 9090 9091 9092 9093 9094 9095 9096 9097 9098 9099 9100 9101 9102 9103 9104 9105 9106 9107 9108 9109 9110 9111 9112 9113 9114 9115 9116 9117 9118 9119 9120 9121 9122 9123 9124 9125 9126 9127 9128 9129 9130 9131 9132 9133 9134 9135 9136 9137 9138 9139 9140 9141 9142 9143 9144 9145 9146 9147 9148 9149 9150 9151 9152 9153 9154 9155 9156 9157 9158 9159 9160 9161 9162 9163 9164 9165 9166 9167 9168 9169 9170 9171 9172 9173 9174 9175 9176 9177 9178 9179 9180 9181 9182 9183 9184 9185 9186 9187 9188 9189 9190 9191 9192 9193 9194 9195 9196 9197 9198 9199 9200 9201 9202 9203 9204 9205 9206 9207 9208 9209 9210 9211 9212 9213 9214 9215 9216 9217 9218 9219 9220 9221 9222 9223 9224 9225 9226 9227 9228 9229 9230 9231 9232 9233 9234 9235 9236 9237 9238 9239 9240 9241 9242 9243 9244 9245 9246 9247 9248 9249 9250 9251 9252 9253 9254 9255 9256 9257 9258 9259 9260 9261 9262 9263 9264 9265 9266 9267 9268 9269 9270 9271 9272 9273 9274 9275 9276 9277 9278 9279 9280 9281 9282 9283 9284 9285 9286 9287 9288 9289 9290 9291 9292 9293 9294 9295 9296 9297 9298 9299 9300 9301 9302 9303 9304 9305 9306 9307 9308 9309 9310 9311 9312 9313 9314 9315 9316 9317 9318 9319 9320 9321 9322 9323 9324 9325 9326 9327 9328 9329 9330 9331 9332 9333 9334 9335 9336 9337 9338 9339 9340 9341 9342 9343 9344
              } else {
                log("*** " & testcasename() & ": FAIL: Receive unexpected message ***");
                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_cfHttpDown_ca();

      } // End of testcase TC_RCA_CTLGEN_01_BV

      testcase TC_RCA_CTLGEN_xx_BV() runs on ItsPkiHttp system ItsPkiHttpSystem {
        // Local variables
        var ToBeSignedRcaCtl v_ctl;
        var Headers v_headers;
        var HttpMessage v_response;
        
        // Test component configuration
        f_cfHttpUp_ca();
        
        // Test control
        if (not PICS_IUT_CA_ROLE) {
          log("*** " & testcasename() & ": PICS_IUT_CA_ROLE required for executing the TC ***");
          setverdict(inconc);
          stop;
        }
        
        // Test component configuration
        f_cfHttpUp_ca();
        
        // Test adapter configuration
        

        /*{
          var Ieee1609Dot2Data v_ieee1609dot2_signed_and_encrypted_data;
          var ToBeSignedRcaCtl p_to_be_signed_rca_ctl;
          var EtsiTs102941Data v_etsi_ts_102941_data;
          var Oct16 v_request_hash;
          var Oct16 v_aes_enc_key;
          var bitstring v_tbs;
          
          f_build_dc_ctl(
                         "CERT_IUT_A_RCA", "CERT_TS_A_AA", "CERT_TS_A_EA",
                         p_to_be_signed_rca_ctl
                         );
          f_sign_dc_ctl("CERT_IUT_A_RCA", p_to_be_signed_rca_ctl, v_ieee1609dot2_signed_and_encrypted_data);
          v_tbs := encvalue(v_ieee1609dot2_signed_and_encrypted_data);
          log("############# ", bit2oct(v_tbs));
          setverdict(inconc);
          stop;
          }*/

        // Preamble
        f_init_default_headers_list(PICS_HEADER_CTL_CONTENT_TYPE, "tlm_request", v_headers);
        f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
        
        // Test Body
        if (f_await_dc_request_send_response("CERT_IUT_A_RCA", "CERT_TS_A_AA", "CERT_TS_A_EA", v_ctl)) {
          log("*** " & testcasename() & ": PASS: ToBeSignedRcaCtl sent ***");
          f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
        } else {
          log("*** " & testcasename() & ": FAIL: Failed to send CTL to the IUT ***");
          f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
        }

        // Postamble
        f_cfHttpDown_ca();

      } // End of testcase TC_RCA_CTLGEN_xx_BV

    } // End of group ctl

    group crl {
    
      /**
       * @desc Check that the RootCA generates the CRL signed with appropriate certificate
       * <pre>
       * Pics Selection: PICS_IUT_CA_ROLE
       * Initial conditions: 
       *     }
       * Expected behaviour:
       *     ensure that {
       *         when {
       *             the RootCA is triggered to add new CA certificate (CERT_CA) to the revocation list
       *         }
       *         then {
       *             the IUT issue a new CRL of type ToBeSignedCrl
       *                 containing emtries
       *                     containing item of type CrlEntry
       *                         indicating HashedId8 of CERT_CA
       *         }
       *     }
       * </pre>
       * 
       * @see       ETSI TS 103 525-2 TP RCA_CRLGEN_01_BV
       * @reference ETSI TS 102 941, clause 6.3.3
       */
      testcase TC_RCA_CRLGEN_01_BV() runs on ItsPkiHttp system ItsPkiHttpSystem {
        // Local variables
        var Headers v_headers;
        var HttpMessage v_response;
        
        // Test control
        if (not PICS_IUT_CA_ROLE) {
          log("*** " & testcasename() & ": PICS_IUT_CA_ROLE required for executing the TC ***");
          setverdict(inconc);
          stop;
        }
        
        // Test component configuration
        f_cfHttpUp_ca();
        
        // Test adapter configuration
        
        // Preamble
        f_init_default_headers_list(PICS_HEADER_CRL_CONTENT_TYPE, "ca_request", v_headers);
        action("the RootCA is triggered to generate new CRL");
        f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
        
        // Test Body
        f_http_send(
                    v_headers,
                    m_http_request(
                                   m_http_request_get(
                                                      PICS_HTTP_GET_URI_CRL,
                                                      v_headers
                                                      )));
        tc_ac.start;
        alt {
          [not(PICS_MULTIPLE_END_POINT)] httpPort.receive(
                                                          mw_http_response(
                                                                           mw_http_response_ok(
                                                                                               mw_http_message_body_binary(
                                                                                                                           mw_binary_body_ieee1609dot2_data(
                                                                                                                                                            mw_etsiTs103097Data_signed(
                                                                                                                                                                                       mw_signedData(
                                                                                                                                                                                                     -,
                                                                                                                                                                                                     mw_toBeSignedData(                                                                                                                                                            mw_signedDataPayload                                                                                                                                        ),
                                                                                                                                                                                                     mw_signerIdentifier_digest
                                                                                                                                                                                                     ))))))) -> value v_response {
            var ToBeSignedCrl v_to_be_signed_crl;

            tc_ac.stop;

            if (f_verify_rca_crl_response_message(v_response.response.body.binary_body.ieee1609dot2_data, true, v_to_be_signed_crl) == false) {
              log("*** " & testcasename() & ": FAIL: Failed to verify RCA message ***");
              f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
            } else {
              if (f_verify_full_crl(v_to_be_signed_crl) == true) {
                log("*** " & testcasename() & ": PASS: ToBeSignedCrl received ***");
                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
              } else {
                log("*** " & testcasename() & ": FAIL: Receive unexpected message ***");
                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
              }
            }
          }
          [PICS_MULTIPLE_END_POINT] httpCaPort.receive(
                                                       mw_http_response(
                                                                        mw_http_response_ok(
                                                                                            mw_http_message_body_binary(
                                                                                                                        mw_binary_body_ieee1609dot2_data(
                                                                                                                                                         mw_etsiTs103097Data_signed(
                                                                                                                                                                                    mw_signedData(
                                                                                                                                                                                                  -,
                                                                                                                                                                                                  mw_toBeSignedData(                                                                                                                                                            mw_signedDataPayload                                                                                                                                        ),
                                                                                                                                                                                                  mw_signerIdentifier_digest
                                                                                                                                                                                                  ))))))) -> value v_response {
            var ToBeSignedCrl v_to_be_signed_crl;

            tc_ac.stop;

            if (f_verify_rca_crl_response_message(v_response.response.body.binary_body.ieee1609dot2_data, true, v_to_be_signed_crl) == false) {
              log("*** " & testcasename() & ": FAIL: Failed to verify RCA message ***");
              f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
            } else {
              if (f_verify_full_crl(v_to_be_signed_crl) == true) {
                log("*** " & testcasename() & ": PASS: ToBeSignedCrl received ***");
                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
              } else {
                log("*** " & testcasename() & ": FAIL: Receive unexpected message ***");
                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_cfHttpDown_ca();

      } // End of testcase TC_RCA_CRLGEN_01_BV

    } // End of group crl

  } // End of group ca_behavior

  group tlm_behavior {
    
    group ctl {

      /**
       * @desc Check that the TLM generates the ECTL when new RootCA is about to be added
       * <pre>
       * Pics Selection: PICS_IUT_CA_ROLE
       * Initial conditions: 
       *     }
       * Expected behaviour:
       *     ensure that {
       *         when {
       *             the TLM is triggered to add new RootCA certificate (CERT_RCA) in the CTL
       *         }
       *         then {
       *             the IUT issue a new CTL of type CtlFormat
       *                 containing isFullCtl
       *                     indicating TRUE
       *                 and containing ctlCommands
       *                     containing CtlCommand
       *                         containing add
       *                             containing rca
       *                                 containing selfsignedRootCa
       *                                     indicating CERT_RCA
       *         }
       *     }
       * </pre>
       * 
       * @see       ETSI TS 103 525-2 TP TLM_ECTLGEN_01_BV
       * @reference ETSI TS 102 941, clause 6.3.1
       */
      testcase TC_TLM_ECTLGEN_01_BV() runs on ItsPkiHttp system ItsPkiHttpSystem {
        // Local variables
        var Headers v_headers;
        var HttpMessage v_response;
        
        // Test control
        if (not PICS_IUT_CA_ROLE) {
          log("*** " & testcasename() & ": PICS_IUT_CA_ROLE required for executing the TC ***");
          setverdict(inconc);
          stop;
        }
        
        // Test component configuration
        f_cfHttpUp_tlm();
        
        // Test adapter configuration
        
        // Preamble
        f_init_default_headers_list(PICS_HEADER_CTL_CONTENT_TYPE, "tlm_request", v_headers);
        action("The TLM is triggered to add new RootCA certificate (CERT_RCA) in the CTL");
        f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
        
        // Test Body
        f_http_send(
                    v_headers,
                    m_http_request(
                                   m_http_request_get(
                                                      PICS_HTTP_GET_URI_ECTL,
                                                      v_headers
                                                      )));
        tc_ac.start;
        alt {
          [not(PICS_MULTIPLE_END_POINT)] httpPort.receive(
                                                          mw_http_response(
                                                                           mw_http_response_ok(
                                                                                               mw_http_message_body_binary(
                                                                                                                           mw_binary_body_ieee1609dot2_data(
                                                                                                                                                            mw_etsiTs103097Data_signed(
                                                                                                                                                                                       mw_signedData(
                                                                                                                                                                                                     -,
                                                                                                                                                                                                     mw_toBeSignedData(                                                                                                                                                            mw_signedDataPayload                                                                                                                                        ),
                                                                                                                                                                                                     - // Certificate or HasedId8
                                                                                                                                                                                                     ))))))) -> value v_response {
            var ToBeSignedTlmCtl v_to_be_signed_tlm_ectl;

            tc_ac.stop;

            // FIXME Can not verify signature, to be checked
            if (f_verify_tlm_ectl_response_message(v_response.response.body.binary_body.ieee1609dot2_data, false, v_to_be_signed_tlm_ectl) == false) {
              log("*** " & testcasename() & ": FAIL: Failed to verify RCA message ***");
              f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
            } else {
              if (f_verify_full_ectl(v_to_be_signed_tlm_ectl) == true) {
                log("*** " & testcasename() & ": PASS: ToBeSignedRcaCtl received ***");
                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
              } else {
                log("*** " & testcasename() & ": FAIL: Receive unexpected message ***");
                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
              }
            }
          }
          [PICS_MULTIPLE_END_POINT] httpTlmPort.receive(
                                                        mw_http_response(
                                                                         mw_http_response_ok(
                                                                                             mw_http_message_body_binary(
                                                                                                                         mw_binary_body_ieee1609dot2_data(
                                                                                                                                                          mw_etsiTs103097Data_signed(
                                                                                                                                                                                     mw_signedData(
                                                                                                                                                                                                   -,
                                                                                                                                                                                                   mw_toBeSignedData(                                                                                                                                                            mw_signedDataPayload                                                                                                                                        ),
                                                                                                                                                                                                   - // Certificate or HasedId8
                                                                                                                                                                                                   ))))))) -> value v_response {
            var ToBeSignedTlmCtl v_to_be_signed_tlm_ectl;

            tc_ac.stop;

            // FIXME Can not verify signature, to be checked
            if (f_verify_tlm_ectl_response_message(v_response.response.body.binary_body.ieee1609dot2_data, false, v_to_be_signed_tlm_ectl) == false) {
              log("*** " & testcasename() & ": FAIL: Failed to verify RCA message ***");
              f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
            } else {
              if (f_verify_full_ectl(v_to_be_signed_tlm_ectl) == true) {
                log("*** " & testcasename() & ": PASS: ToBeSignedRcaCtl received ***");
                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
              } else {
                log("*** " & testcasename() & ": FAIL: Receive unexpected message ***");
                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_cfHttpDown_tlm();

      } // End of testcase TC_TLM_ECTLGEN_01_BV

    } // End of group ctl

  } // End of group tlm_behavior

} // End of module ItsPki_TestCases