A1 simulator for STD 2.0.0
[sim/a1-interface.git] / near-rt-ric-simulator / test / OSC_2.1.0 / basic_test.sh
index 5cc1214..bc2413d 100755 (executable)
 #  ============LICENSE_END=================================================
 #
 
-#Default port for the simulator
-PORT=8085
+# Script for basic test of the simulator.
+# Run the build_and_start with the same arg as this script
+if [ $# -ne 1 ]; then
+    echo "Usage: ./basic_test.sh nonsecure|secure"
+    exit 1
+fi
+if [ "$1" != "nonsecure" ] && [ "$1" != "secure" ]; then
+    echo "Usage: ./basic_test.sh nonsecure|secure"
+    exit 1
+fi
+
+if [ $1 == "nonsecure" ]; then
+    #Default http port for the simulator
+    PORT=8085
+    # Set http protocol
+    HTTPX="http"
+else
+    #Default https port for the simulator
+    PORT=8185
+    # Set https protocol
+    HTTPX="https"
+fi
 
 . ../common/test_common.sh
 
@@ -27,7 +47,7 @@ RESULT="OK"
 do_curl GET / 200
 
 echo "=== Check used and implemented interfaces ==="
-RESULT="Current interface: OSC_2.1.0 All supported A1 interface yamls in this container: ['1.1.x-alpha.2', 'STD_1.1.3', 'OSC_2.1.0']"
+RESULT="Current interface: OSC_2.1.0 All supported A1 interface yamls in this container: ['OSC_2.1.0', 'STD_1.1.3', 'STD_2.0.0']"
 do_curl GET /container_interfaces 200
 
 echo "=== Reset simulator instances ==="
@@ -40,7 +60,7 @@ do_curl POST /deleteall 200
 
 echo "=== API: Healthcheck ==="
 RESULT=""
-do_curl get /a1-p/healthcheck 200
+do_curl GET /a1-p/healthcheck 200
 
 echo "=== API: Get policy types, shall be empty array =="
 RESULT="json:[]"
@@ -75,7 +95,7 @@ RESULT=""
 do_curl PUT /a1-p/policytypes/1 201 jsonfiles/pt1.json
 
 echo "=== API: Get policy type ids, shall contain type 1 =="
-RESULT="json:[ \"1\" ]"
+RESULT="json:[ 1 ]"
 do_curl GET /a1-p/policytypes 200
 
 echo "=== API: Get instances for type 1, shall be empty ==="
@@ -116,14 +136,14 @@ do_curl GET '/a1-p/policytypes/1/policies/pi1/status' 200
 
 echo "=== Load a policy type: 2 ==="
 RESULT="Policy type 2 is OK."
-do_curl PUT '/policytype?id=2' 201 jsonfiles/pt1.json
+do_curl PUT '/policytype?id=2' 201 jsonfiles/pt2.json
 
 echo "=== Load a policy type: 2 again. ==="
 RESULT="Policy type 2 is OK."
-do_curl PUT '/policytype?id=2' 200 jsonfiles/pt1.json
+do_curl PUT '/policytype?id=2' 200 jsonfiles/pt2.json
 
 echo "=== API: Get policy type ids, shall contain type 1 and 2 =="
-RESULT="json:[ \"1\", \"2\" ]"
+RESULT="json:[ 1, 2 ]"
 do_curl GET /a1-p/policytypes 200
 
 echo "=== Get policy type ids, shall contain type 1 and 2 =="
@@ -131,15 +151,15 @@ RESULT="json:[\"1\", \"2\"]"
 do_curl GET /policytypes 200
 
 echo "=== API: Get policy type 2 =="
-RESULT="json:{\"name\": \"pt1\", \"description\": \"pt1 policy type\", \"policy_type_id\": 1, \"create_schema\": {\"\$schema\": \"http://json-schema.org/draft-07/schema#\", \"title\": \"STD_QoSNudging_0.2.0\", \"description\": \"QoS policy type\", \"type\": \"object\", \"properties\": {\"scope\": {\"type\": \"object\", \"properties\": {\"ueId\": {\"type\": \"string\"}, \"qosId\": {\"type\": \"string\"}}, \"additionalProperties\": false, \"required\": [\"ueId\", \"qosId\"]}, \"statement\": {\"type\": \"object\", \"properties\": {\"priorityLevel\": {\"type\": \"number\"}}, \"additionalProperties\": false, \"required\": [\"priorityLevel\"]}}}}"
+RESULT="json:{\"name\": \"pt2\", \"description\": \"pt2 policy type\", \"policy_type_id\": 2, \"create_schema\": {\"\$schema\": \"http://json-schema.org/draft-07/schema#\", \"title\": \"STD_QoSNudging_0.2.0\", \"description\": \"QoS policy type\", \"type\": \"object\", \"properties\": {\"scope\": {\"type\": \"object\", \"properties\": {\"ueId\": {\"type\": \"string\"}, \"qosId\": {\"type\": \"string\"}}, \"additionalProperties\": false, \"required\": [\"ueId\", \"qosId\"]}, \"statement\": {\"type\": \"object\", \"properties\": {\"priorityLevel\": {\"type\": \"number\"}}, \"additionalProperties\": false, \"required\": [\"priorityLevel\"]}}}}"
 do_curl GET /a1-p/policytypes/2 200
 
 echo "=== Delete policy type: 2 ==="
 RESULT=""
-do_curl DELETE '/policytype?id=2' 204 jsonfiles/pt1.json
+do_curl DELETE '/policytype?id=2' 204 jsonfiles/pt2.json
 
 echo "=== API: Get policy type ids, shall contain type 1 =="
-RESULT="json:[ \"1\" ]"
+RESULT="json:[ 1 ]"
 do_curl GET /a1-p/policytypes 200
 
 echo "=== Load a policy type: 2 ==="
@@ -147,8 +167,8 @@ RESULT="Policy type 2 is OK."
 do_curl PUT '/policytype?id=2' 201 jsonfiles/pt2.json
 
 echo "=== API: Get policy type 2 =="
-RESULT="json:{\"name\": \"pt1\", \"description\": \"pt1 policy type\", \"policy_type_id\": 1, \"create_schema\": {\"\$schema\": \"http://json-schema.org/draft-07/schema#\", \"title\": \"STD_QoSNudging_0.2.0\", \"description\": \"QoS policy type\", \"type\": \"object\", \"properties\": {\"scope\": {\"type\": \"object\", \"properties\": {\"ueId\": {\"type\": \"string\"}, \"qosId\": {\"type\": \"string\"}}, \"additionalProperties\": false, \"required\": [\"ueId\", \"qosId\"]}, \"statement\": {\"type\": \"object\", \"properties\": {\"priorityLevel\": {\"type\": \"number\"}}, \"additionalProperties\": false, \"required\": [\"priorityLevel\"]}}}}"
-do_curl GET /a1-p/policytypes/1 200
+RESULT="json:{\"name\": \"pt2\", \"description\": \"pt2 policy type\", \"policy_type_id\": 2, \"create_schema\": {\"\$schema\": \"http://json-schema.org/draft-07/schema#\", \"title\": \"STD_QoSNudging_0.2.0\", \"description\": \"QoS policy type\", \"type\": \"object\", \"properties\": {\"scope\": {\"type\": \"object\", \"properties\": {\"ueId\": {\"type\": \"string\"}, \"qosId\": {\"type\": \"string\"}}, \"additionalProperties\": false, \"required\": [\"ueId\", \"qosId\"]}, \"statement\": {\"type\": \"object\", \"properties\": {\"priorityLevel\": {\"type\": \"number\"}}, \"additionalProperties\": false, \"required\": [\"priorityLevel\"]}}}}"
+do_curl GET /a1-p/policytypes/2 200
 
 echo "=== API: Get instances for type 2, shall be empty ==="
 RESULT="json:[]"
@@ -230,6 +250,10 @@ echo "=== Get counter: interface ==="
 RESULT="OSC_2.1.0"
 do_curl GET '/counter/interface' 200
 
+echo "=== Get counter: remote hosts ==="
+RESULT="*"
+do_curl GET '/counter/remote_hosts' 200
+
 echo "=== DELETE policy pi1 ==="
 RESULT=""
 do_curl DELETE /a1-p/policytypes/1/policies/pi1 202