Automates 5.3.1 tests related to O2 Cloud Notification API. 33/14233/6
authorAlberto Losada <alosadag@redhat.com>
Mon, 10 Mar 2025 11:11:28 +0000 (12:11 +0100)
committerAlberto Losada <alosadag@redhat.com>
Wed, 12 Mar 2025 12:19:52 +0000 (12:19 +0000)
These tests were manual. Includes:
  - A subscription event schema.
  - A robot automated test specific for 5.3.1.
  - Updates configuration yaml to include test mandatory fields.

Change-Id: I3439f392a16ea56b89973620d607f87986351fd6
Signed-off-by: Alberto Losada <alosadag@redhat.com>
test_scripts/O2IMS_Compliance_Test/o2ims_compliance/5.3.1_Create_a_subscription_resource.robot [new file with mode: 0644]
test_scripts/O2IMS_Compliance_Test/o2ims_compliance/schemas/subscription_resource_properties.json [new file with mode: 0644]
test_scripts/O2IMS_Compliance_Test/test_configs.yaml

diff --git a/test_scripts/O2IMS_Compliance_Test/o2ims_compliance/5.3.1_Create_a_subscription_resource.robot b/test_scripts/O2IMS_Compliance_Test/o2ims_compliance/5.3.1_Create_a_subscription_resource.robot
new file mode 100644 (file)
index 0000000..ab613d1
--- /dev/null
@@ -0,0 +1,87 @@
+*** Settings ***
+Documentation  Create a subscription resource
+# Library  REST       ssl_verify=False    loglevel=DEBUG
+Library  REST       ssl_verify=False
+Variables              ${EXECDIR}${/}test_configs.yaml
+
+# Suite Setup            Set REST Headers
+Suite Setup            Set REST Headers And Clear Subscriptions
+Suite Teardown         Clear Subscriptions
+
+*** Variables ***
+${ORAN_HOST_EXTERNAL_IP}       ${ocloud.oran_o2_app.api.host}
+${ORAN_SERVICE_NODE_PORT}      ${ocloud.oran_o2_app.api.node_port}
+${GLOBAL_OCLOUD_ID1}           ${ocloud.oran_o2_app.g_ocloud_id}
+${SMO_TOKEN_DATA}              ${ocloud.oran_o2_app.smo_token_data}
+${globalLocationId}            ${ocloud.oran_o2_app.g_location_id}
+${ENDPOINT_URI}                ${ocloud.oran_o2_notification.endpoint_uri}
+${RESOURCE_ADDRESS}            ${ocloud.oran_o2_notification.resource_address}
+${PUBLISHER_EVENT_ENDPOINT}    ${ocloud.oran_o2_notification.publisher_endpoint}
+
+*** Test Cases ***
+s1, Return code is “201 OK” when the subscription request is correct
+    [documentation]  This test case verifies the capability to create a valid subscription for event notifications.
+    [tags]  ORAN_Compliance     ORAN_O2     ORAN_O2IMS     ORAN_O2IMS_Event_Subscription
+
+    Clear Expectations
+    Expect Response Body        ${CURDIR}/schemas/subscription_resource_properties.json
+    ${subscriptionRequest}      input   {"EndpointUri": "${ENDPOINT_URI}", "ResourceAddress": "${RESOURCE_ADDRESS}"}
+    ${res}     POST   ${PUBLISHER_EVENT_ENDPOINT}       ${subscriptionRequest}
+    log      ${res}   level=DEBUG
+    Integer  response status    201
+    Object   response body
+
+s2, Return code is “400 Bad request” when the subscription request is not correct.
+    [documentation]  This test case verifies the capability to return an error when subscription request is not correct
+    [tags]  ORAN_Compliance     ORAN_O2     ORAN_O2IMS     ORAN_O2IMS_Event_Subscription
+    ${INVALID_ENDPOINT_URI}   input   http://oranosc.local:9043/api/ocloudNotifications/v2/dummy
+
+    Clear Expectations
+    ${subscriptionRequest}      input   {"EndpointUri": "${INVALID_ENDPOINT_URI}", "ResourceAddress": "${RESOURCE_ADDRESS}"}
+    ${res}     POST   ${PUBLISHER_EVENT_ENDPOINT}       ${subscriptionRequest}
+    log      ${res}   level=DEBUG
+    Integer  response status    400
+
+s3, Return code is “404 Not found” when the subscription resource is not available.
+    [documentation]  This test case verifies the capability to return an error when subscription request is not found
+    [tags]  ORAN_Compliance     ORAN_O2     ORAN_O2IMS     ORAN_O2IMS_Event_Subscription
+    ${INVALID_RESOURCE_ADDRESS}   input   /cluster/node/notfound
+
+    Clear Expectations
+    ${subscriptionRequest}      input   {"EndpointUri": "${ENDPOINT_URI}", "ResourceAddress": "${INVALID_RESOURCE_ADDRESS}"}
+    ${res}     POST   ${PUBLISHER_EVENT_ENDPOINT}       ${subscriptionRequest}
+    log      ${res}   level=DEBUG
+    Integer  response status    404
+
+s4, Return code is “409 Conflict” when the subscription resource already exists
+    [documentation]  This test case verifies the capability to inform when a resource already exists.
+    [tags]  ORAN_Compliance     ORAN_O2     ORAN_O2IMS     ORAN_O2IMS_Event_Subscription
+
+    # Note that this subscription already exists from s1
+    Clear Expectations
+    ${subscriptionRequest}      input   {"EndpointUri": "${ENDPOINT_URI}", "ResourceAddress": "${RESOURCE_ADDRESS}"}
+    ${res}     POST   ${PUBLISHER_EVENT_ENDPOINT}       ${subscriptionRequest}
+    log      ${res}   level=DEBUG
+    Integer  response status    409
+
+*** Keywords ***
+Set REST Headers
+    Set Headers     {"accept": "application/json"}
+    Set Headers     {"Content-Type": "application/json"}
+    Set Headers     {"Authorization": "Bearer ${SMO_TOKEN_DATA}"}
+    Set Client Cert   ${CURDIR}/../certs/client.pem
+
+Clear Subscriptions
+    Clear Expectations
+    ${res}     GET   ${PUBLISHER_EVENT_ENDPOINT}
+    log     ${res}   level=DEBUG
+    @{subs}        output  $
+    FOR     ${sub}      IN      @{subs}
+        ${subscriptionId}=  input   ${sub}[SubscriptionId]
+        ${res2}     DELETE   ${PUBLISHER_EVENT_ENDPOINT}/${subscriptionId}
+        log     ${res2}   level=DEBUG
+    END
+
+Set REST Headers And Clear Subscriptions
+    Set REST Headers
+    Clear Subscriptions
\ No newline at end of file
diff --git a/test_scripts/O2IMS_Compliance_Test/o2ims_compliance/schemas/subscription_resource_properties.json b/test_scripts/O2IMS_Compliance_Test/o2ims_compliance/schemas/subscription_resource_properties.json
new file mode 100644 (file)
index 0000000..2ca498e
--- /dev/null
@@ -0,0 +1,23 @@
+{
+      "type": "object",
+      "properties": {
+          "SubscriptionId": {
+              "type": "string"
+          },
+          "UriLocation": {
+              "type": "string"
+          },
+          "ResourceAddress": {
+              "type": "string"
+          },
+          "EndpointUri": {
+              "type": "string"
+          }
+      },
+      "required": [
+          "UriLocation",
+          "SubscriptionId",
+          "ResourceAddress",
+          "EndpointUri"
+      ]
+}
index 41237b7..c1bf60f 100644 (file)
@@ -17,6 +17,10 @@ ocloud:
       host: 192.168.112.15\r
       node_port: 30205\r
       protocol: https\r
+  oran_o2_notification:\r
+    endpoint_uri: put_notification_event_endpoint_here\r
+    resource_address: put_notification_event_resource_address_here\r
+    publisher_endpoint: put_notification_event_publisher_endpoint\r
 #smo mock server ip and callback endpoints\r
 smo:\r
   service:\r