From 2dd0cf99c079fd1492fadce5dfeabb0d8b6b4717 Mon Sep 17 00:00:00 2001
From: piscione <piscione@etsi.org>
Date: Fri, 17 Nov 2023 18:50:09 +0100
Subject: [PATCH] Implemented some of the TCs with filters for MEC040
 specification

---
 MEC040/SRV/FederationEnablement.robot         | 207 ++++++++++++++++++
 MEC040/SRV/environment/variables.txt          |  33 +++
 MEC040/SRV/jsons/SystemInfo.json              |   5 +
 MEC040/SRV/schemas/SystemInfo.schema.json     |  24 ++
 MEC040/SRV/schemas/SystemInfoList.schema.json |  27 +++
 5 files changed, 296 insertions(+)
 create mode 100644 MEC040/SRV/FederationEnablement.robot
 create mode 100644 MEC040/SRV/environment/variables.txt
 create mode 100644 MEC040/SRV/jsons/SystemInfo.json
 create mode 100644 MEC040/SRV/schemas/SystemInfo.schema.json
 create mode 100644 MEC040/SRV/schemas/SystemInfoList.schema.json

diff --git a/MEC040/SRV/FederationEnablement.robot b/MEC040/SRV/FederationEnablement.robot
new file mode 100644
index 0000000..c897a25
--- /dev/null
+++ b/MEC040/SRV/FederationEnablement.robot
@@ -0,0 +1,207 @@
+Y''[Documentation]   robot --outputdir ../../../outputs ./FederationEnablement.robot
+...    Test Suite to validate the Federation Enablement API (FED) operations.
+
+*** Settings ***
+Resource    environment/variables.txt
+Resource    ../../pics.txt
+Resource    ../../GenericKeywords.robot
+Library     REST    ${SCHEMA}://${HOST}:${PORT}    ssl_verify=false
+Library     OperatingSystem    
+
+*** Test Cases ***
+TP_MEC_MEC040_SRV_MEF_001_OK
+    [Documentation]
+    ...  Check that the IUT responds with a list of all available systemInfo 
+    ...  when requested by a MEC Orchestrator - No query parameters
+    ...  ETSI GS MEC 040 V3.1.1, clause 7.3.3.1, clause 5.2.2.2
+    ...  https://www.etsi.org/deliver/etsi_gs/mec/001_099/040/03.01.01_60/gs_mec040v030101p.pdf
+    Retrieve all system info resources
+    Check HTTP Response Status Code Is    200
+    Check HTTP Response Body Json Schema Is  SystemInfoList
+
+
+TP_MEC_MEC040_SRV_MEF_001_OK_02
+    [Documentation]
+    ...  Check that the IUT responds with a selection of all available systemInfo
+    ...  when requested by a MEC Orchestrator - SystemId query parameters
+    ...  ETSI GS MEC 040 V3.1.1, clause 7.3.3.1, clause 5.2.2.2
+    ...  https://www.etsi.org/deliver/etsi_gs/mec/001_099/040/03.01.01_60/gs_mec040v030101p.pdf
+    Retrieve all system info resources with query params   ${SYSTEM_ID_QUERY_PARAM}
+    Check HTTP Response Status Code Is    200
+    Check HTTP Response Body Json Schema Is  SystemInfoList
+    FOR  ${element}  IN  @{response['body']}
+      Should Be Equal As Strings    ${element}[systemId]      ${EXPECTED_SYSTEM_ID}
+    END
+
+TP_MEC_MEC040_SRV_MEF_001_OK_03
+    [Documentation]
+    ...  Check that the IUT responds with a selection of all available systemInfo 
+    ...  when requested by a MEC Orchestrator - Multiple SystemId query parameters
+    ...  ETSI GS MEC 040 V3.1.1, clause 7.3.3.1, clause 5.2.2.2
+    ...  https://www.etsi.org/deliver/etsi_gs/mec/001_099/040/03.01.01_60/gs_mec040v030101p.pdf
+    Retrieve all system info resources with query params   ${MULTIPLE_SYSTEM_ID_QUERY_PARAM}
+    Check HTTP Response Status Code Is    200
+    Check HTTP Response Body Json Schema Is  SystemInfoList
+    
+    FOR  ${element}  IN  @{response['body']}
+      IF    '''${element}[systemId]''' == '''${EXPECTED_SYSTEM_ID}'''
+        ${item}    Set Variable   ${TRUE}
+      END
+      IF    '''${element}[systemId]''' == '''${EXPECTED_SYSTEM_ID2}'''
+        ${item2}    Set Variable   ${TRUE}
+      END
+    END
+    Should Be True  ${item}
+    Should Be True  ${item2}
+   
+TP_MEC_MEC040_SRV_MEF_001_OK_04
+    [Documentation]
+    ...  Check that the IUT responds with a selection of all available systemInfo
+    ...  when requested by a MEC Orchestrator - Empty SystemId query parameters
+    ...  ETSI GS MEC 040 V3.1.1, clause 7.3.3.1, clause 5.2.2.2
+    ...  https://www.etsi.org/deliver/etsi_gs/mec/001_099/040/03.01.01_60/gs_mec040v030101p.pdf
+    Retrieve all system info resources
+    Check HTTP Response Status Code Is    200
+    Check HTTP Response Body Json Schema Is  SystemInfoList
+
+TP_MEC_MEC040_SRV_MEF_001_OK_05
+    [Documentation]
+    ...  Check that the IUT responds with a selection of all available systemInfo
+    ...  when requested by a MEC Orchestrator - SystemName query parameters
+    ...  ETSI GS MEC 040 V3.1.1, clause 7.3.3.1, clause 5.2.2.2
+    ...  https://www.etsi.org/deliver/etsi_gs/mec/001_099/040/03.01.01_60/gs_mec040v030101p.pdf
+    Retrieve all system info resources with query params   ${SYSTEM_NAME_QUERY_PARAM}
+    Check HTTP Response Status Code Is    200
+    Check HTTP Response Body Json Schema Is  SystemInfoList
+    FOR  ${element}  IN  @{response['body']}
+      Should Be Equal As Strings    ${element}[systemName]      ${EXPECTED_SYSTEM_NAME}
+    END
+
+TP_MEC_MEC040_SRV_MEF_001_OK_06
+    [Documentation]
+    ...  Check that the IUT responds with a selection of all available systemInfo
+    ...  when requested by a MEC Orchestrator - Multiple SystemName query parameters
+    ...  ETSI GS MEC 040 V3.1.1, clause 7.3.3.1, clause 5.2.2.2
+    ...  https://www.etsi.org/deliver/etsi_gs/mec/001_099/040/03.01.01_60/gs_mec040v030101p.pdf
+    Retrieve all system info resources with query params     ${MUTIPLE_SYSTEM_NAME_QUERY_PARAM}
+    Check HTTP Response Status Code Is    200
+    Check HTTP Response Body Json Schema Is  SystemInfoList
+    FOR  ${element}  IN  @{response['body']}
+      IF    '''${element}[systemName]''' == '''${EXPECTED_SYSTEM_NAME}'''
+        ${item}    Set Variable   ${TRUE}
+      END
+      IF    '''${element}[systemName]''' == '''${EXPECTED_SYSTEM_NAME2}'''
+        ${item2}    Set Variable   ${TRUE}
+      END
+    END
+    Should Be True  ${item}
+    Should Be True  ${item2}
+
+
+TP_MEC_MEC040_SRV_MEF_001_OK_07
+    [Documentation]
+    ...  Check that the IUT responds with a selection of all available systemInfo
+    ...  when requested by a MEC Orchestrator - Empty SystemName query parameters
+    ...  ETSI GS MEC 040 V3.1.1, clause 7.3.3.1, clause 5.2.2.2
+    ...  https://www.etsi.org/deliver/etsi_gs/mec/001_099/040/03.01.01_60/gs_mec040v030101p.pdf
+    Retrieve all system info resources with query params     ${EMPTY_SYSTEM_NAME_QUERY_PARAM}
+    Check HTTP Response Status Code Is    200
+    Check HTTP Response Body Json Schema Is  SystemInfoList
+    FOR  ${element}  IN  @{response['body']}
+      Should Be Equal As Strings    ${element}[systemName]      ${EMPTY}
+    END
+
+TP_MEC_MEC040_SRV_MEF_001_OK_08
+    [Documentation]
+    ...  Check that the IUT responds with a selection of all available systemInfo
+    ...  when requested by a MEC Orchestrator - systemProvider query parameters
+    ...  ETSI GS MEC 040 V3.1.1, clause 7.3.3.1, clause 5.2.2.2
+    ...  https://www.etsi.org/deliver/etsi_gs/mec/001_099/040/03.01.01_60/gs_mec040v030101p.pdf
+    Retrieve all system info resources with query params     ${SYSTEM_PROVIDER_QUERY_PARAM}
+    Check HTTP Response Status Code Is    200
+    Check HTTP Response Body Json Schema Is  SystemInfoList
+    FOR  ${element}  IN  @{response['body']}
+      Should Be Equal As Strings    ${element}[systemProvider]      ${EXPECTED_SYSTEM_PROVIDER}
+    END    
+
+TP_MEC_MEC040_SRV_MEF_001_OK_09
+    [Documentation]
+    ...  Check that the IUT responds with a selection of all available systemInfo
+    ...  when requested by a MEC Orchestrator - Multiple systemProvider query parameters
+    ...  ETSI GS MEC 040 V3.1.1, clause 7.3.3.1, clause 5.2.2.2
+    ...  https://www.etsi.org/deliver/etsi_gs/mec/001_099/040/03.01.01_60/gs_mec040v030101p.pdf
+    Retrieve all system info resources with query params   ${MUTIPLE_SYS_PROVIDER_QUERY_PAR}
+    Check HTTP Response Status Code Is    200
+    Check HTTP Response Body Json Schema Is  SystemInfoList
+    FOR  ${element}  IN  @{response['body']}
+      IF    '''${element}[systemProvider]''' == '''${EXPECTED_SYSTEM_PROVIDER}'''
+        ${item}    Set Variable   ${TRUE}
+      END
+      IF    '''${element}[systemProvider]''' == '''${EXPECTED_SYSTEM_PROVIDER2}'''
+        ${item2}    Set Variable   ${TRUE}
+      END
+    END
+    Should Be True  ${item}
+    Should Be True  ${item2} 
+
+
+TP_MEC_MEC040_SRV_MEF_001_OK_10
+    [Documentation]
+    ...  Check that the IUT responds with a selection of all available systemInfo
+    ...  when requested by a MEC Orchestrator - Empty systemProvider query parameters
+    ...  ETSI GS MEC 040 V3.1.1, clause 7.3.3.1, clause 5.2.2.2
+    ...  https://www.etsi.org/deliver/etsi_gs/mec/001_099/040/03.01.01_60/gs_mec040v030101p.pdf
+    Retrieve all system info resources with query params   ${EMPTY_SYSTEM_PROVIDER_QUERY_PARAM}
+    Check HTTP Response Status Code Is    200
+    Check HTTP Response Body Json Schema Is  SystemInfoList
+    FOR  ${element}  IN  @{response['body']}
+      Should Be Equal As Strings    ${element}[systemProvider]      ${EMPTY}
+    END
+    
+TP_MEC_MEC040_SRV_MEF_001_OK_11
+    [Documentation]
+    ...  Check that the IUT responds with a selection of all available systemInfo
+    ...  when requested by a MEC Orchestrator - Multiple query parameters
+    ...  ETSI GS MEC 040 V3.1.1, clause 7.3.3.1, clause 5.2.2.2
+    ...  https://www.etsi.org/deliver/etsi_gs/mec/001_099/040/03.01.01_60/gs_mec040v030101p.pdf
+    Retrieve all system info resources with query params   ${FILTER_ON_SYSTEM_ID_AND_NAME}
+    Check HTTP Response Status Code Is    200
+    Check HTTP Response Body Json Schema Is  SystemInfoList
+    ${counterSystemId}    Set Variable    ${0}
+    ${counterSystemName}  Set Variable    ${0}
+    FOR  ${element}  IN  @{response['body']}
+      IF    '''${element}[systemId]''' == '''${EXPECTED_SYSTEM_ID}'''
+        ${counterSystemId}=  set variable  ${counterSystemId+1}
+      END
+      IF    '''${element}[systemId]''' == '''${EXPECTED_SYSTEM_ID}'''
+         ${counterSystemName}=  set variable  ${counterSystemName+1}
+      END
+      ${counterSystemName}=  set variable  ${counterSystemName+1}
+    END
+    Should Be True    '${counterSystemName}'>'0'
+    Should Be True    '${counterSystemId}'>'0'
+                                    
+############################################################################
+      
+*** Keywords ***
+Retrieve all system info resources
+    Should Be True    ${PIC_MEC_PLAT} == 1
+    Should Be True    ${PIC_SERVICES} == 1
+    Set Headers    {"Accept":"application/json"}
+    Set Headers    {"Content-Type":"*/*"}
+    Set Headers    {"Authorization":"${TOKEN}"}
+    GET   ${apiRoot}/${apiName}/${apiVersion}/fed_resources/system_info
+    ${output}=    Output    response
+    Set Suite Variable    ${response}    ${output}
+    
+
+Retrieve all system info resources with query params
+    [Arguments]     ${query_params}
+    Should Be True    ${PIC_MEC_PLAT} == 1
+    Should Be True    ${PIC_SERVICES} == 1
+    Set Headers    {"Accept":"application/json"}
+    Set Headers    {"Content-Type":"*/*"}
+    Set Headers    {"Authorization":"${TOKEN}"}
+    GET   ${apiRoot}/${apiName}/${apiVersion}/fed_resources/system_info?${query_params}
+    ${output}=    Output    response
+    Set Suite Variable    ${response}    ${output}
\ No newline at end of file
diff --git a/MEC040/SRV/environment/variables.txt b/MEC040/SRV/environment/variables.txt
new file mode 100644
index 0000000..8c8cc9e
--- /dev/null
+++ b/MEC040/SRV/environment/variables.txt
@@ -0,0 +1,33 @@
+*** Variables ***
+# Generic variables
+${SCHEMA}                               http
+${HOST}                                 127.0.0.1
+${PORT}                                 8084
+${response}                             {}
+${TOKEN}                                YWxhZGRpbjpvcGVuc2VzYW1l
+${apiRoot}        
+${apiName}                              fed-enablement
+${apiVersion}                           v1
+
+${EXPECTED_SYSTEM_ID}                   SYSTEM_ID
+${EXPECTED_SYSTEM_ID2}                  SYSTEM_ID2
+${SYSTEM_ID_QUERY_PARAM}                systemId=${EXPECTED_SYSTEM_ID} 
+${MULTIPLE_SYSTEM_ID_QUERY_PARAM}       systemId=${EXPECTED_SYSTEM_ID},${EXPECTED_SYSTEM_ID2}
+${EMPTY_SYSTEM_ID_QUERY_PARAM}          systemId=
+
+${EXPECTED_SYSTEM_NAME}                 SYSTEM_NAME
+${EXPECTED_SYSTEM_NAME2}                SYSTEM_NAME2
+${SYSTEM_NAME_QUERY_PARAM}              systemName=${EXPECTED_SYSTEM_NAME}
+${MUTIPLE_SYSTEM_NAME_QUERY_PARAM}      systemName=${EXPECTED_SYSTEM_NAME},${EXPECTED_SYSTEM_NAME2}    
+${EMPTY_SYSTEM_NAME_QUERY_PARAM}        systemName=
+
+${EXPECTED_SYSTEM_PROVIDER}             SYSTEM_PROVIDER
+${EXPECTED_SYSTEM_PROVIDER2}            SYSTEM_PROVIDER2
+${SYSTEM_PROVIDER_QUERY_PARAM}          systemProvider=${EXPECTED_SYSTEM_PROVIDER}
+${MUTIPLE_SYS_PROVIDER_QUERY_PAR}       systemProvider=${EXPECTED_SYSTEM_PROVIDER},${EXPECTED_SYSTEM_PROVIDER2}    
+${EMPTY_SYSTEM_PROVIDER_QUERY_PARAM}        systemProvider=
+
+
+${FILTER_ON_SYSTEM_ID_AND_NAME}       systemId=${EXPECTED_SYSTEM_ID},systemName=${EXPECTED_SYSTEM_NAME}
+
+
diff --git a/MEC040/SRV/jsons/SystemInfo.json b/MEC040/SRV/jsons/SystemInfo.json
new file mode 100644
index 0000000..ce8b0d4
--- /dev/null
+++ b/MEC040/SRV/jsons/SystemInfo.json
@@ -0,0 +1,5 @@
+{
+  "systemId": "systemId",
+  "systemName": "systemNamea",
+  "systemProvider": "systemProvider"
+}
\ No newline at end of file
diff --git a/MEC040/SRV/schemas/SystemInfo.schema.json b/MEC040/SRV/schemas/SystemInfo.schema.json
new file mode 100644
index 0000000..7ded9c9
--- /dev/null
+++ b/MEC040/SRV/schemas/SystemInfo.schema.json
@@ -0,0 +1,24 @@
+{
+  "title": "SystemInfo",
+  "type": "object",
+  "description": "This type represents an information provided by the MEC orchestrator as a part of the \"Registration of MEC system to the federation\"",
+  "properties": {
+    "systemId": {
+      "description": "Identifier of the MEC system. For the uniqueness of the identifier across the federated MEC systems, UUID format [i.9] is recommended. Shall be absent in POST request, and present otherwise.",
+      "type": "string"
+    },
+    "systemName": {
+      "description": "The name of the MEC system. This is how the MEC system identifies other MEC systems",
+      "type": "string"
+    },
+    "systemProvider": {
+      "description": "Provider of the MEC system.",
+      "type": "string"
+    }
+  },
+  "required": [
+    "systemId",
+    "systemName",
+    "systemProvider"
+  ]
+}
\ No newline at end of file
diff --git a/MEC040/SRV/schemas/SystemInfoList.schema.json b/MEC040/SRV/schemas/SystemInfoList.schema.json
new file mode 100644
index 0000000..e237cec
--- /dev/null
+++ b/MEC040/SRV/schemas/SystemInfoList.schema.json
@@ -0,0 +1,27 @@
+{
+  "type": "array",
+  "items": {
+    "title": "SystemInfo",
+    "type": "object",
+    "description": "This type represents an information provided by the MEC orchestrator as a part of the \"Registration of MEC system to the federation\"",
+    "properties": {
+      "systemId": {
+        "description": "Identifier of the MEC system. For the uniqueness of the identifier across the federated MEC systems, UUID format [i.9] is recommended. Shall be absent in POST request, and present otherwise.",
+        "type": "string"
+      },
+      "systemName": {
+        "description": "The name of the MEC system. This is how the MEC system identifies other MEC systems",
+        "type": "string"
+      },
+      "systemProvider": {
+        "description": "Provider of the MEC system.",
+        "type": "string"
+      }
+    },
+    "required": [
+      "systemId",
+      "systemName",
+      "systemProvider"
+    ]
+  }
+}
\ No newline at end of file
-- 
GitLab