Commit 0a2107de authored by Yann Garcia's avatar Yann Garcia
Browse files

Subscribe deletion/lookup and notify TPs implementation for adaptor

parent 5b6b1c11
Loading
Loading
Loading
Loading
+4255 −8

File changed.

Preview size limit exceeded, changes collapsed.

+34 −0
Original line number Diff line number Diff line
@@ -294,66 +294,100 @@ module AtsCise_TestControl {
        execute(TC_CDM_ADAPTOR_PULL_REQUEST_BV_01());
        execute(TC_CDM_ADAPTOR_PULL_DISC_BV_01());
        execute(TC_CDM_ADAPTOR_SUB_BV_01());
        execute(TC_CDM_ADAPTOR_SUB_LOOK_BV_01());
        execute(TC_CDM_ADAPTOR_SUB_DELETE_BV_01());
        execute(TC_CDM_ADAPTOR_NOT_BV_01_01());
        execute(TC_CDM_ADAPTOR_NOT_BV_01_02());
      }

      if (PICS_CDM_ACTION_SERVICE) {
        execute(TC_CDM_ADAPTOR_PULL_REQUEST_BV_02());
        execute(TC_CDM_ADAPTOR_PULL_DISC_BV_02());
        execute(TC_CDM_ADAPTOR_SUB_BV_02());
        execute(TC_CDM_ADAPTOR_SUB_LOOK_BV_02());
        execute(TC_CDM_ADAPTOR_SUB_DELETE_BV_02());
        execute(TC_CDM_ADAPTOR_NOT_BV_02());
      }

      if (PICS_CDM_ANOMALY_SERVICE) {
        execute(TC_CDM_ADAPTOR_PULL_REQUEST_BV_03());
        execute(TC_CDM_ADAPTOR_PULL_DISC_BV_03());
        execute(TC_CDM_ADAPTOR_SUB_BV_03());
        execute(TC_CDM_ADAPTOR_SUB_LOOK_BV_03());
        execute(TC_CDM_ADAPTOR_SUB_DELETE_BV_03());
        execute(TC_CDM_ADAPTOR_NOT_BV_03());
      }

      if (PICS_CDM_CERTIFICATE_DOCUMENT_SERVICE) {
        execute(TC_CDM_ADAPTOR_PULL_REQUEST_BV_04());
        execute(TC_CDM_ADAPTOR_PULL_DISC_BV_04());
        execute(TC_CDM_ADAPTOR_SUB_BV_04());
        execute(TC_CDM_ADAPTOR_SUB_LOOK_BV_04());
        execute(TC_CDM_ADAPTOR_SUB_DELETE_BV_04());
        execute(TC_CDM_ADAPTOR_NOT_BV_04());
      }

      if (PICS_CDM_INCIDENT_SERVICE) {
        execute(TC_CDM_ADAPTOR_PULL_REQUEST_BV_05());
        execute(TC_CDM_ADAPTOR_PULL_DISC_BV_05());
        execute(TC_CDM_ADAPTOR_SUB_BV_05());
        execute(TC_CDM_ADAPTOR_SUB_LOOK_BV_05());
        execute(TC_CDM_ADAPTOR_SUB_DELETE_BV_05());
        execute(TC_CDM_ADAPTOR_NOT_BV_05());
      }

      if (PICS_CDM_IRREGULAR_MIGRATION_INCIDENT_SERVICE) {
        execute(TC_CDM_ADAPTOR_PULL_REQUEST_BV_06());
        execute(TC_CDM_ADAPTOR_PULL_DISC_BV_06());
        execute(TC_CDM_ADAPTOR_SUB_BV_06());
        execute(TC_CDM_ADAPTOR_SUB_LOOK_BV_06());
        execute(TC_CDM_ADAPTOR_SUB_DELETE_BV_06());
        execute(TC_CDM_ADAPTOR_NOT_BV_06());
      }

      if (PICS_CDM_LAW_INFRINGEMENT_INCIDENT_SERVICE) {
        execute(TC_CDM_ADAPTOR_PULL_REQUEST_BV_07());
        execute(TC_CDM_ADAPTOR_PULL_DISC_BV_07());
        execute(TC_CDM_ADAPTOR_SUB_BV_07());
        execute(TC_CDM_ADAPTOR_SUB_LOOK_BV_07());
        execute(TC_CDM_ADAPTOR_SUB_DELETE_BV_07());
        execute(TC_CDM_ADAPTOR_NOT_BV_07());
      }

      if (PICS_CDM_METEO_SERVICE) {
        execute(TC_CDM_ADAPTOR_PULL_REQUEST_BV_08());
        execute(TC_CDM_ADAPTOR_PULL_DISC_BV_08());
        execute(TC_CDM_ADAPTOR_SUB_BV_08());
        execute(TC_CDM_ADAPTOR_SUB_LOOK_BV_08());
        execute(TC_CDM_ADAPTOR_SUB_DELETE_BV_08());
        execute(TC_CDM_ADAPTOR_NOT_BV_08());
      }

      if (PICS_CDM_ORGANIZATION_SERVICE) {
        execute(TC_CDM_ADAPTOR_PULL_REQUEST_BV_09());
        execute(TC_CDM_ADAPTOR_PULL_DISC_BV_09());
        execute(TC_CDM_ADAPTOR_SUB_BV_09());
        execute(TC_CDM_ADAPTOR_SUB_LOOK_BV_09());
        execute(TC_CDM_ADAPTOR_SUB_DELETE_BV_09());
        execute(TC_CDM_ADAPTOR_NOT_BV_09());
      }

      if (PICS_CDM_RISK_SERVICE) {
        execute(TC_CDM_ADAPTOR_PULL_REQUEST_BV_10());
        execute(TC_CDM_ADAPTOR_PULL_DISC_BV_10());
        execute(TC_CDM_ADAPTOR_SUB_BV_10());
        execute(TC_CDM_ADAPTOR_SUB_LOOK_BV_10());
        execute(TC_CDM_ADAPTOR_SUB_DELETE_BV_10());
        execute(TC_CDM_ADAPTOR_NOT_BV_10());
      }

      if (PICS_CDM_CARGO_SERVICE) {
        execute(TC_CDM_ADAPTOR_PULL_REQUEST_BV_11());
        execute(TC_CDM_ADAPTOR_PULL_DISC_BV_11());
        execute(TC_CDM_ADAPTOR_SUB_BV_11());
        execute(TC_CDM_ADAPTOR_SUB_LOOK_BV_11());
        execute(TC_CDM_ADAPTOR_SUB_DELETE_BV_11());
        execute(TC_CDM_ADAPTOR_NOT_BV_11());
      }

    } // PICS_IUT_CDM_ADAPTOR
+216 −1
Original line number Diff line number Diff line
module LibCise_Functions {

  // LibCommon
  //import from LibCommon_Time all;
  import from LibCommon_Time all;
  import from LibCommon_VerdictControl all;
  import from LibCommon_Sync all;

@@ -268,6 +268,175 @@ module LibCise_Functions {
      return v_res_code;
    } // End of function f_process_subscription

    function f_trigger_subscription(
                                    in template (value) UtTrigger p_ut_trigger,
                                    out PullRequest_1 p_pull_request
                                    ) runs on CiseComponent return boolean {
      // Local variables
      var Headers v_headers;
      var HttpMessage v_request;
      var charstring v_created_date_time := f_get_current_date_time();
      var charstring v_message_id := f_generate_uuid();
      var PriorityType v_priority := high;

      log(">>> f_trigger_subscription");

      if (f_ut_trigger(valueof(p_ut_trigger)) == false) {
        log("f_trigger_subscription: Upper Tester failure ***");
        return false;
      }
    
      tc_ac.start;
      alt {
        [] httpPort_notif.receive(
                                  mw_http_request(
                                                  mw_http_request_post(
                                                                        ?,
                                                                        ?,
                                                                        mw_http_message_body_xml(
                                                                                                mw_xml_body_pull_request(
                                                                                                                          mw_pull_request(
                                                                                                                                          -,
                                                                                                                                          -,
                                                                                                                                          -,
                                                                                                                                          mw_service,
                                                                                                                                          -, -,
                                                                                                                                          subscribe,
                                                                                                                                          -, -, -, -, -, -, -, -, -,
                                                                                                                                          mw_service_capability_derivations_subscriptionCapability
                                  )))))) -> value v_request {
            tc_ac.stop;
            p_pull_request := v_request.request.body.xml_body.msg.pull_request;
            // Send Acknowledgement
            f_init_default_headers_list(-, -, v_headers);
            httpPort_notif.send(
                                m_http_response(
                                                m_http_response_ok(
                                                                    m_http_message_body_xml(
                                                                                            m_xml_body_acknowledgement(
                                                                                                                      m_acknowledgement(
                                                                                                                                        v_created_date_time,
                                                                                                                                        v_message_id,
                                                                                                                                        p_pull_request.priority,
                                                                                                                                        {},
                                                                                                                                        success
                                                                                            ))),
                                                                                            v_headers
                                )));

            // Message processing
            f_sleep(PX_MESSAGE_PROCESSING_INTERVAL);
          }
          [] httpPort_notif.receive {
            tc_ac.stop;
            // Send Acknowledgement
            f_init_default_headers_list(-, -, v_headers);
            httpPort_notif.send(
                                m_http_response(
                                                m_http_response_ok(
                                                                    m_http_message_body_xml(
                                                                                            m_xml_body_acknowledgement(
                                                                                                                       m_acknowledgement(
                                                                                                                                         v_created_date_time,
                                                                                                                                         v_message_id,
                                                                                                                                         v_priority,
                                                                                                                                         {},
                                                                                                                                         badRequest
                                                                                            ))),
                                                                                            v_headers
                                )));
            log("f_trigger_subscription: IUT sends an unexpected message ***");
          }
          [] tc_ac.timeout {
            log("f_trigger_subscription: Expected message not received ***");
          }
      } // End of 'alt' statement

      log("<<< f_trigger_subscription");
      return true;
    } // End of function f_trigger_subscription

    function f_trigger_subscription_deletion(
                                             in template (value) UtTrigger p_ut_trigger
                                             ) runs on CiseComponent return boolean {
      // Local variables
      var Headers v_headers;
      var HttpMessage v_request;
      var charstring v_created_date_time := f_get_current_date_time();
      var charstring v_message_id := f_generate_uuid();
      var PriorityType v_priority := high;

      log(">>> f_trigger_subscription_deletion");

      if (f_ut_trigger(valueof(p_ut_trigger)) == false) {
        log("f_trigger_subscription_deletion: Upper Tester failure ***");
        return false;
      }
    
      tc_ac.start;
      alt {
        [] httpPort_notif.receive(
                                  mw_http_request(
                                                  mw_http_request_post(
                                                                        ?,
                                                                        ?,
                                                                        mw_http_message_body_xml(
                                                                                                mw_xml_body_pull_request(
                                                                                                                          mw_pull_request(
                                                                                                                                          -,
                                                                                                                                          -,
                                                                                                                                          -,
                                                                                                                                          mw_service,
                                                                                                                                          -, -,
                                                                                                                                          unsubscribe
                                  )))))) -> value v_request {
            tc_ac.stop;
            // Send Acknowledgement
            f_init_default_headers_list(-, -, v_headers);
            httpPort_notif.send(
                                m_http_response(
                                                m_http_response_ok(
                                                                    m_http_message_body_xml(
                                                                                            m_xml_body_acknowledgement(
                                                                                                                      m_acknowledgement(
                                                                                                                                        v_created_date_time,
                                                                                                                                        v_message_id,
                                                                                                                                        v_request.request.body.xml_body.msg.pull_request.priority,
                                                                                                                                        {},
                                                                                                                                        success
                                                                                            ))),
                                                                                            v_headers
                                )));
          }
          [] httpPort_notif.receive {
            tc_ac.stop;
            // Send Acknowledgement
            f_init_default_headers_list(-, -, v_headers);
            httpPort_notif.send(
                                m_http_response(
                                                m_http_response_ok(
                                                                    m_http_message_body_xml(
                                                                                            m_xml_body_acknowledgement(
                                                                                                                       m_acknowledgement(
                                                                                                                                         v_created_date_time,
                                                                                                                                         v_message_id,
                                                                                                                                         v_priority,
                                                                                                                                         {},
                                                                                                                                         badRequest
                                                                                            ))),
                                                                                            v_headers
                                )));
            log("f_trigger_subscription_deletion: IUT sends an unexpected message ***");
          }
          [] tc_ac.timeout {
            log("f_trigger_subscription_deletion: Expected message not received ***");
          }
      } // End of 'alt' statement

      log("<<< f_trigger_subscription_deletion");
      return true;
    } // End of function f_trigger_subscription_deletion

    function f_process_pull_request_response(
                                             in template (omit) Service p_service,
                                             in template (omit) Service p_recipient,
@@ -512,6 +681,52 @@ module LibCise_Functions {
      return 0;
    } // End of function f_sign_feedback

    function f_sign_push(
                         in Push_1 p_push,
                         in HashAlgorithm p_hash_algorithm,
                         in charstring p_certificate_name,
                         in charstring p_private_key_name,
                         in charstring p_private_key_passwd,
                         out octetstring p_signed_push,
                         out charstring p_push_canonicalized
                         ) return integer {
      var octetstring v_encoded_push;
      var octetstring v_empty_signature;
      var octetstring v_digest;
      var octetstring v_signature;
      var charstring v_x509_certificate_subject;
      var charstring v_x509_certificate_pem;
      var octetstring v_h := char2oct("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>\n");

      // Encode the pull request
      v_encoded_push := bit2oct(encvalue(p_push));
      log("f_sign_push: v_encoded_push: ", v_encoded_push);

      // Encode empty signature
      log("f_sign_push: m_to_be_signed: ", m_to_be_signed);
      v_empty_signature := bit2oct(encvalue(valueof(m_to_be_signed)));
      log("f_sign_push: Empty signature: ", v_empty_signature);

      // Sign the XML document (envelopped signature)
      if (f_sign(v_encoded_push, v_empty_signature, p_certificate_name, p_private_key_name, p_private_key_passwd, v_signature, v_digest, v_x509_certificate_subject, v_x509_certificate_pem, p_push_canonicalized) == -1) {
        log("f_sign_push: failed to sign PullRequest");
        return -1;
      }
      log("f_sign_push: Signature: ", v_signature);

      // Create the XML envelopped signature
      if (f_xml_build_envolopped_signature(v_encoded_push, v_signature, v_digest, v_x509_certificate_subject, "<PullType", v_x509_certificate_pem, p_signed_push) == -1) {
        log("f_sign_push: failed to sign PullRequest");
        return -1;
      }
      log("f_sign_push: p_signed_push: ", p_signed_push);

      // Add XML header, not part of the sugnature
      p_signed_push := v_h & p_signed_push;

      return 0;
    } // End of function f_sign_push

    function f_sign_pull_request_bo(
                                    in PullRequest_1 p_pull_request,
                                    in HashAlgorithm p_hash_algorithm,
+2 −0
Original line number Diff line number Diff line
@@ -129,6 +129,8 @@ module LibCise_Pics {

  modulepar charstring PICS_PUSH_REQUEST_URI := "api/subscribes";

  modulepar charstring PICS_PUSH_URI := "api/notify";

  modulepar charstring PICS_FEEDBACK_URI := "api/feedback";

  modulepar charstring PICS_CISE_ADAPTOR_URI := "/api/v1/messages";
+3 −2
Original line number Diff line number Diff line
@@ -361,10 +361,11 @@ module LibHttp_XmlTemplates {
  group push {

    template (value) XmlBody m_xml_body_push(
                                             in template (value) Push p_push
                                             in template (value) Push p_push,
                                             in template (omit) charstring p_raw := omit
                                             ) := {
      msg := { push := p_push },
      raw := omit
      raw := p_raw
    } // End of template m_xml_body_push

    template (present) XmlBody mw_xml_body_push(