Commit e189f298 authored by Mubeena Ishaq's avatar Mubeena Ishaq
Browse files

Implement TPs, add templates and typing for MEC048

parent d5d414e7
Loading
Loading
Loading
Loading
+1064 −0

File added.

Preview size limit exceeded, changes collapsed.

+56 −0
Original line number Original line Diff line number Diff line
module AtsMec_SelfServiceEnablementAPI_TestControl {
  
  // LibMec/SelfServiceEnablementAPI
  import from SelfServiceEnablementAPI_Pics all;
  
  // LibMec
  import from LibMec_Pics all;
  
  // AtsMec_SelfServiceEnablementAPI
  import from AtsMec_SelfServiceEnablementAPI_TestCases all;
  
  control {

    if (PICS_CSE_API_SUPPORTED) {

      if (PICS_SERVICES) {
        execute(TC_MEC_MEC048_MEO_CSE_001_OK_01());
        execute(TC_MEC_MEC048_MEO_CSE_001_OK_02());
        execute(TC_MEC_MEC048_MEO_CSE_001_OK_03());
        execute(TC_MEC_MEC048_MEO_CSE_002_OK());
        execute(TC_MEC_MEC048_MEO_CSE_002_BR());
        execute(TC_MEC_MEC048_MEO_CSE_003_OK());
        execute(TC_MEC_MEC048_MEO_CSE_003_NF());
        execute(TC_MEC_MEC048_MEO_CSE_004_OK());
        execute(TC_MEC_MEC048_MEO_CSE_004_NF());
        execute(TC_MEC_MEC048_MEO_CSE_004_BR());
        execute(TC_MEC_MEC048_MEO_CSE_005_OK());
        execute(TC_MEC_MEC048_MEO_CSE_005_NF());
        execute(TC_MEC_MEC048_MEO_CSE_006_OK());
        execute(TC_MEC_MEC048_MEO_CSE_006_NF());
        execute(TC_MEC_MEC048_MEO_CSE_007_OK());
        execute(TC_MEC_MEC048_MEO_CSE_007_NF());

        execute(TC_MEC_MEC048_MEO_CSE_013_OK());
        execute(TC_MEC_MEC048_MEO_CSE_013_OK_02());
        execute(TC_MEC_MEC048_MEO_CSE_014_OK());
        execute(TC_MEC_MEC048_MEO_CSE_014_OK_02());
        execute(TC_MEC_MEC048_MEO_CSE_014_BR());
        execute(TC_MEC_MEC048_MEO_CSE_015_OK());
        execute(TC_MEC_MEC048_MEO_CSE_015_NF());
        execute(TC_MEC_MEC048_MEO_CSE_016_OK());
        execute(TC_MEC_MEC048_MEO_CSE_016_NF());
        execute(TC_MEC_MEC048_MEO_CSE_016_BR());
        execute(TC_MEC_MEC048_MEO_CSE_017_OK());
        execute(TC_MEC_MEC048_MEO_CSE_017_NF());

        execute(TC_MEC_MEC048_MEO_CSE_018_OK());
        execute(TC_MEC_MEC048_MEO_CSE_019_OK());
        execute(TC_MEC_MEC048_MEO_CSE_020_OK());
      }

    }

  } // End of 'control' statement

} // End of module AtsMec_SelfServiceEnablementAPI_TestControl
+39 −0
Original line number Original line Diff line number Diff line
suite := AtsMec_SelfServiceEnablementAPI

sources := \
    AtsMec_SelfServiceEnablementAPI_TestCases.ttcn  \
    AtsMec_SelfServiceEnablementAPI_TestControl.ttcn

modules :=  ../LibCommon \
            ../../titan-test-system-framework/ttcn/LibHelpers \
            ../../titan-test-system-framework/ttcn/LibHttp  \
            ../../titan-test-system-framework/ttcn/LibXsd \
            ../../titan-test-system-framework/ttcn/LibJson  \
            ../patch_lib_http \
            ../LibMec \
            ../LibMec/LocationAPI \
            ../LibMec/EdgePlatformApplicationEnablementAPI \
            ../LibMec/ApplicationPackageLifecycleAndOperationGrantingAPI \
            ../LibMec/TrafficManagementAPI \
            ../LibMec/UEAppInterfaceAPI \
            ../LibMec/UEidentityAPI \
            ../LibMec/V2XInformationServiceAPI \
            ../LibMec/DeviceApplicationInterfaceAPI \
            ../LibMec/WlanInformationAPI \
            ../LibMec/FixedAccessInformationServiceAPI \
            ../LibMec/ApplicationMobilityServiceAPI \
            ../LibMec/IoTAPI \
            ../LibMec/FederationEnablementAPI \
            ../LibMec/SelfServiceEnablementAPI \
            ../../titan-test-system-framework/ccsrc/Framework \
            ../../titan-test-system-framework/ccsrc/loggers \
            ../../titan-test-system-framework/ccsrc/Protocols/Http \
            ../../titan-test-system-framework/ccsrc/Protocols/Tcp \
            ../../titan-test-system-framework/ccsrc/Protocols/Xml \
            ../../titan-test-system-framework/ccsrc/Helpers \
            ../../ccsrc/Ports/LibHttp \
            ../../ccsrc/EncDec/LibMec \
            ../../ccsrc/externals \
            ../../ccsrc/Protocols/Http \
            ../../ccsrc/Protocols/Json \
            ../modules/titan.TestPorts.Common_Components.Abstract_Socket \
+6 −0
Original line number Original line Diff line number Diff line
sources := \
    ttcn/SelfServiceEnablementAPI_Pics.ttcn \
    ttcn/SelfServiceEnablementAPI_Pixits.ttcn \
    ttcn/SelfServiceEnablementAPI_Templates.ttcn \
    ttcn/SelfServiceEnablementAPI_Functions.ttcn \
    ttcn/SelfServiceEnablementAPI_TypesAndValues.ttcn
+190 −0
Original line number Original line Diff line number Diff line
module SelfServiceEnablementAPI_Functions {
  
  // JSON
  import from Json all;

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

  // LibHttp
  import from LibHttp_TypesAndValues all;
  import from LibHttp_Functions all;
  import from LibHttp_Templates all;
  import from LibHttp_JsonTemplates all;
  import from LibHttp_TestSystem all;

  // LibMec/SelfServiceEnablementAPI
  import from SelfServiceEnablementAPI_TypesAndValues all;
  import from SelfServiceEnablementAPI_Templates all;
  import from SelfServiceEnablementAPI_Pixits all;

  // LibMec
  import from LibMec_Templates all;
  import from LibMec_Functions all;
  import from LibMec_Pics all;
  import from LibMec_Pixits all;

  function f_create_tenant_info_list(
                                     inout TenantInfoList p_tenant_info_list,
                                     out charstring_list p_tenant_id_list
                                     ) runs on HttpComponent {
    log(">>> f_create_tenant_info_list: ", p_tenant_info_list);
    var charstring v_tenant_id;
    for (var integer i := 0; i < lengthof(p_tenant_info_list); i := i + 1) {
      f_create_tenant_info(p_tenant_info_list[i], v_tenant_id);
      p_tenant_id_list := p_tenant_id_list & { v_tenant_id };
    }
  } // End of function f_create_tenant_info_list

  function f_create_tenant_info(
                                inout TenantInfo p_tenant_info,
                                out charstring p_tenant_id
                                ) runs on HttpComponent {
    var Headers v_headers;
    var HttpMessage v_response;

    log(">>> f_create_tenant_info: ", p_tenant_info);

    f_init_default_headers_list(-, -, v_headers);
    httpPort.send(
                  m_http_request(
                                 m_http_request_post(
                                                     PICS_ROOT_API & PX_CSE_TENANTS_INFO,
                                                     v_headers,
                                                     m_http_message_body_json(
                                                                              m_body_json_cse_tenant_info(p_tenant_info)
                  ))));
    tc_ac.start;
    alt {
      [] httpPort.receive(
                          mw_http_response(
                                          mw_http_response_201_created(
                                                                      mw_http_message_body_json(
                                                                                                mw_body_json_cse_tenant_info(
                                                                                                                              mw_tenant_info(
                                                                                                                                              ?,
                                                                                                                                              ?,
                                                                                                                                              ?,
                                                                                                                                              ?,
                                                                                                                                              ?
                                                                                                                                            )
                          ))))) -> value v_response {
        tc_ac.stop;

        // Extract HTTP Location header
        var charstring_list v_tenant_id;
        f_get_header(v_response.response.header, "Location", v_tenant_id);
        // Extract HTTP tenant id
        p_tenant_id := regexp(
                                    v_tenant_id[0],
                                    "?+" & PX_CSE_TENANTS_INFO & "/(?*)",
                                    0
                                    );

        p_tenant_info := v_response.response.body.json_body.tenantInfo;
        log("f_create_tenant_info: INFO: IUT successfully creates the Tenants: ", p_tenant_info);
      }
      [] tc_ac.timeout {
        log("f_create_tenant_info: INCONC: Expected message not received");
      }
    } // End of 'alt' statement
  
  } // End of function f_create_tenant_info

  function f_delete_tenant_info_list(
                                     in TenantInfoList p_tenant_info_list
                                     ) runs on HttpComponent {
    for (var integer i := 0; i < lengthof(p_tenant_info_list); i := i + 1) {
      if (ispresent(p_tenant_info_list[i].tenantId)) {
        f_delete_tenant_info(p_tenant_info_list[i]);
      }
    }
  } // End of function f_delete_tenant_info_list

  function f_delete_tenant_info(
                                in TenantInfo p_tenant_info
                                ) runs on HttpComponent {
    var Headers v_headers;
    var HttpMessage v_response;
  
    // Check if tenantId is present
    if (not ispresent(p_tenant_info.tenantId)) {
    log("f_delete_tenant_info: INCONC: tenantId not present, cannot delete.");
    return;
    }

    f_init_default_headers_list(-, -, v_headers);
    
    httpPort.send(
                  m_http_request(
                                 m_http_request_delete(
                                                       PICS_ROOT_API & PX_CSE_TENANTS_INFO & "/" & oct2char(unichar2oct(p_tenant_info.tenantId, "UTF-8")),
                                                       v_headers
                  )));
      tc_ac.start;
      alt {
        [] httpPort.receive(
                            mw_http_response(
                                             mw_http_response_204_no_content
                            )) {
          tc_ac.stop;
        }
        [] tc_ac.timeout {
          log("f_delete_tenant_info: INCONC: Expected message not received");
        }
    } // End of 'alt' statement
  
  } // End of function f_delete_tenant_info

  function f_create_resource_quota_info(
                                        inout ResourceQuotaInfo p_resource_quota_info,
                                        in charstring p_tenant_id
                                        ) runs on HttpComponent {
    var Headers v_headers;
    var HttpMessage v_response;

    log(">>> f_create_resource_quota_info: ", p_resource_quota_info);

    f_init_default_headers_list(-, -, v_headers);
    httpPort.send(
                  m_http_request(
                                 m_http_request_post(
                                                     PICS_ROOT_API & PX_CSE_TENANTS_INFO  & "/" & p_tenant_id & "/resources/quota_in_system",
                                                     v_headers,
                                                     m_http_message_body_json(
                                                                              m_body_json_cse_resource_quota_info(
                                                                                                                  m_resource_quota_info(
                                                                                                                                        PX_CPU_QUOTA,
                                                                                                                                        PX_MEMORY_QUOTA,
                                                                                                                                        PX_DISK_QUOTA
                                                                                                                                        )
                  )))));
    tc_ac.start;
    alt {
      [] httpPort.receive(
                          mw_http_response(
                                          mw_http_response_201_created(
                                                                      mw_http_message_body_json(
                                                                                                mw_body_json_cse_resource_quota_info(
                                                                                                                                      mw_resource_quota_info(
                                                                                                                                                              PX_CPU_QUOTA,
                                                                                                                                                              PX_MEMORY_QUOTA,
                                                                                                                                                              PX_DISK_QUOTA
                                                                                                                                                            )
                          ))))) -> value v_response {
        tc_ac.stop;

        p_resource_quota_info := v_response.response.body.json_body.resourceQuotaInfo;
        log("f_create_resource_quota_info: INFO: IUT successfully creates the resources: ", p_resource_quota_info);
      }
      [] tc_ac.timeout {
        log("f_create_resource_quota_info: INCONC: Expected message not received");
      }
    } // End of 'alt' statement
  
  } // End of function f_create_resource_quota_info

  } // End of module SelfServiceEnablementAPI_Functions
Loading